From a03d1db029e453baaf1baa777656f0cbc9272c8a Mon Sep 17 00:00:00 2001 From: g7hoo Date: Wed, 21 Sep 2022 10:15:53 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E8=AE=BE=E5=A4=87=E6=95=88=E7=8E=87?= =?UTF-8?q?=E5=88=86=E6=9E=90=E5=A4=B4=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monitoring/equipmentEfficiency.vue | 122 ++++++++++++++++-- 1 file changed, 113 insertions(+), 9 deletions(-) diff --git a/src/views/modules/monitoring/equipmentEfficiency.vue b/src/views/modules/monitoring/equipmentEfficiency.vue index 87b398b..956cda2 100644 --- a/src/views/modules/monitoring/equipmentEfficiency.vue +++ b/src/views/modules/monitoring/equipmentEfficiency.vue @@ -2,13 +2,39 @@
+ - + + + + + + + + + + + + + + + + + + + + + + + + + + + {{ $t('search') }} - {{ $t('add') }} - {{ $t('export') }} + @@ -38,6 +64,7 @@ import CKEditor from 'ckeditor4-vue' import { calcMaxHeight } from '@/utils' import { timeFilter } from '@/utils/filters' import Cookies from 'js-cookie' +import moment from 'moment' const tableConfigs = [ { @@ -241,11 +268,21 @@ const addOrUpdateConfigs = { export default { data() { return { + /** hfxny part */ + factoryList: [], + productLineList: [], + /** */ calcMaxHeight, tableConfigs, addOrUpdateConfigs, + timeType: 'range', + rawTime: null, // [] or datetime dataForm: { - key: '' + type: 1, + ftId: null, + productlines: [], + startTime: null, + entTime: null }, dataList: [], pageIndex: 1, @@ -260,13 +297,80 @@ export default { AddOrUpdate, BaseTable }, - activated() { - console.log('activated') - this.getDataList() - this.getGroupList() - this.getTypeList() + // activated() { + // console.log('activated') + // this.getDataList() + // this.getGroupList() + // this.getTypeList() + // }, + created() { + this.getFactoryList() + this.getProductLineList() + }, + watch: { + timeType() { + // 防止切换日期类型时报错 + this.rawTime = null + } }, methods: { + // 获取工厂列表 + getFactoryList() { + this.$http({ + url: this.$http.adornUrl('/monitoring/factory/page'), + method: 'get' + }).then(({ data }) => { + if (data && data.code === 0) { + this.factoryList = data.data.list + /** set default */ + if (this.factoryList.length) { + this.dataForm.ftId = this.factoryList[0].id + } + } else { + this.factoryList = [] + this.dataForm.ftId = null + } + }) + }, + // 获取产线列表 + getProductLineList() { + this.$http({ + url: this.$http.adornUrl('/monitoring/productionLine/page'), + method: 'get' + }).then(({ data }) => { + if (data && data.code === 0) { + this.productLineList = data.data.list + /** set default */ + if (this.productLineList.length) { + this.dataForm.productlines = [this.productLineList[0].id] + } + } else { + this.productLineList = [] + } + }) + }, + // 时间类型预处理 + getTimeRange() { + let startTime + let endTime + + if (this.headFormValue.timeValue instanceof Array) { + startTime = this.headFormValue.timeValue[0] ? moment(this.headFormValue.timeValue[0]).format('YYYY-MM-DDTHH:mm:ss') : '' // 强制axios使用北京时间 + endTime = this.headFormValue.timeValue[1] ? moment(this.headFormValue.timeValue[1]).format('YYYY-MM-DDTHH:mm:ss') : '' + } else { + if (this.headFormValue.timeValue) { + startTime = moment(this.headFormValue.timeValue).format('YYYY-MM-DDTHH:mm:ss') + endTime = moment(startTime) + .add(1, 'd') + .format('YYYY-MM-DDTHH:mm:ss') + } else { + startTime = '' + endTime = '' + } + } + + return { startTime, endTime } + }, // 获取设备类型列表 getTypeList() { this.$http({