Bladeren bron

Merge branch 'master' of http://192.168.1.41:3000/maixinrong/Calculation

TonyKang 5 jaren geleden
bovenliggende
commit
f6d2e3e59c
6 gewijzigde bestanden met toevoegingen van 58 en 27 verwijderingen
  1. 4 2
      app/base/base_bills_service.js
  2. 2 0
      app/public/js/ledger.js
  3. 2 1
      app/public/js/revise.js
  4. 48 23
      app/public/js/stage_pay.js
  5. 1 1
      app/view/stage/pay.ejs
  6. 1 0
      config/web.js

+ 4 - 2
app/base/base_bills_service.js

@@ -509,8 +509,10 @@ class BaseBillsSerivce extends TreeService {
     }
 
     async deal2sgfh(tid) {
-        const sql = 'UPDATE ' + this.tableName + ' SET sgfh_qty = deal_qty, quantity = deal_qty + sjcl_qty + qtcl_qty, ' +
-            '   sgfh_tp = deal_tp, total_price = deal_tp + sjcl_tp + qtcl_tp' +
+        const sql = 'UPDATE ' + this.tableName + ' SET sgfh_qty = deal_qty,' +
+            '    quantity = IFNULL(deal_qty, 0) + IFNULL(sjcl_qty, 0) + IFNULL(qtcl_qty, 0), ' +
+            '    sgfh_tp = deal_tp,' +
+            '    total_price = IFNULL(deal_tp, 0) + IFNULL(sjcl_tp, 0) + IFNULL(qtcl_tp, 0)' +
             '  WHERE tender_id = ?';
         const sqlParam = [tid];
         await this.db.query(sql, sqlParam);

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

@@ -1149,6 +1149,7 @@ $(document).ready(function() {
         if (!checkTzMeasureType()) {
             billsContextMenuOptions.items.applyDeal2Sgfh = {
                 name: '填设计量',
+                icon: 'fa-pencil',
                 callback: function (key, opt) {
                     postData(window.location.pathname + '/deal2sgfh', null, function (result) {
                         ledgerTree.loadDatas(result.bills);
@@ -2068,6 +2069,7 @@ $(document).ready(function() {
                     items: {
                         apply: {
                             name: '应用全部清单单价至台账',
+                            icon: 'fa-magic',
                             disabled: function (key, opt) {
                                 const sheet = self.spread.getActiveSheet();
                                 return sheet.getRowCount() === 0;

+ 2 - 1
app/public/js/revise.js

@@ -656,7 +656,8 @@ $(document).ready(() => {
             switch (col.field) {
                 case 'code':
                     const posRange = pos.getLedgerPos(node.id);
-                    return posRange && posRange.length > 0;
+                    info.cancel = posRange && posRange.length > 0;
+                    break;
                 case 'unit_price':
                     info.cancel = (node.children && node.children.length > 0) || node.used;
                     break;

+ 48 - 23
app/public/js/stage_pay.js

@@ -293,13 +293,13 @@ $(document).ready(() => {
                 } else if (/^[a-z]/.test(expr[i])) {
                     if (num !== '') {
                         param.push({type: 'num', value: num});
-                        base = '';
+                        num = '';
                     }
                     base = base + expr[i];
                 } else if (expr[i] === '(') {
                     if (num !== '') {
                         param.push({type: 'num', value: num});
-                        base = '';
+                        num = '';
                     }
                     if (base !== '') {
                         param.push({type: 'base', value: base});
@@ -309,7 +309,7 @@ $(document).ready(() => {
                 } else if (expr[i] === ')') {
                     if (num !== '') {
                         param.push({type: 'num', value: num});
-                        base = '';
+                        num = '';
                     }
                     if (base !== '') {
                         param.push({type: 'base', value: base});
@@ -319,7 +319,7 @@ $(document).ready(() => {
                 } else if (/^[\+\-*\/]/.test(expr[i])) {
                     if (num !== '') {
                         param.push({type: 'num', value: num});
-                        base = '';
+                        num = '';
                     }
                     if (base !== '') {
                         param.push({type: 'base', value: base});
@@ -332,7 +332,7 @@ $(document).ready(() => {
             }
             if (num !== '') {
                 param.push({type: 'num', value: num});
-                base = '';
+                num = '';
             }
             if (base !== '') {
                 param.push({type: 'base', value: base});
@@ -373,7 +373,7 @@ $(document).ready(() => {
                         return [false, '输入的表达式非法:不存在计算基数' + p.value];
                     if (invalidParam && invalidParam.indexOf(p.value) >= 0)
                         return [false, '不可使用计算基数' + p.value];
-                    if (i > 0 && param[i - 1].type === 'calc')
+                    if (i > 0 && (param[i - 1].type === 'num' || param[i - 1].type === 'right'))
                         return [false, '输入的表达式非法:' + p.value + '前应有运算符'];
                 }
                 if (p.type === 'left') {
@@ -478,6 +478,24 @@ $(document).ready(() => {
             setObjEnable($('#up-move'), !readOnly && select && !payBase.isSpecial(select) && dealPay.indexOf(select) > 3);
             setObjEnable($('#down-move'), !readOnly && select && !payBase.isSpecial(select) && dealPay.indexOf(select) < dealPay.length - 1);
         },
+        loadExprToInput: function () {
+            const sheet = paySpread.getActiveSheet();
+            const sel = sheet.getSelections()[0];
+            const col = sheet.zh_setting.cols[sel.col];
+            const data = SpreadJsObj.getSelectObject(sheet);
+            if (col.field === 'tp') {
+                $('#expr').val(data.expr).attr('field', 'expr').attr('org', data.expr)
+                    .attr('readOnly', readOnly|| payBase.isSpecial(data));
+            } else if (col.field === 'sprice') {
+                $('#expr').val(data.sexpr).attr('field', 'sexpr').attr('org', data.sexpr)
+                    .attr('readOnly', readOnly|| payCol.readOnly.sprice(data));
+            } else if (col.field === 'rprice') {
+                $('#expr').val(data.rexpr).attr('field', 'rexpr').attr('org', data.rexpr)
+                    .attr('readOnly', readOnly|| payCol.readOnly.rprice(data));
+            } else {
+                $('#expr').val('').attr('readOnly', true);
+            }
+        },
         add: function () {
             const sheet = paySpread.getActiveSheet();
             postData(window.location.pathname + '/save', {type: 'add'}, function (result) {
@@ -555,21 +573,7 @@ $(document).ready(() => {
         },
         selectionChanged: function (e, info) {
             paySpreadObj.refreshActn();
-            const sel = info.sheet.getSelections()[0];
-            const col = info.sheet.zh_setting.cols[sel.col];
-            const data = SpreadJsObj.getSelectObject(info.sheet);
-            if (col.field === 'tp') {
-                $('#expr').val(data.expr).attr('field', 'expr').attr('org', data.expr)
-                    .attr('readOnly', readOnly|| payBase.isSpecial(data));
-            } else if (col.field === 'sprice') {
-                $('#expr').val(data.sexpr).attr('field', 'sexpr').attr('org', data.sexpr)
-                    .attr('readOnly', readOnly|| payCol.readOnly.sprice(data));
-            } else if (col.field === 'rprice') {
-                $('#expr').val(data.rexpr).attr('field', 'rexpr').attr('org', data.rexpr)
-                    .attr('readOnly', readOnly|| payCol.readOnly.rprice(data));
-            } else {
-                $('#expr').val('').attr('readOnly', true);
-            }
+            paySpreadObj.loadExprToInput();
         },
         editEnded: function (e, info) {
             if (info.sheet.zh_setting) {
@@ -645,6 +649,7 @@ $(document).ready(() => {
                 postData(window.location.pathname + '/save', data, function (result) {
                     loadUpdateDealPays(result, col.field === 'name' ? ['name'] : null);
                     SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
+                    paySpreadObj.loadExprToInput();
                 }, function () {
                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
                 });
@@ -743,6 +748,7 @@ $(document).ready(() => {
                     postData(window.location.pathname + '/save', data, function (result) {
                         loadUpdateDealPays(result, col.field === 'name' ? ['name'] : null);
                         SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
+                        paySpreadObj.loadExprToInput();
                     })
                 }
             }
@@ -811,6 +817,7 @@ $(document).ready(() => {
                         postData(window.location.pathname + '/save', data, function (result) {
                             loadUpdateDealPays(result, col.field === 'name' ? ['name'] : null);
                             SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
+                            paySpreadObj.loadExprToInput();
                         }, function () {
                             SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
                         });
@@ -842,7 +849,13 @@ $(document).ready(() => {
             const data = {};
             if (field === 'expr') {
                 data.type = 'stage';
-                data.updateData = { pid: select.pid, tp: null, expr: newValue }
+                data.updateData = { pid: select.pid, tp: null, expr: newValue };
+                const [valid, msg] = paySpreadObj._checkExpr(newValue, data.updateData);
+                if (!valid) {
+                    toastr.warning(msg);
+                    this.value = select.expr;
+                    return;
+                }
             } else if (field === 'sexpr') {
                 data.type = 'info';
                 data.updateData = {id: select.pid};
@@ -870,7 +883,10 @@ $(document).ready(() => {
                 loadUpdateDealPays(result);
                 SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
             });
-        })
+        });
+        // $('#expr').bind('onpaste', function (e) {
+        //     console.log(e);
+        // });
     }
 
     const deadlineObj = {
@@ -1180,3 +1196,12 @@ $(document).ready(() => {
         });
     })
 });
+const pasteExpr = function (e, obj) {
+    let text = e.clipboardData.getData('text');
+    e.preventDefault();
+    text = trimInvalidChar(_.trim(text));
+    const start = obj.selectionStart, end = obj.selectionEnd;
+    obj.value = obj.value.substr(0, start) + text + obj.value.substring(end, obj.value.length);
+    obj.selectionStart = start + text.length;
+    obj.selectionEnd = start + text.length;
+};

+ 1 - 1
app/view/stage/pay.ejs

@@ -15,7 +15,7 @@
                         <div class="input-group-prepend">
                             <span class="input-group-text" id="basic-addon1">表达式</span>
                         </div>
-                        <input type="text" class="form-control m-0" <% if (stage.readOnly) { %> readonly="" <% } %> id="expr">
+                        <input type="text" class="form-control m-0" <% if (stage.readOnly) { %> readonly="" <% } %> id="expr" onpaste="pasteExpr(event, this);">
                     </div>
                 </div>
             </div>

+ 1 - 0
config/web.js

@@ -284,6 +284,7 @@ const JsFiles = {
             pay: {
                 files: [
                     "/public/js/spreadjs/sheets/v11/gc.spread.sheets.all.11.2.2.min.js",
+                    "/public/js/math.min.js",
                 ],
                 mergeFiles: [
                     "/public/js/sub_menu.js",