ソースを参照

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

MaiXinRong 3 年 前
コミット
8e7acaea10

+ 2 - 0
app/controller/change_controller.js

@@ -724,6 +724,8 @@ module.exports = app => {
                         }
                     }
                     renderData.changeList = changeList;
+                    renderData.changeLedgerList = await ctx.service.changeLedger.getAllDataByCondition({ where: { tender_id: ctx.tender.id } });
+                    renderData.changePosList = await ctx.service.changePos.getAllDataByCondition({ where: { tid: ctx.tender.id } });
                 }
                 renderData.auditList = auditList;
 

+ 3 - 0
app/public/js/change_information_approval.js

@@ -45,6 +45,9 @@ $(document).ready(() => {
                     indent: 16,
                     getColor: function (index, data) {
                         if (!data) return;
+                        if (_.findIndex(changeLedgerList, { id: data.gcl_id }) !== -1 || _.findIndex(changePosList, { id: data.mx_id }) !== -1) {
+                            return '#dc3545';
+                        }
                         if(data.lid != 0) return;
                         return '#007bff';
                     }

+ 0 - 2
app/public/js/change_revise.js

@@ -1398,12 +1398,10 @@ $(document).ready(() => {
             if (col && col.type === 'Number') {
                 const data = SpreadJsObj.getSelectObject(posSheet);
                 if (data) {
-                    console.log(data);
                     const exprInfo = getExprInfo(col.field);
                     const value = exprInfo
                         ? (data[exprInfo.expr] ? data[exprInfo.expr] : data[col.field])
                         : data[col.field];
-                    console.log(cell.locked(), !data.ccid);
                     $('#pos-expr').val(value).attr('field', col.field).attr('org', data[col.field])
                         .attr('readOnly', readOnly || (!data.ccid && cell.locked())).attr('data-row', sel.row);
                 } else {

+ 19 - 6
app/service/change_audit_list.js

@@ -728,12 +728,25 @@ module.exports = app => {
 
         async updateToLedger(transaction, tid, cid) {
             // 找出本条变更属于新增部位的数据
-            const sql = 'SELECT a.* FROM ?? a LEFT JOIN ?? b ON a.id = b.gcl_id WHERE b.tid = ? AND b.cid = ? GROUP BY a.id';
-            const sqlParam = [this.ctx.service.changeLedger.tableName, this.tableName, tid, cid];
-            const result = await transaction.query(sql, sqlParam);
-            const sql2 = 'SELECT a.* FROM ?? a LEFT JOIN ?? b ON a.id = b.mx_id WHERE b.tid = ? AND b.cid = ?';
-            const sqlParam2 = [this.ctx.service.changePos.tableName, this.tableName, tid, cid];
-            const result2 = await transaction.query(sql2, sqlParam2);
+            const allList = await transaction.select(this.tableName, { where: { tid, cid } });
+            const result = [];
+            const result2 = [];
+            for (const l of allList) {
+                const changeLedgerInfo = await transaction.get(this.ctx.service.changeLedger.tableName, { id: l.gcl_id });
+                if (changeLedgerInfo && this._.findIndex(result, { id: l.gcl_id }) === -1) {
+                    result.push(changeLedgerInfo);
+                }
+                const changePosInfo = await transaction.get(this.ctx.service.changePos.tableName, { id: l.mx_id });
+                if (changePosInfo) {
+                    result2.push(changePosInfo);
+                }
+            }
+            // const sql = 'SELECT a.* FROM ?? a LEFT JOIN ?? b ON a.id = b.gcl_id WHERE b.tid = ? AND b.cid = ? GROUP BY a.id';
+            // const sqlParam = [this.ctx.service.changeLedger.tableName, this.tableName, tid, cid];
+            // const result = await transaction.query(sql, sqlParam);
+            // const sql2 = 'SELECT a.* FROM ?? a LEFT JOIN ?? b ON a.id = b.mx_id WHERE b.tid = ? AND b.cid = ?';
+            // const sqlParam2 = [this.ctx.service.changePos.tableName, this.tableName, tid, cid];
+            // const result2 = await transaction.query(sql2, sqlParam2);
             if (result.length > 0 || result2.length > 0) {
                 const changeLedgerGclIdList = this._.map(result, 'id');
                 const changeLedgerIdList = this._.uniq(this._.map(result, 'ledger_pid'));// 父节点集合

+ 2 - 0
app/view/change/information.ejs

@@ -462,6 +462,8 @@
     const aidList = _.map(auditList2, 'uid');
     aidList.splice(0, 1);
     let changeUsedData = JSON.parse(unescape('<%- escape(JSON.stringify(changeUsedData)) %>'));
+    const changeLedgerList = JSON.parse(unescape('<%- escape(JSON.stringify(changeLedgerList)) %>'));
+    const changePosList = JSON.parse(unescape('<%- escape(JSON.stringify(changePosList)) %>'));
 </script>
 <script src="/public/js/change_information_approval.js"></script>
 <% } %>