|
@@ -2082,13 +2082,12 @@ function tableDataRemake(changeListData) {
|
|
|
let listinfo = changeListData.find(function (item) {
|
|
|
return (item.id !== undefined && item.id == clinfo.lid) || (item.id === undefined && item.leafXmjs !== undefined && item.leafXmjs.length !== 0 && item.leafXmjs[0].gcl_id == clinfo.lid);
|
|
|
});
|
|
|
- let info = '';
|
|
|
if (listinfo === undefined || (clinfo.lid && clinfo.gcl_id && clinfo.lid !== clinfo.gcl_id)) {
|
|
|
// 有可能这部分台账发生变化,此时要更新清单lid信息,防止数据丢失
|
|
|
const newlistinfo = changeListData.find(function (item) {
|
|
|
return (item.id !== undefined && item.id == clinfo.gcl_id) || (item.id === undefined && item.leafXmjs !== undefined && item.leafXmjs.length !== 0 && _.find(item.leafXmjs, {gcl_id: clinfo.gcl_id }));
|
|
|
});
|
|
|
- if (listinfo === undefined && newlistinfo || (listinfo && newlistinfo && !isObjEqual(listinfo, newlistinfo))) {
|
|
|
+ if ((listinfo === undefined && newlistinfo) || (listinfo && newlistinfo && !isObjEqual(listinfo, newlistinfo))) {
|
|
|
listinfo = newlistinfo;
|
|
|
updateList.push({id: clinfo.id, lid: newlistinfo.leafXmjs[0].gcl_id});
|
|
|
// 更新lid
|
|
@@ -2107,90 +2106,8 @@ function tableDataRemake(changeListData) {
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
- let pushbwmx = '0*;*0';
|
|
|
- if (listinfo.leafXmjs !== undefined) {
|
|
|
- const leafInfo = listinfo.leafXmjs.find(function (item) {
|
|
|
- const flag = (item.bwmx === undefined || item.bwmx === clinfo.bwmx || item.jldy === clinfo.bwmx) && item.gcl_id === clinfo.gcl_id && (!clinfo.mx_id || (item.mx_id && clinfo.mx_id && item.mx_id === clinfo.mx_id)) && (item.quantity !== null ? item.quantity === parseFloat(clinfo.oamount) : 0 === parseFloat(clinfo.oamount));
|
|
|
- if (flag && item.code === clinfo.xmj_code) {
|
|
|
- return flag && item.code === clinfo.xmj_code;
|
|
|
- }
|
|
|
- return flag;
|
|
|
- });
|
|
|
- if (leafInfo) {
|
|
|
- info = leafInfo;
|
|
|
- pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' +
|
|
|
- (leafInfo.dwgc ? leafInfo.dwgc : '') + '!_!' +
|
|
|
- (leafInfo.fbgc ? leafInfo.fbgc : '') + '!_!' +
|
|
|
- (leafInfo.fxgc ? leafInfo.fxgc : '') + '!_!' +
|
|
|
- (leafInfo.gcl_id ? leafInfo.gcl_id : '') + '!_!' +
|
|
|
- (leafInfo.mx_id ? leafInfo.mx_id : '') + '!_!' +
|
|
|
- (leafInfo.bwmx !== undefined ? leafInfo.bwmx : (leafInfo.jldy !== undefined ? leafInfo.jldy : '')) + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
|
|
|
- } else {
|
|
|
- toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
|
|
|
- if (changeStatus !== auditConst.status.revise) {
|
|
|
- removeList.push(clinfo);
|
|
|
- } else {
|
|
|
- updateList.push(makeWhiteList(clinfo));
|
|
|
- }
|
|
|
- continue;
|
|
|
- }
|
|
|
- } else {
|
|
|
- pushbwmx = '0*;*' + (listinfo.quantity !== null ? listinfo.quantity : 0);
|
|
|
- }
|
|
|
- const bwmx = $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').attr('data-bwmx');
|
|
|
- if (bwmx) {
|
|
|
- const bwmxArray = bwmx.split('$#$');
|
|
|
- bwmxArray.push(pushbwmx);
|
|
|
- $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').attr('data-bwmx', bwmxArray.join('$#$'));
|
|
|
- } else {
|
|
|
- $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').attr('data-bwmx', pushbwmx);
|
|
|
- }
|
|
|
- $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').addClass('table-success');
|
|
|
- } else {
|
|
|
- let pushbwmx = '0*;*0';
|
|
|
- if (listinfo.leafXmjs !== undefined) {
|
|
|
- const leafInfo = listinfo.leafXmjs.find(function (item) {
|
|
|
- const flag = (item.bwmx === undefined || item.bwmx === clinfo.bwmx || item.jldy === clinfo.bwmx) && item.gcl_id === clinfo.gcl_id && (!clinfo.mx_id || (item.mx_id && clinfo.mx_id && item.mx_id === clinfo.mx_id)) && (item.quantity !== null ? item.quantity === parseFloat(clinfo.oamount) : 0 === parseFloat(clinfo.oamount));
|
|
|
- if (flag && item.code === clinfo.xmj_code) {
|
|
|
- return flag && item.code === clinfo.xmj_code;
|
|
|
- }
|
|
|
- return flag;
|
|
|
- });
|
|
|
- if (leafInfo) {
|
|
|
- console.log(leafInfo, clinfo);
|
|
|
- info = leafInfo;
|
|
|
- pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' +
|
|
|
- (leafInfo.dwgc ? leafInfo.dwgc : '') + '!_!' +
|
|
|
- (leafInfo.fbgc ? leafInfo.fbgc : '') + '!_!' +
|
|
|
- (leafInfo.fxgc ? leafInfo.fxgc : '') + '!_!' +
|
|
|
- (leafInfo.gcl_id ? leafInfo.gcl_id : '') + '!_!' +
|
|
|
- (leafInfo.mx_id ? leafInfo.mx_id : '') + '!_!' +
|
|
|
- (leafInfo.bwmx !== undefined ? leafInfo.bwmx : (leafInfo.jldy !== undefined ? leafInfo.jldy : '')) + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
|
|
|
- } else {
|
|
|
- // console.log(clinfo, listinfo.leafXmjs);
|
|
|
- // changeList.splice(index, 1);
|
|
|
- toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
|
|
|
- if (changeStatus !== auditConst.status.revise) {
|
|
|
- removeList.push(clinfo);
|
|
|
- } else {
|
|
|
- updateList.push(makeWhiteList(clinfo));
|
|
|
- }
|
|
|
- continue;
|
|
|
- }
|
|
|
- } else {
|
|
|
- pushbwmx = '0*;*' + (listinfo.quantity !== null ? listinfo.quantity : 0);
|
|
|
- }
|
|
|
- const bwmx = $('#table-list-select tr[data-lid="'+ clinfo.lid +'"]').attr('data-bwmx');
|
|
|
- if (bwmx) {
|
|
|
- const bwmxArray = bwmx.split('$#$');
|
|
|
- bwmxArray.push(pushbwmx);
|
|
|
- $('#table-list-select tr[data-lid="'+ clinfo.lid +'"]').attr('data-bwmx', bwmxArray.join('$#$'));
|
|
|
- } else {
|
|
|
- $('#table-list-select tr[data-lid="'+ clinfo.lid +'"]').attr('data-bwmx', pushbwmx);
|
|
|
- }
|
|
|
- $('#table-list-select tr[data-lid="'+ clinfo.lid +'"]').addClass('table-success');
|
|
|
}
|
|
|
-
|
|
|
+ const info = makePushBwmx(clinfo, listinfo, removeList, updateList);
|
|
|
if (info && _.findIndex(changeLedgerList, { id: clinfo.gcl_id }) !== -1) {
|
|
|
// 可能因为升降级关系:细目,分部分项等会发生变化,更新清单
|
|
|
const updateInfo = {};
|
|
@@ -2223,10 +2140,10 @@ function tableDataRemake(changeListData) {
|
|
|
}
|
|
|
}
|
|
|
if(updateList.length > 0) {
|
|
|
- // console.log(updateList);
|
|
|
- postData(window.location.pathname + '/save', { type:'update_list', updateData: updateList }, function (result) {
|
|
|
- }, function () {
|
|
|
- });
|
|
|
+ console.log(updateList);
|
|
|
+ // postData(window.location.pathname + '/save', { type:'update_list', updateData: updateList }, function (result) {
|
|
|
+ // }, function () {
|
|
|
+ // });
|
|
|
}
|
|
|
if(removeList.length > 0) {
|
|
|
_.pullAll(changeList, removeList);
|
|
@@ -2237,6 +2154,91 @@ function tableDataRemake(changeListData) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function makePushBwmx(clinfo, listinfo, removeList, updateList) {
|
|
|
+ let info = '';
|
|
|
+ const checkKey = ['name', 'unit', 'unit_price', 'oamount'];
|
|
|
+ let pushbwmx = '0*;*0';
|
|
|
+ if (listinfo.leafXmjs !== undefined) {
|
|
|
+ const leafInfo = listinfo.leafXmjs.find(function (item) {
|
|
|
+ // const flag = (item.bwmx === undefined || item.bwmx === clinfo.bwmx || item.jldy === clinfo.bwmx) && item.gcl_id === clinfo.gcl_id && (!clinfo.mx_id || (item.mx_id && clinfo.mx_id && item.mx_id === clinfo.mx_id)) && (item.quantity !== null ? item.quantity === parseFloat(clinfo.oamount) : 0 === parseFloat(clinfo.oamount));
|
|
|
+ const flag = (item.bwmx === undefined || item.bwmx === clinfo.bwmx || item.jldy === clinfo.bwmx) && item.gcl_id === clinfo.gcl_id && (!clinfo.mx_id || (item.mx_id && clinfo.mx_id && item.mx_id === clinfo.mx_id));
|
|
|
+ if (flag && item.code === clinfo.xmj_code) {
|
|
|
+ return flag && item.code === clinfo.xmj_code;
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ });
|
|
|
+ if (leafInfo) {
|
|
|
+ // 判断要不要更新名称,单位,原数量,单价
|
|
|
+ checkKey.forEach(function (key) {
|
|
|
+ const oneUpdate = { id: clinfo.id };
|
|
|
+ let needUpdate = false;
|
|
|
+ // 只有数量是对比leafInfo,其它对比listinfo,且有些值需要重新计算
|
|
|
+ if (key === 'oamount') {
|
|
|
+ if (leafInfo.quantity !== clinfo[key]) {
|
|
|
+ oneUpdate[key] = leafInfo[key];
|
|
|
+ clinfo[key] = leafInfo.quantity;
|
|
|
+ needUpdate = true;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (listinfo[key] !== clinfo[key]) {
|
|
|
+ oneUpdate[key] = listinfo[key];
|
|
|
+ clinfo[key] = listinfo[key];
|
|
|
+ if (key === 'unit') {
|
|
|
+ const oamount = ZhCalc.round(clinfo.oamount, findDecimal(listinfo[key]));
|
|
|
+ if (oamount !== clinfo.oamount) {
|
|
|
+ oneUpdate.oamount = oamount;
|
|
|
+ clinfo.oamount = oamount;
|
|
|
+ }
|
|
|
+ const camount = ZhCalc.round(clinfo.camount, findDecimal(listinfo[key]));
|
|
|
+ if (camount !== clinfo.camount) {
|
|
|
+ oneUpdate.camount = camount;
|
|
|
+ clinfo.camount = camount;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // else if (key === 'unit_price') {
|
|
|
+ // // 可能要更新总金额了
|
|
|
+ // oneUpdate[key] = ZhCalc.round(listinfo[key], unitPriceUnit);
|
|
|
+ // clinfo[key] = ZhCalc.round(listinfo[key], unitPriceUnit);
|
|
|
+ // }
|
|
|
+ needUpdate = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (needUpdate) {
|
|
|
+ updateList.push(oneUpdate);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ info = leafInfo;
|
|
|
+ pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' +
|
|
|
+ (leafInfo.dwgc ? leafInfo.dwgc : '') + '!_!' +
|
|
|
+ (leafInfo.fbgc ? leafInfo.fbgc : '') + '!_!' +
|
|
|
+ (leafInfo.fxgc ? leafInfo.fxgc : '') + '!_!' +
|
|
|
+ (leafInfo.gcl_id ? leafInfo.gcl_id : '') + '!_!' +
|
|
|
+ (leafInfo.mx_id ? leafInfo.mx_id : '') + '!_!' +
|
|
|
+ (leafInfo.bwmx !== undefined ? leafInfo.bwmx : (leafInfo.jldy !== undefined ? leafInfo.jldy : '')) + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
|
|
|
+ } else {
|
|
|
+ toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
|
|
|
+ if (changeStatus !== auditConst.status.revise) {
|
|
|
+ removeList.push(clinfo);
|
|
|
+ } else {
|
|
|
+ updateList.push(makeWhiteList(clinfo));
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ pushbwmx = '0*;*' + (listinfo.quantity !== null ? listinfo.quantity : 0);
|
|
|
+ }
|
|
|
+ const bwmx = $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').attr('data-bwmx');
|
|
|
+ if (bwmx) {
|
|
|
+ const bwmxArray = bwmx.split('$#$');
|
|
|
+ bwmxArray.push(pushbwmx);
|
|
|
+ $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').attr('data-bwmx', bwmxArray.join('$#$'));
|
|
|
+ } else {
|
|
|
+ $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').attr('data-bwmx', pushbwmx);
|
|
|
+ }
|
|
|
+ $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').addClass('table-success');
|
|
|
+ return info;
|
|
|
+}
|
|
|
+
|
|
|
function makeWhiteList(clinfo) {
|
|
|
clinfo.lid = 0;
|
|
|
clinfo.xmj_code = null;
|