From c1ab37bfc11d137cba210ed2abc2a4cfe3ec38a5 Mon Sep 17 00:00:00 2001 From: fhysy <1149505133@qq.com> Date: Wed, 21 May 2025 11:52:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(iot):=20=E6=96=B0=E5=A2=9E=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=8A=9F=E8=83=BD=E8=B0=83=E7=94=A8=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加功能列表和事件列表的 vuex state管理 - 实现功能调用的简化模式和高级模式 - 增加功能调用结果的展示和记录 - 优化设备信息展示界面,支持功能和事件的显示 - 新增 Monaco 编辑器组件用于 JSON 数据编辑 --- package.json | 2 + src/store/getters.js | 1 + src/store/modules/attribute.js | 51 +- src/views/components/my-monaco-editor.vue | 106 +++ src/views/iot/device/profile/functionWrap.vue | 885 ++++++++++++++++-- src/views/iot/model/index.vue | 13 +- src/views/profile/DeviceRunStarts/index.vue | 149 ++- src/views/profile/attribute/attributeView.vue | 1 - .../profile/attribute/functionFormModel.vue | 31 +- src/views/profile/attribute/index.vue | 11 +- vue.config.js | 4 +- 11 files changed, 1118 insertions(+), 136 deletions(-) create mode 100644 src/views/components/my-monaco-editor.vue diff --git a/package.json b/package.json index b81a0122..5a59c332 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,8 @@ "jsbarcode": "^3.11.6", "jsencrypt": "3.0.0-rc.1", "moment": "^2.29.4", + "monaco-editor": "0.24.0", + "monaco-editor-webpack-plugin": "3.1.0", "nprogress": "0.2.0", "qrcodejs2": "^0.0.2", "quill": "1.3.7", diff --git a/src/store/getters.js b/src/store/getters.js index 5ec56868..2bacb96d 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -18,6 +18,7 @@ const getters = { attributeList: state => state.attribute.attributeList, groupList: state => state.attribute.groupList, functionList: state => state.attribute.functionList, + eventList: state => state.attribute.eventList, attributeInfo: state => state.permission.attribute } export default getters diff --git a/src/store/modules/attribute.js b/src/store/modules/attribute.js index 458f7b90..dbef5110 100644 --- a/src/store/modules/attribute.js +++ b/src/store/modules/attribute.js @@ -6,6 +6,7 @@ const attribute = { attributeList: [], groupList: [], functionList: [], + eventList: [], }, mutations: { @@ -66,6 +67,25 @@ const attribute = { GET_FUNCTION_LIST: (state) => { return state.functionList }, + //功能 + SET_EVENT_LIST: (state, list) => { + state.eventList = list + }, + PUSH_EVENT: (state, item) => { + state.eventList.push(item) + }, + UPDATE_EVENT: (state, {item, idx}) => { + state.eventList[idx] = item + }, + DELETE_EVENT: (state, idx) => { + state.eventList.splice(idx,1); + }, + GET_EVENT_ITEM: (state, idx) => { + return state.eventList[idx] + }, + GET_EVENT_LIST: (state) => { + return state.eventList + }, }, actions: { @@ -85,6 +105,11 @@ const attribute = { resolve(state.functionList) }) }, + GetEventList({state}) { + return new Promise((resolve, reject) => { + resolve(state.eventList) + }) + }, setAttribute({ commit, state }, data){ commit('SET_ATTRIBUTE_LIST', data) }, @@ -93,6 +118,7 @@ const attribute = { commit('SET_ATTRIBUTE_LIST', data.attrList) commit('SET_GROUP_LIST', data.groupList) commit('SET_FUNCTION_LIST', data.functionList) + commit('SET_EVENT_LIST', data.eventList) console.log('res:', state, data) }, // 新增 属性 @@ -107,6 +133,10 @@ const attribute = { AddFunction({ commit, state }, data) { commit('PUSH_FUNCTION', data) }, + // 新增 功能 + AddEvent({ commit, state }, data) { + commit('PUSH_EVENT', data) + }, // 获取 属性 单个信息 GetAttributeItem({ commit, state }, idx) { return new Promise((resolve, reject) => { @@ -119,6 +149,18 @@ const attribute = { resolve(state.groupList[idx]) }) }, + // 获取 功能 单个信息 + GetFunctionItem({ commit, state }, idx) { + return new Promise((resolve, reject) => { + resolve(state.functionList[idx]) + }) + }, + // 获取 功能 单个信息 + GetEventItem({ commit, state }, idx) { + return new Promise((resolve, reject) => { + resolve(state.eventList[idx]) + }) + }, // 修改 属性 EditAttribute({ commit, state }, param) { commit('UPDATE_ATTRIBUTE', param) @@ -131,6 +173,10 @@ const attribute = { EditFunction({ commit, state }, param) { commit('UPDATE_FUNCTION', param) }, + // 修改 事件 + EditEvent({ commit, state }, param) { + commit('UPDATE_EVENT', param) + }, // 删除分组 删除分组 判断分组是否有属性,有属性就不能删除 DeleteGroup({ commit, state }, idx) { let groupItem = state.groupList[idx]; @@ -153,7 +199,10 @@ const attribute = { DeleteFunction({ commit, state }, idx) { commit('DELETE_FUNCTION', idx) }, - + // 删除事件 + DeleteEvent({ commit, state }, idx) { + commit('DELETE_EVENT', idx) + }, } } diff --git a/src/views/components/my-monaco-editor.vue b/src/views/components/my-monaco-editor.vue new file mode 100644 index 00000000..03ce62cd --- /dev/null +++ b/src/views/components/my-monaco-editor.vue @@ -0,0 +1,106 @@ + + + + + + + + + diff --git a/src/views/iot/device/profile/functionWrap.vue b/src/views/iot/device/profile/functionWrap.vue index fff9ccda..1991540d 100644 --- a/src/views/iot/device/profile/functionWrap.vue +++ b/src/views/iot/device/profile/functionWrap.vue @@ -14,9 +14,259 @@ +