Compare commits

...

2 Commits

  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 request = require('superagent');
async function dataExport (ctx) {
async function dataExport(ctx) {
try {
let tableAttributesCopy = {}
const models = ctx.fs.dc.models;
@ -85,8 +85,11 @@ async function dataExport (ctx) {
if (municipalType) {
findOption.where.type = municipalType
}
const exportData = await models[modalOption.tableName].findAll(findOption)
if (modalOption.tableName === 'Road') {
findOption.where.del = false
}
const towns = await models.Town.findAll()
let exportData = await models[modalOption.tableName].findAll(findOption)
const tableAttributes = models[modalOption.tableName].tableAttributes
//过滤project部门字段
if (modalOption.tableName === 'Project') {
@ -96,6 +99,24 @@ async function dataExport (ctx) {
entryName, projectMileage, investment, buildUnit,
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 {
tableAttributesCopy = tableAttributes
}
@ -103,7 +124,7 @@ async function dataExport (ctx) {
let header = []
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 (comment == '品名' && municipalType == '出租车') {
continue
@ -123,7 +144,7 @@ async function dataExport (ctx) {
header.push({
title: comment || '-',
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 {
const models = ctx.fs.dc.models;
const { userId } = ctx.fs.api

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

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

Loading…
Cancel
Save