|
|
@@ -810,12 +810,14 @@ rationItemDAO.prototype.batchAddFromExcel = async function(rationRepId, data) {
|
|
|
stdGLJListByID[tmp.ID] = tmp;
|
|
|
}
|
|
|
let lastData = {};
|
|
|
+ // 定额xx下提示的次数
|
|
|
+ let lastFailCount = 0;
|
|
|
const rationData = [];
|
|
|
// 编码列表,用于查找库中是否有对应数据
|
|
|
let rationCodeList = [];
|
|
|
let gljCodeList = [];
|
|
|
// 插入失败的工料机列表(用于提示)
|
|
|
- this.failGLJList = [];
|
|
|
+ let failGLJList = [];
|
|
|
for (const tmp of data) {
|
|
|
if (tmp.length <= 0) {
|
|
|
continue;
|
|
|
@@ -824,8 +826,12 @@ rationItemDAO.prototype.batchAddFromExcel = async function(rationRepId, data) {
|
|
|
if (tmp[0] === undefined && Object.keys(lastData).length > 0) {
|
|
|
// 如果不存在对应的工料机库数据则跳过
|
|
|
if (stdGLJList[tmp[1]] === undefined) {
|
|
|
- const failString = '定额' + lastData.code + '下的' + tmp[1];
|
|
|
- this.failGLJList.push(failString);
|
|
|
+ if (lastFailCount === 0) {
|
|
|
+ failGLJList.push('定额' + lastData.code + '下的');
|
|
|
+ lastFailCount++;
|
|
|
+ }
|
|
|
+ //const failString = '定额' + lastData.code + '下的' + tmp[1];
|
|
|
+ failGLJList.push(tmp[1]);
|
|
|
continue;
|
|
|
}
|
|
|
const tmpRationGlj = {
|
|
|
@@ -843,7 +849,7 @@ rationItemDAO.prototype.batchAddFromExcel = async function(rationRepId, data) {
|
|
|
if (tmp[0] === '定额' && Object.keys(lastData).length > 0) {
|
|
|
rationData.push(lastData);
|
|
|
}
|
|
|
-
|
|
|
+ lastFailCount = 0;
|
|
|
// 组装数据
|
|
|
lastData = {
|
|
|
code: tmp[1],
|
|
|
@@ -901,7 +907,7 @@ rationItemDAO.prototype.batchAddFromExcel = async function(rationRepId, data) {
|
|
|
}
|
|
|
// 如果都已经存在,直接返回
|
|
|
if (insertData.length <= 0) {
|
|
|
- return true;
|
|
|
+ return failGLJList;
|
|
|
}
|
|
|
//计算价格
|
|
|
for(let ration of insertData){
|
|
|
@@ -919,8 +925,8 @@ rationItemDAO.prototype.batchAddFromExcel = async function(rationRepId, data) {
|
|
|
count++;
|
|
|
}
|
|
|
// 插入数据库
|
|
|
- const result = await rationItemModel.create(insertData);
|
|
|
- return result.length > 0;
|
|
|
+ await rationItemModel.create(insertData);
|
|
|
+ return failGLJList;
|
|
|
};
|
|
|
|
|
|
/**
|