删除多余代码注释

This commit is contained in:
zyy 2020-08-27 13:13:15 +08:00
parent c2f549523a
commit 8a3287ca22
5 changed files with 93 additions and 104 deletions

View File

@ -3,7 +3,6 @@ class Theme {
this._code = '02'; this._code = '02';
this._mapMenu = { this._mapMenu = {
'01': 'chengdu_01', '01': 'chengdu_01',
// '01': 'ningbo_03',
'02': 'fuzhou_01', '02': 'fuzhou_01',
'03': 'beijing_01', '03': 'beijing_01',
'04': 'chengdu_03', '04': 'chengdu_03',

View File

@ -14,114 +14,101 @@ export default {
ExcelConfig: { ExcelConfig: {
beginRow: 1, beginRow: 1,
beginCol: 0, beginCol: 0,
fieldNum: 10, fieldNum: 6,
sepField: '行车间隔', sepField: '车次号',
trainId: 'TrainID', columns: {
columns: ['折返线', 'TrainID', '行车间隔'] '停车站名称': { key: 'stationName', formatter: (val) => { return val; } },
'到达时间': { key: 'arriveTime', formatter: (val) => { return val; } },
'出发时间': { key: 'departureTime', formatter: (val) => { return val; } }
}
}, },
/** 解析exal数据转换为Json后台数据*/ /** 解析exal数据转换为Json后台数据*/
importData(Sheet, JsonData) { importData(Sheet, JsonData) {
var dataList = convertSheetToList(Sheet, true); const dataList = convertSheetToList(Sheet, true);
if (dataList && dataList.length) { const needList = Object.keys(this.ExcelConfig.columns);
if (dataList && dataList.length && dataList[1] && dataList[0]) { debugger;
// const tIndex = dataList.findIndex(it => { return it[0]; }); // 设置不用过滤行数
const tIndex = 9; // 设置不用过滤行数
/** 解析二维数组为json对象*/ if (dataList && dataList.length) {
const reg3 = /^(\d+:\d+:\d+|)/; // 06:12:00 for (let colIndex = this.ExcelConfig.beginCol; colIndex < dataList.length; colIndex += this.ExcelConfig.fieldNum + 1) {
dataList.forEach((elem, i) => { let isContinue = true;
var begin = -1; let tripObj = { code: '', directionCode: '', arrivalList: [] };
/** 跳过名称所在的行*/ for (let rowIndex = this.ExcelConfig.beginRow; isContinue; rowIndex += 1) {
if (i != tIndex && elem && elem.length > 0) { isContinue = false;
let flag = false;
let count = 0; const stationObj = {};
let param = { begTime: '', endTime: '' }; for (let index = 0; index < this.ExcelConfig.fieldNum; index += 1) {
if (i > tIndex) { elem.reverse(); } if (dataList[colIndex + index]) {
elem.forEach((item, j) => { const title = dataList[colIndex + index][0];
/** 过滤空值*/ const value = dataList[colIndex + index][rowIndex];
if (item) {
let title = ''; if (title && value) {
var value = `${item}`.trim(); // 数据列解析
if (i > tIndex) { // 上行线 isContinue = true;
title = `${dataList[tIndex][dataList[tIndex].length - j - 1]}`.replace(/\s*/g, ''); const titleStr = `${title}`.trim();
if (title == 'undefined') { let valueStr = `${value}`.trim();
title = `${dataList[tIndex][dataList[tIndex].length - j - 2]}`.replace(/\s*/g, '');
} if (titleStr == this.ExcelConfig.sepField) {
} else { // 下行线 valueStr = `${dataList[colIndex + index - 1][rowIndex]}${valueStr}`;
title = `${dataList[tIndex][j]}`.replace(/\s*/g, ''); if (tripObj.code) {
if (title == 'undefined') { const length = tripObj.arrivalList.length;
title = `${dataList[tIndex][j - 1]}`.replace(/\s*/g, ''); if (length == 1) {
tripObj.arrivalList[0]['flag'] = true;
}
if (valueStr != tripObj.code) {
JsonData.push(tripObj);
const strVal = `${value}`.trim();
tripObj = { code: valueStr, directionCode: strVal[0], arrivalList: [] };
}
} else {
const strVal = `${value}`.trim();
tripObj.code = valueStr;
tripObj.directionCode = strVal[0];
} }
} }
/** 匹配到开始位置或者结束位置*/ // 取需要的字段
if (title == this.ExcelConfig.trainId) { if (needList.findIndex(elem => { return elem == titleStr; }) >= 0) {
if (begin == -1) { stationObj[this.ExcelConfig.columns[titleStr].key] = this.ExcelConfig.columns[titleStr].formatter(valueStr);
flag = true; if (this.ExcelConfig.columns[titleStr].key == 'arriveTime' || this.ExcelConfig.columns[titleStr].key == 'departureTime') {
begin = value; // 设置初始索引 stationObj[this.ExcelConfig.columns[titleStr].key] = this.ExcelConfig.columns[titleStr].formatter(prefixTime(valueStr));
JsonData.push({
code: value,
destinationCode: '',
arrivalList: []
});
} else if (flag) {
begin = -1; // 清空初始索引
JsonData[JsonData.length - 1].destinationCode = value;
flag = false;
}
} else if (begin !== -1) {
/** 匹配到中间位置*/
var stationName = title.replace(/\s/, '');
if (this.ExcelConfig.columns.indexOf(stationName) == -1 && reg3.test(value)) {
let need = false;
if (value.split(':')[0] == '24') { // 24:XX:XX 类似这种数据 变24为00
const arr = value.split(':');
arr[0] = '00';
value = arr.join(':');
}
if (count == 1) {
count = 0;
param.endTime = value;
}
if (count == 0) {
count = 1;
param.begTime = param.begTime || value;
}
if (param.begTime && param.endTime) {
need = true;
}
/** 添加json数据*/
if (need) { // 储存非空 数据
var stationObj = {
stationName: stationName
};
stationObj['arriveTime'] = prefixTime(param.begTime);
stationObj['departureTime'] = prefixTime(param.endTime);
JsonData[JsonData.length - 1].arrivalList.push(stationObj);
param = { begTime: '', endTime: '' };
count = 0;
}
} }
} }
} }
}); }
} }
});
// 添加字段值
if (Object.keys(stationObj).length) {
if (stationObj.arriveTime) {
tripObj.arrivalList.push(stationObj);
}
}
}
// 添加最后那条没有车次的记录
if (tripObj.code) {
const length = tripObj.arrivalList.length;
if (length) {
tripObj.arrivalList[length - 1]['flag'] = true;
}
JsonData.push(tripObj);
}
} }
} }
return JsonData; return JsonData;
}, },
/** 将后台数据解析成图表*/ /** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeCoordMap, lineStyle) { convertDataToModels(data, stations, kmRangeCoordMap, lineStyle) {
var models = []; var models = [];
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) { if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
/** 按服务遍历数据*/ /** 按服务遍历数据*/
data.serviceNumberDataList.forEach((service) => { data.serviceNumberDataList.forEach((service) => {
/** 按车次遍历数据*/ /** 按车次遍历数据*/
var isBackup = true;
var opt = { name: '', markPointData: [], data: [] }; var opt = { name: '', markPointData: [], data: [] };
if (service.tripNumberDataList && service.tripNumberDataList.length) { if (service.tripNumberDataList && service.tripNumberDataList.length) {
service.tripNumberDataList.forEach((train, j) => { service.tripNumberDataList.forEach((train, j) => {
@ -134,7 +121,8 @@ export default {
/** 如果车次号为空,不显示名称*/ /** 如果车次号为空,不显示名称*/
if (train.tripNumber) { if (train.tripNumber) {
/** 创建标记点名称和坐标*/ /** 创建标记点名称和坐标*/
pointdata.name = `${service.serviceNumber}${train.tripNumber}${train.destinationCode || ''}`; // pointdata.name = `${service.serviceNumber}${train.directionCode}${train.tripNumber}`;
pointdata.name = `${service.serviceNumber}${train.tripNumber}`;
pointdata.color = '#000' || lineStyle.color; pointdata.color = '#000' || lineStyle.color;
pointdata.directionCode = train.directionCode; pointdata.directionCode = train.directionCode;
pointdata.coord = [train.stationTimeList[1].secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, train.stationTimeList[1], train.directionCode, false)]; pointdata.coord = [train.stationTimeList[1].secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, train.stationTimeList[1], train.directionCode, false)];
@ -152,7 +140,7 @@ export default {
index == train.stationTimeList.length - 2 && train.stationTimeList[index].secondTime != train.stationTimeList[index + 1].secondTime || index == train.stationTimeList.length - 2 && train.stationTimeList[index].secondTime != train.stationTimeList[index + 1].secondTime ||
index > 0 && index < train.stationTimeList.length - 1) { index > 0 && index < train.stationTimeList.length - 1) {
const aa = `${train.directionCode}${train.tripNumber}`; const aa = `${train.directionCode}${train.tripNumber}`;
opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, elem, elem.directionCode, false), elem.stationCode, aa, `${service.serviceNumber}${train.tripNumber}${train.destinationCode || ''}`]); opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, elem, elem.directionCode, false), elem.stationCode, aa]);
} }
}); });
@ -161,8 +149,9 @@ export default {
lastPoint = train.stationTimeList[idx - 1]; lastPoint = train.stationTimeList[idx - 1];
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[1]; nextPoint = service.tripNumberDataList[j + 1].stationTimeList[1];
num = this.computedReentryNumber(train.tripNumber); num = this.computedReentryNumber(train.tripNumber);
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, lastPoint, train.directionCode, true, num), lastPoint.stationCode, `${service.serviceNumber}${train.tripNumber}${train.destinationCode || ''}`]); const aa = `${train.directionCode}${train.tripNumber}`;
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, nextPoint, train.directionCode, true, num), nextPoint.stationCode, `${service.serviceNumber}${train.tripNumber}${train.destinationCode || ''}`]); opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, lastPoint, train.directionCode, true, num), lastPoint.stationCode, aa]);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeCoordMap, nextPoint, train.directionCode, true, num), nextPoint.stationCode, aa]);
} }
/** 如果是备用车,按车次添加线*/ /** 如果是备用车,按车次添加线*/
@ -175,10 +164,12 @@ export default {
opt = { name: '', markPointData: [], data: [] }; opt = { name: '', markPointData: [], data: [] };
} }
} }
isBackup = train.backup;
}); });
// 不是备用车,按服务添加线 // 不是备用车,按服务添加线
if (!service.backup) { if (!isBackup) {
/** 创建一条完成的服务数据*/ /** 创建一条完成的服务数据*/
var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle)); var model = createSeriesModel(opt, Object.assign({ color: hexColor.toCreate() }, lineStyle));
if (model) { if (model) {
@ -201,6 +192,7 @@ export default {
if (!runPlanData[elem.serviceNumber]) { if (!runPlanData[elem.serviceNumber]) {
/** 创建一个新服务号标记*/ /** 创建一个新服务号标记*/
runPlanData[elem.serviceNumber] = {}; runPlanData[elem.serviceNumber] = {};
/** 不存在此服务号则需要创建一条新的line*/ /** 不存在此服务号则需要创建一条新的line*/
series.push(createSeriesModel({ series.push(createSeriesModel({
zlevel: 1, zlevel: 1,
@ -229,17 +221,17 @@ export default {
serie.markPoint.data.push(createMartPoint({ serie.markPoint.data.push(createMartPoint({
directionCode: elem.directionCode, directionCode: elem.directionCode,
coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)], coord: [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false)],
name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}${elem.destinationCode || ''}`, name: `(${elem.groupNumber})${elem.serviceNumber}${elem.tripNumber}`,
color: lineStyle.color || '#000' color: lineStyle.color || '#000'
})); }));
} }
/** 计算折返点*/ /** 计算折返点*/
var nextPoint = [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, false), elem.directionCode]; var num = this.computedReentryNumber(elem.tripNumber);
var nextPoint = [parseInt(elem.secondTime), this.getCoordYByElem(stations, kmRangeCoordMap, elem, elem.directionCode, false, num), elem.directionCode];
if (serie.data.length > 0) { if (serie.data.length > 0) {
var lastPoint = serie.data[serie.data.length - 1]; var lastPoint = serie.data[serie.data.length - 1];
if (lastPoint[2] !== nextPoint[2]) { if (lastPoint[2] !== nextPoint[2]) {
var num = this.computedReentryNumber(elem.tripNumber);
serie.data.push([lastPoint[0], this.getYvalueByDirectionCode(lastPoint[1], lastPoint[2], num), lastPoint[2]]); serie.data.push([lastPoint[0], this.getYvalueByDirectionCode(lastPoint[1], lastPoint[2], num), lastPoint[2]]);
serie.data.push([nextPoint[0], this.getYvalueByDirectionCode(nextPoint[1], lastPoint[2], num), lastPoint[2]]); serie.data.push([nextPoint[0], this.getYvalueByDirectionCode(nextPoint[1], lastPoint[2], num), lastPoint[2]]);
} }

View File

@ -73,7 +73,8 @@ export default {
{ {
name: '发布', name: '发布',
handleClick: this.publishScript, handleClick: this.publishScript,
type: 'primary' type: 'primary',
showControl: (row) => { return !row.publish; }
} }
] ]
} }

View File

@ -219,7 +219,6 @@ export default {
for (const index in wb.Sheets) { for (const index in wb.Sheets) {
jsonData = that.planConvert.importData(wb.Sheets[index], jsonData); jsonData = that.planConvert.importData(wb.Sheets[index], jsonData);
} }
console.log(jsonData, '解析后数据');
if (that.$route.query.lineCode == '02' && !jsonData[0].downTrack && !jsonData[0].upTrack) { if (that.$route.query.lineCode == '02' && !jsonData[0].downTrack && !jsonData[0].upTrack) {
that.loadingDig.close(); that.loadingDig.close();

View File

@ -214,13 +214,11 @@ export default {
}); });
} }
if (wb) { if (wb) {
try { let jsonData = [];
let jsonData = []; for (const index in wb.Sheets) {
for (const index in wb.Sheets) { jsonData = that.planConvert.importData(wb.Sheets[index], jsonData);
jsonData = that.planConvert.importData(wb.Sheets[index], jsonData); }
} if (jsonData.length) {
console.log(jsonData, '解析后数据');
if (that.$route.query.lineCode == '02' && !jsonData[0].downTrack && !jsonData[0].upTrack) { if (that.$route.query.lineCode == '02' && !jsonData[0].downTrack && !jsonData[0].upTrack) {
that.loadingDig.close(); that.loadingDig.close();
that.$message.warning(`运行图暂无默认上行折返轨或默认下行折返轨,请输入`); that.$message.warning(`运行图暂无默认上行折返轨或默认下行折返轨,请输入`);
@ -237,9 +235,9 @@ export default {
that.$message.warning(`${that.$t('tip.importRunGraphFailed')} ${error.message}`); that.$message.warning(`${that.$t('tip.importRunGraphFailed')} ${error.message}`);
}); });
} }
} catch (error) { } else {
that.loadingDig.close(); that.loadingDig.close();
that.$message.warning(`${that.$t('tip.parseRunGraphFailed')} ${error.message}`); that.$message.warning(that.$t('tip.parseRunGraphFailed'));
} }
} }
}; };