MaiXinRong 3 years ago
parent
commit
869334a404

+ 6 - 6
app/controller/change_controller.js

@@ -79,7 +79,7 @@ module.exports = app => {
                             changeAudit = await ctx.service.changeAudit.getLastUser(c.cid, c.times - 1, status);
                             changeAudit = await ctx.service.changeAudit.getLastUser(c.cid, c.times - 1, status);
                             auditStatus = c.uid === ctx.session.sessionUser.accountId ? 1 : 0;
                             auditStatus = c.uid === ctx.session.sessionUser.accountId ? 1 : 0;
                             const back_changeUsedData = await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, c.cid);
                             const back_changeUsedData = await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, c.cid);
-                            c.stageChangeNum = this.ctx.helper.sum(back_changeUsedData.map(x => { return Math.abs(x.used_qty); }));
+                            c.stageChangeNum = this.ctx.helper.sum(back_changeUsedData.map(x => { return Math.abs(x.qty); }));
                             break;
                             break;
                         case 6:
                         case 6:
                             changeAudit = await ctx.service.changeAudit.getLastBackUser(c.cid, c.times);
                             changeAudit = await ctx.service.changeAudit.getLastBackUser(c.cid, c.times);
@@ -89,7 +89,7 @@ module.exports = app => {
                         case 9:
                         case 9:
                             auditStatus = 9;
                             auditStatus = 9;
                             const changeUsedData = await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, c.cid);
                             const changeUsedData = await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, c.cid);
-                            c.stageChangeNum = this.ctx.helper.sum(changeUsedData.map(x => { return Math.abs(x.used_qty); }));
+                            c.stageChangeNum = this.ctx.helper.sum(changeUsedData.map(x => { return Math.abs(x.qty); }));
                             break;
                             break;
                         default:
                         default:
                             break;
                             break;
@@ -563,7 +563,7 @@ module.exports = app => {
 
 
                 // 获取是否已存在调用变更令
                 // 获取是否已存在调用变更令
                 const changeUsedData = await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, change.cid);
                 const changeUsedData = await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, change.cid);
-                renderData.stageChangeNum = this.ctx.helper.sum(changeUsedData.map(x => { return Math.abs(x.used_qty); }));
+                renderData.stageChangeNum = this.ctx.helper.sum(changeUsedData.map(x => { return Math.abs(x.qty); }));
                 await this.layout('change/info.ejs', renderData, 'change/info_modal.ejs');
                 await this.layout('change/info.ejs', renderData, 'change/info_modal.ejs');
             } catch (err) {
             } catch (err) {
                 this.log(err);
                 this.log(err);
@@ -760,7 +760,7 @@ module.exports = app => {
                 // 获取是否已存在调用变更令
                 // 获取是否已存在调用变更令
                 let changeUsedData = await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, change.cid);
                 let changeUsedData = await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, change.cid);
                 changeUsedData = ctx.helper._.filter(changeUsedData, function(item) {
                 changeUsedData = ctx.helper._.filter(changeUsedData, function(item) {
-                    return item.used_qty !== null;
+                    return item.qty !== null;
                 })
                 })
                 renderData.changeUsedData = changeUsedData;
                 renderData.changeUsedData = changeUsedData;
                 renderData.stageChangeNum = this.ctx.helper.sum(changeUsedData.map(x => { return Math.abs(x.used_qty); }));
                 renderData.stageChangeNum = this.ctx.helper.sum(changeUsedData.map(x => { return Math.abs(x.used_qty); }));
@@ -1395,7 +1395,7 @@ module.exports = app => {
 
 
                 // 获取是否已存在调用变更令
                 // 获取是否已存在调用变更令
                 const changeUsedData = await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, changeData.cid);
                 const changeUsedData = await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, changeData.cid);
-                const stageChangeNum = this.ctx.helper.sum(changeUsedData.map(x => { return Math.abs(x.used_qty); }));
+                const stageChangeNum = this.ctx.helper.sum(changeUsedData.map(x => { return Math.abs(x.qty); }));
                 if (stageChangeNum !== 0) {
                 if (stageChangeNum !== 0) {
                     throw '该变更令已被调用,无法重新审批';
                     throw '该变更令已被调用,无法重新审批';
                 }
                 }
