浏览代码

中间计量,定位

MaiXinRong 5 年之前
父节点
当前提交
6e518e23dd
共有 3 个文件被更改,包括 70 次插入2 次删除
  1. 43 0
      app/public/js/stage.js
  2. 14 1
      app/public/js/stage_im.js
  3. 13 1
      app/view/stage/index.ejs

+ 43 - 0
app/public/js/stage.js

@@ -1758,6 +1758,9 @@ $(document).ready(() => {
             this.detailObj = {
                 selectionChanged: function (e, info) {
                     self.reLoadDetailData();
+                    if (!info.oldSelections || !info.oldSelections[0] || info.oldSelections[0].row !== info.newSelections[0].row) {
+                        self.loadLocateInfo();
+                    }
                 },
                 editEnded: function(e, info) {
                     if (info.sheet.zh_setting) {
@@ -1931,6 +1934,7 @@ $(document).ready(() => {
 
             this._initImTypeSetRela();
             this._initModifyDetail();
+            this._initLocateRela();
             // 草图相关
             this._initImageRela();
             this.reBuildImData();
@@ -2210,6 +2214,35 @@ $(document).ready(() => {
                 });
             });
         }
+        _initLocateRela() {
+            const self = this;
+            $('#im-locate2bills').click(function () {
+                const curIndex = parseInt($('#im-locate-info')[0].innerText.split('/')[0]);
+                const select = SpreadJsObj.getSelectObject(self.spread.getActiveSheet());
+                if (select && select.source) {
+                    SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), select.source[curIndex-1].id, true);
+                }
+            });
+            $('#im-locate-pre').click(function () {
+                const curIndex = parseInt($('#im-locate-info')[0].innerText.split('/')[0]);
+                const select = SpreadJsObj.getSelectObject(self.spread.getActiveSheet());
+                if (select && select.source) {
+                    const targetIndex = math.max(curIndex-1, 1);
+                    SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), select.source[targetIndex-1].id, true);
+                    $('#im-locate-info')[0].innerText = targetIndex + '/' + select.source.length;
+                }
+            });
+            $('#im-locate-next').click(function () {
+                const curIndex = parseInt($('#im-locate-info')[0].innerText.split('/')[0]);
+                const select = SpreadJsObj.getSelectObject(self.spread.getActiveSheet());
+                if (select && select.source) {
+                    const targetIndex = math.min(curIndex+1, select.source.length);
+                    SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), select.source[targetIndex-1].id, true);
+                    $('#im-locate-info')[0].innerText = targetIndex + '/' + select.source.length;
+                }
+
+            });
+        }
         _initModifyDetail() {
             const self = this;
             // 编辑
@@ -2444,6 +2477,7 @@ $(document).ready(() => {
             const imData = stageIm.buildImData();
             SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Data, imData);
             this.reLoadDetailData();
+            this.loadLocateInfo();
         }
         loadStageLedgerUpdateData(data) {
             const imData = stageIm.loadUpdateLedgerData(data);
@@ -2460,6 +2494,15 @@ $(document).ready(() => {
             SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Data, imData);
             this.reLoadDetailData();
         }
+        loadLocateInfo() {
+            const select = SpreadJsObj.getSelectObject(this.sheet);
+            if (select.source.length > 1) {
+                $('#im-locate2bills').next().show();
+            } else {
+                $('#im-locate2bills').next().hide();
+            }
+            $('#im-locate-info')[0].innerText = '1/' + select.source.length;
+        }
         reLoadDetailData() {
             const data = SpreadJsObj.getSelectObject(this.spread.getActiveSheet());
 

+ 14 - 1
app/public/js/stage_im.js

@@ -433,6 +433,7 @@ const stageIm = (function () {
                 position: '',
                 lIndex: nodeIndex,
                 custom_define: [],
+                source: [{id: node.ledger_id, code: node.code, b_code: node.b_code}],
             };
             if (stage.im_gather && node.check) {
                 im.bw = getZlGatherBw(node, peg);
@@ -490,6 +491,7 @@ const stageIm = (function () {
                 bw: bw, jldy: node.name,
                 changes: [], gclBills: [],
                 custom_define: [],
+                source: [{id: node.ledger_id, code: node.code, b_code: node.b_code}],
             };
             checkCustomDetail(imDefault);
             for (const p of posterity) {
@@ -513,10 +515,12 @@ const stageIm = (function () {
                                 bw: bw, jldy: pp.name,
                                 changes: [], gclBills: [],
                                 custom_define: [],
+                                source: [],
                             };
                             nodeImData.push(im);
                             checkCustomDetail(im);
                         }
+                        im.source.push({id: p.ledger_id, code: p.code, b_code: p.b_code});
 
                         for (const c of changes) {
                             if (c.lid === p.id && c.pid == pp.id && c.qty && c.qty !== 0) {
@@ -651,6 +655,7 @@ const stageIm = (function () {
                     position: '',
                     lIndex: nodeIndex,
                     custom_define: [],
+                    source: [],
                 };
                 if (stage.im_gather && node.check) {
                     im.bw = getZlGatherBw(node, peg);
@@ -665,6 +670,7 @@ const stageIm = (function () {
                 checkCustomDetail(im);
                 ImData.push(im);
             }
+            im.source.push({id: p.ledger_id, code: p.code, b_code: p.b_code});
             //if (!stage.im_gather || !node.check) {
                 generateZlLeafXmjData(p, im, 'gather_qty');
             //}
@@ -691,7 +697,7 @@ const stageIm = (function () {
                         lid: node.id, code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price, pid: pp.id,
                         jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty,
                         //im_code: getNewImCode(),
-                        bw: bw,
+                        bw: bw, jldy: pp.name,
                         peg: CheckPeg(pp.name) ? getPegStr(pp.name) : (peg ? getPegStr(peg.name) : ''),
                         xm: pp.name,
                         drawing_code: pp.drawing_code,
@@ -699,6 +705,7 @@ const stageIm = (function () {
                         position: pp.position,
                         lIndex: nodeIndex,
                         custom_define: [],
+                        source: [{id: p.ledger_id, code: p.code, b_code: p.b_code}],
                     };
                     im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + ' ' + im.unit;
                     checkCustomDetail(im);
@@ -726,6 +733,7 @@ const stageIm = (function () {
                     position: '',
                     lIndex: gsTree.getNodeIndex(node),
                     custom_define: [],
+                    source: [{id: p.ledger_id, code: p.code, b_code: p.b_code}],
                 };
                 im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + ' ' + im.unit;
                 checkCustomDetail(im);
@@ -784,6 +792,11 @@ const stageIm = (function () {
             });
         }
         for (const [i, im] of ImData.entries()) {
+            if (im.source.length > 1) {
+                im.source.sort(function (x, y) {
+                    return compareCode(x.b_code, y.b_code);
+                });
+            }
             getCalcMemo(im);
             getChangeInfo(im);
             im.im_code = pre + getNumberFormat(stage.order, 2) + splitChar + getNumberFormat(i + 1, 3)

+ 13 - 1
app/view/stage/index.ejs

@@ -105,7 +105,19 @@
                     <!--中间计量-->
                     <div id="zhongjian" class="tab-pane tab-select-show">
                         <div class="sjs-bar">
-                            <button class="btn btn-sm btn-outline-primary pull-right" href="#choose" data-toggle="modal" data-target="#choose">设置生成规则</button>
+                            <div class="row px-3">
+                                <button class="btn btn-sm btn-outline-primary" id="im-locate2bills">定位</button>
+                                <div class="input-group input-group-sm col-6">
+                                    <div class="input-group-prepend">
+                                        <span class="input-group-text" id="im-locate-info">1/20</span>
+                                    </div>
+                                    <div class="input-group-append">
+                                        <button class="btn btn-outline-secondary" type="button" title="上一个" id="im-locate-pre"><i class="fa fa-angle-double-left"></i></button>
+                                        <button class="btn btn-outline-secondary" type="button" title="下一个" id="im-locate-next"><i class="fa fa-angle-double-right"></i></button>
+                                    </div>
+                                </div>
+                                <button class="btn btn-sm btn-outline-primary ml-auto" href="#choose" data-toggle="modal" data-target="#choose">设置生成规则</button>
+                            </div>
                         </div>
                         <div class="sjs-height-5" id="detail-spread" style="overflow:hidden">
                         </div>