瀏覽代碼

标记增加计量单元

laiguoran 3 年之前
父節點
當前提交
eec84dcf70
共有 3 個文件被更改,包括 40 次插入9 次删除
  1. 17 0
      app/controller/change_controller.js
  2. 7 7
      app/public/js/change_revise.js
  3. 16 2
      app/service/change_pos.js

+ 17 - 0
app/controller/change_controller.js

@@ -942,6 +942,23 @@ module.exports = app => {
                 const posData = await ctx.service.pos.getPosData({ tid: ctx.tender.id });
                 const changePosData = lastRevise && lastRevise.status !== audit.revise.status.checked && data.from !== 'revise' ? [] : await ctx.service.changePos.getPosData({ tid: ctx.tender.id });
                 const dealBills = await ctx.service.dealBills.getAllDataByCondition({ where: { tender_id: ctx.tender.id } });
+                // 标记ledger,搜索需求
+                if (changePosData.length > 0) {
+                    const cplIdList = ctx.helper._.uniq(ctx.helper._.map(changePosData, 'lid'));
+                    const cLIdList = ctx.helper._.map(changeLedgerData, 'id');
+                    const ledgerIdList = [];
+                    for (const cp of cplIdList) {
+                        if (ctx.helper._.indexOf(cLIdList, cp) === -1) {
+                            ledgerIdList.push(cp);
+                        }
+                    }
+                    if (ledgerIdList.length > 0) {
+                        for (const lid of ledgerIdList) {
+                            const data = ctx.helper._.find(ledgerData, { id: lid });
+                            data.cid = 1;
+                        }
+                    }
+                }
                 ctx.body = { err: 0, msg: '', data: { bills: ctx.helper._.concat(ledgerData, changeLedgerData), pos: ctx.helper._.concat(posData, changePosData), dealBills } };
             } catch (err) {
                 this.log(err);

+ 7 - 7
app/public/js/change_revise.js

@@ -76,7 +76,7 @@ $(document).ready(() => {
                 return !readOnly && !data.ccid;
             }
         }
-    }
+    };
     // 初始化spread
     const billsSpread = SpreadJsObj.createNewSpread($('#bills-spread')[0]);
     const billsSheet = billsSpread.getActiveSheet();
@@ -88,12 +88,12 @@ $(document).ready(() => {
                 indent: 16,
                 getColor: function (index, data) {
                     if (!data) return;
-                    if(!data.ccid) return;
-                    return '#007bff';
+                    if(!data.ccid && !data.cid) return;
+                    return '#dc3545';
                 }
             },
         },
-    ],
+    ];
     sjsSettingObj.setFxTreeStyle(billsSpreadSetting, sjsSettingObj.FxTreeStyle.jz);
     if (thousandth) sjsSettingObj.setTpThousandthFormat(billsSpreadSetting);
     SpreadJsObj.initSpreadSettingEvents(billsSpreadSetting, billsCol);
@@ -109,11 +109,11 @@ $(document).ready(() => {
                 getColor: function (index, data) {
                     if (!data) return;
                     if(!data.ccid) return;
-                    return '#007bff';
+                    return '#dc3545';
                 }
             },
         },
-    ],
+    ];
     sjsSettingObj.setGridSelectStyle(posSpreadSetting);
     if (thousandth) sjsSettingObj.setTpThousandthFormat(posSpreadSetting);
     SpreadJsObj.initSpreadSettingEvents(posSpreadSetting, posCol);
@@ -2481,7 +2481,7 @@ $(document).ready(() => {
                             {
                                 key: 'revise', title: '新增部位', valid: true,
                                 check: function (node) {
-                                    if (node.ccid) {
+                                    if (node.ccid || node.cid) {
                                         return true;
                                     } else {
                                         return false;

+ 16 - 2
app/service/change_pos.js

@@ -59,7 +59,15 @@ module.exports = app => {
                 await this.ctx.service.changeAuditList.deleteDataByRevise(transaction, tid, [data.lid], 'gcl_id', '');
                 await transaction.insert(this.tableName, data);
                 await transaction.commit();
-                return { pos: data };
+                const returnData = { pos: data };
+                const bills = await this.ctx.service.ledger.getDataById(data.lid);
+                if (bills) {
+                    bills.cid = 1;
+                    returnData.ledger = {
+                        update: [bills],
+                    };
+                }
+                return returnData;
             } catch (err) {
                 await transaction.rollback();
                 throw err;
@@ -231,16 +239,21 @@ module.exports = app => {
             let bills = await this.ctx.service.changeLedger.getDataById(pos[0].lid);
             let newBills = false;
             let billsPos = await this.getAllDataByCondition({ where: { tid: tid, lid: pos[0].lid } });
+            let cid = 1;
             if (bills) {
                 newBills = true;
             } else {
                 bills = await this.ctx.service.ledger.getDataById(pos[0].lid);
                 const posData = await this.ctx.service.pos.getAllDataByCondition({ where: { tid: tid, lid: pos[0].lid } });
+                if (billsPos.length === data.length) {
+                    cid = null;
+                }
                 billsPos = this._.concat(posData, billsPos);
             }
             // const bills = await this.ctx.service.reviseBills.getDataById(pos[0].lid);
             // const billsPos = await this.getAllDataByCondition({ where: {tid: tid, lid: bills.id} });
             const updateBills = {id: bills.id, sgfh_qty: null, sjcl_qty: null, qtcl_qty: null, quantity: null};
+            updateBills.cid = cid;
             for (const bp of billsPos) {
                 if (data.indexOf(bp.id) >= 0) continue;
                 updateBills.sgfh_qty = this.ctx.helper.add(updateBills.sgfh_qty, bp.sgfh_qty);
@@ -340,6 +353,7 @@ module.exports = app => {
                     if (d.id) {
                         await transaction.update(this.tableName, d);
                     } else {
+                        updateBills.cid = 1;
                         await this._insertPosData(transaction, d, tid, cid);
                     }
                 }
@@ -359,7 +373,7 @@ module.exports = app => {
                 throw err;
             }
             result.pos = data;
-            result.ledger.update = needUpdateBills ? [updateBills] : [];
+            result.ledger.update = needUpdateBills ? [updateBills] : updateBills.cid && updateBills.cid === 1 ? [{ id: bills.id, ledger_id: bills.ledger_id, cid: 1 }] : [];
             return result;
         }