Browse Source

(*)回款和开票明细表导入 去掉编号判重

master
wuqun 2 years ago
parent
commit
6482a356d4
  1. 24
      api/app/lib/controllers/report/achievement.js
  2. 18
      web/client/src/sections/business/containers/performanceReport/importBackModal.jsx
  3. 18
      web/client/src/sections/business/containers/performanceReport/importInvoicingDetailsModal.js

24
api/app/lib/controllers/report/achievement.js

@ -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;

18
web/client/src/sections/business/containers/performanceReport/importBackModal.jsx

@ -199,15 +199,15 @@ const ImportBackModal = props => {
error(`${i + 2}行【序号】填写错误,需要为非负整数`) error(`${i + 2}行【序号】填写错误,需要为非负整数`)
return return
} }
let exist = allNumbers.find(m => m.number == obj.number);// // let exist = allNumbers.find(m => m.number == obj.number);//
if (exist) { // if (exist) {
error(`${i + 2}行的【编号】在系统中已存在`) // error(`${i + 2}`)
return // return
} // }
if (postData.some(p => p.number == obj.number)) {// // if (postData.some(p => p.number == obj.number)) {//
error(`${i + 2}行【编号】重复,请更改后重新上传`) // error(`${i + 2}`)
return // return
} // }
// //
if (obj.receivableYear && !yearPattern.test(obj.receivableYear)) { if (obj.receivableYear && !yearPattern.test(obj.receivableYear)) {
error(`${i + 2}行【回款年份】填写错误`) error(`${i + 2}行【回款年份】填写错误`)

18
web/client/src/sections/business/containers/performanceReport/importInvoicingDetailsModal.js

@ -185,15 +185,15 @@ const ImportInvoicingDetailsModal = props => {
error(`${i + 2}行【序号】填写错误,需要为非负整数`) error(`${i + 2}行【序号】填写错误,需要为非负整数`)
return return
} }
let exist = allNumbers.find(m => m.number == obj.number);//数据库中 已有该编号 // let exist = allNumbers.find(m => m.number == obj.number);//数据库中 已有该编号
if (exist) { // if (exist) {
error(`${i + 2}行的【编号】在系统中已存在`) // error(`第${i + 2}行的【编号】在系统中已存在`)
return // return
} // }
if (postData.some(p => p.number == obj.number)) {//编号 唯一 // if (postData.some(p => p.number == obj.number)) {//编号 唯一
error(`${i + 2}行【编号】重复,请更改后重新上传`) // error(`第${i + 2}行【编号】重复,请更改后重新上传`)
return // return
} // }
for (let k = 0; k < ColumnDateKey.length; k++) { for (let k = 0; k < ColumnDateKey.length; k++) {
let cValid = judgeTimeValid(obj[ColumnDateKey[k]]); let cValid = judgeTimeValid(obj[ColumnDateKey[k]]);

Loading…
Cancel
Save