diff --git a/src/store/getters.js b/src/store/getters.js index 13170fce..5ec56868 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -17,6 +17,7 @@ const getters = { userId: state => state.user.userId, attributeList: state => state.attribute.attributeList, groupList: state => state.attribute.groupList, + functionList: state => state.attribute.functionList, attributeInfo: state => state.permission.attribute } export default getters diff --git a/src/store/modules/attribute.js b/src/store/modules/attribute.js index 494c7ed2..76c0cbbf 100644 --- a/src/store/modules/attribute.js +++ b/src/store/modules/attribute.js @@ -4,7 +4,8 @@ import { Notification, MessageBox, Message } from 'element-ui' const attribute = { state: { attributeList: [], - groupList: [] + groupList: [], + functionList: [], }, mutations: { @@ -12,39 +13,59 @@ const attribute = { // debugger state.attributeList = list }, - SET_GROUP_LIST: (state, list) => { - state.groupList = list - }, PUSH_ATTRIBUTE: (state, item) => { state.attributeList.push(item) }, - PUSH_GROUP: (state, item) => { - state.groupList.push(item) - }, UPDATE_ATTRIBUTE: (state, {item, idx}) => { state.attributeList[idx] = item }, - UPDATE_GROUP: (state, {item, idx}) => { - state.groupList[idx] = item - }, DELETE_ATTRIBUTE: (state, idx) => { state.attributeList.splice(idx,1); }, - DELETE_GROUP: (state, idx) => { - state.groupList.splice(idx,1); - }, GET_ATTRIBUTE_ITEM: (state, idx) => { return state.attributeList[idx] }, - GET_GROUP_ITEM: (state, idx) => { - return state.groupList[idx] - }, GET_ATTRIBUTE_LIST: (state) => { return state.attributeList }, + + SET_GROUP_LIST: (state, list) => { + state.groupList = list + }, + PUSH_GROUP: (state, item) => { + state.groupList.push(item) + }, + UPDATE_GROUP: (state, {item, idx}) => { + state.groupList[idx] = item + }, + DELETE_GROUP: (state, idx) => { + state.groupList.splice(idx,1); + }, + GET_GROUP_ITEM: (state, idx) => { + return state.groupList[idx] + }, GET_GROUP_LIST: (state) => { return state.groupList }, + //功能 + SET_FUNCTION_LIST: (state, list) => { + state.functionList = list + }, + PUSH_FUNCTION: (state, item) => { + state.functionList.push(item) + }, + UPDATE_FUNCTION: (state, {item, idx}) => { + state.functionList[idx] = item + }, + DELETE_FUNCTION: (state, idx) => { + state.functionList.splice(idx,1); + }, + GET_FUNCTION_ITEM: (state, idx) => { + return state.functionList[idx] + }, + GET_FUNCTION_LIST: (state) => { + return state.functionList + }, }, actions: { @@ -59,6 +80,11 @@ const attribute = { resolve(state.groupList) }) }, + GetFunctionList({state}) { + return new Promise((resolve, reject) => { + resolve(state.functionList) + }) + }, setAttribute({ commit, state }, data){ commit('SET_ATTRIBUTE_LIST', data) }, @@ -66,6 +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) console.log('res:', state, data) }, // 新增 属性 @@ -76,6 +103,10 @@ const attribute = { AddGroup({ commit, state }, data) { commit('PUSH_GROUP', data) }, + // 新增 功能 + AddFunction({ commit, state }, data) { + commit('PUSH_FUNCTION', data) + }, // 获取 属性 单个信息 GetAttributeItem({ commit, state }, idx) { return new Promise((resolve, reject) => { @@ -96,6 +127,10 @@ const attribute = { EditGroup({ commit, state }, param) { commit('UPDATE_GROUP', param) }, + // 修改 列表 + EditFunction({ commit, state }, param) { + commit('UPDATE_FUNCTION', param) + }, // 删除分组 删除分组 判断分组是否有属性,有属性就不能删除 DeleteGroup({ commit, state }, idx) { let groupItem = state.groupList[idx]; @@ -113,7 +148,12 @@ const attribute = { // 删除属性 DeleteAttribute({ commit, state }, idx) { commit('DELETE_ATTRIBUTE', idx) - } + }, + // 删除方法 + DeleteFunction({ commit, state }, idx) { + commit('DELETE_FUNCTION', idx) + }, + } } diff --git a/src/views/iot/model/index.vue b/src/views/iot/model/index.vue index 66118dfb..698029cb 100644 --- a/src/views/iot/model/index.vue +++ b/src/views/iot/model/index.vue @@ -517,7 +517,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; }, @@ -1032,8 +1035,19 @@ export default { }); groupList.sort((a, b) => a.sort - b.sort); } - console.log(groupList, attrList); - this.form.prodJson = JSON.stringify(attrList) || null; + let functionList = []; + if ( + this.$store.getters.functionList && + this.$store.getters.functionList.length > 0 + ) { + functionList = this.$store.getters.functionList; + } + + this.form.prodJson = JSON.stringify({ + properties:attrList, + functions:functionList, + events:[] + }) || null; this.form.remark = JSON.stringify(groupList) || null; } diff --git a/src/views/iot/modelScries/index.vue b/src/views/iot/modelScries/index.vue index d2debcf3..0afee8b3 100644 --- a/src/views/iot/modelScries/index.vue +++ b/src/views/iot/modelScries/index.vue @@ -522,7 +522,20 @@ export default { }); groupList.sort((a, b) => a.sort - b.sort); } - this.form.prodJson = JSON.stringify(attrList) || null; + + let functionList = []; + if ( + this.$store.getters.functionList && + this.$store.getters.functionList.length > 0 + ) { + functionList = this.$store.getters.functionList; + } + + this.form.prodJson = JSON.stringify({ + properties:attrList, + functions:functionList, + events:[] + }) || null; this.form.remark = JSON.stringify(groupList) || null; // } diff --git a/src/views/profile/DeviceRunStarts/index.vue b/src/views/profile/DeviceRunStarts/index.vue index db34afe9..8c3093d4 100644 --- a/src/views/profile/DeviceRunStarts/index.vue +++ b/src/views/profile/DeviceRunStarts/index.vue @@ -1,53 +1,53 @@