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

75 lines
2.1 KiB
JavaScript
Raw Normal View History

const runPlan = {
namespaced: true,
state: {
stations: [], // 车站列表
2020-10-19 18:39:19 +08:00
planData: [], // 运行图原始数据
editData: {}, // 运行图编辑数据
planSizeCount: 0, // 运行图canvas 大小变更标识
planLoadedCount: 0, // 运行图数据更新
planUpdateCount: 0, // 运行图更新标识
selected: {}, // 选择的对象
2020-10-27 16:51:57 +08:00
refreshCount: 0, // 刷新页面重新加载
width: 800, // 运行图canvas 容器 宽度
height: 600 // 运行图canvas 容器 高度
},
getters: {
stations: (state) => {
return state.stations || [];
2020-10-27 16:51:57 +08:00
},
planData: (state) => {
return state.planData || [];
}
},
mutations: {
2020-10-27 16:51:57 +08:00
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: {
2020-10-27 16:51:57 +08:00
/** 更新数据*/
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;