123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- import Vue from "vue";
- import Vuex from "vuex";
- Vue.use(Vuex);
- export default new Vuex.Store({
- state: {
- editCmd: "", //编辑器编辑命令
- legendObj: null, //获取的相关图例数据obj
- name: "", //图名称
- folderId: "", //文件id
- folderName: "", //文件夹名称
- buildingId: "", //建筑id
- floorId: "", //楼层id
- floorMap: "", //floorMap
- floorLocalName: "", //楼层本地名称
- id: "", //图id
- graphId: "", //图graphId
- state: "", //图状态, Draft: 未发布, WaitCheck: 待审核, Checked: 审核完成, Recyle: 回收站, Publish: 发布
- // graphId: '', //图 id 用于读图
- // id: '', // id 用于读图
- isPub: 0, // 用于读图 区分读取 已发布 or 未发布
- projectId: "Pj1101050029", // projectId
- categoryId: "", //类型id 用于读图
- // folderId: '',// 文件夹id
- tupoName: "", //拓扑图名称
- version: "", //版本号
- equipmentItemList: [], // 图上相关的设备实例
- equipmentItemNum: 0, // 图上相关的设备实例的数量
- equipItemList: {}, // 图上相关的设备实例
- equipItemNum: 0, // 图上相关的设备的数量
- zoneItemList: {}, // 图上相关的空间实例
- zoneItemNum: 0, // 图上相关的空间实例的数量
- style: {}, // 样式库信息
- equiPos: {}, // 设备位置信息
- },
- mutations: {
- // 修改编辑器命令
- SETCHOICELEHEND(state, data) {
- state.editCmd = data;
- },
- // 修改编辑器图例
- SETLEGENDOBJ(state, data) {
- state.legendObj = data;
- },
- // 设置项目信息
- SETPROJECT(state, data) {
- // name:'',//图名称
- // folderId: "", //文件id
- // folderName: "", //文件夹名称
- // buildingId: "", //建筑id
- // floorId: "", //楼层id
- // floorMap: "", //floorMap
- // floorLocalName: "", //楼层本地名称
- // id: "", //图id
- // graphId: "", //图graphId
- // state:'', //图状态, Draft: 未发布, WaitCheck: 待审核, Checked: 审核完成, Recyle: 回收站, Publish: 发布
- // const { folderId, folderName, buildingId, floorId, floorMap, floorLocalName, id, graphId, state } = data;
- const arr = ["name", "folderId", "folderName", "buildingId", "floorId", "floorMap", "floorLocalName", "id", "graphId", "state"];
- arr.map((key) => {
- // 对传入的参数进行修改
- if (data[key] !== undefined) {
- // @ts-ignore
- state[key] = data[key];
- }
- });
- },
- // 设置项目id
- SETISPUB(state, val) {
- state.isPub = val; // 是否发布 用于读图
- },
- // 设置类型id
- SETCATEGROY(state, val) {
- state.categoryId = val.categoryId;
- // state.folderId = val.folderId;
- state.tupoName = val.name; //拓扑图名称
- state.version = val.version; //版本号
- },
- SETVERSION(state, val) {
- console.log("asdfasfas", val);
- state.version = val; //版本号
- },
- // 增加设备实例 item
- ADDEQUIPITEM(state, item): void {
- state.equipmentItemList.push(item);
- state.equipmentItemNum = state.equipmentItemList.length;
- },
- // 删除设备实例 item
- EDITEQUIPITEM(state): void {
- // 如果设备实例数组中parent 为null 则删除该数组
- let arr1 = state.equipmentItemList;
- if (!arr1.length) return;
- for (var i = 0; i < arr1.length; i++) {
- if (!arr1[i].parent) {
- arr1.splice(i, 1);
- i--; //i需要自减,否则每次删除都会讲原数组索引发生变化
- }
- }
- state.equipmentItemList = arr1;
- state.equipmentItemNum = state.equipmentItemList.length;
- },
- // 初始化设备位置信息
- INITEQUIPOS(state, data) {
- state.equiPos = data;
- },
- // 初始化样式库信息
- INITSTYLE(state, data) {
- state.style = data;
- },
- // 添加样式信息
- ADDSTYLE(state, data) {
- // const {id, style} = {...data}
- // state.style[data.id] = style
- },
- // 增加设备实例item
- ADDEQUIP(state, item): void {
- // @ts-ignore
- if (!state.equipItemList[item.id]) {
- // @ts-ignore
- state.equipItemList[item.id] = item;
- state.equipItemNum = Object.keys(state.equipItemList).length;
- }
- },
- DELETEQUIP(state): void {
- // 如果设备实例数组中parent 为null 则删除该数组
- let arr1 = Object.keys(state.equipItemList);
- if (!arr1.length) return;
- arr1.forEach((key) => {
- // @ts-ignore
- if (!state.equipItemList[key].parent) {
- // @ts-ignore
- delete state.equipItemList[key];
- }
- });
- },
- },
- actions: {},
- modules: {},
- });
|