Explorar o código

getRationPrefix、清单定额库非叶子节点默认收起

zhongzewei %!s(int64=7) %!d(string=hai) anos
pai
achega
5c8be8f658

+ 1 - 1
modules/all_models/ration.js

@@ -55,7 +55,7 @@ let rationSchema = new Schema({
     rationAssList: [rationAssItemSchema],
     content: String,                            // 工作内容
     ruleText: String,                            // 计算规则
-    prefix: {type: Number, default: 0},                              //定额是补充、借用时用 1 complementary 2 borrow
+    prefix: {type: String, default: ''},                              //定额是补充、借用时用  补 借
 
     //工料机特有属性
     projectGLJID:Number,  //项目工料机ID

+ 6 - 6
modules/main/facade/ration_facade.js

@@ -80,13 +80,13 @@ async function insertNewRation(newData,firstLibID,std,calQuantity) {//插入新
             newData.comments = std.chapter.explanation;
             newData.ruleText = std.chapter.ruleText;
         }
-        newData.prefix = 0;
+        newData.prefix = '';
         newData.from = std.type === 'complementary' ? 'cpt' : 'std';
         if(firstLibID !== std.rationRepId){//借
-            newData.prefix = 2;
+            newData.prefix = '借';
         }
         else if(std.rationRepId === firstLibID && newData.from === 'cpt') {
-            newData.prefix = 1;
+            newData.prefix = '补';
         }
         newData.programID = std.feeType;
         newData.rationAssList =  createRationAss(std);
@@ -317,13 +317,13 @@ async function  updateRation(std,firstLibID,rationID,billsItemID,projectID,calQu
     }
     ration.from = std.type === 'complementary' ? 'cpt' : 'std';
     //定额前缀 none:0, complementary:1, borrow: 2
-    ration.prefix = 0;
+    ration.prefix = '';
     //借用优先级比补充高
     if(std.rationRepId !== parseInt(firstLibID)){//借用
-        ration.prefix = 2;
+        ration.prefix = '借';
     }
     else if(std.rationRepId === firstLibID && ration.from === 'cpt') {
-        ration.prefix = 1;
+        ration.prefix = '补';
     }
     ration.programID = std.feeType;
     ration.rationAssList = createRationAss(std);//生成辅助定额

+ 9 - 0
public/web/id_tree.js

@@ -679,6 +679,15 @@ var idTree = {
             }
             return data;
         };
+        //非叶子节点默认收起展开
+        Tree.prototype.setRootExpanded = function(nodes, expanded){
+            for(let node of nodes){
+                if(node.children.length > 0){
+                    node.setExpanded(expanded);
+                    this.setRootExpanded(node.children, expanded);
+                }
+            }
+        };
 
         /*Tree.prototype.editedData = function (field, id, newText) {
             var node = this.findNode(id), result = {allow: false, nodes: []};

+ 7 - 3
web/building_saas/main/js/models/main_consts.js

@@ -159,9 +159,13 @@ const rationType = {
     install:4
 };
 const rationPrefix = { //定额前缀,补/借
-    none: 0,
-    complementary: 1,
-    borrow: 2
+    none: '',
+    complementary: '补',
+    borrow: '借'
+};
+const rationFrom = {
+    std: 'std',
+    cpt: 'cpt'
 };
 const leafBillGetFeeType = {
     rationContent: 0,

+ 11 - 0
web/building_saas/main/js/models/ration.js

@@ -630,6 +630,17 @@ var Ration = {
                 return 0;
             }
         } ;
+        //获取定额前缀
+        ration.prototype.getRationPrefix = function(firstLibID, ration){
+            if(firstLibID !== ration.libID){
+                return rationPrefix.borrow;
+            }
+            if(ration.from && ration.from === rationFrom.cpt){
+                return rationPrefix.complementary;
+            }
+            return rationPrefix.none;
+        };
+
         return new ration(project);
     }
 };

+ 2 - 8
web/building_saas/main/js/views/main_tree_col.js

@@ -43,15 +43,9 @@ let MainTreeCol = {
         },
         code: function (node) {
             if(node.sourceType === projectObj.project.Ration.getSourceType() && node.data.type === rationType.ration
-                && isDef(node.data.code) && isDef(node.data.prefix)){
-                if(node.data.prefix === rationPrefix.complementary){
-                    return '补' +  node.data.code.replace(new RegExp('补'), '');
-                }
-                if(node.data.prefix === rationPrefix.borrow){
-                    return '借' +  node.data.code.replace(new RegExp('借'), '');
-                }
+                && isDef(node.data.code) && isDef(node.data.prefix) && node.data.prefix !== ''){
+                return node.data.prefix + node.data.code.replace(new RegExp(node.data.prefix, 'g'), '');
             }
-
             return isDef(node.data.code) ? node.data.code : '';
         },
         marketPrice:function (node) {

+ 3 - 4
web/building_saas/main/js/views/std_bills_lib.js

@@ -165,10 +165,9 @@ var billsLibObj = {
         CommonAjax.post('/stdBillsEditor/getBills', {userId: userID, billsLibId: stdBillsLibID}, function (datas) {
             stdBills = datas;
             stdBillsTree.loadDatas(stdBills);
-            //第一层默认收起
-            for(let root of stdBillsTree.roots){
-                root.setExpanded(false);
-            }
+            //非叶子节点默认收起
+            stdBillsTree.setRootExpanded(stdBillsTree.roots, false);
+
             stdBillsTreeController.showTreeData();
             billsLibObj.setTagForHint(datas);
             showBillsRela(stdBillsTree.firstNode());

+ 2 - 4
web/building_saas/main/js/views/std_ration_lib.js

@@ -50,10 +50,8 @@ var rationLibObj = {
             that.tree = rationChapterTree;
             var rationChapterTreeController = TREE_SHEET_CONTROLLER.createNew(rationChapterTree, that.rationChapterSpread.getActiveSheet(), that.rationChapterTreeSetting);
             rationChapterTree.loadDatas(datas);
-            //第一层默认收起
-            for(let root of that.tree.roots){
-                root.setExpanded(false);
-            }
+            //非叶子节点默认收起
+            that.tree.setRootExpanded(that.tree.roots, false);
             rationChapterTreeController.showTreeData();
 
             rationChapterTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, function (node) {