From a15e78dcafcfcf1c3b0b04f58c721d206254e161 Mon Sep 17 00:00:00 2001 From: g7hoo Date: Wed, 17 Aug 2022 17:02:58 +0800 Subject: [PATCH] =?UTF-8?q?update=20attr-form=20=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91,TODO:=E6=A3=80=E6=9F=A5=E4=BA=A7=E5=93=81=E6=B1=A0?= =?UTF-8?q?=E5=92=8C=E8=AE=BE=E5=A4=87=E4=BF=A1=E6=81=AF=E7=9A=84=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=AD=90=E8=A1=A8=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/base-dialog/AttrForm/index.vue | 24 ++++++++++++------- .../base-dialog/addOrUpdate/index.vue | 2 +- src/views/modules/monitoring/equipment.vue | 12 ++++++++++ src/views/modules/monitoring/product.vue | 1 + 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/components/base-dialog/AttrForm/index.vue b/src/components/base-dialog/AttrForm/index.vue index ab4ef86..9d0bdce 100644 --- a/src/components/base-dialog/AttrForm/index.vue +++ b/src/components/base-dialog/AttrForm/index.vue @@ -66,8 +66,14 @@ export default { default: () => [] }, /** 表单提交需要的属性 */ - pId: { + relatedId: { type: String, + required: true, + default: null + }, + relatedField: { + type: String, + required: true, default: null } }, @@ -96,12 +102,12 @@ export default { }, mounted() { this.getDataList() - /** 设置 AttrForm 的 rules */ - for(const config of this.tableConfigs) { - if (config.rules) { - this.$set(this.AttrFormRules, [config.prop], config.rules) - } - } + /** 设置 AttrForm 的 rules */ + for (const config of this.tableConfigs) { + if (config.rules) { + this.$set(this.AttrFormRules, [config.prop], config.rules) + } + } }, methods: { /** init dataform */ @@ -127,7 +133,7 @@ export default { params: this.$http.adornParams({ page: this.pageIndex, limit: this.pageSize, - productId: this.pId + [this.relatedField]: this.relatedId // order: 'asc/desc', // orderField: 'name' }) @@ -210,7 +216,7 @@ export default { headers: { 'Content-Type': 'application/json' }, - data: JSON.stringify({ ...this.AttrForm, productId: this.pId }) + data: JSON.stringify({ ...this.AttrForm, [this.relatedField]: this.relatedId }) }).then(({ data }) => { if (data && data.code === 0) { this.$message({ diff --git a/src/components/base-dialog/addOrUpdate/index.vue b/src/components/base-dialog/addOrUpdate/index.vue index 2411e11..36dcd98 100644 --- a/src/components/base-dialog/addOrUpdate/index.vue +++ b/src/components/base-dialog/addOrUpdate/index.vue @@ -66,7 +66,7 @@ diff --git a/src/views/modules/monitoring/equipment.vue b/src/views/modules/monitoring/equipment.vue index d9eb275..8e3b289 100644 --- a/src/views/modules/monitoring/equipment.vue +++ b/src/views/modules/monitoring/equipment.vue @@ -154,6 +154,18 @@ const addOrUpdateConfigs = { } } ], + subtable: { + title: '查看设备属性', + url: '/monitoring/equipmentAttr', + relatedField: 'equipmentId', + tableConfigs: [ + { type: 'index', name: '序号' }, + { prop: 'createTime', name: '创建时间' }, + { prop: 'attrName', name: '属性名称', formField: true }, + { prop: 'attrValue', name: '属性值', formField: true }, + { prop: 'operate', name: '操作', options: ['edit', 'delete'] } + ] + }, operations: [ { name: 'cancel', showAlways: true }, { name: 'save', url: '/monitoring/equipment', permission: '', showOnEdit: false }, diff --git a/src/views/modules/monitoring/product.vue b/src/views/modules/monitoring/product.vue index 805c2ce..277bda0 100644 --- a/src/views/modules/monitoring/product.vue +++ b/src/views/modules/monitoring/product.vue @@ -140,6 +140,7 @@ const addOrUpdateConfigs = { // for i18n title: '动态属性', url: '/monitoring/productArrt', + relatedField: 'productId', tableConfigs: [ { type: 'index', name: '序号' }, { prop: 'createTime', name: '添加时间', filter: val => (val ? moment(val).format('YYYY-MM-DD hh:mm:ss') : '-') },