@@ -1451,7 +1451,7 @@ module.exports = app => {
 
 
                 // 获取是否已存在调用变更令
                 // 获取是否已存在调用变更令
                 // const changeUsedData = await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, changeData.cid);
                 // const changeUsedData = await ctx.service.stageChange.getFinalUsedData(ctx.tender.id, changeData.cid);
-                // const stageChangeNum = this.ctx.helper.sum(changeUsedData.map(x => { return Math.abs(x.used_qty); }));
+                // const stageChangeNum = this.ctx.helper.sum(changeUsedData.map(x => { return Math.abs(x.qty); }));
                 // if (stageChangeNum !== 0) {
                 // if (stageChangeNum !== 0) {
                 //     throw '该变更令已被调用,无法重新审批';
                 //     throw '该变更令已被调用,无法重新审批';
                 // }
                 // }

+ 9 - 8
app/public/js/change_information_set.js

@@ -154,7 +154,7 @@ $(document).ready(() => {
                 return ZhCalc.round(data.camount, findDecimal(data.unit));
                 return ZhCalc.round(data.camount, findDecimal(data.unit));
             },
             },
             del_list: function (data) {
             del_list: function (data) {
-                return !_.find(changeUsedData, { id: data.id }) ? '移除' : '';
+                return !_.find(changeUsedData, { cbid: data.id }) ? '移除' : '';
             }
             }
         },
         },
         readOnly: {
         readOnly: {
@@ -162,7 +162,7 @@ $(document).ready(() => {
                 return !readOnly && data.lid != 0;
                 return !readOnly && data.lid != 0;
             },
             },
             isEdit2: function (data) {
             isEdit2: function (data) {
-                return !readOnly && (data.lid != 0 || (data.lid == 0 && _.findIndex(changeUsedData, { id: data.id }) !== -1));
+                return !readOnly && (data.lid != 0 || (data.lid == 0 && _.findIndex(changeUsedData, { cbid: data.id }) !== -1));
             },
             },
         },
         },
     };
     };
