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

74 lines
2.0 KiB
JavaScript
Raw Normal View History

2019-08-27 14:17:36 +08:00
import Vue from 'vue';
/**
* ibp状态数据
*/
const ibp = {
2019-12-06 17:54:38 +08:00
namespaced: true,
2019-08-27 14:17:36 +08:00
2019-12-06 17:54:38 +08:00
state: {
ibp: null, // 数据
updateDeviceData: {}, // 修改的数据
rightClickCount: 0, // 右键点击设备
ibpBgDevice: {} // ibp背景设备
},
2019-08-27 14:17:36 +08:00
2019-12-06 17:54:38 +08:00
getters: {
ibp: (state) => {
return state.ibp;
},
updateDeviceData: (state) => {
return state.updateDeviceData;
}
},
2019-08-27 14:17:36 +08:00
2019-12-06 17:54:38 +08:00
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;
}
},
2019-08-27 14:17:36 +08:00
2019-12-06 17:54:38 +08:00
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);
}
}
2019-08-27 14:17:36 +08:00
};
export default ibp;