|
@ -256,13 +256,17 @@ async function exportAchievementDetail(ctx, dataList) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
|
|
|
* 查询明细表已存在编号数据,回款、合同、开票通用 |
|
|
|
|
|
* @param {*} ctx ctx ctx.query:{tableModel表模型名} |
|
|
|
|
|
*/ |
|
|
async function getReceivedNumbers(ctx) { |
|
|
async function getReceivedNumbers(ctx) { |
|
|
|
|
|
let errorMsg = { name: 'FindError', message: '查询失败' }; |
|
|
try { |
|
|
try { |
|
|
const { tableModel } = ctx.query; |
|
|
const { tableModel } = ctx.query; |
|
|
const models = ctx.fs.dc.models; |
|
|
const models = ctx.fs.dc.models; |
|
|
let model = tableModel || 'ReceivableDetail' |
|
|
let modelName = tableModel || 'ReceivableDetail' |
|
|
let list = await models[model].findAll({//查编号
|
|
|
let list = await models[modelName].findAll({//查编号
|
|
|
attributes: ['number'] |
|
|
attributes: ['number'] |
|
|
}); |
|
|
}); |
|
|
ctx.status = 200 |
|
|
ctx.status = 200 |
|
@ -270,20 +274,23 @@ async function getReceivedNumbers(ctx) { |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
ctx.status = 400; |
|
|
ctx.status = 400; |
|
|
ctx.body = { |
|
|
ctx.body = errorMsg; |
|
|
message: typeof error == 'string' ? error : undefined |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
|
|
|
* 导入明细表数据,回款、合同、开票通用 |
|
|
|
|
|
* @param {*} ctx ctx ctx.query:{tableModel表模型名} |
|
|
|
|
|
*/ |
|
|
async function importBackDetails(ctx) { |
|
|
async function importBackDetails(ctx) { |
|
|
let errorMsg = { message: '导入回款明细失败' }; |
|
|
let errorMsg = { message: '导入失败' }; |
|
|
const transaction = await ctx.fs.dc.orm.transaction(); |
|
|
const transaction = await ctx.fs.dc.orm.transaction(); |
|
|
try { |
|
|
try { |
|
|
const models = ctx.fs.dc.models; |
|
|
const models = ctx.fs.dc.models; |
|
|
const data = ctx.request.body; |
|
|
const data = ctx.request.body; |
|
|
|
|
|
const { tableModel } = ctx.query; |
|
|
|
|
|
let modelName = tableModel || 'ReceivableDetail' |
|
|
let addArr = []; |
|
|
let addArr = []; |
|
|
let dataList = await models.ReceivableDetail.findAll({//查编号
|
|
|
let dataList = await models[modelName].findAll({//查编号
|
|
|
attributes: ['number'] |
|
|
attributes: ['number'] |
|
|
}); |
|
|
}); |
|
|
data.map(d => { |
|
|
data.map(d => { |
|
@ -294,7 +301,7 @@ async function importBackDetails(ctx) { |
|
|
}) |
|
|
}) |
|
|
//只处理新增的
|
|
|
//只处理新增的
|
|
|
if (addArr.length) { |
|
|
if (addArr.length) { |
|
|
await models.ReceivableDetail.bulkCreate(addArr); |
|
|
await models[modelName].bulkCreate(addArr, { transaction }); |
|
|
} |
|
|
} |
|
|
await transaction.commit(); |
|
|
await transaction.commit(); |
|
|
ctx.status = 204; |
|
|
ctx.status = 204; |
|
@ -440,8 +447,8 @@ module.exports = { |
|
|
getReceivedDetail,//回款
|
|
|
getReceivedDetail,//回款
|
|
|
getAchievementDetail,//业绩
|
|
|
getAchievementDetail,//业绩
|
|
|
|
|
|
|
|
|
getReceivedNumbers,//查询回款明细表 已有的所有编号
|
|
|
getReceivedNumbers,//查询回款、合同、开票明细表 已有的所有编号
|
|
|
importBackDetails,//导入回款明细
|
|
|
importBackDetails,//导入回款、合同、开票明细
|
|
|
importAchieveDetails,//导入业绩明细
|
|
|
importAchieveDetails,//导入业绩明细
|
|
|
getContractDetail, |
|
|
getContractDetail, |
|
|
getInvoicingDetail, |
|
|
getInvoicingDetail, |
|
|