@@ -211,7 +211,7 @@ $(document).ready(() => {
         del: function () {
         del: function () {
             const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
             const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
             const index = changeList.indexOf(select);
             const index = changeList.indexOf(select);
-            if (index > -1 && !_.find(changeUsedData, { id: select.id })) {
+            if (index > -1 && !_.find(changeUsedData, { cbid: select.id })) {
                 postData(window.location.pathname + '/save', {type: 'del', id: select.id}, function (result) {
                 postData(window.location.pathname + '/save', {type: 'del', id: select.id}, function (result) {
                     changeList.splice(index, 1);
                     changeList.splice(index, 1);
                     changeSpreadSheet.deleteRows(index, 1);
                     changeSpreadSheet.deleteRows(index, 1);
@@ -240,7 +240,7 @@ $(document).ready(() => {
             const sel = info.sheet.getSelections()[0];
             const sel = info.sheet.getSelections()[0];
             const col = info.sheet.zh_setting.cols[sel.col];
             const col = info.sheet.zh_setting.cols[sel.col];
             const data = SpreadJsObj.getSelectObject(info.sheet);
             const data = SpreadJsObj.getSelectObject(info.sheet);
-            if (col && col.field === 'del_list' && !_.find(changeUsedData, { id: data.id })) {
+            if (col && col.field === 'del_list' && !_.find(changeUsedData, { cbid: data.id })) {
                 changeSpreadObj.del();
                 changeSpreadObj.del();
             }
             }
             changeSpreadObj.resetXmjSpread(data);
             changeSpreadObj.resetXmjSpread(data);
@@ -281,7 +281,7 @@ $(document).ready(() => {
                 }
                 }
                 if(col.field === 'camount') {
                 if(col.field === 'camount') {
                     // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
                     // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
-                    const usedInfo = _.find(changeUsedData, { id: select.id });
+                    const usedInfo = _.find(changeUsedData, { cbid: select.id });
                     if (usedInfo && usedInfo.used_qty >= 0 && validText < usedInfo.used_qty) {
                     if (usedInfo && usedInfo.used_qty >= 0 && validText < usedInfo.used_qty) {
                         toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.used_qty);
                         toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.used_qty);
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
@@ -371,7 +371,7 @@ $(document).ready(() => {
                         }
                         }
                         if(colSetting.field === 'camount') {
                         if(colSetting.field === 'camount') {
                             // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
                             // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
-                            const usedInfo = _.find(changeUsedData, { id: sortData[curRow].id });
+                            const usedInfo = _.find(changeUsedData, { cbid: sortData[curRow].id });
                             if (usedInfo && usedInfo.used_qty >= 0 && validText < usedInfo.used_qty) {
                             if (usedInfo && usedInfo.used_qty >= 0 && validText < usedInfo.used_qty) {
                                 toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.used_qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.used_qty);
                                 toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.used_qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.used_qty);
                                 bPaste = false;
                                 bPaste = false;
@@ -619,7 +619,7 @@ $(document).ready(() => {
                         const sel = changeSpreadSheet.getSelections()[0];
                         const sel = changeSpreadSheet.getSelections()[0];
                         changeSpreadObj.resetXmjSpread(select);
                         changeSpreadObj.resetXmjSpread(select);
                         // console.log(select, sel);
                         // console.log(select, sel);
-                        if (!readOnly && select && sel.row !== changeSpreadSheet.getRowCount() - 1 && !_.find(changeUsedData, { id: select.id })) {
+                        if (!readOnly && select && sel.row !== changeSpreadSheet.getRowCount() - 1 && !_.find(changeUsedData, { cbid: select.id })) {
                             return false;
                             return false;
                         } else {
                         } else {
                             return true;
                             return true;
@@ -659,7 +659,8 @@ $(document).ready(() => {
                     + '!_!' + (leaf.gcl_id ? leaf.gcl_id : '0') + '!_!' + (leaf.mx_id ? leaf.mx_id : '') + '!_!' +
                     + '!_!' + (leaf.gcl_id ? leaf.gcl_id : '0') + '!_!' + (leaf.mx_id ? leaf.mx_id : '') + '!_!' +
                     (bwmx !== undefined ? bwmx : leaf.jldy ? leaf.jldy : '') + '*;*' + quantity) !== -1 && isCheck ?
                     (bwmx !== undefined ? bwmx : leaf.jldy ? leaf.jldy : '') + '*;*' + quantity) !== -1 && isCheck ?
                     'checked' : '';
                     'checked' : '';
-                const isUsed = _.find(changeUsedData, { gcl_id: leaf.gcl_id, bwmx: (bwmx ? bwmx : leaf.jldy ? leaf.jldy : ''), oamount: leaf.quantity });
+                const existGcl = _.find(changeList, {gcl_id: leaf.gcl_id, bwmx: (bwmx ? bwmx : leaf.jldy ? leaf.jldy : ''), oamount: leaf.quantity});
+                const isUsed = existGcl ? _.find(changeUsedData, { cbid: existGcl.id }) : null;
                 const isDisabled = isUsed ? 'disabled ' : '';
                 const isDisabled = isUsed ? 'disabled ' : '';
                 codeHtml += '<tr quantity="' + quantity + '" gcl_id="' + gcl_id + '" mx_id="' + mx_id + '">' +
                 codeHtml += '<tr quantity="' + quantity + '" gcl_id="' + gcl_id + '" mx_id="' + mx_id + '">' +
                     '<td class="text-center">' + (index+1) + (leaf.cid ? '<i class="text-danger" style="font-weight: 900">*</i>' : '') + '</td>' +
                     '<td class="text-center">' + (index+1) + (leaf.cid ? '<i class="text-danger" style="font-weight: 900">*</i>' : '') + '</td>' +

+ 1 - 1
app/service/stage_change.js

@@ -308,7 +308,7 @@ module.exports = app => {
         }
         }
 
 
         async getFinalUsedData(tid, cid) {
         async getFinalUsedData(tid, cid) {
-            const stage = this.ctx.service.stage.getLastestStage(tid, true);
+            const stage = await this.ctx.service.stage.getLastestStage(tid, true);
             if (stage.status === audit.stage.status.checked) {
             if (stage.status === audit.stage.status.checked) {
                 const sql = 'SELECT scf.* ' +
                 const sql = 'SELECT scf.* ' +
                     '  FROM ' + this.ctx.service.stageChangeFinal.tableName + ' scf ' +
                     '  FROM ' + this.ctx.service.stageChangeFinal.tableName + ' scf ' +