index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  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.js";
  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: true,
  144. delBtn: true,
  145. addBtn: true,
  146. addBtnText: "添加测站",
  147. menuWidth: 220,
  148. dialogType: "drawer",
  149. dialogClickModal: false,
  150. columnBtn: false,
  151. column: [
  152. {
  153. label: "站点编码",
  154. prop: "rtuCode",
  155. search: true,
  156. span: 24,
  157. width: 120,
  158. // tip: '*编码仅支持字母+数字的编码组合,长度为20个字符',
  159. rules: [
  160. {
  161. required: true,
  162. message: "请录入站点编码",
  163. trigger: "click",
  164. },
  165. ],
  166. },
  167. {
  168. label: "站点名称",
  169. prop: "rtuName",
  170. search: true,
  171. span: 24,
  172. rules: [
  173. {
  174. required: true,
  175. message: "请录入站点名称",
  176. trigger: "click",
  177. },
  178. ],
  179. },
  180. {
  181. label: "测站类型",
  182. prop: "rtuKindDesc",
  183. span: 24,
  184. editDisplay: false,
  185. addDisplay: false,
  186. display: false,
  187. },
  188. {
  189. label: '测站类型',
  190. prop: 'rtuKind',
  191. type: 'select',
  192. hide: true,
  193. editDisplay: false,
  194. addDisplay: false,
  195. display: false,
  196. search: true,
  197. props: {
  198. label: 'name',
  199. value: 'code'
  200. },
  201. span: 6,
  202. dicData: [{
  203. name: '雨量站',
  204. code: 1
  205. }, {
  206. name: '水位站',
  207. code: 2
  208. }, {
  209. name: '墒情站',
  210. code: 3
  211. }, {
  212. name: '视频站',
  213. code: 4
  214. }],
  215. },
  216. {
  217. label: '测站类型',
  218. prop: 'siteKind',
  219. type: 'checkbox',
  220. hide: true,
  221. props: {
  222. label: 'name',
  223. value: 'code'
  224. },
  225. span: 24,
  226. dicData: [{
  227. name: '雨量站',
  228. code: "1"
  229. }, {
  230. name: '水位站',
  231. code: "2"
  232. }, {
  233. name: '墒情站',
  234. code: "3"
  235. }, {
  236. name: '视频站',
  237. code: "4"
  238. }],
  239. rules: [
  240. {
  241. message: "请选择站点类型",
  242. trigger: "click",
  243. required: true,
  244. },
  245. ],
  246. },
  247. {
  248. label: "盟市",
  249. prop: "adCity",
  250. span: 24,
  251. editDisplay: false,
  252. addDisplay: false,
  253. },
  254. {
  255. label: "盟市",
  256. prop: "adCityCode",
  257. span: 24,
  258. hide: true,
  259. type: 'select',
  260. props: {
  261. label: 'adnm',
  262. value: 'adcd'
  263. },
  264. cascader: ['adCode'],
  265. dicUrl: `api/galaxy-business/baseinfo/region/children/list`,
  266. rules: [
  267. {
  268. required: true,
  269. message: "请录入盟市名称",
  270. trigger: "click",
  271. },
  272. ],
  273. },
  274. {
  275. label: "旗县区",
  276. prop: "adDist",
  277. span: 24,
  278. editDisplay: false,
  279. addDisplay: false,
  280. },
  281. {
  282. label: "旗县区",
  283. prop: "adCode",
  284. span: 24,
  285. hide: true,
  286. type: 'select',
  287. props: {
  288. label: 'adnm',
  289. value: 'adcd'
  290. },
  291. dicUrl: `api/galaxy-business/baseinfo/region/children/list/{{adCityCode}}`,
  292. rules: [
  293. {
  294. required: true,
  295. message: "请录入旗县区",
  296. trigger: "click",
  297. },
  298. ],
  299. },
  300. {
  301. label: "运维单位",
  302. prop: "manageCompany",
  303. span: 24,
  304. },
  305. {
  306. label: "经度",
  307. prop: "lng",
  308. span: 12,
  309. hide: true,
  310. },
  311. {
  312. label: "纬度",
  313. prop: "lat",
  314. span: 12,
  315. hide: true,
  316. },
  317. {
  318. label: "测站位置",
  319. prop: "locationDesc",
  320. span: 24,
  321. overHidden: true,
  322. hide: true,
  323. },
  324. // {
  325. // label: "是否雨量站",
  326. // prop: "isRain",
  327. // span: 8,
  328. // hide: true,
  329. // editDisplay: false,
  330. // addDisplay: false
  331. // },
  332. // {
  333. // label: "是否河道站",
  334. // prop: "isRiver",
  335. // span: 8,
  336. // hide: true,
  337. // editDisplay: false,
  338. // addDisplay: false
  339. // },
  340. // {
  341. // label: "是否水库站",
  342. // prop: "isRes",
  343. // span: 8,
  344. // hide: true,
  345. // editDisplay: false,
  346. // addDisplay: false
  347. // },
  348. // {
  349. // label: "是否墒情站",
  350. // prop: "isGround",
  351. // span: 8,
  352. // hide: true,
  353. // editDisplay: false,
  354. // addDisplay: false
  355. // },
  356. // {
  357. // label: "是否视频站",
  358. // prop: "isVideo",
  359. // span: 8,
  360. // hide: true,
  361. // editDisplay: false,
  362. // addDisplay: false
  363. // },
  364. {
  365. label: "RTU品牌",
  366. prop: "rtuBrand",
  367. span: 24,
  368. hide: true,
  369. },
  370. {
  371. label: "RTU型号",
  372. prop: "rtuModel",
  373. span: 24,
  374. hide: true,
  375. },
  376. {
  377. label: "RTU更换时间",
  378. prop: "rtuReplaceDate",
  379. span: 24,
  380. hide: true,
  381. type: "date",
  382. valueFormat: 'yyyy-MM-dd',
  383. },
  384. {
  385. label: "雨量传感器品牌",
  386. prop: "rainSensorBrand",
  387. span: 24,
  388. hide: true,
  389. },
  390. {
  391. label: "雨量传感器型号",
  392. prop: "rainSensorModel",
  393. span: 24,
  394. hide: true,
  395. },
  396. {
  397. label: "雨量传感器更换时间",
  398. prop: "rainSensorReplaceDate",
  399. span: 24,
  400. hide: true,
  401. type: "date",
  402. valueFormat: 'yyyy-MM-dd',
  403. },
  404. {
  405. label: "水位计传感器品牌",
  406. prop: "waterSensorBrand",
  407. span: 24,
  408. hide: true,
  409. },
  410. {
  411. label: "水位计传感器型号",
  412. prop: "waterSensorModel",
  413. span: 24,
  414. hide: true,
  415. },
  416. {
  417. label: "水位计传感器类型",
  418. prop: "waterSensorType",
  419. span: 24,
  420. hide: true,
  421. type: 'radio',
  422. // dicData: [{
  423. // label: '雷达',
  424. // value: 1
  425. // }, {
  426. // label: '超声波',
  427. // value: 2
  428. // }],
  429. props: {
  430. label: 'dictValue',
  431. value: 'id'
  432. },
  433. dicUrl: '/api/galaxy-system/dict-biz/dictionary?code=water_level_sensor_type',
  434. },
  435. {
  436. label: "水位计传感器更换时间",
  437. prop: "waterSensorReplaceDate",
  438. span: 24,
  439. hide: true,
  440. type: "date",
  441. valueFormat: 'yyyy-MM-dd',
  442. },
  443. {
  444. label: "墒情传感器品牌",
  445. prop: "groundSensorBrand",
  446. span: 24,
  447. hide: true,
  448. },
  449. {
  450. label: "墒情传感器型号",
  451. prop: "groundSensorModel",
  452. span: 24,
  453. hide: true,
  454. },
  455. {
  456. label: "墒情传感器类型",
  457. prop: "groundSensorType",
  458. span: 24,
  459. hide: true,
  460. type: 'radio',
  461. // dicData: [{
  462. // label: '插针式',
  463. // value: 1
  464. // }, {
  465. // label: '导管式',
  466. // value: 2
  467. // }],
  468. props: {
  469. label: 'dictValue',
  470. value: 'id'
  471. },
  472. dicUrl: '/api/galaxy-system/dict-biz/dictionary?code=ground_water_sensor_type',
  473. },
  474. {
  475. label: "墒情传感器更换时间",
  476. prop: "groundSensorReplaceDate",
  477. span: 24,
  478. hide: true,
  479. type: "date",
  480. valueFormat: 'yyyy-MM-dd',
  481. },
  482. {
  483. label: "供电系统电池型号",
  484. prop: "batteryModel",
  485. span: 24,
  486. hide: true,
  487. },
  488. {
  489. label: "供电系统电池更换时间",
  490. prop: "batteryReplaceDate",
  491. span: 24,
  492. hide: true,
  493. type: "date",
  494. valueFormat: 'yyyy-MM-dd',
  495. },
  496. {
  497. label: "太阳能板型号",
  498. prop: "sunPowerModel",
  499. span: 24,
  500. hide: true,
  501. },
  502. {
  503. label: "太阳能控制器品牌",
  504. prop: "sunPowerControllerBrand",
  505. span: 24,
  506. hide: true,
  507. },
  508. {
  509. label: "太阳能控制器型号",
  510. prop: "sunPowerControllerModel",
  511. span: 24,
  512. hide: true,
  513. },
  514. {
  515. label: "SIN卡号",
  516. prop: "networkSimId",
  517. span: 24,
  518. hide: true,
  519. },
  520. {
  521. label: "开卡单位",
  522. prop: "networkPayer",
  523. span: 24,
  524. hide: true,
  525. },
  526. {
  527. label: "缴费截止时间",
  528. prop: "networkPayEndDate",
  529. span: 24,
  530. hide: true,
  531. type: "date",
  532. valueFormat: 'yyyy-MM-dd',
  533. },
  534. {
  535. label: "是否北斗通信",
  536. prop: "isSatellite",
  537. span: 24,
  538. hide: true,
  539. type: 'radio',
  540. dicData: [{
  541. label: '否',
  542. value: 0
  543. }, {
  544. label: '是',
  545. value: 1
  546. }],
  547. },
  548. {
  549. label: "北斗通讯类型",
  550. prop: "satelliteModel",
  551. span: 24,
  552. hide: true,
  553. type: 'radio',
  554. // dicData: [{
  555. // label: '北斗2代',
  556. // value: 1
  557. // }, {
  558. // label: '北斗3代',
  559. // value: 2
  560. // }],
  561. props: {
  562. label: 'dictValue',
  563. value: 'id'
  564. },
  565. dicUrl: '/api/galaxy-system/dict-biz/dictionary?code=satellite_model',
  566. },
  567. {
  568. label: "备注说明",
  569. prop: "remark",
  570. span: 24,
  571. type: "textarea",
  572. hide: true
  573. },
  574. ],
  575. },
  576. data: [],
  577. };
  578. },
  579. computed: {
  580. ...mapGetters(["userInfo", "permission"]),
  581. permissionList() {
  582. return {
  583. addBtn: this.vaildData(this.permission.rtu_add, false),
  584. viewBtn: this.vaildData(this.permission.rtu_view, false),
  585. delBtn: this.vaildData(this.permission.rtu_del, false),
  586. editBtn: this.vaildData(this.permission.rtu_edit, false),
  587. importBtn: this.vaildData(this.permission.rtu_import, false),
  588. videoSiteAdd: this.vaildData(this.permission.video_site_add, false),
  589. };
  590. },
  591. },
  592. created() {
  593. this.initTree();
  594. },
  595. beforeDestroy() {
  596. },
  597. methods: {
  598. initTree() {
  599. this.treeData = [];
  600. getTree().then(res => {
  601. this.treeData = res.data.data.map(item => {
  602. return {
  603. ...item,
  604. leaf: !item.hasChildren
  605. }
  606. })
  607. this.treeOption.defaultExpandedKeys.push(this.treeData[0].id);
  608. this.treeCode = this.treeData[0].id;
  609. });
  610. },
  611. update_table() {
  612. this.onLoad(this.page, this.query);
  613. },
  614. toRtuImpoartHandler() {
  615. this.rtuImportDialog = true;
  616. },
  617. toRtuImportHistoryHandler() {
  618. this.rtuImportHistoryDialog = true;
  619. },
  620. toAddVideoSite() {
  621. this.videoSiteAddDialog = true;
  622. this.$nextTick(() => {
  623. this.$refs["videositeadd"].init();
  624. });
  625. },
  626. downloadTemplate() {
  627. window.open('/file/download/template/站点信息记录表模板.xlsx')
  628. },
  629. nodeClick(data) {
  630. this.treeCode = data.id;
  631. this.treeParentCode = data.parentId;
  632. this.query = {};
  633. this.query['adCode'] = this.treeCode;
  634. this.page.currentPage = 1;
  635. var params = {};
  636. this.onLoad(this.page, params);
  637. },
  638. searchReset() {
  639. this.query = {};
  640. this.query['adCode'] = this.treeCode;
  641. this.page.currentPage = 1;
  642. this.onLoad(this.page);
  643. },
  644. searchChange(params, done) {
  645. this.query = params;
  646. this.query['adCode'] = this.treeCode;
  647. this.page.currentPage = 1;
  648. this.onLoad(this.page, params);
  649. done();
  650. },
  651. currentChange(currentPage) {
  652. console.log("currentPage " + currentPage);
  653. this.page.currentPage = currentPage;
  654. },
  655. sizeChange(pageSize) {
  656. this.page.pageSize = pageSize;
  657. },
  658. refreshChange() {
  659. var params = {};
  660. this.onLoad(this.page, params);
  661. },
  662. selectionChange(list) {
  663. this.selectionList = list;
  664. },
  665. selectChange(item) {
  666. console.log(JSON.stringify(item));
  667. },
  668. selectionClear() {
  669. this.selectionList = [];
  670. this.$refs.crud.toggleSelection();
  671. },
  672. rowSave(row, done, loading) {
  673. console.log(JSON.stringify(row))
  674. add(row).then(
  675. () => {
  676. this.onLoad(this.page);
  677. this.$message({
  678. type: "success",
  679. message: "操作成功!",
  680. });
  681. done();
  682. },
  683. (error) => {
  684. window.console.log(error);
  685. loading();
  686. }
  687. );
  688. },
  689. rowUpdate(row, index, done, loading) {
  690. update(row).then(
  691. () => {
  692. this.onLoad(this.page);
  693. this.$message({
  694. type: "success",
  695. message: "操作成功!",
  696. });
  697. done();
  698. },
  699. (error) => {
  700. window.console.log(error);
  701. loading();
  702. }
  703. );
  704. },
  705. rowDel(row) {
  706. this.$confirm("确定将选择数据删除?", {
  707. confirmButtonText: "确定",
  708. cancelButtonText: "取消",
  709. type: "warning",
  710. })
  711. .then(() => {
  712. return remove(row.id);
  713. })
  714. .then(() => {
  715. this.onLoad(this.page);
  716. this.$message({
  717. type: "success",
  718. message: "操作成功!",
  719. });
  720. });
  721. },
  722. handleDelete() {
  723. if (this.selectionList.length === 0) {
  724. this.$message.warning("请选择至少一条数据");
  725. return;
  726. }
  727. this.$confirm("确定将选择数据删除?", {
  728. confirmButtonText: "确定",
  729. cancelButtonText: "取消",
  730. type: "warning",
  731. })
  732. .then(() => {
  733. return remove(this.ids);
  734. })
  735. .then(() => {
  736. this.onLoad(this.page);
  737. this.$message({
  738. type: "success",
  739. message: "操作成功!",
  740. });
  741. this.$refs.crud.toggleSelection();
  742. });
  743. },
  744. beforeOpen(done, type) {
  745. if (["edit", "view"].includes(type)) {
  746. getDetail(this.form.id).then((res) => {
  747. this.form = res.data.data;
  748. });
  749. }
  750. done();
  751. },
  752. onLoad(page, params = {}) {
  753. this.loading = true;
  754. getPage(
  755. page.currentPage,
  756. page.pageSize,
  757. Object.assign(params, this.query)
  758. ).then((res) => {
  759. const data = res.data.data;
  760. this.page.total = data.total;
  761. this.data = data.records;
  762. this.loading = false;
  763. this.selectionClear();
  764. });
  765. },
  766. },
  767. };
  768. </script>
  769. <style>
  770. .box {
  771. height: 800px;
  772. }
  773. .el-scrollbar {
  774. height: 100%;
  775. }
  776. .box .el-scrollbar__wrap {
  777. overflow: scroll;
  778. }
  779. </style>