Selaa lähdekoodia

台账分解,项目节,新增清单时,检查协同范围

MaiXinRong 6 kuukautta sitten
vanhempi
commit
763f921e2d
3 muutettua tiedostoa jossa 35 lisäystä ja 6 poistoa
  1. 8 5
      app/public/js/cost_tmpl.js
  2. 21 0
      app/public/js/ledger.js
  3. 6 1
      app/service/pos_calc_detail.js

+ 8 - 5
app/public/js/cost_tmpl.js

@@ -430,13 +430,16 @@ $(document).ready(() => {
         const getCurTemplate = function() {
         const getCurTemplate = function() {
             return curTemplate;
             return curTemplate;
         };
         };
-        const getTemplateCaptionHtml = function(template) {
+        const getTemplateCaptionInnerHtml = function(template) {
             const usedHtml = template.used_count > 0 ? '<i class="ml-1 fa fa-lock text-danger"></i>' : '';
             const usedHtml = template.used_count > 0 ? '<i class="ml-1 fa fa-lock text-danger"></i>' : '';
-            return `<div class="d-flex justify-content-between align-items-center table-file" templateId="${template.id}"><div>${template.name}${usedHtml}</div>` +
+            return `<div>${template.name}${usedHtml}</div>` +
                 '    <div class="btn-group-table" style="display: none;">\n' +
                 '    <div class="btn-group-table" style="display: none;">\n' +
                 '    <a href="javascript: void(0);" class="mr-1" data-toggle="tooltip" data-placement="bottom" data-original-title="编辑" name="renameTemplate"><i class="fa fa-pencil fa-fw"></i></a>\n' +
                 '    <a href="javascript: void(0);" class="mr-1" data-toggle="tooltip" data-placement="bottom" data-original-title="编辑" name="renameTemplate"><i class="fa fa-pencil fa-fw"></i></a>\n' +
                 '    <a href="javascript: void(0);" class="mr-1" data-toggle="tooltip" data-placement="bottom" data-original-title="删除" name="delTemplate"><i class="fa fa-trash-o fa-fw text-danger"></i></a>\n' +
                 '    <a href="javascript: void(0);" class="mr-1" data-toggle="tooltip" data-placement="bottom" data-original-title="删除" name="delTemplate"><i class="fa fa-trash-o fa-fw text-danger"></i></a>\n' +
-                '</div></div>';
+                '</div>';
+        };
+        const getTemplateCaptionHtml = function(template) {
+            return `<div class="d-flex justify-content-between align-items-center table-file" templateId="${template.id}">` + getTemplateCaptionInnerHtml(template) + '</div>';
         };
         };
         const getTemplateHtml = function(template) {
         const getTemplateHtml = function(template) {
             const html = [];
             const html = [];
@@ -469,7 +472,7 @@ $(document).ready(() => {
             });
             });
         };
         };
         if (templates.length > 0) setCurTemplate(templates[0]);
         if (templates.length > 0) setCurTemplate(templates[0]);
