rt-sim-training-client/src/store/modules/ibp.js

80 lines
1.6 KiB
JavaScript
Raw Normal View History

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