From 312fdff7ff4360db5e343729f7492705ef96ea21 Mon Sep 17 00:00:00 2001 From: yinq Date: Fri, 28 Jun 2024 16:43:42 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20add=E8=83=BD=E6=BA=90=E9=A2=84?= =?UTF-8?q?=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 +- .../report/energyStatisticalReport/index.vue | 157 ++++++++++-------- 2 files changed, 90 insertions(+), 70 deletions(-) diff --git a/package.json b/package.json index f0a3beb..e979295 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,8 @@ "vue-meta": "2.4.0", "vue-router": "3.4.9", "vuedraggable": "2.24.3", - "vuex": "3.6.0" + "vuex": "3.6.0", + "xlsx": "^0.17.0" }, "devDependencies": { "@vue/cli-plugin-babel": "4.4.6", diff --git a/src/views/ems/report/energyStatisticalReport/index.vue b/src/views/ems/report/energyStatisticalReport/index.vue index cbc7a21..59db612 100644 --- a/src/views/ems/report/energyStatisticalReport/index.vue +++ b/src/views/ems/report/energyStatisticalReport/index.vue @@ -30,9 +30,21 @@ + label-width="100px" + > + + + + + - + - + 搜索 - 重置 + @@ -75,13 +87,13 @@ - - - - - - - + + + + + + + import { getWorkUnitTrees } from '@/api/ems/base/baseWorkUnit' -import Treeselect from "@riophae/vue-treeselect"; -import "@riophae/vue-treeselect/dist/vue-treeselect.css"; +import Treeselect from '@riophae/vue-treeselect' +import '@riophae/vue-treeselect/dist/vue-treeselect.css' import { energyStatisticalReportList } from '@//api/ems/report/reportPort.js' import { parseTime } from '@//utils/ruoyi' export default { - name: "EnergyStatisticalReport", + name: 'EnergyStatisticalReport', components: { Treeselect }, data() { @@ -129,103 +141,110 @@ export default { monitorWorkUnitList: [], daterangeCollectTime: [], // 弹出层标题 - title: "", + title: '', // 是否显示弹出层 open: false, // 查询参数 queryParams: { pageNum: 1, pageSize: 10, + energyType: '2', monitorCode: null, workUnitCode: null, monitorStatus: null, monitorType: null, - dateType: 10, + dateType: 10 }, // 表单参数 form: {}, workUnitProps: { - children: "children", - label: "label" + children: 'children', + label: 'label' }, dateTypeList: [ - {dateTypeCode: 19, dateTypeName: '时'}, - {dateTypeCode: 10, dateTypeName: '日'}, - {dateTypeCode: 7, dateTypeName: '月'}, - {dateTypeCode: 4, dateTypeName: '年'}, + { dateTypeCode: 19, dateTypeName: '时' }, + { dateTypeCode: 10, dateTypeName: '日' }, + { dateTypeCode: 7, dateTypeName: '月' }, + { dateTypeCode: 4, dateTypeName: '年' } ], columns: [ - {key: 0, label: `主键标识`, visible: false}, - {key: 1, label: `统计单元编号`, visible: true}, - {key: 2, label: `统计单元名称`, visible: true}, - {key: 3, label: `耗量(kwh)`, visible: true}, - {key: 4, label: `开始日期`, visible: true}, - {key: 5, label: `结束日期`, visible: true}, - {key: 6, label: `仪表值(kwh)`, visible: true} + { key: 0, label: `主键标识`, visible: false }, + { key: 1, label: `统计单元编号`, visible: true }, + { key: 2, label: `统计单元名称`, visible: true }, + { key: 3, label: `耗量(kwh)`, visible: true }, + { key: 4, label: `开始时间`, visible: true }, + { key: 5, label: `结束时间`, visible: true }, + { key: 6, label: `仪表值(kwh)`, visible: true } + ], + // 能源类型选项 + energyTypeList: [ + { value: '2', label: '电' }, + // { value: '3', label: '水' }, + // { value: '4', label: '蒸汽' } ] - }; + } }, created() { const nowDate = parseTime(new Date(), '{y}-{m}-{d}') - this.daterangeCollectTime[0] = nowDate - this.daterangeCollectTime[1] = nowDate - this.getList(); - this.getWorkUnitTrees(); + this.daterangeCollectTime[0] = nowDate + ' 00:00:00' + this.daterangeCollectTime[1] = nowDate + ' 23:59:59' + this.getList() + this.getWorkUnitTrees() }, watch: { // 根据名称筛选部门树 workUnitName(val) { - this.$refs.tree.filter(val); + this.$refs.tree.filter(val) } }, methods: { /** 转换统计单元信息数据结构 */ workUnitOptionsNormalizer(node) { if (node.children && !node.children.length) { - delete node.children; + delete node.children } return { id2: node.workUnitCode, label2: node.workUnitName, children2: node.children - }; + } }, /** 查询计量设备下拉树结构 */ getWorkUnitTrees() { getWorkUnitTrees().then(response => { - this.workUnitOptions = []; - this.workUnitOptions = JSON.parse(JSON.stringify(response.data).replaceAll('id','id2').replaceAll('code','id')); - }); + this.workUnitOptions = [] + this.workUnitOptions = JSON.parse(JSON.stringify(response.data).replaceAll('id', 'id2').replaceAll('code', 'id')) + }) }, // 筛选节点 filterNode(value, data) { - if (!value) return true; - return data.label.indexOf(value) !== -1; + if (!value) return true + return data.label.indexOf(value) !== -1 }, // 节点单击事件 handleNodeClick(data) { - this.queryParams.workUnitCode = data.id; - this.handleQuery(); + this.queryParams.workUnitCode = data.id + this.handleQuery() }, /** 查询统计计量信息列表 */ getList() { - this.loading = true; - this.queryParams.beginCollectTime = null; - this.queryParams.endCollectTime = null; + this.loading = true + this.queryParams.beginCollectTime = null + this.queryParams.endCollectTime = null if (this.daterangeCollectTime != null && this.daterangeCollectTime !== '') { - this.queryParams.beginCollectTime = this.daterangeCollectTime[0]; - this.queryParams.endCollectTime = this.daterangeCollectTime[1]; + this.queryParams.beginCollectTime = this.daterangeCollectTime[0] + this.queryParams.endCollectTime = this.daterangeCollectTime[1] } energyStatisticalReportList(this.queryParams).then(response => { - this.monitorWorkUnitList = response.rows; - this.total = response.total; - this.loading = false; - }); + this.monitorWorkUnitList = response.rows + this.total = response.total + this.loading = false + }) }, // 取消按钮 cancel() { - this.open = false; - this.reset(); + this.open = false + this.reset() }, // 表单重置 reset() { @@ -236,20 +255,20 @@ export default { monitorCode: null, workUnitCode: null, monitorStatus: 0, - monitorType: 1, - }; - this.resetForm("form"); + monitorType: 1 + } + this.resetForm('form') }, /** 搜索按钮操作 */ handleQuery() { - this.queryParams.pageNum = 1; - this.getList(); + this.queryParams.pageNum = 1 + this.getList() }, /** 重置按钮操作 */ resetQuery() { - this.resetForm("queryForm"); - this.queryParams.workUnitCode = null; - this.handleQuery(); + this.resetForm('queryForm') + this.queryParams.workUnitCode = null + this.handleQuery() }, // 多选框选中数据 handleSelectionChange(selection) { @@ -264,5 +283,5 @@ export default { }, `统计能耗报表_${new Date().getTime()}.xlsx`) } } -}; +}