const runPlan = { namespaced: true, state: { stations: [], // 车站列表 planData: [], // 运行图原始数据 editData: {}, // 运行图编辑数据 planSizeCount: 0, // 运行图canvas 大小变更标识 planLoadedCount: 0, // 运行图数据更新 planUpdateCount: 0, // 运行图更新标识 selected: {}, // 选择的对象 refreshCount: 0, // 刷新页面重新加载 width: 800, // 运行图canvas 容器 宽度 height: 600, // 运行图canvas 容器 高度 }, getters: { stations: (state) => { return state.stations || []; }, planData: (state) => { return state.planData || []; } }, mutations: { setWidth: (state, width) => { state.width = width; state.planSizeCount += 1; }, setHeight: (state, height) => { state.height = height; state.planSizeCount += 1; }, setStations: (state, stations) => { state.stations = stations; }, setPlanData: (state, data) => { state.planData = data; state.editData = {}; state.planLoadedCount++; }, setSelected: (state, selected) => { state.selected = selected; }, clear: (state) => { state.planData = {}; state.editData = {}; state.selected = {}; }, refresh: (state) => { state.refreshCount++; } }, actions: { /** 更新数据*/ updateRunPlanData: ({ commit }, data) => { commit('updateRunPlanData', data); }, /** 设置运行图大小*/ resize({ commit }, opt) { if (opt.width) { commit('setWidth', opt.width); } if (opt.height) { commit('setHeight', opt.height); } }, /** 刷新页面*/ refresh: ({commit}) => { commit('refresh'); } } }; export default runPlan;