2019-08-27 14:17:36 +08:00
|
|
|
import Vue from 'vue';
|
|
|
|
import { parser } from '@/ibp/utils/parser';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ibp状态数据
|
|
|
|
*/
|
|
|
|
const ibp = {
|
|
|
|
namespaced: true,
|
|
|
|
|
|
|
|
state: {
|
|
|
|
ibp: null, // 数据
|
|
|
|
ibpDevice: {}, // 解析后的地图数据
|
|
|
|
ibpList: {}, // 数据列表
|
|
|
|
ibpIdList: {} // 数据列表(以id为标识)
|
|
|
|
},
|
|
|
|
|
|
|
|
getters: {
|
|
|
|
ibpList: (state) => {
|
|
|
|
return state.ibpList;
|
|
|
|
},
|
|
|
|
ibp: (state) => {
|
|
|
|
return state.ibp;
|
|
|
|
},
|
|
|
|
version: (state) => {
|
|
|
|
if (state.ibp) {
|
|
|
|
return state.ibp.version;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mutations: {
|
|
|
|
ibpRender: (state, devices) => {
|
2019-08-28 09:57:32 +08:00
|
|
|
console.log('--2', devices);
|
2019-08-27 14:17:36 +08:00
|
|
|
Vue.prototype.$ibp && Vue.prototype.$ibp.render(devices);
|
|
|
|
},
|
|
|
|
setIbpData: (state, ibp) => {
|
|
|
|
state.ibp = ibp;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ibp;
|