90 lines
1.9 KiB
JavaScript
90 lines
1.9 KiB
JavaScript
import Vue from 'vue';
|
|
|
|
/**
|
|
* ibp状态数据
|
|
*/
|
|
const ibp = {
|
|
namespaced: true,
|
|
|
|
state: {
|
|
ibp: null, // 数据
|
|
ibpDevice: {}, // 解析后的地图数据
|
|
ibpList: {}, // 数据列表
|
|
ibpIdList: {}, // 数据列表(以id为标识)
|
|
updateDeviceData: {}, // 修改的数据
|
|
rightClickCount: 0, // 右键点击设备
|
|
ibpBgDevice: {} // ibp背景设备
|
|
},
|
|
|
|
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;
|
|
},
|
|
ibpBgDevice: (state) => {
|
|
return state.ibpBgDevice;
|
|
}
|
|
},
|
|
|
|
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);
|
|
},
|
|
setIbpBgDevice: (state, ibpBgDevice) => {
|
|
state.ibpBgDevice = ibpBgDevice;
|
|
}
|
|
},
|
|
|
|
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);
|
|
},
|
|
setIbpBgDevice: ( { commit }, device) => {
|
|
commit('setIbpBgDevice', device);
|
|
}
|
|
}
|
|
};
|
|
|
|
export default ibp;
|