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

224 lines
8.8 KiB
JavaScript
Raw Normal View History

2019-07-26 13:32:43 +08:00
const runPlan = {
namespaced: true,
2019-07-26 13:32:43 +08:00
state: {
stations: [], // 车站列表
planData: {}, // 运行图原始数据
editData: {}, // 运行图编辑数据
planSizeCount: 0, // 运行图canvas 大小变更标识
planLoadedCount: 0, // 运行图数据更新
2020-12-01 10:20:54 +08:00
// planUpdateCount: 0, // 运行图更新标识
selected: {}, // 选择的对象
width: 800, // 运行图canvas 容器 宽度
height: 600, // 运行图canvas 容器 高度
2020-02-27 22:09:51 +08:00
refreshCount: 0, // 刷新页面重新加载
2020-08-14 18:30:04 +08:00
initialPlanData: {}, // 运行图原始数据
draftSelected: {}, // 草稿运行图选中对象
2020-12-15 18:15:48 +08:00
draftStations: [], // 草稿运行图车站列表
runPlanMap: {}, // 运行图数据map以id和version 为标识)
2020-12-24 15:33:06 +08:00
runPlanInfo: {}, // 运行图信息
loadRunPlanCount: 0 // 运行图加载数据完成
},
getters: {
stations: (state) => {
return state.stations || [];
},
2020-08-17 18:12:51 +08:00
draftStations: (state) => {
return state.draftStations || [];
2020-12-15 18:15:48 +08:00
},
getRunPlanData: (state) => {
if (!state.runPlanInfo || !state.runPlanInfo.templateId) {
return '';
} else {
return state.runPlanMap[`runPlan_${state.runPlanInfo.templateId}_${state.runPlanInfo.version}`];
}
}
},
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;
},
2020-08-14 18:30:04 +08:00
setDraftStations: (state, stations) => {
state.draftStations = stations;
},
2020-02-27 22:09:51 +08:00
setInitialPlanData: (state, data) => {
state.initialPlanData = {};
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
const serviceList = data.serviceNumberDataList;
serviceList.forEach((service, i) => {
const trainList = service.tripNumberDataList;
state.initialPlanData[service.serviceNumber] = { oldIndex: i, serviceNumber: service.serviceNumber, backup: service.backup, trainMap: {} };
trainList.forEach((train, j) => {
2020-10-22 18:30:02 +08:00
state.initialPlanData[service.serviceNumber].trainMap[`${train.tripNumber}`] = { oldIndex: j, tripNumber: train.tripNumber, directionCode: train.directionCode, reentry: train.reentry, stationTimeList: train.stationTimeList };
2020-02-27 22:09:51 +08:00
});
});
}
},
setPlanData: (state, data) => {
state.planData = data;
state.editData = {};
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
const serviceList = data.serviceNumberDataList;
serviceList.forEach((service, i) => {
const trainList = service.tripNumberDataList;
state.editData[service.serviceNumber] = { oldIndex: i, serviceNumber: service.serviceNumber, backup: service.backup, trainMap: {} };
trainList.forEach((train, j) => {
2020-10-22 18:30:02 +08:00
// ${train.directionCode}
state.editData[service.serviceNumber].trainMap[`${train.tripNumber}`] = { oldIndex: j, tripNumber: train.tripNumber, directionCode: train.directionCode, reentry: train.reentry, stationTimeList: train.stationTimeList };
});
});
}
state.planLoadedCount++;
},
2020-08-14 18:30:04 +08:00
setDraftPlanData: (state, data) => {
state.draftPlanData = data;
state.draftEditData = {};
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
const serviceList = data.serviceNumberDataList;
serviceList.forEach((service, i) => {
const trainList = service.tripNumberDataList;
state.draftEditData[service.serviceNumber] = { oldIndex: i, serviceNumber: service.serviceNumber, backup: service.backup, trainMap: {} };
trainList.forEach((train, j) => {
2020-10-22 18:30:02 +08:00
// ${train.directionCode}
state.draftEditData[service.serviceNumber].trainMap[`${train.tripNumber}`] = { oldIndex: j, tripNumber: train.tripNumber, directionCode: train.directionCode, reentry: train.reentry, stationTimeList: train.stationTimeList };
2020-08-14 18:30:04 +08:00
});
});
}
},
setSelected: (state, selected) => {
state.selected = selected;
},
2020-08-14 18:30:04 +08:00
setDraftSelected: (state, draftSelected) => {
state.draftSelected = draftSelected;
},
addserviceNumber: (state, serviceNumber) => {
const serviceObj = state.planData[serviceNumber];
if (serviceObj) {
const oldIndex = serviceObj.oldIndex;
state.planData[serviceNumber] = { oldIndex, serviceNumber, trainMap: {} };
state.planLoadedCount++;
}
},
clear: (state) => {
2020-08-07 10:29:18 +08:00
// state.stations = [];
state.planData = {};
state.editData = {};
state.selected = {};
},
2020-08-14 18:30:04 +08:00
draftClear: (state) => {
state.draftPlanData = {};
state.draftEditData = {};
state.draftSelecte = {};
},
refresh: (state) => {
state.refreshCount++;
2020-12-15 18:15:48 +08:00
},
setRunPlanMap: ( state, data) => {
if (state.runPlanInfo && state.runPlanInfo.templateId) {
state.runPlanMap[`runPlan_${state.runPlanInfo.templateId}_${state.runPlanInfo.version}`] = data;
}
},
setRunPlanInfo: (state, data) => {
state.runPlanInfo = data;
2020-12-24 15:33:06 +08:00
},
loadRunPlanCountIncrease:(state, data) => {
state.loadRunPlanCount++;
}
},
actions: {
/** 设置运行图大小*/
resize({ commit }, opt) {
if (opt.width) {
commit('setWidth', opt.width);
}
if (opt.height) {
commit('setHeight', opt.height);
}
},
/** 设置stations数据 */
setStations: ({ commit }, mapModel) => {
return new Promise((resolve) => {
commit('setStations', mapModel);
resolve(mapModel);
});
},
2020-08-14 18:30:04 +08:00
/** 设置草稿stations数据 */
setDraftStations: ({ commit }, mapModel) => {
return new Promise((resolve) =>{
commit('setDraftStations', mapModel);
resolve(mapModel);
});
},
/** 重置运行图数据更新池 */
resetRunPlanData:({ commit }) => {
commit('resetRunPlanData');
},
/** 删除运行图第一条shuj */
shiftRunPlanData:({ commit }) => {
commit('shiftRunPlanData');
},
/** 设置运行图数据 */
setPlanData: ({ commit }, data) => {
commit('setPlanData', data);
},
2020-08-14 18:30:04 +08:00
setDraftPlanData: ({ commit }, data) => {
commit('setDraftPlanData', data);
},
2020-02-27 22:09:51 +08:00
/** 设置初始运行图数据 */
setInitialPlanData: ({ commit }, data) => {
commit('setInitialPlanData', data);
},
/** 增加服务号*/
addserviceNumber: ({ commit }, serviceNumber) => {
commit('addserviceNumber', serviceNumber);
},
/** 选择车次*/
setSelected: ({ commit }, selected) => {
commit('setSelected', selected);
},
2020-08-14 18:30:04 +08:00
setDraftSelected: ({ commit }, draftSelected) => {
commit('setDraftSelected', draftSelected);
},
/** 更新数据*/
updateRunPlanData: ({ commit }, data) => {
commit('updateRunPlanData', data);
},
/** 清空数据*/
clear: ({ commit }) => {
2020-08-03 18:45:24 +08:00
return new Promise((resolve) => {
commit('clear');
resolve();
});
},
2020-08-14 18:30:04 +08:00
draftClear: ({ commit }) => {
return new Promise(resolve => {
commit('draftClear');
resolve();
});
},
/** 刷新页面*/
refresh: ({commit}) => {
commit('refresh');
2020-12-15 18:15:48 +08:00
},
setRunPlanInfo: ({commit}, data) => {
commit('setRunPlanInfo', data);
},
setRunPlanMap: ({commit}, data) => {
commit('setRunPlanMap', data);
2020-12-24 15:33:06 +08:00
},
loadRunPlanCountIncrease: ({commit}) => {
commit('loadRunPlanCountIncrease');
}
}
2019-07-26 13:32:43 +08:00
};
export default runPlan;