From bae4c40a651463b1395a24ebde65f0d58b001df7 Mon Sep 17 00:00:00 2001 From: fhysy <1149505133@qq.com> Date: Mon, 19 May 2025 14:45:11 +0800 Subject: [PATCH] =?UTF-8?q?feat(iot):=20=E6=96=B0=E5=A2=9E=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E7=89=A9=E6=A8=A1=E5=9E=8B=E6=9F=A5=E7=9C=8B=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在模型和模型系列页面添加物模型按钮和对话框 - 调整对接系列和型号代码 - 优化属性和函数的展示方式 - 添加 JSON 查看器组件vue-json-viewer用于展示物模型数据 --- package.json | 1 + src/store/modules/attribute.js | 2 +- src/views/iot/model/index.vue | 36 +++++- src/views/iot/modelScries/index.vue | 47 ++++++- src/views/profile/attribute/attributeForm.vue | 13 +- src/views/profile/attribute/attributeView.vue | 55 ++++---- .../profile/attribute/functionFormModel.vue | 26 ++-- src/views/profile/attribute/index.vue | 12 +- src/views/profile/attribute/paramsJson.vue | 121 +++++++++--------- 9 files changed, 202 insertions(+), 111 deletions(-) diff --git a/package.json b/package.json index 0605af82..b81a0122 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "vue-count-to": "1.0.13", "vue-cron-editor-buefy": "^0.2.17", "vue-cropper": "0.5.5", + "vue-json-viewer": "^2.2.22", "vue-router": "3.4.9", "vue-seamless-scroll": "^1.1.23", "vuedraggable": "2.24.3", diff --git a/src/store/modules/attribute.js b/src/store/modules/attribute.js index 76c0cbbf..458f7b90 100644 --- a/src/store/modules/attribute.js +++ b/src/store/modules/attribute.js @@ -92,7 +92,7 @@ const attribute = { InitAttributeAndGroup({ commit, state }, data) { commit('SET_ATTRIBUTE_LIST', data.attrList) commit('SET_GROUP_LIST', data.groupList) - commit('SET_FUNCTIon_LIST', data.functionList) + commit('SET_FUNCTION_LIST', data.functionList) console.log('res:', state, data) }, // 新增 属性 diff --git a/src/views/iot/model/index.vue b/src/views/iot/model/index.vue index 698029cb..dc0e9f60 100644 --- a/src/views/iot/model/index.vue +++ b/src/views/iot/model/index.vue @@ -258,7 +258,8 @@ position: relative; top: -10px;" > - 选择型号系列 + 物模型 + 选择型号系列 @@ -394,6 +395,24 @@ > + + + + @@ -420,6 +439,7 @@ import attributeForm from "@/views/profile/attribute/attributeForm"; import groupForm from "@/views/profile/attribute/groupForm"; import paramsJson from "@/views/profile/attribute/paramsJson"; import { listModelSeries, getModelSeries } from "@/api/iot/modelSeries"; +import ParamsJsonWrap from "@/views/profile/attribute/paramsJson"; const deviceStartsOpt = { 0: "禁用", @@ -436,9 +456,12 @@ export default { attributeForm, groupForm, paramsJson, + ParamsJsonWrap }, data() { return { + modelOpen: false, + modelValue: "", componectVal: "attributeForm", childOpt: { type: "add", @@ -618,6 +641,15 @@ export default { }; this.selectTableShow = true; }, + openModelDialog() { + this.modelOpen=true; + this.modelValue = JSON.parse( + JSON.stringify({ + properties:this.$store.getters.attributeList, + functions:this.$store.getters.functionList, + }) + ); + }, openTableSelectScriesDialog() { this.selectResult = {}; this.tableSelectOption = { @@ -914,6 +946,7 @@ export default { }, // 点击确定按钮 resuleClick() { + debugger switch(this.selectResult.tableType) { case 'vendor': this.form.vendorId = this.selectResult.vendorId; @@ -936,6 +969,7 @@ export default { _this.$refs.attributeref.handleInitData(); _this.$refs.attributeref.forceUpdateList('groupForm'); _this.$refs.attributeref.forceUpdateList('attributeForm'); + _this.$refs.attributeref.forceUpdateList('functionForm'); }, 100); break; diff --git a/src/views/iot/modelScries/index.vue b/src/views/iot/modelScries/index.vue index 0afee8b3..538c24d1 100644 --- a/src/views/iot/modelScries/index.vue +++ b/src/views/iot/modelScries/index.vue @@ -178,11 +178,21 @@ + + 物模型 + + + + @@ -297,6 +324,7 @@ import groupForm from "@/views/profile/attribute/groupForm"; import paramsJson from "@/views/profile/attribute/paramsJson"; import ParamWrap from "@/components/ParamWrap/deviceParam"; import AttributeView from "@/views/profile/attribute/index"; +import ParamsJsonWrap from "@/views/profile/attribute/paramsJson"; export default { name: "ModelSeries", @@ -307,9 +335,12 @@ export default { paramsJson, AttributeView, ParamWrap, + ParamsJsonWrap }, data() { return { + modelOpen: false, + modelValue: "", // 遮罩层 loading: true, // 选中数组 @@ -380,6 +411,15 @@ export default { this.getList(); }, methods: { + openModelDialog() { + this.modelOpen=true; + this.modelValue = JSON.parse( + JSON.stringify({ + properties:this.$store.getters.attributeList, + functions:this.$store.getters.functionList, + }) + ); + }, indexFormatter(val) { return ( val + 1 + (this.queryParams.pageNum - 1) * this.queryParams.pageSize @@ -392,7 +432,10 @@ export default { (this.childOpt.paramIdx = data.paramIdx); this.AttributeViewShow = true; this.functionList = JSON.parse( - JSON.stringify(this.$store.getters.attributeList) + JSON.stringify({ + properties:this.$store.getters.attributeList, + functions:this.$store.getters.groupList, + }) ); this.componectVal = data.component; }, diff --git a/src/views/profile/attribute/attributeForm.vue b/src/views/profile/attribute/attributeForm.vue index 9e493dd1..56b52c1c 100644 --- a/src/views/profile/attribute/attributeForm.vue +++ b/src/views/profile/attribute/attributeForm.vue @@ -32,8 +32,8 @@ /> - - + + 新增 - - 物模型参数 - + + + + + + + + + @@ -221,23 +221,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -352,11 +352,12 @@ export default { console.log('666', res) this.functionList = res this.$forceUpdate() - this.loading = false + this.loading = false }); }, 50) }, setList(list) { + debugger this.loading = true this.functionList = [] setTimeout(() => { diff --git a/src/views/profile/attribute/functionFormModel.vue b/src/views/profile/attribute/functionFormModel.vue index d2addd5d..a0dde441 100644 --- a/src/views/profile/attribute/functionFormModel.vue +++ b/src/views/profile/attribute/functionFormModel.vue @@ -124,22 +124,22 @@ @@ -341,7 +341,7 @@ export default { output: {} }; } - + // 确保输入参数表单也被重置 this.inputFormObj = { isEdit: false, @@ -433,18 +433,18 @@ export default { // 添加一个新的枚举项 const newEnumItem = JSON.parse(JSON.stringify(defaultenumForm)); - newEnumItem.valueError = false; - newEnumItem.textError = false; + newEnumItem.value = false; + newEnumItem.text = false; this.inputFormObj.form.valueType.elements.push(newEnumItem); }, validateEnumItem(item, field, index) { if (field === 'value') { - item.valueError = !item.value; + item.value = !item.value; } else if (field === 'text') { - item.textError = !item.text; + item.text = !item.text; } - return !item.valueError && !item.textError; + return !item.value && !item.text; }, // 修改提交方法,增加枚举项验证 @@ -465,9 +465,9 @@ export default { let hasError = false; for (let i = 0; i < this.inputFormObj.form.valueType.elements.length; i++) { const item = this.inputFormObj.form.valueType.elements[i]; - item.valueError = !item.value; - item.textError = !item.text; - if (item.valueError || item.textError) { + item.value = !item.value; + item.text = !item.text; + if (item.value || item.text) { hasError = true; } } diff --git a/src/views/profile/attribute/index.vue b/src/views/profile/attribute/index.vue index ac28d040..58476731 100644 --- a/src/views/profile/attribute/index.vue +++ b/src/views/profile/attribute/index.vue @@ -11,7 +11,7 @@ /> - +
-
- - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - 暂无数据 -
+ + + + + + + + + + + + + + + +
-
- 复制 +
+ + +
-
{{paramsList}}
+ + + +