-        return { setCurTemplate, getCurTemplate, addTemplate, delTemplate, renameTemplate, getTemplateCaptionHtml }
+        return { setCurTemplate, getCurTemplate, addTemplate, delTemplate, renameTemplate, getTemplateCaptionHtml, getTemplateCaptionInnerHtml }
     })(templateList);
     })(templateList);
 
 
     $('body').on('click', '.table-file', function(e) {
     $('body').on('click', '.table-file', function(e) {
@@ -513,7 +516,7 @@ $(document).ready(() => {
         const template = templateList.find(x => { return x.id === templateId; });
         const template = templateList.find(x => { return x.id === templateId; });
         if (!template) return;
         if (!template) return;
 
 
-        $(`.table-file[templateId=${templateId}]`).html(templateObj.getTemplateCaptionHtml(template));
+        $(`.table-file[templateId=${templateId}]`).html(templateObj.getTemplateCaptionInnerHtml(template));
     });
     });
 
 
     $('body').on('click', 'a[name=delTemplate]', function(e) {
     $('body').on('click', 'a[name=delTemplate]', function(e) {

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

@@ -166,6 +166,7 @@ $(document).ready(function() {
                     specCol.cellTypeKey = 'specSelect';
                     specCol.cellTypeKey = 'specSelect';
                     specCol.maxDrop = 10;
                     specCol.maxDrop = 10;
                 }
                 }
+                template.spread_cache.forceLoadEmpty = true;
                 SpreadJsObj.initSheet(sheet, template.spread_cache);
                 SpreadJsObj.initSheet(sheet, template.spread_cache);
             } else {
             } else {
                 SpreadJsObj.initSheet(sheet, emptySetting);
                 SpreadJsObj.initSheet(sheet, emptySetting);
@@ -3363,6 +3364,26 @@ $(document).ready(function() {
                 toastr.warning('非最底层项目下,不应添加清单');
                 toastr.warning('非最底层项目下,不应添加清单');
                 return;
                 return;
             }
             }
+            if (tender.isAssUser && (mainNode._invalid && !mainNode._insertValid)) {
+                toastr.warning('非协作范围内,不可添加');
+                return;
+            }
+        }
+        if (updateData.postData.stdType === 'xmj' && tender.isAssUser) {
+            let leafRelaXmj = null;
+            for (const sd of updateData.postData.stdData) {
+                let rela = _.find(ledgerTree.nodes, {code: sd.code, name: sd.name});
+                if (!rela && sd.name.indexOf('x') >= 0) rela = _.find(ledgerTree.nodes, {code: sd.code});
+                if (rela) {
+                    leafRelaXmj = rela;
+                } else {
+                    break;
+                }
+            }
+            if (!leafRelaXmj || (leafRelaXmj._invalid && !leafRelaXmj._insertValid)) {
+                toastr.warning('非协作范围内,不可添加');
+                return;
+            }
         }
         }
 
 
         updateData.postData.id = ledgerTree.getNodeKey(mainNode);
         updateData.postData.id = ledgerTree.getNodeKey(mainNode);

+ 6 - 1
app/service/pos_calc_detail.js

@@ -10,6 +10,10 @@
 const strField = ['str1', 'str2', 'str3', 'str4'];
 const strField = ['str1', 'str2', 'str3', 'str4'];
 const numField = ['num_a', 'num_b', 'num_c', 'num_d', 'num_e', 'num_f', 'num_g', 'num_h', 'num_i'];
 const numField = ['num_a', 'num_b', 'num_c', 'num_d', 'num_e', 'num_f', 'num_g', 'num_h', 'num_i'];
 const specialField = ['spec', 'qty', 'expr'];
 const specialField = ['spec', 'qty', 'expr'];
+const math = require('mathjs');
+math.config({
+    number: 'BigNumber',
+});
 
 
 module.exports = app => {
 module.exports = app => {
 
 
@@ -51,7 +55,8 @@ module.exports = app => {
             }
             }
         }
         }
         _reCalcQty(data, template) {
         _reCalcQty(data, template) {
-            const result = { id: data.id, expr: template.calc_expr.qty || '' };
+            const qtyExpr = template.calc_expr.find(x => { return x.field === 'qty'; });
+            const result = { id: data.id, expr: qtyExpr ? qtyExpr.expr : '' };
             for (const nf of numField) {
             for (const nf of numField) {
                 result[nf] = this.ctx.helper.round(data[nf] || 0, this.getDecimal(template.decimal, nf));
                 result[nf] = this.ctx.helper.round(data[nf] || 0, this.getDecimal(template.decimal, nf));
                 result.expr = result.expr.replace(new RegExp(nf, 'gm'), data[nf] || 0);
                 result.expr = result.expr.replace(new RegExp(nf, 'gm'), data[nf] || 0);