index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <!--
  2. * @Title:
  3. * @Description:
  4. * @Author: swp
  5. * @Date: 2022-08-24 10:49:21
  6. * @LastEditors:
  7. * @LastEditTime: 2022-08-24 10:49:21
  8. -->
  9. <template>
  10. <div>
  11. <el-row>
  12. <el-col :span="4">
  13. <div class="box">
  14. <el-scrollbar>
  15. <basic-container>
  16. <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick">
  17. <span class="el-tree-node__label" slot-scope="{ node, data }">
  18. <span>
  19. <i class="el-icon-office-building"></i>
  20. {{ (node || {}).label }}
  21. </span>
  22. </span>
  23. </avue-tree>
  24. </basic-container>
  25. </el-scrollbar>
  26. </div>
  27. </el-col>
  28. <el-col :span="20">
  29. <basic-container>
  30. <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page"
  31. :before-open="beforeOpen" ref="crud" v-model="form" :permission="permissionList" @row-del="rowDel"
  32. @row-update="rowUpdate" @row-save="rowSave" @search-change="searchChange"
  33. @search-reset="searchReset" @selection-change="selectionChange" @current-change="currentChange"
  34. @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad"
  35. @before-open="beforeOpen" @select-change="selectChange">
  36. <template slot-scope="scope" slot="menuLeft">
  37. <el-button v-if="permissionList.importBtn" type="primary" icon="el-icon-upload2" size="small"
  38. @click="toRtuImpoartHandler">导入测站</el-button>
  39. <el-button v-if="permissionList.importBtn" type="primary" icon="el-icon-finished" size="small"
  40. @click="toRtuImportHistoryHandler">测站导入历史</el-button>
  41. <el-button v-if="permissionList.importBtn" type="primary" icon="el-icon-download" size="small"
  42. @click="downloadTemplate">测站信息模板下载</el-button>
  43. <el-button v-if="permissionList.videoSiteAdd" type="primary" icon="el-icon-plus" size="small"
  44. @click="toAddVideoSite">添加视频站</el-button>
  45. </template>
  46. </avue-crud>
  47. </basic-container>
  48. </el-col>
  49. </el-row>
  50. <el-drawer :visible.sync="rtuImportHistoryDialog" v-if="rtuImportHistoryDialog" title="测站导入操作记录" direction="rtl"
  51. size="60%" append-to-body="true">
  52. <rtuImportHistoryView ref="rtuImportHistoryView"></rtuImportHistoryView>
  53. </el-drawer>
  54. <el-dialog title="测站导入向导" :visible.sync="rtuImportDialog" width="60%" height="60%" :close-on-click-modal="false"
  55. append-to-body :v-loading="importLoading" v-if="rtuImportDialog">
  56. <rtuImportView :importLoading="importLoading" :visible.sync="rtuImportDialog" ref="rtuImportView">
  57. </rtuImportView>
  58. </el-dialog>
  59. <el-dialog title="添加视频站" :visible.sync="videoSiteAddDialog" width="60%" height="60%" :close-on-click-modal="false"
  60. append-to-body :v-loading="importLoading" v-if="videoSiteAddDialog">
  61. <videositeadd :importLoading="importLoading" :visible.sync="videoSiteAddDialog" ref="videositeadd"
  62. @fevent="update_table">
  63. </videositeadd>
  64. </el-dialog>
  65. </div>
  66. </template>
  67. <script>
  68. import { getPage, getDetail, add, update, remove } from "@/api/baseinfo/rtu.js";
  69. import { getTree } from "@/api/baseinfo/region";
  70. import { mapGetters } from "vuex";
  71. import rtuImportHistoryView from './rtuimport.vue';
  72. import rtuImportView from './rtuImportProcess.vue';
  73. import videositeadd from './videositeadd.vue';
  74. export default {
  75. components: {
  76. rtuImportView,
  77. rtuImportHistoryView,
  78. videositeadd
  79. },
  80. data() {
  81. return {
  82. importLoading: false,
  83. rtuImportDialog: false,
  84. rtuImportHistoryDialog: false,
  85. videoSiteAddDialog: false,
  86. id: "",
  87. form: {},
  88. selectionList: [],
  89. query: {},
  90. loading: true,
  91. page: {
  92. pageSize: 10,
  93. currentPage: 1,
  94. total: 0,
  95. },
  96. treeCode: '',
  97. treeParentCode: '',
  98. treeData: [],
  99. treeOption: {
  100. nodeKey: "id",
  101. defaultExpandedKeys: [],
  102. lazy: false,
  103. // treeLoad: function (node, resolve) {
  104. // const parentCode = (node.level === 0) ? "00" : node.data.value;
  105. // getLazyTree(parentCode).then(res => {
  106. // resolve(res.data.data.map(item => {
  107. // return {
  108. // ...item,
  109. // leaf: !item.hasChildren
  110. // }
  111. // }))
  112. // });
  113. // },
  114. addBtn: false,
  115. menu: true,
  116. size: "small",
  117. props: {
  118. labelText: "标题",
  119. label: "title",
  120. value: "value",
  121. children: "children",
  122. },
  123. },
  124. option: {
  125. labelWidth: 140,
  126. viewLabelWidth: 140,
  127. searchLabelWidth: 140,
  128. height: "auto",
  129. calcHeight: 80,
  130. align: "center",
  131. headerAlign: "center",
  132. lazy: false,
  133. tip: false,
  134. simplePage: true,
  135. searchShow: true,
  136. searchMenuSpan: 6,
  137. tree: true,
  138. border: true,
  139. index: true,
  140. selection: false,
  141. viewBtn: true,
  142. viewTitle: "测站信息",
  143. editBtn: false,
  144. delBtn: false,
  145. addBtn: false,
  146. menuWidth: 120,
  147. dialogType: "drawer",
  148. dialogClickModal: false,
  149. columnBtn: false,
  150. column: [
  151. {
  152. label: "站点名称",
  153. prop: "rtuName",
  154. search: true,
  155. span: 6,
  156. rules: [
  157. {
  158. required: true,
  159. message: "请录入站点名称",
  160. trigger: "click",
  161. },
  162. ],
  163. },
  164. {
  165. label: "站点编码",
  166. prop: "rtuCode",
  167. search: true,
  168. span: 6,
  169. editDisabled: true,
  170. rules: [
  171. {
  172. required: true,
  173. message: "请录入站点编码",
  174. trigger: "click",
  175. },
  176. ],
  177. },
  178. {
  179. label: "测站类型",
  180. prop: "rtuKindDesc",
  181. span: 24,
  182. editDisplay: false,
  183. addDisplay: false,
  184. },
  185. {
  186. label: '测站类型',
  187. prop: 'rtuKind',
  188. type: 'select',
  189. hide: true,
  190. editDisplay: false,
  191. addDisplay: false,
  192. search: true,
  193. props: {
  194. label: 'name',
  195. value: 'code'
  196. },
  197. span: 6,
  198. dicData: [{
  199. name: '雨量站',
  200. code: 1
  201. }, {
  202. name: '水位站',
  203. code: 2
  204. }, {
  205. name: '墒情站',
  206. code: 3
  207. }, {
  208. name: '视频站',
  209. code: 4
  210. }]
  211. },
  212. // {
  213. // label: "运维单位",
  214. // prop: "manageCompany",
  215. // span: 24,
  216. // editDisplay: false,
  217. // addDisplay: false,
  218. // },
  219. {
  220. label: "经度",
  221. prop: "lng",
  222. span: 24,
  223. editDisplay: false,
  224. addDisplay: false,
  225. },
  226. {
  227. label: "纬度",
  228. prop: "lat",
  229. span: 24,
  230. editDisplay: false,
  231. addDisplay: false,
  232. },
  233. {
  234. label: "测站位置",
  235. prop: "locationDesc",
  236. span: 24,
  237. editDisplay: false,
  238. addDisplay: false,
  239. overHidden: true,
  240. },
  241. {
  242. label: "备注说明",
  243. prop: "remark",
  244. span: 24,
  245. type: "textarea",
  246. hide: true
  247. },
  248. ],
  249. },
  250. data: [],
  251. };
  252. },
  253. computed: {
  254. ...mapGetters(["userInfo", "permission"]),
  255. permissionList() {
  256. return {
  257. // addBtn: this.vaildData(this.permission.rtu_add, false),
  258. viewBtn: this.vaildData(this.permission.rtu_view, false),
  259. // delBtn: this.vaildData(this.permission.rtu_del, false),
  260. // editBtn: this.vaildData(this.permission.rtu_edit, false),
  261. importBtn: this.vaildData(this.permission.rtu_import, false),
  262. videoSiteAdd: this.vaildData(this.permission.video_site_add, false),
  263. };
  264. },
  265. },
  266. created() {
  267. this.initTree();
  268. },
  269. beforeDestroy() {
  270. },
  271. methods: {
  272. initTree() {
  273. this.treeData = [];
  274. getTree().then(res => {
  275. this.treeData = res.data.data.map(item => {
  276. return {
  277. ...item,
  278. leaf: !item.hasChildren
  279. }
  280. })
  281. this.treeOption.defaultExpandedKeys.push(this.treeData[0].id);
  282. this.treeCode = this.treeData[0].id;
  283. });
  284. },
  285. update_table() {
  286. this.onLoad(this.page, this.query);
  287. },
  288. toRtuImpoartHandler() {
  289. this.rtuImportDialog = true;
  290. },
  291. toRtuImportHistoryHandler() {
  292. this.rtuImportHistoryDialog = true;
  293. },
  294. toAddVideoSite() {
  295. this.videoSiteAddDialog = true;
  296. this.$nextTick(() => {
  297. this.$refs["videositeadd"].init();
  298. });
  299. },
  300. downloadTemplate() {
  301. window.open('/file/download/template/站点信息记录表模板.xlsx')
  302. },
  303. nodeClick(data) {
  304. this.treeCode = data.id;
  305. this.treeParentCode = data.parentId;
  306. this.query = {};
  307. this.query['adCode'] = this.treeCode;
  308. this.page.currentPage = 1;
  309. var params = {};
  310. this.onLoad(this.page, params);
  311. },
  312. searchReset() {
  313. this.query = {};
  314. this.query['adCode'] = this.treeCode;
  315. this.page.currentPage = 1;
  316. this.onLoad(this.page);
  317. },
  318. searchChange(params, done) {
  319. this.query = params;
  320. this.query['adCode'] = this.treeCode;
  321. this.page.currentPage = 1;
  322. this.onLoad(this.page, params);
  323. done();
  324. },
  325. currentChange(currentPage) {
  326. console.log("currentPage " + currentPage);
  327. this.page.currentPage = currentPage;
  328. },
  329. sizeChange(pageSize) {
  330. this.page.pageSize = pageSize;
  331. },
  332. refreshChange() {
  333. var params = {};
  334. this.onLoad(this.page, params);
  335. },
  336. selectionChange(list) {
  337. this.selectionList = list;
  338. },
  339. selectChange(item) {
  340. console.log(JSON.stringify(item));
  341. },
  342. selectionClear() {
  343. this.selectionList = [];
  344. this.$refs.crud.toggleSelection();
  345. },
  346. // initData() {
  347. // getRtuKindList('rtu_kind').then((res) => {
  348. // const column = this.findObject(this.option.column, "rtuKinds");
  349. // column.dicData = res.data.data;
  350. // });
  351. // },
  352. rowSave(row, done, loading) {
  353. add(row).then(
  354. () => {
  355. this.onLoad(this.page);
  356. this.$message({
  357. type: "success",
  358. message: "操作成功!",
  359. });
  360. done();
  361. },
  362. (error) => {
  363. window.console.log(error);
  364. loading();
  365. }
  366. );
  367. },
  368. rowUpdate(row, index, done, loading) {
  369. update(row).then(
  370. () => {
  371. this.onLoad(this.page);
  372. this.$message({
  373. type: "success",
  374. message: "操作成功!",
  375. });
  376. done();
  377. },
  378. (error) => {
  379. window.console.log(error);
  380. loading();
  381. }
  382. );
  383. },
  384. rowDel(row) {
  385. this.$confirm("确定将选择数据删除?", {
  386. confirmButtonText: "确定",
  387. cancelButtonText: "取消",
  388. type: "warning",
  389. })
  390. .then(() => {
  391. return remove(row.id);
  392. })
  393. .then(() => {
  394. this.onLoad(this.page);
  395. this.$message({
  396. type: "success",
  397. message: "操作成功!",
  398. });
  399. });
  400. },
  401. handleDelete() {
  402. if (this.selectionList.length === 0) {
  403. this.$message.warning("请选择至少一条数据");
  404. return;
  405. }
  406. this.$confirm("确定将选择数据删除?", {
  407. confirmButtonText: "确定",
  408. cancelButtonText: "取消",
  409. type: "warning",
  410. })
  411. .then(() => {
  412. return remove(this.ids);
  413. })
  414. .then(() => {
  415. this.onLoad(this.page);
  416. this.$message({
  417. type: "success",
  418. message: "操作成功!",
  419. });
  420. this.$refs.crud.toggleSelection();
  421. });
  422. },
  423. beforeOpen(done, type) {
  424. if (["edit", "view"].includes(type)) {
  425. getDetail(this.form.id).then((res) => {
  426. this.form = res.data.data;
  427. });
  428. }
  429. done();
  430. },
  431. onLoad(page, params = {}) {
  432. this.loading = true;
  433. getPage(
  434. page.currentPage,
  435. page.pageSize,
  436. Object.assign(params, this.query)
  437. ).then((res) => {
  438. const data = res.data.data;
  439. this.page.total = data.total;
  440. this.data = data.records;
  441. this.loading = false;
  442. this.selectionClear();
  443. });
  444. },
  445. },
  446. };
  447. </script>
  448. <style>
  449. .box {
  450. height: 800px;
  451. }
  452. .el-scrollbar {
  453. height: 100%;
  454. }
  455. .box .el-scrollbar__wrap {
  456. overflow: scroll;
  457. }
  458. </style>