Browse Source

(*)道路导出功能提交

dev
peng.peng 10 months ago
parent
commit
2422728b43
  1. 33
      api/app/lib/controllers/data/index.js
  2. 3
      api/app/lib/models/road.js

33
api/app/lib/controllers/data/index.js

@ -4,7 +4,7 @@ const xlsxDownload = require('../../../../utils/xlsxDownload.js');
const moment = require('moment'); const moment = require('moment');
const request = require('superagent'); const request = require('superagent');
async function dataExport (ctx) { async function dataExport(ctx) {
try { try {
let tableAttributesCopy = {} let tableAttributesCopy = {}
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -85,8 +85,11 @@ async function dataExport (ctx) {
if (municipalType) { if (municipalType) {
findOption.where.type = municipalType findOption.where.type = municipalType
} }
if (modalOption.tableName === 'Road') {
const exportData = await models[modalOption.tableName].findAll(findOption) findOption.where.del = false
}
const towns = await models.Town.findAll()
let exportData = await models[modalOption.tableName].findAll(findOption)
const tableAttributes = models[modalOption.tableName].tableAttributes const tableAttributes = models[modalOption.tableName].tableAttributes
//过滤project部门字段 //过滤project部门字段
if (modalOption.tableName === 'Project') { if (modalOption.tableName === 'Project') {
@ -96,6 +99,24 @@ async function dataExport (ctx) {
entryName, projectMileage, investment, buildUnit, entryName, projectMileage, investment, buildUnit,
constructionControlUnit, designUnit, constructionUnit, qutityUnit, startTime, remark, done constructionControlUnit, designUnit, constructionUnit, qutityUnit, startTime, remark, done
} }
} else if (modalOption.tableName === 'Road') {
tableAttributesCopy = {
...tableAttributes,
townName: {
comment: '乡镇名称',
field: "townName",
index: 79
}
}
exportData = exportData.map(s => {
let town = towns.find(v => v.code == s.townshipCode)
return {
...s.dataValues,
townName: town ? town.name : '-',
spot: s.spot ? '否' : '是'
}
})
} else { } else {
tableAttributesCopy = tableAttributes tableAttributesCopy = tableAttributes
} }
@ -103,7 +124,7 @@ async function dataExport (ctx) {
let header = [] let header = []
for (let k in tableAttributesCopy) { for (let k in tableAttributesCopy) {
let comment = tableAttributes[k].comment let comment = modalOption.tableName === 'Road' ? tableAttributesCopy[k].comment : tableAttributes[k].comment
if (k != 'id' && comment) { if (k != 'id' && comment) {
if (comment == '品名' && municipalType == '出租车') { if (comment == '品名' && municipalType == '出租车') {
continue continue
@ -123,7 +144,7 @@ async function dataExport (ctx) {
header.push({ header.push({
title: comment || '-', title: comment || '-',
key: k, key: k,
index: tableAttributes[k].index, index: modalOption.tableName === 'Road' ? tableAttributesCopy[k].index : tableAttributes[k].index,
}) })
} }
} }
@ -146,7 +167,7 @@ async function dataExport (ctx) {
} }
} }
async function godTrans (ctx) { async function godTrans(ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { userId } = ctx.fs.api const { userId } = ctx.fs.api

3
api/app/lib/models/road.js

@ -795,10 +795,11 @@ module.exports = dc => {
autoIncrement: false autoIncrement: false
}, },
spot: { spot: {
index: 78,
type: DataTypes.BOOLEAN, type: DataTypes.BOOLEAN,
allowNull: true, allowNull: true,
defaultValue: true, defaultValue: true,
comment: null, comment: '是否隐藏',
primaryKey: false, primaryKey: false,
field: "spot", field: "spot",
autoIncrement: false autoIncrement: false

Loading…
Cancel
Save