瀏覽代碼

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

Tony Kang 1 年之前
父節點
當前提交
3aa5f87525
共有 4 個文件被更改,包括 30 次插入4 次删除
  1. 1 1
      app/controller/file_controller.js
  2. 4 1
      app/public/js/ledger.js
  3. 8 0
      app/public/js/stage.js
  4. 17 2
      app/service/filing.js

+ 1 - 1
app/controller/file_controller.js

@@ -53,7 +53,7 @@ module.exports = app => {
                 renderData.categoryData = await ctx.service.category.getAllCategory(ctx.session.sessionProject.id);
                 renderData.canFiling = ctx.subProject.permission.file_permission.indexOf(ctx.service.subProjPermission.PermissionConst.file.filing.value) >= 0;
                 renderData.canUpload = ctx.subProject.permission.file_permission.indexOf(ctx.service.subProjPermission.PermissionConst.file.upload.value) >= 0;
-                renderData.filingTypes = ctx.service.filing.filingType;
+                renderData.filingTypes = ctx.service.filing.analysisFilingType(renderData.filing);
                 await this.layout('file/file.ejs', renderData, 'file/file_modal.ejs');
             } catch (err) {
                 ctx.log(err);

+ 4 - 1
app/public/js/ledger.js

@@ -1718,7 +1718,10 @@ $(document).ready(function() {
             },
             visible: function (key, opt) {
                 const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
-                return node.children.length === 0;
+                if (node.children && node.children.length > 0) return false;
+                const posRange = pos.getLedgerPos(node.id);
+                if (posRange && posRange.length > 0) return false;
+                return true;
             }
         };
     }

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

@@ -1681,8 +1681,16 @@ $(document).ready(() => {
                     TreeExprCalc.setCalcType(TreeExprCalc.calcType.sortCache);
 
                     const calcExpr = stageTree.nodes.filter(x => {
+                        if (x.children && x.children.length > 0) return false;
+                        const posRange = stagePos.getLedgerPos(x.id);
+                        if (posRange && posRange.length > 0) return false;
                         return !!x.calc_expr;
                     }).map(x => { return { id: x.id, expr: x.calc_expr, unit_price: x.unit_price, calcField: x.is_tp ? 'tp' : 'qty' }});
+                    if (calcExpr.length === 0) {
+                        toastr.warning('沒有可计算的公式');
+                        return;
+                    }
+
                     TreeExprCalc.calcAllExpr(calcExpr);
                     const updateData = calcExpr.map(x => {
                         const data = { lid: x.id, contract_expr: x.formula };

+ 17 - 2
app/service/filing.js

@@ -36,13 +36,29 @@ module.exports = app => {
         constructor(ctx) {
             super(ctx);
             this.tableName = 'filing';
-            this.filingType = filingType;
         }
 
         get allFilingType () {
             return filingType.map(x => { return x.value });
         }
 
+        analysisFilingType(filing) {
+            const curFilingType = filing.filter(f => {
+                return f.tree_level === 1;
+            });
+            curFilingType.sort((x, y) => {
+                return x.tree_order - y.tree_order;
+            });
+            return curFilingType.map(f => {
+                return { value: f.filing_type, name: f.name }
+            });
+        }
+
+        async getFilingType(spid) {
+            const filing = await ctx.service.filing.getValidFiling(ctx.params.id, ctx.subProject.permission.filing_type);
+            return this.analysisFilingType(filing);
+        }
+
         async initFiling(spid, templateId, transaction) {
             const count = await this.count({ spid });
             if (count > 0) return;
@@ -76,7 +92,6 @@ module.exports = app => {
             return await this.getAllDataByCondition({ where: condition });
         }
 
-
         async getPosterityData(id){
             const result = [];
             let cur = await this.getAllDataByCondition({ where: { tree_pid: id } });