From 907db90e93d6f79cb0625a076b02e833021fa72e Mon Sep 17 00:00:00 2001 From: lb Date: Mon, 9 Oct 2023 16:27:44 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E8=AE=BE=E5=A4=87=E5=88=86=E7=BB=84?= =?UTF-8?q?=E7=9A=84=E6=8A=BD=E5=B1=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DialogForm/index.vue | 2 + src/mixins/lb/basicPageMixin.js | 3 + .../equipmentGroup/components/BasicDrawer.vue | 476 ++++++++++++++++++ src/views/base/equipmentGroup/index.vue | 171 ++++++- src/views/core/base/equipment/index.vue | 62 ++- 5 files changed, 661 insertions(+), 53 deletions(-) create mode 100644 src/views/base/equipmentGroup/components/BasicDrawer.vue diff --git a/src/components/DialogForm/index.vue b/src/components/DialogForm/index.vue index 03c05be4..80c08798 100644 --- a/src/components/DialogForm/index.vue +++ b/src/components/DialogForm/index.vue @@ -89,6 +89,8 @@ function findMaxLabelWidth(rows) { let max = 0; rows.forEach((row) => { row.forEach((opt) => { + // debugger; + if (!opt.label) return 0; if (opt.label.length > max) { max = opt.label.length; } diff --git a/src/mixins/lb/basicPageMixin.js b/src/mixins/lb/basicPageMixin.js index 8eab17ff..36c61708 100644 --- a/src/mixins/lb/basicPageMixin.js +++ b/src/mixins/lb/basicPageMixin.js @@ -53,6 +53,9 @@ export default { case 'delete': this.handleDelete(data); break; + case 'detail': + this.handleDetail(data); + break; } }, // 处理搜索栏按钮 diff --git a/src/views/base/equipmentGroup/components/BasicDrawer.vue b/src/views/base/equipmentGroup/components/BasicDrawer.vue new file mode 100644 index 00000000..4869984a --- /dev/null +++ b/src/views/base/equipmentGroup/components/BasicDrawer.vue @@ -0,0 +1,476 @@ + + + + + + + diff --git a/src/views/base/equipmentGroup/index.vue b/src/views/base/equipmentGroup/index.vue index 24d248fe..8afc99fb 100644 --- a/src/views/base/equipmentGroup/index.vue +++ b/src/views/base/equipmentGroup/index.vue @@ -40,6 +40,57 @@ @confirm="submitForm"> + + + @@ -53,17 +104,27 @@ import { exportEquipmentGroupExcel, } from '@/api/base/equipmentGroup'; import moment from 'moment'; +import { publicFormatter } from '@/utils/dict'; import basicPageMixin from '@/mixins/lb/basicPageMixin'; -import { getAccessToken } from '@/utils/auth'; +// import { getAccessToken } from '@/utils/auth'; +import BasicDrawer from './components/BasicDrawer.vue'; export default { name: 'EquipmentGroup', mixins: [basicPageMixin], - components: {}, + components: { BasicDrawer }, data() { return { + editVisible: false, + editMode: '', searchBarKeys: ['name', 'code'], tableBtn: [ + this.$auth.hasPermi('base:equipment-group:update') + ? { + type: 'detail', + btnName: '查看报警', + } + : undefined, this.$auth.hasPermi('base:equipment-group:update') ? { type: 'edit', @@ -88,33 +149,78 @@ export default { { prop: 'name', label: '设备分组名称' }, { prop: 'code', label: '设备分组编码' }, { prop: 'remark', label: '备注' }, - { - _action: 'equipment-group-show-alert', - label: '报警', - subcomponent: { - props: ['injectData'], - render: function (h) { - const _this = this; - return h( - 'el-button', - { - props: { type: 'text' }, - on: { - click: function () { - console.log('inejctdata', _this.injectData); - _this.$emit('emitData', { - action: _this.injectData._action, - // value: _this.injectData.id, - value: _this.injectData, - }); - }, - }, - }, - '查看报警' - ); - }, + // { + // _action: 'equipment-group-show-alert', + // label: '报警', + // subcomponent: { + // props: ['injectData'], + // render: function (h) { + // const _this = this; + // return h( + // 'el-button', + // { + // props: { type: 'text' }, + // on: { + // click: function () { + // console.log('inejctdata', _this.injectData); + // _this.$emit('emitData', { + // action: _this.injectData._action, + // // value: _this.injectData.id, + // value: _this.injectData, + // }); + // }, + // }, + // }, + // '查看报警' + // ); + // }, + // }, + // }, + ], + drawerBaseInfoRows: [ + [ + { + input: true, + label: '设备分组名称', + prop: 'name', + rules: [{ required: true, message: '不能为空', trigger: 'blur' }], + // bind: { + // disabled: this.editMode == 'detail', // some condition, like detail mode... + // } }, + { + input: true, + label: '设备分组编码', + prop: 'code', + // url: '/base/equipment/getCode', + } + ] + ], + drawerListProps: [ + { + prop: 'createTime', + label: '添加时间', + fixed: true, + width: 180, + filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'), }, + { width: 240, prop: 'code', label: '报警编码' }, + { + width: 100, + prop: 'type', + label: '报警类型', + filter: (val) => + val != null ? ['-', '字符型', '布尔型', '-'][val] : '-', + }, + { + width: 90, + prop: 'grade', + label: '报警级别', + filter: publicFormatter(this.DICT_TYPE.EQU_ALARM_LEVEL), + }, + { width: 180, prop: 'alarmCode', label: '设备报警编码' }, + { width: 128, prop: 'plcParamName', label: '参数列名' }, + { width: 128, prop: 'alarmContent', label: '报警内容' }, ], searchBarFormConfig: [ { @@ -299,6 +405,17 @@ export default { }); }); }, + handleDetail(row) { + const { id, code, name, createTime } = row; + + // 打开抽屉 + this.editMode = 'detail'; + this.form.id = id; + this.editVisible = true; + this.$nextTick(() => { + this.$refs['drawer'].init(); + }); + }, /** 删除按钮操作 */ handleDelete(row) { const id = row.id; diff --git a/src/views/core/base/equipment/index.vue b/src/views/core/base/equipment/index.vue index 5b70519e..37aaaac1 100644 --- a/src/views/core/base/equipment/index.vue +++ b/src/views/core/base/equipment/index.vue @@ -139,6 +139,12 @@ export default { btnName: '删除', } : undefined, + this.$auth.hasPermi(`base:equipment:update`) + ? { + type: 'detail', + btnName: '详情', + } + : undefined, ].filter((v) => v), tableProps: [ { @@ -153,32 +159,32 @@ export default { { prop: 'equipmentType', label: '设备类型' }, { prop: 'enName', label: '英文名称' }, { prop: 'abbr', label: '缩写' }, - { - action: 'show-detail', - label: '详情', - subcomponent: { - props: ['injectData'], - render: function (h) { - const _this = this; - return h( - 'el-button', - { - props: { type: 'text', size: 'mini' }, - on: { - click: function () { - console.log('inejctdata', _this.injectData); - _this.$emit('emitData', { - action: _this.injectData.action, - value: _this.injectData.id, - }); - }, - }, - }, - '查看详情' - ); - }, - }, - }, + // { + // action: 'show-detail', + // label: '详情', + // subcomponent: { + // props: ['injectData'], + // render: function (h) { + // const _this = this; + // return h( + // 'el-button', + // { + // props: { type: 'text', size: 'mini' }, + // on: { + // click: function () { + // console.log('inejctdata', _this.injectData); + // _this.$emit('emitData', { + // action: _this.injectData.action, + // value: _this.injectData.id, + // }); + // }, + // }, + // }, + // '查看详情' + // ); + // }, + // }, + // }, ], searchBarFormConfig: [ { @@ -532,6 +538,10 @@ export default { case 'delete': this.handleDelete(data); break; + case 'detail': + const { id } = data; + this.viewDetail(id); + break; } }, },