Explorar el Código

中间计量排序调整

MaiXinRong hace 1 año
padre
commit
96c7d02f52
Se han modificado 3 ficheros con 37 adiciones y 10 borrados
  1. 24 6
      app/lib/stage_im.js
  2. 1 1
      app/public/js/stage.js
  3. 12 3
      app/public/js/stage_im.js

+ 24 - 6
app/lib/stage_im.js

@@ -12,6 +12,10 @@ const Ledger = require('./ledger');
 const imType = require('../const/tender').imType;
 const imType = require('../const/tender').imType;
 const mergeChar = ';';
 const mergeChar = ';';
 const version = '1.0';
 const version = '1.0';
+const SortType = {
+    GCL: 'gcl',
+    TZ: 'tz'
+};
 
 
 class StageIm {
 class StageIm {
     constructor(ctx) {
     constructor(ctx) {
@@ -1030,10 +1034,29 @@ class StageIm {
         }
         }
     }
     }
 
 
+    _sortImData() {
+        const st = (['fj', 'sz'].indexOf(this.tender.s_type) > 0 && [imType.zl.value, imType.bw.value].indexOf(stage.im_type) >= 0)
+            ? SortType.TZ
+            : (stage.im_type !== imType.tz.value && stage.im_type !== imType.bb.value ? SortType.TZ : SortType.GCL);
+        if (st === SortType.GCL) {
+            const helper = this.ctx.helper;
+            this.ImData.sort(function(x, y) {
+                const iCode = helper.compareCode(x.code, y.code);
+                return iCode === 0 ? x.lIndex - y.lIndex : iCode;
+            });
+        } else {
+            this.ImData.sort(function(x, y) {
+                return x.lIndex - y.lIndex;
+            });
+        }
+
+    }
+
     // 生成中间计量数据
     // 生成中间计量数据
     async buildImData() {
     async buildImData() {
         this.up_field = 'unit_price';
         this.up_field = 'unit_price';
         const self = this;
         const self = this;
+        this.tender = this.ctx.tender;
         this.stage = this.ctx.stage;
         this.stage = this.ctx.stage;
         // 初始化
         // 初始化
         await this._loadMainData();
         await this._loadMainData();
@@ -1044,12 +1067,7 @@ class StageIm {
         // 生成数据
         // 生成数据
         this._recursiveBuildImData(this.billsTree.children);
         this._recursiveBuildImData(this.billsTree.children);
         // 排序
         // 排序
-        if (this.stage.im_type !== imType.tz.value && this.stage.im_type !== imType.bb.value) {
-            this.ImData.sort(function(x, y) {
-                const iCode = self.ctx.helper.compareCode(x.code, y.code);
-                return iCode === 0 ? x.lIndex - y.lIndex : iCode;
-            });
-        }
+        this._sortImData();
         // 生成数据(需要缓存,并清理缓存)
         // 生成数据(需要缓存,并清理缓存)
         const pre = (this.stage.im_pre && this.stage.im_pre !== '') ? this.stage.im_pre + this.splitChar : '';
         const pre = (this.stage.im_pre && this.stage.im_pre !== '') ? this.stage.im_pre + this.splitChar : '';
         for (const [i, im] of this.ImData.entries()) {
         for (const [i, im] of this.ImData.entries()) {

+ 1 - 1
app/public/js/stage.js

@@ -2354,7 +2354,7 @@ $(document).ready(() => {
             exprCacheKey: ['bqhtje'],
             exprCacheKey: ['bqhtje'],
         });
         });
         // 加载中间计量
         // 加载中间计量
-        stageIm.init(stage, imType, tenderInfo.decimal, stage.assist ? stage.assist.ass_ledger_id : '');
+        stageIm.init(tender, stage, imType, tenderInfo.decimal, stage.assist ? stage.assist.ass_ledger_id : '');
         stageIm.loadData(result.ledgerData, result.posData, result.detailData, result.changeData, result.import_change, result.detailAtt);
         stageIm.loadData(result.ledgerData, result.posData, result.detailData, result.changeData, result.import_change, result.detailAtt);
 
 
         errorList.loadHisErrorData();
         errorList.loadHisErrorData();

+ 12 - 3
app/public/js/stage_im.js

@@ -13,7 +13,11 @@ const stageIm = (function () {
     const resetFields = ['peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'position', 'jldy'];
     const resetFields = ['peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'position', 'jldy'];
     const splitChar = '-';
     const splitChar = '-';
     const mergeChar = ';';
     const mergeChar = ';';
-    let stage, imType, decimal, filter, details, changes, importChanges, detailsAtt, ImData, pre, orgImData;
+    const SortType = {
+        GCL: 'gcl',
+        TZ: 'tz'
+    };
+    let tender, stage, imType, decimal, filter, details, changes, importChanges, detailsAtt, ImData, pre, orgImData;
     let up_field = 'unit_price';
     let up_field = 'unit_price';
     const gsTreeSetting = {
     const gsTreeSetting = {
         id: 'ledger_id',
         id: 'ledger_id',
@@ -55,7 +59,8 @@ const stageIm = (function () {
     };
     };
     const gsPos = new StagePosData(gsPosSetting);
     const gsPos = new StagePosData(gsPosSetting);
 
 
-    function init (s, i, d, f) {
+    function init (t, s, i, d, f) {
+        tender = t;
         stage = s;
         stage = s;
         imType = i;
         imType = i;
         decimal = d;
         decimal = d;
@@ -951,7 +956,10 @@ const stageIm = (function () {
     }
     }
 
 
     function _sortImData() {
     function _sortImData() {
-        if (stage.im_type !== imType.tz.value && stage.im_type !== imType.bb.value) {
+        const st = (['fj', 'sz'].indexOf(tender.s_type) > 0 && [imType.zl.value, imType.bw.value].indexOf(stage.im_type) >= 0)
+            ? SortType.TZ
+            : (stage.im_type !== imType.tz.value && stage.im_type !== imType.bb.value ? SortType.TZ : SortType.GCL);
+        if (st === SortType.GCL) {
             ImData.sort(function (x, y) {
             ImData.sort(function (x, y) {
                 const iCode = compareCode(x.code, y.code);
                 const iCode = compareCode(x.code, y.code);
                 return iCode === 0 ? x.lIndex - y.lIndex : iCode;
                 return iCode === 0 ? x.lIndex - y.lIndex : iCode;
@@ -1233,5 +1241,6 @@ const stageIm = (function () {
         getRelaImData: getRelaImData,
         getRelaImData: getRelaImData,
         getRelaImData4Rela: getRelaImData4Rela,
         getRelaImData4Rela: getRelaImData4Rela,
         resetFields,
         resetFields,
+        SortType,
     }
     }
 })();
 })();