87 lines
2.3 KiB
JavaScript
87 lines
2.3 KiB
JavaScript
import Vue from 'vue';
|
|
|
|
/**
|
|
* ibp状态数据
|
|
*/
|
|
const ibp = {
|
|
namespaced: true,
|
|
|
|
state: {
|
|
ibp: null, // 数据
|
|
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;
|