2019-07-26 13:32:43 +08:00
|
|
|
const runPlan = {
|
2019-11-13 14:29:20 +08:00
|
|
|
namespaced: true,
|
2019-07-26 13:32:43 +08:00
|
|
|
|
2019-11-13 14:29:20 +08:00
|
|
|
state: {
|
|
|
|
stations: [], // 车站列表
|
|
|
|
planData: {}, // 运行图原始数据
|
|
|
|
editData: {}, // 运行图编辑数据
|
|
|
|
planSizeCount: 0, // 运行图canvas 大小变更标识
|
|
|
|
planLoadedCount: 0, // 运行图数据更新
|
|
|
|
planUpdateCount: 0, // 运行图更新标识
|
|
|
|
selected: {}, // 选择的对象
|
|
|
|
width: 800, // 运行图canvas 容器 宽度
|
|
|
|
height: 600, // 运行图canvas 容器 高度
|
2020-02-27 22:09:51 +08:00
|
|
|
refreshCount: 0, // 刷新页面重新加载
|
2020-03-17 14:54:03 +08:00
|
|
|
initialPlanData: {} // 运行图原始数据
|
2020-07-31 16:03:32 +08:00
|
|
|
|
2019-11-13 14:29:20 +08:00
|
|
|
},
|
|
|
|
getters: {
|
|
|
|
stations: (state) => {
|
|
|
|
return state.stations || [];
|
|
|
|
},
|
|
|
|
convertPlanData: (state) => () => {
|
|
|
|
const data = { serviceNumberDataList: [] };
|
|
|
|
const serviceNumberList = Object.keys(state.editData).sort((a, b) => {
|
|
|
|
return state.editData[a].oldIndex - state.editData[b].oldIndex;
|
|
|
|
});
|
2019-07-26 13:32:43 +08:00
|
|
|
|
2019-11-13 14:29:20 +08:00
|
|
|
serviceNumberList.forEach(serviceNumber => {
|
|
|
|
const serviceObj = {
|
|
|
|
serviceNumber: serviceNumber,
|
|
|
|
tripNumberDataList: []
|
|
|
|
};
|
2019-07-26 13:32:43 +08:00
|
|
|
|
2019-11-13 14:29:20 +08:00
|
|
|
if (state.editData[serviceNumber].backup) {
|
|
|
|
serviceObj['backup'] = state.editData[serviceNumber].backup;
|
|
|
|
}
|
2019-07-26 13:32:43 +08:00
|
|
|
|
2019-11-13 14:29:20 +08:00
|
|
|
const trainMap = state.editData[serviceNumber].trainMap;
|
|
|
|
const tripNumberList = Object.keys(trainMap).sort((a, b) => {
|
|
|
|
return trainMap[a].oldIndex - trainMap[b].oldIndex;
|
|
|
|
});
|
2019-07-26 13:32:43 +08:00
|
|
|
|
2019-11-13 14:29:20 +08:00
|
|
|
tripNumberList.forEach(tripNumber => {
|
|
|
|
serviceObj.tripNumberDataList.push(trainMap[tripNumber]);
|
|
|
|
});
|
2019-07-26 13:32:43 +08:00
|
|
|
|
2019-11-13 14:29:20 +08:00
|
|
|
data.serviceNumberDataList.push(serviceObj);
|
|
|
|
});
|
2019-07-26 13:32:43 +08:00
|
|
|
|
2019-11-13 14:29:20 +08:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
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-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) => {
|
|
|
|
state.initialPlanData[service.serviceNumber].trainMap[`${train.directionCode}${train.tripNumber}`] = { oldIndex: j, tripNumber: train.tripNumber, directionCode: train.directionCode, reentry: train.reentry, stationTimeList: train.stationTimeList };
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2019-11-13 14:29:20 +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) => {
|
|
|
|
state.editData[service.serviceNumber].trainMap[`${train.directionCode}${train.tripNumber}`] = { oldIndex: j, tripNumber: train.tripNumber, directionCode: train.directionCode, reentry: train.reentry, stationTimeList: train.stationTimeList };
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
state.planLoadedCount++;
|
|
|
|
},
|
|
|
|
setSelected: (state, selected) => {
|
|
|
|
state.selected = selected;
|
|
|
|
},
|
|
|
|
addserviceNumber: (state, serviceNumber) => {
|
|
|
|
const serviceObj = state.planData[serviceNumber];
|
|
|
|
if (serviceObj) {
|
|
|
|
const oldIndex = serviceObj.oldIndex;
|
|
|
|
state.planData[serviceNumber] = { oldIndex, serviceNumber, trainMap: {} };
|
|
|
|
state.planLoadedCount++;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
clear: (state) => {
|
|
|
|
state.stations = [];
|
|
|
|
state.planData = {};
|
|
|
|
state.editData = {};
|
|
|
|
state.selected = {};
|
|
|
|
},
|
|
|
|
refresh: (state) => {
|
|
|
|
state.refreshCount++;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
actions: {
|
|
|
|
/** 设置运行图大小*/
|
|
|
|
resize({ commit }, opt) {
|
|
|
|
if (opt.width) {
|
|
|
|
commit('setWidth', opt.width);
|
|
|
|
}
|
|
|
|
if (opt.height) {
|
|
|
|
commit('setHeight', opt.height);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/** 设置stations数据 */
|
|
|
|
setStations: ({ commit }, mapModel) => {
|
2020-08-03 15:27:14 +08:00
|
|
|
return new Promise((resolve) => {
|
|
|
|
commit('setStations', mapModel);
|
|
|
|
resolve(mapModel);
|
|
|
|
});
|
2019-11-13 14:29:20 +08:00
|
|
|
},
|
2020-07-31 16:03:32 +08:00
|
|
|
/** 重置运行图数据更新池 */
|
|
|
|
resetRunPlanData:({ commit }) => {
|
|
|
|
commit('resetRunPlanData');
|
|
|
|
},
|
|
|
|
/** 删除运行图第一条shuj */
|
|
|
|
shiftRunPlanData:({ commit }) => {
|
|
|
|
commit('shiftRunPlanData');
|
|
|
|
},
|
2019-11-13 14:29:20 +08:00
|
|
|
/** 设置运行图数据 */
|
|
|
|
setPlanData: ({ commit }, data) => {
|
|
|
|
commit('setPlanData', data);
|
|
|
|
},
|
2020-02-27 22:09:51 +08:00
|
|
|
/** 设置初始运行图数据 */
|
|
|
|
setInitialPlanData: ({ commit }, data) => {
|
|
|
|
commit('setInitialPlanData', data);
|
|
|
|
},
|
2019-11-13 14:29:20 +08:00
|
|
|
/** 增加服务号*/
|
|
|
|
addserviceNumber: ({ commit }, serviceNumber) => {
|
|
|
|
commit('addserviceNumber', serviceNumber);
|
|
|
|
},
|
|
|
|
/** 选择车次*/
|
|
|
|
setSelected: ({ commit }, selected) => {
|
|
|
|
commit('setSelected', selected);
|
|
|
|
},
|
|
|
|
/** 更新数据*/
|
|
|
|
updateRunPlanData: ({ commit }, data) => {
|
|
|
|
commit('updateRunPlanData', data);
|
|
|
|
},
|
|
|
|
/** 清空数据*/
|
|
|
|
clear: ({ commit }) => {
|
2020-08-03 18:45:24 +08:00
|
|
|
return new Promise((resolve) => {
|
|
|
|
commit('clear');
|
|
|
|
resolve();
|
|
|
|
});
|
2019-11-13 14:29:20 +08:00
|
|
|
},
|
|
|
|
/** 刷新页面*/
|
|
|
|
refresh: ({commit}) => {
|
|
|
|
commit('refresh');
|
|
|
|
}
|
|
|
|
}
|
2019-07-26 13:32:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export default runPlan;
|