|
@ -1194,58 +1194,75 @@ async function exportSpotRode (ctx) { |
|
|
}] |
|
|
}] |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
let town = await models.Town.findAll({}) || [] |
|
|
|
|
|
let village = await models.Village.findAll({ attributes: ['id', 'name'] }) || [] |
|
|
|
|
|
|
|
|
const header = [{ |
|
|
const header = [{ |
|
|
key: 'level', |
|
|
key: 'townshipCode', |
|
|
title: '道路类型', |
|
|
title: '所属乡镇', |
|
|
|
|
|
}, { |
|
|
|
|
|
key: 'villageId', |
|
|
|
|
|
title: '所属行政村', |
|
|
}, { |
|
|
}, { |
|
|
key: 'routeName', |
|
|
key: 'routeName', |
|
|
title: '路线名称', |
|
|
title: '道路名称', |
|
|
}, { |
|
|
}, { |
|
|
key: 'routeCode', |
|
|
key: 'routeCode', |
|
|
title: '路线代码', |
|
|
title: '道路代码', |
|
|
|
|
|
}, { |
|
|
|
|
|
key: 'startStation', |
|
|
|
|
|
title: '起点桩号', |
|
|
|
|
|
}, { |
|
|
|
|
|
key: 'stopStation', |
|
|
|
|
|
title: '止点桩号', |
|
|
|
|
|
}, { |
|
|
|
|
|
key: 'technicalLevel', |
|
|
|
|
|
title: '技术等级', |
|
|
}, { |
|
|
}, { |
|
|
key: 'sectionNo', |
|
|
key: 'pavementType', |
|
|
title: '路段序号', |
|
|
title: '路面类型', |
|
|
}, { |
|
|
}, { |
|
|
key: 'startingPlaceName', |
|
|
key: 'pavementWidth', |
|
|
title: '起点名称', |
|
|
title: '路面宽度', |
|
|
}, { |
|
|
}, { |
|
|
key: 'stopPlaceName', |
|
|
key: 'subgradeWidth', |
|
|
title: '止点名称', |
|
|
title: '路基宽度', |
|
|
}, { |
|
|
}, { |
|
|
key: 'chainageMileage', |
|
|
key: 'chainageMileage', |
|
|
title: '里程', |
|
|
title: '桩号里程', |
|
|
}, { |
|
|
}, { |
|
|
key: 'maintenanceCount', |
|
|
key: 'maintenanceCount', |
|
|
title: '养护次数(次)', |
|
|
title: '养护次数(次)', |
|
|
},] |
|
|
},] |
|
|
|
|
|
|
|
|
function judgeLevel (routeCode) { |
|
|
// function judgeLevel (routeCode) {
|
|
|
if (routeCode) { |
|
|
// if (routeCode) {
|
|
|
if (routeCode.startsWith('X')) { |
|
|
// if (routeCode.startsWith('X')) {
|
|
|
return '县道' |
|
|
// return '县道'
|
|
|
} else if (routeCode.startsWith('Y')) { |
|
|
// } else if (routeCode.startsWith('Y')) {
|
|
|
return '乡道' |
|
|
// return '乡道'
|
|
|
} else if (routeCode.startsWith('C')) { |
|
|
// } else if (routeCode.startsWith('C')) {
|
|
|
return '村道' |
|
|
// return '村道'
|
|
|
} |
|
|
// }
|
|
|
return '' |
|
|
// return ''
|
|
|
} else { |
|
|
// } else {
|
|
|
return '' |
|
|
// return ''
|
|
|
} |
|
|
// }
|
|
|
} |
|
|
// }
|
|
|
|
|
|
|
|
|
let exportData = listRes.map(({ dataValues: item }) => { |
|
|
let exportData = listRes.map(({ dataValues: item }) => { |
|
|
let road = item.road && item.road.dataValues || {} |
|
|
let road = item.road && item.road.dataValues || {} |
|
|
return { |
|
|
return { |
|
|
level: |
|
|
townshipCode: (town.find(d => d.code == road.townshipCode) || {}).name || '--', |
|
|
judgeLevel(road.routeCode) |
|
|
villageId: (village.find(d => road.villageId == d.id) || {}).name || '--', |
|
|
, |
|
|
|
|
|
routeName: road.routeName, |
|
|
routeName: road.routeName, |
|
|
routeCode: road.routeCode, |
|
|
routeCode: road.routeCode, |
|
|
sectionNo: road.sectionNo, |
|
|
startStation: road.startStation, |
|
|
startingPlaceName: road.startingPlaceName, |
|
|
stopStation: road.stopStation, |
|
|
stopPlaceName: road.stopPlaceName, |
|
|
technicalLevel: road.technicalLevel, |
|
|
|
|
|
pavementType: road.pavementType, |
|
|
|
|
|
pavementWidth: road.pavementWidth, |
|
|
|
|
|
subgradeWidth: road.subgradeWidth, |
|
|
chainageMileage: road.chainageMileage, |
|
|
chainageMileage: road.chainageMileage, |
|
|
maintenanceCount: item.maintenanceCount, |
|
|
maintenanceCount: item.maintenanceCount, |
|
|
} |
|
|
} |
|
@ -1253,8 +1270,8 @@ async function exportSpotRode (ctx) { |
|
|
|
|
|
|
|
|
const fileName = `${moment(previewRes.date).format('YYYY年MM月DD日HH时mm分')}道路抽查记录` + '.csv' |
|
|
const fileName = `${moment(previewRes.date).format('YYYY年MM月DD日HH时mm分')}道路抽查记录` + '.csv' |
|
|
const filePath = await xlsxDownload.simpleExcelDown({ |
|
|
const filePath = await xlsxDownload.simpleExcelDown({ |
|
|
|
|
|
data: exportData, header, fileName: fileName |
|
|
// data: exportData, header, fileName: fileName, gather: { data: previewRes.gather || [] }
|
|
|
// data: exportData, header, fileName: fileName, gather: { data: previewRes.gather || [] }
|
|
|
data: exportData, header, fileName: fileName, |
|
|
|
|
|
}) |
|
|
}) |
|
|
const fileData = fs.readFileSync(filePath); |
|
|
const fileData = fs.readFileSync(filePath); |
|
|
|
|
|
|
|
|