|
@ -289,19 +289,19 @@ async function importBackDetails(ctx) { |
|
|
const data = ctx.request.body; |
|
|
const data = ctx.request.body; |
|
|
const { tableModel } = ctx.query; |
|
|
const { tableModel } = ctx.query; |
|
|
let modelName = tableModel || 'ReceivableDetail' |
|
|
let modelName = tableModel || 'ReceivableDetail' |
|
|
let addArr = []; |
|
|
//let addArr = [];
|
|
|
let dataList = await models[modelName].findAll({//查编号
|
|
|
// let dataList = await models[modelName].findAll({//查编号
|
|
|
attributes: ['number'] |
|
|
// attributes: ['number']
|
|
|
}); |
|
|
// });
|
|
|
data.map(d => { |
|
|
//data.map(d => {
|
|
|
let exist = dataList.find(m => m.dataValues.number == d.number); |
|
|
//let exist = dataList.find(m => m.dataValues.number == d.number);
|
|
|
if (!exist) { |
|
|
//if (!exist) {
|
|
|
addArr.push(d); |
|
|
//addArr.push(d);
|
|
|
} |
|
|
//}
|
|
|
}) |
|
|
//})
|
|
|
//只处理新增的
|
|
|
//只处理新增的
|
|
|
if (addArr.length) { |
|
|
if (data.length) { |
|
|
await models[modelName].bulkCreate(addArr, { transaction }); |
|
|
await models[modelName].bulkCreate(data, { transaction }); |
|
|
} |
|
|
} |
|
|
await transaction.commit(); |
|
|
await transaction.commit(); |
|
|
ctx.status = 204; |
|
|
ctx.status = 204; |
|
|