import Vue from 'vue'; /** * ibp状态数据 */ const ibp = { namespaced: true, state: { ibp: null, // 数据 ibpDevice: {}, // 解析后的地图数据 ibpList: {}, // 数据列表 ibpIdList: {}, // 数据列表(以id为标识) updateDeviceData: {}, // 修改的数据 rightClickCount: 0 // 右键点击设备 }, getters: { ibpList: (state) => { return state.ibpList; }, ibp: (state) => { return state.ibp; }, version: (state) => { if (state.ibp) { return state.ibp.version; } else { return null; } }, updateDeviceData: (state) => { return state.updateDeviceData; } }, mutations: { ibpRender: (state, devices) => { Vue.prototype.$ibp && Vue.prototype.$ibp.render(devices); }, setIbpData: (state, ibp) => { state.ibp = ibp; }, setUpdateDeviceData: (state, model) => { state.rightClickCount++; state.updateDeviceData = model; }, deleteIbpDevices: (state, devices) => { Vue.prototype.$ibp && Vue.prototype.$ibp.render(devices); } }, actions: { setIbpData: ({ commit }, ibp) => { commit('setIbpData', ibp); }, updateIbpDevices: ({ commit }, models) => { return new Promise((resolve) => { if (!(models instanceof Array)) { models = [models]; } commit('ibpRender', models); resolve(models); }); }, setUpdateDeviceData: ({ commit }, models) => { commit('setUpdateDeviceData', models); }, deleteIbpDevices: ({ commit }, models ) => { models = Object.assign(models, {dispose: true}); if (!(models instanceof Array)) { models = [models]; } commit('deleteIbpDevices', models); } } }; export default ibp;