AbnormalDataMaintenance.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. <template>
  2. <!-- 异常数据维护 -->
  3. <div class="AbnormalDataMaintenance">
  4. <div class="box">
  5. <div class="box-top">
  6. <el-form
  7. style="overflow: hidden;"
  8. :style="filterForm.show ? null : { height: '0px' }"
  9. size="mini"
  10. label-width="80px"
  11. >
  12. <el-row>
  13. <el-col :span="6">
  14. <el-form-item label="日期">
  15. <zj-timegran-date
  16. v-model="filterForm.data.clock"
  17. style="width: 100%;"
  18. :type="'daterange'"
  19. :timegranId="filterForm.data.timegranid"
  20. :oneFoo="getTableData"
  21. :defaultOffset="-1"
  22. :custom="1"
  23. ></zj-timegran-date>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :span="6">
  27. <el-form-item label="能介类型">
  28. <el-select
  29. filterable
  30. clearable
  31. v-model="filterForm.data.energytypeid"
  32. placeholder="能介类型"
  33. style="width: 100%;"
  34. >
  35. <el-option
  36. v-for="item of energytypeid.arr"
  37. :key="item.id"
  38. :value="item.id"
  39. :label="item.name"
  40. ></el-option>
  41. </el-select>
  42. </el-form-item>
  43. </el-col>
  44. <el-col :span="6">
  45. <el-form-item label="能介">
  46. <el-select
  47. filterable
  48. clearable
  49. v-model="filterForm.data.energyid"
  50. multiple
  51. collapse-tags
  52. placeholder="能介"
  53. style="width: 100%;"
  54. >
  55. <el-option
  56. v-for="item of nameObj.energyid.arr"
  57. :key="item.id"
  58. :value="item.id"
  59. :label="item.name"
  60. ></el-option>
  61. </el-select>
  62. </el-form-item>
  63. </el-col>
  64. <el-col :span="6">
  65. <el-form-item label="位置">
  66. <el-select
  67. filterable clearable
  68. v-model="filterForm.data.locateid"
  69. placeholder="位置"
  70. multiple
  71. collapse-tags
  72. style="width: 100%;"
  73. >
  74. <el-option
  75. v-for="item of nameObj.locateid.arr"
  76. :key="item.id"
  77. :value="item.id"
  78. :label="item.name"
  79. ></el-option>
  80. </el-select>
  81. </el-form-item>
  82. </el-col>
  83. </el-row>
  84. <el-row>
  85. <el-col :span="6">
  86. <el-form-item label="计量点编号">
  87. <el-input
  88. clearable
  89. v-model.trim="filterForm.data.itemid"
  90. placeholder="计量点编号"
  91. style="width: 100%;"
  92. @keyup.enter.native="getTableData(1)"
  93. ></el-input>
  94. </el-form-item>
  95. </el-col>
  96. <el-col :span="6">
  97. <el-form-item label="计量点名称">
  98. <el-input
  99. clearable
  100. v-model.trim="filterForm.data.itemname"
  101. placeholder="计量点名称"
  102. style="width: 100%;"
  103. @keyup.enter.native="getTableData(1)"
  104. ></el-input>
  105. </el-form-item>
  106. </el-col>
  107. </el-row>
  108. </el-form>
  109. <div class="box-top-gjl">
  110. <div style="float:right; text-align: right;">
  111. <el-button
  112. class="button"
  113. type="primary"
  114. size="mini"
  115. icon="el-icon-search"
  116. v-privilege="activeMenu + 'QUERY'"
  117. @click="getTableData(1)"
  118. >查询</el-button>
  119. <el-button
  120. class="button"
  121. type="primary"
  122. size="mini"
  123. icon="el-icon-refresh"
  124. v-privilege="activeMenu + 'QUERY'"
  125. @click="tableDataCancel();"
  126. >重置</el-button>
  127. <el-button
  128. size="mini"
  129. :icon="filterForm.show ? 'el-icon-caret-top' : 'el-icon-caret-bottom'"
  130. :title="filterForm.show ? '收起搜索区' : '展开搜索区'"
  131. @click="filterForm.show = !filterForm.show;
  132. $nextTick(() => {
  133. singleTableHeight = getRoleHeight($refs['singleTable'].$el) - 45;
  134. }
  135. );"
  136. >{{ filterForm.show ? '收起' : '展开' }}</el-button>
  137. </div>
  138. </div>
  139. </div>
  140. <div class="box-bottom">
  141. <el-form
  142. size="mini"
  143. ref="dialog_form_arr"
  144. label-width="0px"
  145. :model="tableFormDataObj"
  146. >
  147. <el-table
  148. stripe
  149. id="singleTable"
  150. ref="singleTable"
  151. :data="tableData"
  152. v-loading="tableLoading"
  153. style="width: 100%;"
  154. :height="singleTableHeight"
  155. border
  156. size="mini"
  157. highlight-current-row
  158. show-summary
  159. :summary-method="getSummaries"
  160. >
  161. <!-- <el-table-column
  162. sortable
  163. type="selection"
  164. width="40"
  165. align="center"
  166. fixed="left"
  167. ></el-table-column> -->
  168. <el-table-column
  169. sortable
  170. prop="clock"
  171. label="时间"
  172. width="140px"
  173. :show-overflow-tooltip="true"
  174. ></el-table-column>
  175. <el-table-column
  176. sortable
  177. prop="itemid"
  178. label="计量点编号"
  179. min-width="100px"
  180. :show-overflow-tooltip="true"
  181. ></el-table-column>
  182. <el-table-column
  183. sortable
  184. prop="itemname"
  185. label="计量点名称"
  186. min-width="120px"
  187. :show-overflow-tooltip="true"
  188. ></el-table-column>
  189. <el-table-column
  190. sortable
  191. prop="energyid"
  192. label="能介"
  193. min-width="100px"
  194. :show-overflow-tooltip="true"
  195. > <template slot-scope="scope">
  196. <span>{{nameObj.energyid.obj[scope.row.energyid] ? nameObj.energyid.obj[scope.row.energyid] : scope.row.energyid }}</span>
  197. </template>
  198. </el-table-column>
  199. <el-table-column
  200. sortable
  201. prop="energytypeid"
  202. label="能介类型"
  203. width="80px"
  204. :show-overflow-tooltip="true"
  205. > <template slot-scope="scope">
  206. <span>{{energytypeid.obj[scope.row.energytypeid] ? energytypeid.obj[scope.row.energytypeid] : scope.row.energytypeid }}</span>
  207. </template>
  208. </el-table-column>
  209. <el-table-column
  210. sortable
  211. prop="extype"
  212. label="异常数据类型"
  213. width="100px"
  214. :show-overflow-tooltip="true"
  215. >
  216. </el-table-column>
  217. <el-table-column
  218. sortable
  219. prop="locateid"
  220. label="位置"
  221. min-width="80px"
  222. :show-overflow-tooltip="true"
  223. >
  224. <template slot-scope="scope">
  225. <span>{{nameObj.locateid.obj[scope.row.locateid] ? nameObj.locateid.obj[scope.row.locateid] : scope.row.locateid }}</span>
  226. </template>
  227. </el-table-column>
  228. <el-table-column
  229. sortable
  230. prop="maxvalue"
  231. label="日最大值"
  232. min-width="90px"
  233. :show-overflow-tooltip="true"
  234. ></el-table-column>
  235. <el-table-column
  236. sortable
  237. prop="minvalue"
  238. label="日最小值"
  239. width="90px"
  240. :show-overflow-tooltip="true"
  241. ></el-table-column>
  242. <el-table-column
  243. sortable prop="apportvalue"
  244. label="最终值"
  245. width="90px"
  246. :show-overflow-tooltip="true"
  247. ></el-table-column>
  248. <el-table-column
  249. sortable
  250. prop="befvalue"
  251. label="仪表变小前值"
  252. min-width="70px"
  253. :show-overflow-tooltip="true"
  254. ></el-table-column>
  255. <el-table-column
  256. sortable
  257. prop="curvalue"
  258. label="仪表当前值"
  259. min-width="70px"
  260. :show-overflow-tooltip="true"
  261. ></el-table-column>
  262. <el-table-column
  263. sortable
  264. prop="createtime"
  265. label="创建时间"
  266. min-width="100px"
  267. :show-overflow-tooltip="true"
  268. ></el-table-column>
  269. <el-table-column
  270. sortable
  271. prop="bz"
  272. label="备注"
  273. min-width="140px"
  274. :show-overflow-tooltip="true"
  275. ></el-table-column>
  276. </el-table>
  277. </el-form>
  278. <el-pagination
  279. layout="total, sizes, prev, pager, next, jumper"
  280. :total="total"
  281. :page-sizes="[10, 20, 50, 100, 500, 1000]"
  282. :page-size="pageSize"
  283. :current-page.sync="pageNum"
  284. @size-change="tableSizeChange"
  285. @current-change="getTableData()"
  286. style="text-align: right;margin-top: 10px;"
  287. ></el-pagination>
  288. </div>
  289. </div>
  290. </div>
  291. </template>
  292. <script>
  293. import { zCheckNumber1 } from '~/utils/validator.js'
  294. import store from '@/store/index.js';
  295. import timegranDate from '@/components/zg/timegranDate.vue'
  296. import { formatDate, XtcommonSummaries } from '@/utils/util.js';
  297. export default {
  298. name: 'AbnormalDataMaintenance',
  299. components: {
  300. 'zj-timegran-date': timegranDate
  301. },
  302. data () {
  303. return {
  304. multipleSelection: [],
  305. tableFormDataObj: {},
  306. store,
  307. userInfo: {
  308. data: null
  309. },
  310. activeMenu: '',
  311. filterForm: {
  312. show: true,
  313. data: {
  314. id: '',
  315. clock: '',
  316. itemid: '',
  317. extype: '',
  318. maxvalue: '',
  319. minvalue: '',
  320. apportvalue: '',
  321. befvalue: '',
  322. curvalue: '',
  323. createtime: '',
  324. itemname: '',
  325. energyid: '',
  326. energytypeid: '',
  327. locateid: '',
  328. bz: ''
  329. },
  330. disabled: {
  331. locateid: false,
  332. energyid: false
  333. },
  334. rules: {
  335. }
  336. },
  337. pageNum: 1,
  338. pageSize: 20,
  339. total: 0,
  340. singleTableHeight: 200,
  341. tableData: [],
  342. loading: false,
  343. tableLoading: false,
  344. energytypeid: {
  345. obj: {
  346. 'W': '水',
  347. 'E': '电',
  348. 'P': '动力'
  349. },
  350. arr: [
  351. {
  352. id: 'W',
  353. name: '水'
  354. },
  355. {
  356. id: 'E',
  357. name: '电'
  358. },
  359. {
  360. id: 'P',
  361. name: '动力'
  362. }
  363. ]
  364. },
  365. nameObj: {
  366. locateid: {
  367. obj: {},
  368. arr: []
  369. },
  370. energyid: {
  371. obj: {},
  372. arr: []
  373. }
  374. },
  375. dialog: {
  376. editorBox: {
  377. show: false,
  378. type: '',
  379. form: {
  380. data: {
  381. locateid: '',
  382. energyid: ''
  383. }
  384. }
  385. },
  386. trendChart: {
  387. show: false,
  388. size: 7,
  389. form: {
  390. data: {
  391. chartSeriesType: 'bar'
  392. }
  393. },
  394. chart: {
  395. show: true,
  396. option: {
  397. tooltip: {
  398. trigger: 'axis'
  399. },
  400. legend: {
  401. data: []
  402. },
  403. toolbox: {
  404. feature: {
  405. saveAsImage: {}
  406. }
  407. },
  408. xAxis: {
  409. type: 'category',
  410. data: []
  411. },
  412. yAxis: {
  413. type: 'value'
  414. },
  415. series: [
  416. ]
  417. }
  418. }
  419. }
  420. }
  421. }
  422. },
  423. created () {
  424. this.activeMenu = window.localStorage.getItem('activeMenu');
  425. },
  426. mounted () {
  427. let that = this;
  428. window.PEDataObj = {
  429. // 将数据绑定到window上,供main页面使用
  430. vm: that,
  431. // tableArr:用于导出成Excel的表格的信息
  432. tableArr: [
  433. {
  434. name: '',
  435. id: 'singleTable'
  436. }
  437. ]
  438. };
  439. that.$nextTick(() => {
  440. // 立即获取的height有一定偏差,通过setTimeout延迟来解决
  441. setTimeout(() => {
  442. that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 45;
  443. }, 1);
  444. });
  445. that.store.dispatch('getUserInfo').then((res) => {
  446. that.userInfo.data = res.data;
  447. });
  448. // 接收路由参数
  449. if (that.$route.query.locateid) {
  450. that.filterForm.disabled.locateid = true;
  451. that.filterForm.data.locateid = that.$route.query.locateid;
  452. }
  453. if (that.$route.query.energyid) {
  454. that.filterForm.disabled.energyid = true;
  455. that.filterForm.data.energyid = that.$route.query.energyid;
  456. }
  457. if (that.$route.query.itemtype) {
  458. that.filterForm.data.itemtype = that.$route.query.itemtype;
  459. }
  460. // that.getTableData();
  461. that.getlocateid();
  462. that.getenergyid();
  463. },
  464. methods: {
  465. // 计算树区域高度
  466. getRoleHeight (dom) {
  467. return window.innerHeight - dom.offsetTop;
  468. },
  469. // 自定义的表格合计方法:只给指定列进行合计
  470. getSummaries (param) {
  471. const prop = []; // 合计列绑定的prop
  472. return XtcommonSummaries(param, prop);
  473. },
  474. // 获取表格中的数据
  475. getTableData (pageNum) {
  476. let that = this,
  477. params = {
  478. id: that.filterForm.data.id,
  479. clock: that.filterForm.data.clock[0],
  480. clocke: that.filterForm.data.clock[1],
  481. itemid: that.filterForm.data.itemid,
  482. itemname: that.filterForm.data.itemname,
  483. extype: that.filterForm.data.extype,
  484. maxvalue: that.filterForm.data.maxvalue,
  485. minvalue: that.filterForm.data.minvalue,
  486. apportvalue: that.filterForm.data.apportvalue,
  487. befvalue: that.filterForm.data.befvalue,
  488. curvalue: that.filterForm.data.curvalue,
  489. createtime: that.filterForm.data.createtime,
  490. energytypeid: that.filterForm.data.energytypeid,
  491. energyid: that.filterForm.data.energyid.toString(),
  492. locateid: that.filterForm.data.locateid.toString(),
  493. bz: that.filterForm.data.bz
  494. };
  495. that.pageNum = pageNum || that.pageNum;
  496. that.tableLoading = true;
  497. let url = 'pass/ems/v1/trmcalpointexvalues/getExData?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize;
  498. that.axios.get(url, {
  499. params: params
  500. })
  501. .then(function (res) {
  502. if (res.code === '0') {
  503. let arr = [];
  504. for (let item of res.data.list) {
  505. arr.push({
  506. id: item.ID,
  507. clock: item.CLOCK,
  508. itemid: item.ITEMID,
  509. itemname: item.ITEMNAME,
  510. extype: item.EXTYPE,
  511. maxvalue: item.MAXVALUE,
  512. minvalue: item.MINVALUE,
  513. apportvalue: item.APPORTVALUE,
  514. befvalue: item.BEFVALUE,
  515. curvalue: item.CURVALUE,
  516. createtime: item.CREATETIME,
  517. energytypeid: item.ENERGYTYPEID,
  518. energyid: item.ENERGYID,
  519. locateid: item.LOCATEID,
  520. bz: item.BZ
  521. })
  522. }
  523. that.tableData = arr;
  524. that.total = res.data.total;
  525. } else {
  526. that.$message.error(res.message);
  527. }
  528. that.tableLoading = false;
  529. that.$nextTick(() => {
  530. setTimeout(() => {
  531. that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 46;
  532. }, 1);
  533. });
  534. }).catch(function () {
  535. that.tableLoading = false;
  536. });
  537. },
  538. // 改变表格显示条数
  539. tableSizeChange (val) {
  540. let that = this;
  541. that.pageSize = val;
  542. that.getTableData(1);
  543. },
  544. // 重置搜索
  545. tableDataCancel () {
  546. let that = this;
  547. for (let key in that.filterForm.data) {
  548. if (!that.filterForm.disabled || !that.filterForm.disabled[key]) {
  549. if (that.filterForm.data[key] instanceof Array) {
  550. that.filterForm.data[key] = [];
  551. } else {
  552. that.filterForm.data[key] = '';
  553. }
  554. }
  555. }
  556. that.getTableData(1);
  557. },
  558. // 获取位置
  559. getlocateid () {
  560. let that = this
  561. let url = 'pass/ems/v1/trmlocations/getidandname/';
  562. that.axios.get(url)
  563. .then(function (res) {
  564. if (res.code === '0') {
  565. let arr = [];
  566. let obj = {};
  567. for (let item of res.data) {
  568. arr.push({
  569. id: item.id,
  570. name: item.name
  571. })
  572. obj[item.id] = item.name;
  573. }
  574. that.nameObj.locateid.arr = arr;
  575. that.nameObj.locateid.obj = obj;
  576. } else {
  577. that.$message.error(res.message);
  578. }
  579. });
  580. },
  581. // 获取能介
  582. getenergyid () {
  583. let that = this;
  584. let url = 'pass/ems/v1/trmenergys/selectNameAndId/';
  585. that.axios.get(url)
  586. .then(function (res) {
  587. if (res.code === '0') {
  588. let arr = [];
  589. let obj = {};
  590. for (let item of res.data) {
  591. arr.push({
  592. id: item.id,
  593. name: item.name,
  594. energytypeid: item.energytypeid,
  595. unitid: item.unitid
  596. })
  597. obj[item.id] = item.name
  598. }
  599. that.nameObj.energyid.arr = arr;
  600. that.nameObj.energyid.obj = obj;
  601. } else {
  602. that.$message.error(res.message);
  603. }
  604. });
  605. },
  606. // 表格中多选按钮的相关方法
  607. handleSelectionChange (val) {
  608. let that = this;
  609. let tableFormDataObj = {};
  610. for (let item of that.tableData) {
  611. item.isSelection = false;
  612. }
  613. for (let item of val) {
  614. let obj = {};
  615. let xId = item.itemid + '-' + item.clock + '-' + item.timegranid;
  616. if (that.tableFormDataObj[xId]) {
  617. tableFormDataObj[xId] = that.tableFormDataObj[xId];
  618. } else {
  619. for (let key in item) {
  620. obj[key] = item[key];
  621. }
  622. tableFormDataObj[xId] = obj;
  623. }
  624. item.isSelection = true;
  625. }
  626. that.tableFormDataObj = tableFormDataObj;
  627. that.multipleSelection = val;
  628. },
  629. look_trendChart () {
  630. let that = this;
  631. if (this.multipleSelection && this.multipleSelection.length > 0) {
  632. that.getTrendChart();
  633. that.dialog.trendChart.show = true;
  634. } else {
  635. this.$message.error('请选择计量点');
  636. }
  637. },
  638. chartSeriesType () {
  639. let that = this;
  640. for (let item of that.dialog.trendChart.chart.option.series) {
  641. item.type = that.dialog.trendChart.form.data.chartSeriesType;
  642. }
  643. // that.dialog.trendChart.chart.show = false;
  644. // setTimeout(() => {
  645. // that.dialog.trendChart.chart.show = true;
  646. // }, 100);
  647. that.$refs['graphical'].setGraphical();
  648. }
  649. }
  650. }
  651. </script>
  652. <style lang="less">
  653. .AbnormalDataMaintenance {
  654. min-width: 700px;
  655. height: 100%;
  656. .box {
  657. height: 100%;
  658. padding: 15px 15px 0 15px;
  659. .box-top {
  660. .el-form-item {
  661. margin-bottom: 7px;
  662. }
  663. .box-top-gjl {
  664. overflow: hidden;
  665. padding: 7px 0;
  666. border-top: 1px solid #ccc;
  667. // border-bottom: 1px solid #ccc;
  668. // margin-bottom: 6px;
  669. }
  670. }
  671. .el-table .el-table__row {
  672. height: 35px;
  673. }
  674. .el-table__body .el-form-item--mini.el-form-item {
  675. margin: 0px;
  676. .error {
  677. overflow: hidden;
  678. color: #f56c6c;
  679. font-size: 12px;
  680. line-height: 1;
  681. }
  682. }
  683. }
  684. .attribute-box {
  685. .item {
  686. border: #ccc 1px solid;
  687. padding: 5px;
  688. margin-bottom: 6px;
  689. .bt {
  690. font-size: 14px;
  691. font-weight: 600;
  692. color: #000;
  693. padding-left: 10px;
  694. border-left: #008fe0 5px solid;
  695. }
  696. }
  697. }
  698. }
  699. </style>