Ver código fonte

计量台账,调用变更令,用户筛选数据前后,不允许隐藏,必须删除不显示数据

MaiXinRong 6 anos atrás
pai
commit
8db1961eb3
3 arquivos alterados com 21 adições e 10 exclusões
  1. 11 5
      app/public/js/stage.js
  2. 9 4
      app/service/stage_pos.js
  3. 1 1
      app/service/stage_pos_final.js

+ 11 - 5
app/public/js/stage.js

@@ -301,7 +301,7 @@ $(document).ready(() => {
             // 添加调用变更令
             $('#usg-bg-ok').click(function () {
                 const data = { target: self.callData, change: [] };
-                for (const c of self.changes) {
+                for (const c of self.displayChanges) {
                     if (c.uamount) {
                         if (!c.vamount || checkZero(c.vamount)) {
                             toast('变更令:' + c.code + ' 当前不可使用', 'error');
@@ -334,6 +334,7 @@ $(document).ready(() => {
                 c.vamount = ZhCalc.sub(c.bamount, c.used_amount);
                 const uc = _.find(this.useChanges, {cid: c.cid, cbid: c.cbid});
                 if (uc) {
+                    c.org_uamount = uc.qty;
                     c.uamount = uc.qty;
                     c.vamount = ZhCalc.add(c.vamount, c.uamount);
                 }
@@ -396,21 +397,26 @@ $(document).ready(() => {
         _viewChanges() {
             const sheet = this.spread.getActiveSheet();
             if (this.changes) {
-                SpreadJsObj.loadSheetData(sheet, SpreadJsObj.DataType.Data, this.changes);
                 sheet.setSelection(0, 0, 1, 1);
-                this._loadChangeDetail(this.changes[0]);
+                //SpreadJsObj.loadSheetData(sheet, SpreadJsObj.DataType.Data, this.changes);
                 this._filterChange(!$('#filterEmpty')[0].checked, $('#matchPos')[0].checked);
+                this._loadChangeDetail(this.changes[0]);
             } else {
                 toast('查询变更令有误,请刷新页面后重试', 'warning');
             }
         }
         _filterChange(filterEmpty, matchPosName) {
+            this.displayChanges = [];
             for (const c of this.changes) {
                 const filterVisible = filterEmpty ? (c.vamount ? !checkZero(c.vamount) : false) : true;
                 const matchVisible = matchPosName && this.callData.pos ? c.b_bwmx === this.callData.pos.name : true;
-                c.visible = filterVisible && matchVisible;
+                if ((filterVisible && matchVisible) || (c.org_uamount)) {
+                    this.displayChanges.push(c);
+                }
+                //c.visible = filterVisible && matchVisible;
             }
-            SpreadJsObj.refreshTreeRowVisible(this.spread.getActiveSheet());
+            SpreadJsObj.loadSheetData(this.spread.getActiveSheet(), SpreadJsObj.DataType.Data, this.displayChanges);
+            //SpreadJsObj.refreshTreeRowVisible(this.spread.getActiveSheet());
         }
         loadChanges(data) {
             this.callData = data;

+ 9 - 4
app/service/stage_pos.js

@@ -25,7 +25,7 @@ module.exports = app => {
             this.qtyFields = ['contract_qty', 'qc_qty']
         }
 
-        _getPosFilterSql(where, asTable) {
+        _getPosFilterSql(where, asTable = '') {
             let whereSql = '';
             if (!where) return whereSql;
             if (where.pid) {
@@ -54,7 +54,7 @@ module.exports = app => {
          */
         async getLastestStageData(tid, sid, where) {
             const filterSql = this._getPosFilterSql(where);
-            const sql = 'SELECT Pos.lid, Pos.pid, Pos.contract_qty, Pos.qc_qty, Pos.postil FROM ' +
+            const sql = 'SELECT Pos.lid, Pos.pid, Pos.contract_qty, Pos.qc_qty, Pos.postil, Pos.times, Pos.order FROM ' +
                 '  (SELECT * FROM ' + this.tableName + ' WHERE tid = ? And sid = ?) As Pos ' +
                 '  INNER JOIN ( ' +
                 '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `tid`, `sid`, `pid` From ' + this.tableName +
@@ -76,7 +76,7 @@ module.exports = app => {
          */
         async getAuditorStageData(tid, sid, times, order, where) {
             const filterSql = this._getPosFilterSql(where);
-            const sql = 'SELECT Pos.pid, Pos.lid, Pos.contract_qty, Pos.qc_qty, Pos.postil FROM ' +
+            const sql = 'SELECT Pos.pid, Pos.lid, Pos.contract_qty, Pos.qc_qty, Pos.postil, Pos.times, Pos.order FROM ' +
                 '  (SELECT * FROM '+ this.tableName + ' WHERE tid = ? And sid = ?) As Pos ' +
                 '  INNER JOIN ( ' +
                 '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `pid`, `sid` From ' + this.tableName +
@@ -315,7 +315,12 @@ module.exports = app => {
         }
 
         async updateChangeQuantity(transaction, pos, qty) {
-            const orgPos = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, {pid: pos.id})[0];
+            let orgPos = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, {pid: pos.id});
+            if (orgPos.length > 1) {
+                throw '数据错误';
+            } else {
+                orgPos = orgPos[0];
+            }
             if (orgPos && orgPos.times === this.ctx.stage.curTimes && orgPos.order === this.ctx.stage.curOrder) {
                 await transaction.update(this.tableName, {id: orgPos.id, qc_qty: qty});
             } else {

+ 1 - 1
app/service/stage_pos_final.js

@@ -33,7 +33,7 @@ module.exports = app => {
         async getFinalData(tender, stage) {
             const sql = 'SELECT Pos.pid, Pos.contract_qty, Pos.qc_qty FROM ' +
                 //'  (SELECT pid, contract_qty, qc_qty, sorder FROM ' + this.tableName + ' WHERE tid = ?) As Pos' +
-                this.tableName + 'As Pos' +
+                this.tableName + ' As Pos' +
                 '  INNER JOIN ( ' +
                 '    SELECT MAX(`sorder`) As `sorder`, `pid` From ' + this.tableName +
                 '      WHERE tid = ? AND sorder < ?' +