From 2df5897f3d85fa49dbb16077ff57055a42a4448f Mon Sep 17 00:00:00 2001 From: g7hoo Date: Thu, 1 Sep 2022 09:16:51 +0800 Subject: [PATCH] update timeFilter --- TODO.md | 3 +- src/utils/filters.js | 7 +- src/views/modules/monitoring/equipment.vue | 67 +++++-------------- .../modules/monitoring/equipmentAlarmLog.vue | 5 +- .../modules/monitoring/equipmentFile.vue | 5 +- .../modules/monitoring/equipmentGroup.vue | 5 +- .../monitoring/equipmentGroupAlarm.vue | 3 +- src/views/modules/monitoring/equipmentPlc.vue | 1 + .../monitoring/equipmentPlcConnect.vue | 1 + .../modules/monitoring/equipmentPlcParam.vue | 1 + .../modules/monitoring/equipmentQuantity.vue | 5 +- .../modules/monitoring/equipmentStatusLog.vue | 5 +- .../modules/monitoring/equipmentType.vue | 3 +- .../modules/monitoring/equipmentTypeFile.vue | 5 +- .../modules/monitoring/equipmentattr.vue | 3 +- src/views/modules/monitoring/factory.vue | 3 +- src/views/modules/monitoring/product.vue | 3 +- src/views/modules/monitoring/productArrt.vue | 3 +- .../modules/monitoring/productionLine.vue | 3 +- .../monitoring/productionLineRecSch.vue | 1 + .../monitoring/qualityInspectionCurrent.vue | 1 + .../monitoring/qualityInspectionDet.vue | 3 +- .../monitoring/qualityInspectionRecord.vue | 5 +- .../monitoring/qualityInspectionType.vue | 3 +- .../modules/monitoring/realtimeEquipment.vue | 1 + .../monitoring/realtimeProductLine.vue | 1 + .../monitoring/realtimeQualityInspection.vue | 1 + .../modules/monitoring/reportCategory.vue | 7 +- src/views/modules/monitoring/reportDetail.vue | 3 +- src/views/modules/monitoring/reportList.vue | 2 +- src/views/modules/monitoring/reportSheet.vue | 3 +- .../monitoring/reportSheetCategory.vue | 3 +- src/views/modules/monitoring/sysfile.vue | 5 +- src/views/modules/monitoring/sysfileType.vue | 5 +- .../modules/monitoring/workShopSection.vue | 3 +- .../monitoring/workShopSectionEquipment.vue | 3 +- 36 files changed, 91 insertions(+), 90 deletions(-) diff --git a/TODO.md b/TODO.md index f845bbd..142065b 100644 --- a/TODO.md +++ b/TODO.md @@ -2,4 +2,5 @@ 1. 按钮加权限 2. 国际化 -3. 表格高度 \ No newline at end of file +3. 表格高度 +4. 表格时间格式修改 \ No newline at end of file diff --git a/src/utils/filters.js b/src/utils/filters.js index 46188dc..a41e535 100644 --- a/src/utils/filters.js +++ b/src/utils/filters.js @@ -1,7 +1,12 @@ /** filters */ +import moment from 'moment' export const dictFilter = dictTypeId => { return val => { return JSON.parse(localStorage.getItem('dictList'))[dictTypeId].find(item => item.dictValue === val)?.dictLabel || '-' } -} \ No newline at end of file +} + +export const timeFilter = (val) => { + return moment(val).format('YYYY-MM-DD HH:mm:ss') +} diff --git a/src/views/modules/monitoring/equipment.vue b/src/views/modules/monitoring/equipment.vue index e6f13ff..2b8f919 100644 --- a/src/views/modules/monitoring/equipment.vue +++ b/src/views/modules/monitoring/equipment.vue @@ -1,36 +1,17 @@ @@ -58,9 +33,9 @@ import AddOrUpdate from '@/components/base-dialog/addOrUpdate' import BaseTable from '@/components/base-table' import TableOperateComponent from '@/components/base-table/components/operationComponent' import TableTextComponent from '@/components/base-table/components/detailComponent' -import moment from 'moment' import CKEditor from 'ckeditor4-vue' import { calcMaxHeight } from '@/utils' +import { timeFilter } from '@/utils/filters' const tableConfigs = [ { @@ -75,7 +50,7 @@ const tableConfigs = [ { prop: 'createTime', name: i18n.t('createTime'), - filter: val => moment(val).format('YYYY-MM-DD HH:mm:ss') + filter: timeFilter }, { prop: 'name', name: '设备名称' }, { prop: 'code', name: '设备编码' }, @@ -235,7 +210,7 @@ const addOrUpdateConfigs = { relatedField: 'equipmentId', tableConfigs: [ { type: 'index', name: '序号' }, - { prop: 'createTime', name: '创建时间' }, + { prop: 'createTime', name: '创建时间', filter: timeFilter }, { prop: 'attrName', name: '属性名称', formField: true }, { prop: 'attrValue', name: '属性值', formField: true }, { @@ -313,9 +288,7 @@ export default { // key: this.dataForm.key }) }).then(({ data }) => { - const eqTypeConfig = this.addOrUpdateConfigs.fields.find( - item => item.name === 'equipmentTypeId' - ) + const eqTypeConfig = this.addOrUpdateConfigs.fields.find(item => item.name === 'equipmentTypeId') eqTypeConfig.options = data.data?.list?.map(item => ({ value: item.id, @@ -334,9 +307,7 @@ export default { // key: this.dataForm.key }) }).then(({ data }) => { - const groupConfig = this.addOrUpdateConfigs.fields.find( - item => item.name === 'groupId' - ) + const groupConfig = this.addOrUpdateConfigs.fields.find(item => item.name === 'groupId') groupConfig.options = data.data?.list?.map(item => ({ value: item.id, @@ -412,9 +383,7 @@ export default { let fileName = 'equipment-list.xls' if (res.headers['content-disposition']) { const contentDisposition = res.headers['content-disposition'] - fileName = contentDisposition.slice( - contentDisposition.indexOf('filename=') + 9 - ) + fileName = contentDisposition.slice(contentDisposition.indexOf('filename=') + 9) } fileName = decodeURIComponent(fileName) @@ -456,15 +425,11 @@ export default { : this.dataListSelections.map(item => { return item.id }) - this.$confirm( - `确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, - '提示', - { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning' - } - ).then(() => { + this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { this.$http({ url: this.$http.adornUrl('/monitoring/equipment'), method: 'delete', diff --git a/src/views/modules/monitoring/equipmentAlarmLog.vue b/src/views/modules/monitoring/equipmentAlarmLog.vue index 2968107..3a45f95 100644 --- a/src/views/modules/monitoring/equipmentAlarmLog.vue +++ b/src/views/modules/monitoring/equipmentAlarmLog.vue @@ -32,6 +32,7 @@ import BaseTable from '@/components/base-table' import TableOperateComponent from '@/components/base-table/components/operationComponent' import TableTextComponent from '@/components/base-table/components/detailComponent' import { calcMaxHeight } from '@/utils' +import { timeFilter } from '@/utils/filters' const tableConfigs = [ { prop: 'id', name: 'ID' }, { prop: 'alarmId', name: '报警信息ID,关联T_equipment_group_alarm表' }, @@ -42,10 +43,10 @@ const tableConfigs = [ { prop: 'valid', name: '删除标志,是否有效:1 可用 0不可用' }, { prop: 'creatorId', name: '创建人' }, { prop: 'creatorName', name: '创建人姓名' }, - { prop: 'createTime', name: '创建时间' }, + { prop: 'createTime', name: '创建时间', filter: timeFilter }, { prop: 'updaterId', name: '更新人' }, { prop: 'updaterName', name: '更新人姓名' }, - { prop: 'updateTime', name: '更新时间' }, + { prop: 'updateTime', name: '更新时间', filter: timeFilter }, { prop: 'version', name: '版本号' }, { prop: 'operations', name: '操作', fixed: 'right', width: 180, subcomponent: TableOperateComponent, options: ['edit', 'delete'] } ] diff --git a/src/views/modules/monitoring/equipmentFile.vue b/src/views/modules/monitoring/equipmentFile.vue index 2cb65a0..d5695cd 100644 --- a/src/views/modules/monitoring/equipmentFile.vue +++ b/src/views/modules/monitoring/equipmentFile.vue @@ -57,6 +57,7 @@ import BaseTable from '@/components/base-table' import TableOperateComponent from '@/components/base-table/components/operationComponent' import TableTextComponent from '@/components/base-table/components/detailComponent' import { calcMaxHeight } from '@/utils' +import { timeFilter } from '@/utils/filters' const tableConfigs = [ { prop: 'id', name: '' }, { prop: 'equipmentId', name: '设备ID' }, @@ -67,10 +68,10 @@ const tableConfigs = [ { prop: 'valid', name: '删除标志,是否有效:1 可用 0不可用' }, { prop: 'creatorId', name: '创建人' }, { prop: 'creatorName', name: '创建人姓名' }, - { prop: 'createTime', name: '添加时间' }, + { prop: 'createTime', name: '添加时间', filter: timeFilter }, { prop: 'updaterId', name: '更新人' }, { prop: 'updaterName', name: '更新人姓名' }, - { prop: 'updateTime', name: '更新时间' }, + { prop: 'updateTime', name: '更新时间', filter: timeFilter }, { prop: 'version', name: '版本号' }, { prop: 'typeCode', name: '文件类型编号' }, { prop: 'fileName', name: '文件名字' }, diff --git a/src/views/modules/monitoring/equipmentGroup.vue b/src/views/modules/monitoring/equipmentGroup.vue index 43d6b0e..0d70db3 100644 --- a/src/views/modules/monitoring/equipmentGroup.vue +++ b/src/views/modules/monitoring/equipmentGroup.vue @@ -27,7 +27,8 @@