Explorar o código

中间计量,桩号取值调整

MaiXinRong %!s(int64=5) %!d(string=hai) anos
pai
achega
4a8976e67b
Modificáronse 1 ficheiros con 38 adicións e 5 borrados
  1. 38 5
      app/public/js/stage_im.js

+ 38 - 5
app/public/js/stage_im.js

@@ -137,10 +137,40 @@ const stageIm = (function () {
     }
 
     function CheckPeg(text) {
-        const pegReg = /[kK][0-9][++][0-9]{3}/;
+        const pegReg = /[a-zA-Z]?[kK][0-9]+[++][0-9]{3}([.][0-9]+)?/;
+        console.log(text);
+        console.log(text.match(pegReg));
         return pegReg.test(text);
     }
 
+    function getPegStr(text) {
+        const pegReg1 = /[a-zA-Z]?[kK][0-9]+[++][0-9]{3}([.][0-9]+)?[~~—][a-zA-Z]?[kK][0-9]+[++][0-9]{3}([.][0-9]+)?/;
+        const result1 = text.match(pegReg1);
+        console.log(result1);
+        if (result1) {
+            return result1[0];
+        } else {
+            const pegReg2 = /[a-zA-Z]?[kK][0-9]+[++][0-9]{3}([.][0-9]+)?-[a-zA-Z]?[kK][0-9]+[++][0-9]{3}([.][0-9]+)?/;
+            const result2 = text.match(pegReg2);
+            if (result2) {
+                return result2[0];
+            } else {
+                const pegReg3 = /[a-zA-Z]?[kK][0-9]+[++][0-9]{3}([.][0-9]+)?/;
+                const result3 = text.match(pegReg3);
+                return result3 ? result3[0] : '';
+            }
+        }
+        //const pegReg = /[a-zA-Z]?[kK][0-9]+[++][0-9]{3}([.][0-9]+)?/g;
+        // const result = text.match(pegReg);
+        // if (result.length === 1) {
+        //     return result[0]
+        // } else {
+        //     const iBegin = text.indexOf(result[0]);
+        //     const iEnd = text.indexOf(result[result.length - 1]);
+        //     return text.substring(iBegin, iEnd) + result[result.length - 1];
+        // }
+    }
+
     function getPegNode (node) {
         if (node) {
             if (CheckPeg(node.name)) {
@@ -351,7 +381,7 @@ const stageIm = (function () {
                 lid: node.id, code: node.code,
                 jl: node.gather_tp, contract_jl: node.contract_tp, qc_jl: node.qc_tp,
                 im_code: getNewImCode(),
-                peg: peg ? peg.name : '', drawing_code: getDrawingCode(node),
+                peg: peg ? getPegStr(peg.name) : '', drawing_code: getDrawingCode(node),
             };
             if (stage.im_gather && node.check) {
                 im.bw = getZlGatherBw(node, peg);
@@ -454,7 +484,7 @@ const stageIm = (function () {
                     lid: node.id, code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price,
                     jl: 0, contract_jl: 0, qc_jl: 0,
                     im_code: getNewImCode(),
-                    peg: peg ? peg.name : '', drawing_code: getDrawingCode(node),
+                    peg: peg ? getPegStr(peg.name) : '', drawing_code: getDrawingCode(node),
                 };
                 if (stage.im_gather && node.check) {
                     im.bw = getZlGatherBw(node, peg);
@@ -493,7 +523,7 @@ const stageIm = (function () {
                         jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty,
                         im_code: getNewImCode(),
                         bw: bw,
-                        peg: CheckPeg(pp.name) ? pp.name : (peg ? peg.name : ''),
+                        peg: CheckPeg(pp.name) ? getPegStr(pp.name) : (peg ? getPegStr(peg.name) : ''),
                         xm: pp.name,
                         drawing_code: pp.drawing_code,
                         changes: [],
@@ -517,7 +547,7 @@ const stageIm = (function () {
                     jl: p.gather_qty, contract_jl: p.contract_qty, qc_jl: p.qc_qty,
                     im_code: getNewImCode(),
                     bw: bw,
-                    peg: peg ? peg.name : '',
+                    peg: peg ? getPegStr(peg.name) : '',
                     xm: node.name,
                     drawing_code: getDrawingCode(node),
                     changes: [],
@@ -574,6 +604,9 @@ const stageIm = (function () {
             getCalcMemo(im);
             getChangeInfo(im);
         }
+        if (stage.im_type !== imType.zl.value) {
+            stage.im_type
+        }
         return ImData;
     }