index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  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" :page.sync="page" :data="data" ref="crud"
  31. v-model="form" :permission="permissionList" @search-change="searchChange"
  32. @search-reset="searchReset" @selection-change="selectionChange" @current-change="currentChange"
  33. @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad"
  34. @before-open="beforeOpen" @sort-change="sortChange" @cell-click="cellClick">
  35. <template slot="runStatusId" slot-scope="row">
  36. <div v-if="row.row.runStatusId == 0" style="color: blue;">
  37. 正常
  38. </div>
  39. <div v-else-if="row.row.runStatusId == 1"
  40. style="color: red;cursor:pointer;text-decoration-line: underline;"
  41. @click="openWarningInfo(row.row)">
  42. 异常
  43. </div>
  44. <div v-else>
  45. </div>
  46. </template>
  47. <template slot-scope="{ row, index }" slot="menu">
  48. <el-button type="text" size="small" @click="toHistroyData(row)" icon="el-icon-s-data">历史数据
  49. </el-button>
  50. </template>
  51. </avue-crud>
  52. </basic-container>
  53. </el-col>
  54. </el-row>
  55. <el-drawer :visible.sync="historyDataDialog" v-if="historyDataDialog" title="历史信息" direction="rtl" size="60%"
  56. append-to-body="true">
  57. <div slot="title" class="header-title">
  58. <span class="name">{{ dialogTitle }}</span>
  59. </div>
  60. <waterflowratehistorylistvue :mpcd="mpcd" ref="waterflowratehistorylist"></waterflowratehistorylistvue>
  61. </el-drawer>
  62. </div>
  63. </template>
  64. <script>
  65. import { getPage, getDetail } from "@/api/business/monitor/waterflowrate.js";
  66. import { getTree } from "@/api/baseinfo/org";
  67. import { mapGetters } from "vuex";
  68. import waterflowratehistorylistvue from "./waterflowratehistorylist.vue"
  69. export default {
  70. components: {
  71. waterflowratehistorylistvue
  72. },
  73. data() {
  74. return {
  75. id: "",
  76. historyDataDialog: false,
  77. dialogTitle: "",
  78. mpcd: '',
  79. form: {},
  80. selectionList: [],
  81. query: {},
  82. sort: {},
  83. loading: true,
  84. page: {
  85. pageSize: 10,
  86. currentPage: 1,
  87. total: 0,
  88. },
  89. treeCode: '',
  90. treeParentCode: '',
  91. treeData: [],
  92. treeOption: {
  93. nodeKey: "id",
  94. defaultExpandedKeys: [],
  95. lazy: false,
  96. // treeLoad: function (node, resolve) {
  97. // const parentCode = (node.level === 0) ? "" : node.data.id;
  98. // getLazyDeptTree(parentCode, {}).then(res => {
  99. // resolve(res.data.data.map(item => {
  100. // return {
  101. // ...item,
  102. // leaf: !item.hasChildren
  103. // }
  104. // }))
  105. // });
  106. // },
  107. addBtn: false,
  108. menu: true,
  109. size: "small",
  110. props: {
  111. labelText: "标题",
  112. label: "title",
  113. value: "value",
  114. children: "children",
  115. },
  116. },
  117. option: {
  118. labelWidth: 160,
  119. viewLabelWidth: 160,
  120. searchLabelWidth: 160,
  121. height: "auto",
  122. calcHeight: 80,
  123. align: "center",
  124. headerAlign: "center",
  125. tip: false,
  126. simplePage: true,
  127. searchShow: true,
  128. searchMenuSpan: 6,
  129. tree: true,
  130. border: true,
  131. index: true,
  132. selection: false,
  133. viewBtn: true,
  134. editBtn: false,
  135. delBtn: false,
  136. addBtn: false,
  137. menuWidth: 160,
  138. menu: true,
  139. dialogType: "drawer",
  140. dialogClickModal: false,
  141. columnBtn: false,
  142. column: [
  143. {
  144. label: "监测点状态",
  145. prop: "runStatusId",
  146. span: 24,
  147. width: 110,
  148. viewDisplay: false,
  149. },
  150. {
  151. label: "监测点编码",
  152. prop: "mpcd",
  153. span: 24,
  154. search: true,
  155. width: 130,
  156. },
  157. {
  158. label: "监测点名称",
  159. prop: "mpnm",
  160. search: true,
  161. span: 24,
  162. },
  163. {
  164. label: "上次报文时间",
  165. prop: "tm",
  166. span: 24,
  167. width: 150,
  168. sortable: 'custom',
  169. },
  170. {
  171. label: "监测站名称",
  172. prop: "wiustNm",
  173. span: 24,
  174. },
  175. {
  176. label: "取用水户名称",
  177. prop: "wiuNm",
  178. span: 24,
  179. },
  180. {
  181. label: '监测项目',
  182. prop: 'mpItem',
  183. type: 'select',
  184. hide: true,
  185. editDisplay: false,
  186. addDisplay: false,
  187. props: {
  188. label: 'name',
  189. value: 'code'
  190. },
  191. span: 24,
  192. dicData: [{
  193. name: '水位',
  194. code: '1'
  195. }, {
  196. name: '流量',
  197. code: '2'
  198. }]
  199. },
  200. {
  201. label: '监测类型',
  202. prop: 'isAuto',
  203. type: 'select',
  204. hide: true,
  205. editDisplay: false,
  206. addDisplay: false,
  207. props: {
  208. label: 'name',
  209. value: 'code'
  210. },
  211. span: 24,
  212. dicData: [{
  213. name: '间接推算',
  214. code: '0'
  215. }, {
  216. name: '直接监测',
  217. code: '1'
  218. }]
  219. },
  220. {
  221. label: "监测点地址",
  222. prop: "mpAddr",
  223. span: 24,
  224. hide: true,
  225. editDisplay: false,
  226. addDisplay: false,
  227. },
  228. {
  229. label: "经度",
  230. prop: "lng",
  231. span: 24,
  232. hide: true,
  233. editDisplay: false,
  234. addDisplay: false,
  235. },
  236. {
  237. label: "纬度",
  238. prop: "lat",
  239. span: 24,
  240. hide: true,
  241. editDisplay: false,
  242. addDisplay: false,
  243. },
  244. {
  245. label: "监测站名称",
  246. prop: "wiustNm",
  247. span: 24,
  248. hide: true,
  249. },
  250. {
  251. label: "取用水户名称",
  252. prop: "wiuNm",
  253. span: 24,
  254. hide: true,
  255. },
  256. {
  257. label: "瞬时流量",
  258. prop: "mpq",
  259. span: 24,
  260. width: 120,
  261. },
  262. {
  263. label: "累计流量",
  264. prop: "accw",
  265. span: 24,
  266. width: 120,
  267. },
  268. {
  269. label: "上小时累计流量",
  270. prop: "hourw",
  271. span: 24,
  272. width: 140,
  273. },
  274. ],
  275. },
  276. data: [],
  277. };
  278. },
  279. computed: {
  280. ...mapGetters(["userInfo", "permission"]),
  281. permissionList() {
  282. return {
  283. addBtn: false,
  284. viewBtn: true,
  285. delBtn: false,
  286. editBtn: false,
  287. };
  288. },
  289. ids() {
  290. let ids = [];
  291. this.selectionList.forEach((ele) => {
  292. ids.push(ele.id);
  293. });
  294. return ids.join(",");
  295. },
  296. },
  297. mounted() { },
  298. created() {
  299. this.initTree();
  300. },
  301. methods: {
  302. initTree() {
  303. this.treeData = [];
  304. getTree().then(res => {
  305. this.treeData = res.data.data.map(item => {
  306. return {
  307. ...item,
  308. leaf: !item.hasChildren
  309. }
  310. })
  311. this.treeOption.defaultExpandedKeys.push(this.treeData[0].id);
  312. this.treeCode = this.treeData[0].id;
  313. this.query = {};
  314. this.query['orgId'] = this.treeCode;
  315. });
  316. },
  317. nodeClick(data) {
  318. this.treeCode = data.id;
  319. this.excludeCode = data.exclude;
  320. this.treeParentCode = data.parentId;
  321. this.query = {};
  322. this.query['orgId'] = this.treeCode;
  323. this.page.currentPage = 1;
  324. var params = {};
  325. this.onLoad(this.page, params);
  326. },
  327. sortChange(val) {
  328. //console.log(JSON.stringify(val))
  329. //prop":"tm","order":"ascending" descending
  330. let prop = val.prop;
  331. if (prop === 'tm') {
  332. this.page.currentPage = 1;
  333. var params = {};
  334. let order = val.order;
  335. if (order) {
  336. params['order'] = order;
  337. params['prop'] = prop;
  338. this.sort = {};
  339. Object.assign(this.sort, params)
  340. } else {
  341. this.sort = {};
  342. }
  343. this.onLoad(this.page);
  344. }
  345. },
  346. cellClick(row, column, cell, event) {
  347. if (event.isTrusted) {
  348. // this.rtuCode = row.rtuCode;
  349. // if (column.label === 'RTU更换时间') {
  350. // if (row.rtuReplaceDate) {
  351. // this.dialogTitle = row.rtuName + 'RTU更换信息';
  352. // this.rtureplacelistDialog = true;
  353. // this.$nextTick(() => {
  354. // this.$refs["rtureplacelist"].init();
  355. // });
  356. // }
  357. // }
  358. }
  359. },
  360. toHistroyData(row) {
  361. this.dialogTitle = "历史数据[" + row.mpnm + row.mpcd + "]";
  362. this.mpcd = row.mpcd;
  363. this.historyDataDialog = true;
  364. this.$nextTick(() => {
  365. this.$refs["waterflowratehistorylist"].init();
  366. });
  367. },
  368. searchReset() {
  369. this.query = {};
  370. this.query['adCode'] = this.treeCode;
  371. this.page.currentPage = 1;
  372. this.onLoad(this.page);
  373. },
  374. searchChange(params, done) {
  375. this.query = {};
  376. this.query['adCode'] = this.treeCode;
  377. Object.assign(this.query, params)
  378. this.page.currentPage = 1;
  379. this.onLoad(this.page, params);
  380. done();
  381. },
  382. selectionChange(list) {
  383. this.selectionList = list;
  384. },
  385. selectionClear() {
  386. this.selectionList = [];
  387. this.$refs.crud.toggleSelection();
  388. },
  389. beforeOpen(done, type) {
  390. if (["view"].includes(type)) {
  391. getDetail(this.form.id).then((res) => {
  392. this.form = res.data.data;
  393. });
  394. }
  395. done();
  396. },
  397. currentChange(currentPage) {
  398. this.page.currentPage = currentPage;
  399. },
  400. sizeChange(pageSize) {
  401. this.page.pageSize = pageSize;
  402. },
  403. refreshChange() {
  404. var params = {};
  405. this.onLoad(this.page, params);
  406. },
  407. onLoad(page, params = {}) {
  408. this.loading = true;
  409. getPage(
  410. page.currentPage,
  411. page.pageSize,
  412. Object.assign(params, this.sort, this.query)
  413. ).then((res) => {
  414. const data = res.data.data;
  415. //console.log(JSON.stringify(data))
  416. this.page.total = data.total;
  417. this.data = data.records;
  418. this.loading = false;
  419. this.selectionClear();
  420. });
  421. },
  422. },
  423. };
  424. </script>
  425. <style lang="scss" scoped></style>