Browse Source

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionOperation

TonyKang 7 năm trước cách đây
mục cha
commit
0fc115efa2

+ 3 - 2
modules/ration_repository/controllers/ration_controller.js

@@ -10,8 +10,9 @@ var callback = function(req, res, err, message, data){
 
 class RationController extends BaseController{
     getRationItemsBySection(req, res){
-        var sectionId = req.body.sectionID;
-        rationItem.getRationItemsBySection(sectionId, function(err, message, rst){
+        let sectionId = req.body.sectionID;
+        let rationRepId = req.body.rationRepId;
+        rationItem.getRationItemsBySection(rationRepId, sectionId, function(err, message, rst){
             if (err) {
                 callback(req, res, err, message, null);
             } else {

+ 7 - 6
modules/ration_repository/controllers/ration_section_tree_controller.js

@@ -10,8 +10,9 @@ var callback = function(req,res,err,message, data){
 
 class RationChapterTreeController extends BaseController{
     getRationChapterTree(req,res){
-        var rationLibId = req.body.rationLibId;
-        var repId = req.body.rationRepositoryId;
+        let data = JSON.parse(req.body.data);
+        var rationLibId = data.rationLibId;
+        var repId = data.rationRepositoryId;
         if (rationLibId) {
             rationChapterTreeData.getRationChapterTree(rationLibId,function(err,data){
                 callback(req,res,err, "", data);
@@ -32,10 +33,10 @@ class RationChapterTreeController extends BaseController{
         });
     }
     updateNodes(req, res) {
-        var nodes = JSON.parse(req.body.nodes);
-        let lastOpr = req.body.lastOpr;
-        let repId = req.body.repId;
-        rationChapterTreeData.updateNodes(repId, lastOpr, nodes, function(err,results){
+        let data = JSON.parse(req.body.data);
+        let lastOpr = data.lastOpr;
+        let updateData = data.updateData;
+        rationChapterTreeData.updateNodes(lastOpr, updateData, function(err,results){
             callback(req,res, err, "", results)
         });
     }

+ 2 - 2
modules/ration_repository/models/ration_item.js

@@ -41,9 +41,9 @@ rationItemDAO.prototype.sortToNumber = function (datas) {
     }
 };
 
-rationItemDAO.prototype.getRationItemsBySection = function(sectionId,callback){
+rationItemDAO.prototype.getRationItemsBySection = function(rationRepId, sectionId,callback){
     let me = this;
-    rationItemModel.find({"sectionId": sectionId, "$or": [{"isDeleted": null}, {"isDeleted": false} ]},function(err,data){
+    rationItemModel.find({"rationRepId": rationRepId, "sectionId": sectionId, "$or": [{"isDeleted": null}, {"isDeleted": false} ]},function(err,data){
         if(err) callback(true, "Fail to get items", "");
         else {
             me.sortToNumber(data);

+ 46 - 22
modules/ration_repository/models/ration_section_tree.js

@@ -12,17 +12,17 @@ var rationChapterTreeDAO = function(){};
 
 rationChapterTreeDAO.prototype.getRationChapterTree = function(rationLibId,callback){
     rationChapterTreeModel.find({"rationRepId": rationLibId, "$or": [{"isDeleted": null}, {"isDeleted": false} ]},function(err,data){
-        if(data.length) callback(false,data);
-        else  if(err) callback("获取定额树错误!",false)
-        else callback(false,false);
+        if(data.length) callback(0,data);
+        else  if(err) callback("获取定额树错误!",[])
+        else callback(0,[]);
     })
 }
 
 rationChapterTreeDAO.prototype.getRationChapterTreeByRepId = function(repId,callback){
     rationChapterTreeModel.find({"rationRepId": repId, "$or": [{"isDeleted": null}, {"isDeleted": false} ]},function(err,data){
-        if(data.length) callback(false,data);
-        else  if(err) callback("获取定额树错误!",false)
-        else callback(false,false);
+        if(data.length) callback(0,data);
+        else  if(err) callback("获取定额树错误!",[])
+        else callback(false,[]);
     })
 }
 
@@ -152,30 +152,54 @@ rationChapterTreeDAO.prototype.updateAnnoSituation = function (lastOpr, repId, n
     });
 };
 
-rationChapterTreeDAO.prototype.updateNodes = function(repId, lastOpr, nodes,callback){
+rationChapterTreeDAO.prototype.updateNodes = function(lastOpr, updateData,callback){
     var functions = [];
-    for (var i=0; i < nodes.length; i++) {
+    for (var i=0; i < updateData.length; i++) {
         //var md = new rationChapterTreeModel(nodes[i]);
         //md.isNew = false;
         functions.push((function(doc) {
             return function(cb) {
-                rationChapterTreeModel.update({ID: doc.ID}, doc, cb);
-            };
-        })(nodes[i]));
-    }
-    functions.push((function () {
-        return function (cb) {
-            rationRepositoryDao.updateOprArr({ID: repId}, lastOpr, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
-                if(err){
-                    cb(err);
+                if(doc.updateType === 'update'){
+                    rationChapterTreeModel.update({rationRepId: doc.updateData.rationRepId, ID: doc.updateData.ID}, doc.updateData, function (err) {
+                        if(err){
+                            cb(err);
+                        }
+                        else {
+                            cb(null);
+                        }
+                    });
                 }
-                else{
-                    cb(null);
+                else if(doc.updateType === 'new'){
+                    rationChapterTreeModel.create(doc.updateData, function (err) {
+                        if(err){
+                            cb(err);
+                        }
+                        else {
+                            cb(null);
+                        }
+                    });
                 }
-            })
-        }
-    })());
+            };
+        })(updateData[i]));
+    }
+    if(updateData.length > 0){
+        functions.push((function () {
+            return function (cb) {
+                rationRepositoryDao.updateOprArr({ID: updateData[0].updateData.rationRepId}, lastOpr, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
+                    if(err){
+                        cb(err);
+                    }
+                    else{
+                        cb(null);
+                    }
+                })
+            }
+        })());
+    }
     async.parallel(functions, function(err, results) {
+        if(!err){
+            err = 0;
+        }
         callback(err, results);
     });
 };

+ 18 - 6
web/maintain/ration_repository/dinge.html

@@ -46,12 +46,17 @@
         <div class="content">
             <div class="container-fluid">
                 <div class="row">
-                  <div class="main-side col-lg-3 p-0" style="width: 100%; height: 100%; overflow: auto">
+                  <div class="main-side col-lg-3 p-0" style="width: 100%; height: 100%; overflow: hidden">
                       <div class="tab-bar">
-                          <a id="addRootA" onclick="zTreeOprObj.addRootNode()" class="btn btn-secondary btn-sm">增加根节点</a>
+                          <a href="javascript:void(0);" id="tree_Insert" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="插入"><i class="fa fa-plus" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_remove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_upLevel" class="btn btn-sm " data-toggle="tooltip" data-placement="bottom" title="" data-original-title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_downLevel" class="btn btn-sm " data-toggle="tooltip" data-placement="bottom" title="" data-original-title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_downMove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_upMove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                       </div>
-                    <div class="tab-content">
-                      <ul id="rationChapterTree" class="ztree"></ul>
+                    <div class="tab-content" id="sectionSpread" style="overflow: hidden">
+                      <!--<ul id="rationChapterTree" class="ztree"></ul>-->
                     </div>
                   </div>
                   <div class="main-content col-lg-9 p-0">
@@ -442,7 +447,14 @@
         <script type="text/javascript" src="/lib/ztree/jquery.ztree.excheck.js"></script>
         <script type="text/javascript" src="/lib/ztree/jquery.ztree.exedit.js"></script>
         <script type="text/javascript" src="/web/maintain/ration_repository/js/section_tree.js"></script>
+        <script type="text/javascript" src="/web/maintain/ration_repository/js/explanatory.js"></script>
+        <script type="text/javascript" src="/web/maintain/ration_repository/js/jobContent.js"></script>
+        <script type="text/javascript" src="/web/maintain/ration_repository/js/annotation.js"></script>
         <script type="text/javascript" src="/public/web/scMathUtil.js"></script>
+        <script type="text/javascript" src="/public/web/common_ajax.js"></script>
+        <script type="text/javascript" src="/public/web/id_tree.js"></script>
+        <script type="text/javascript" src="/public/web/tree_sheet/tree_sheet_controller.js"></script>
+        <script src="/public/web/tree_sheet/tree_sheet_helper.js"></script>
         <script type="text/javascript" src="/public/web/ztree_common.js"></script>
         <script type="text/javascript" src="/public/web/sheet/sheet_common.js"></script>
         <script type="text/javascript" src="/web/maintain/ration_repository/js/sheetsOpr.js"></script>
@@ -457,7 +469,7 @@
         <script type="text/javascript" src="/public/web/storageUtil.js"></script>
         <script type="text/javascript">
             let userAccount = '<%=userAccount %>';
-            var setting = {
+          /*  var setting = {
                 view: {
                     addHoverDom: zTreeOprObj.addHoverDom,
                     removeHoverDom: zTreeOprObj.removeHoverDom,
@@ -504,7 +516,7 @@
                     onDrop: zTreeOprObj.onDrop,
 
                 }
-            };
+            };*/
             $(document).ready(function(){
                 pageOprObj.initPage();
                 rationOprObj.buildSheet($("#rationItemsSheet")[0]);

+ 407 - 0
web/maintain/ration_repository/js/annotation.js

@@ -0,0 +1,407 @@
+/**
+ * Created by Zhong on 2017/12/20.
+ */
+//附注
+let annotationOprObj = {
+    situations: {ALL: 'ALL', PARTIAL: 'PARTIAL', NONE: 'NONE'},
+    currentSituation: null,//本项适用情况
+    radios: $("input[name = 'fzRadios']"),
+    fzTableAll: $('#fzTableAll'),
+    fzTablePartial: $('#fzTablePartial'),
+    currentOprTr: null,
+    currentAnnotation: null,
+    addCon: $('#fzAddCon'),//勾选编码模态框
+    updateCon: $('#fzUpdateCon'),//编辑编码模态框
+    clickUpdate: function (txtarea) {//解决编辑完后在未失去焦点的时候直接定额章节树
+        let me = annotationOprObj;
+        if(txtarea.is(':focus')){
+            let annotation = txtarea.val();
+            if(annotation !== me.currentAnnotation){
+                jobContentOprObj.preTreeNode.data.annotation = annotation;
+                me.unbindEvents(txtarea);
+                txtarea.blur();
+                let updateCodes = [];
+                for(let i = 0, len = jobContentOprObj.currentRationItems.length; i < len; i++){
+                    updateCodes.push(jobContentOprObj.currentRationItems[i].code);
+                    jobContentOprObj.currentRationItems[i].annotation = annotation;
+                }
+                me.updateAnnotation(pageOprObj.rationLibId, me.getUpdateArr(updateCodes, annotation), function () {
+                    me.bindAllEvents(txtarea);
+                });
+            }
+            else {
+                txtarea.blur();
+            }
+        }
+    },
+    getGroup: function (rationItems) {
+        let rst = [];//rst = [{jobContent: String, items: Array}]
+        for(let i = 0, len = rationItems.length; i < len; i++){
+            if(typeof rationItems[i].annotation !== 'undefined' && rationItems[i].annotation.toString().trim().length > 0){
+                let isExist = false;
+                for(let j = 0, jLen = rst.length; j < jLen; j++){
+                    if(rst[j].annotation === rationItems[i].annotation){
+                        isExist = true;
+                        rst[j].items.push(rationItems[i].code);
+                        break;
+                    }
+                }
+                if(!isExist){
+                    rst.push({annotation: rationItems[i].annotation, items: [rationItems[i].code]});
+                }
+            }
+        }
+        return rst;
+    },
+    hideTable: function (tableAll, tablePartial) {
+        if(tableAll){
+            tableAll.hide();
+        }
+        if(tablePartial){
+            tablePartial.hide();
+        }
+    },
+    //建table
+    buildTablePartial: function (table, group) {
+        let me = annotationOprObj;
+        table.empty();
+        let $thead = $("<thead><tr><th></th><th>编码</th><th>附注</th>/tr></thead>");
+        let $tbody = $("<tbody></tbody>");
+        let count = 1;
+        for(let i = 0, len = group.length; i < len; i++){
+            let $newTr = me.getNewTr($tbody, group[i].items, group[i].annotation);
+            $tbody.append($newTr);
+            count++;
+        }
+        let $trEnd = $("<tr><td>"+ count +"</td><td><a href data-toggle='modal' data-target='#fzEditBianma' class='m-0'>点击勾选编码</a></td><td><textarea class='form-control'></textarea></td></tr>");//勾选行
+        $($trEnd.children().children()[0]).bind('click', function () {
+            me.onclickFuncAdd($(this));
+            me.currentOprTr = $trEnd;
+            me.currentAnnotation = $(me.currentOprTr.children()[2]).children().val();
+        });
+        $tbody.append($trEnd);
+        table.append($thead);
+        table.append($tbody);
+    },
+    //新增一行tr
+    getNewTr: function (tbody, codes, jobContent) {
+        let me = annotationOprObj;
+        let count = tbody.children().length > 0 ? tbody.children().length : 1;
+        let $textTd = $("<td></td>");
+        let $textarea = $("<textarea class='form-control'></textarea>");
+        $textarea.val(jobContent);
+        $textTd.append($textarea);
+        let $tr = $("<tr><td>" + count + "</td><td><a href data-toggle='modal' data-target='#fzEditBianmaQ' class='m-0'>编辑编码</a></td></tr>");
+        $tr.children().children().bind('click', function () {
+            me.currentOprTr = $tr;
+            me.currentAnnotation = $(me.currentOprTr.children()[2]).children().val();
+            me.onclickFuncEdit($(this));
+        });
+        //文本变化;
+        $textarea.bind('change', function () {
+            let codes = me.getUpdateCodes($($(this).parent().parent().children()[1]).children());
+            let annotation = $(this).val();
+            me.updateAnnotation(pageOprObj.rationLibId, me.getUpdateArr(codes, annotation), function () {
+                if(annotation.trim().length === 0){
+                    me.buildTablePartial(me.fzTablePartial, me.getGroup(jobContentOprObj.currentRationItems));
+                }
+            });
+        });
+        $tr.append($textTd);
+        for(let i = 0, len = codes.length; i < len; i ++){
+            let $p = $("<p class='m-0'>" + codes[i] + "</p>");
+            $tr.children()[1].append($p[0]);
+        }
+        me.setTextareaHeight($textarea, codes.length + 1);
+        return $tr[0];
+    },
+    onclickFuncAdd: function (obj) {
+        let me = annotationOprObj;
+        let txtarea = $(obj.parent().parent().children().children()[1]);
+        let annotation = txtarea.val();
+        if(annotation.trim().length > 0){
+            let codesObj = me.getAddCodes(jobContentOprObj.currentRationItems);
+            me.buildCheckCodesCon(me.addCon, codesObj.checkedCodes, codesObj.disabledCodes)
+            obj.attr('data-target', '#fzEditBianma');
+        }
+        else{
+            obj.attr('data-target', '');
+            alert("附注不能为空!");
+        }
+    },
+    onclickFuncEdit: function (obj) {
+        let me = annotationOprObj;
+        me.buildEditableCodesCon(jobContentOprObj.currentRationItems, me.updateCon, me.getUpdateCodes(obj));
+    },
+    //获取编码td中的编码
+    getUpdateCodes: function (jq) {
+        let rst = [];
+        let nodes = jq.parent().children();
+        for(let i = 1, len = nodes.length; i < len; i++){
+            rst.push(nodes[i].textContent);
+        }
+        return rst;
+    },
+    //建一个编码checkbox Div
+    buildCodeOption: function (code, attr) {
+        let $div = $("<div class='col'><label class='form-check-label'><input class='form-check-input' type='checkbox' value= "+ code +"> "+ code +"</label></div>");
+        let $checkBox = $div.children().children();
+        if(attr){
+            $checkBox.attr(attr, true);
+        }
+        return $div;
+    },
+    //建修改编码弹窗
+    buildEditableCodesCon: function (rationItems, container, codes) {
+        let me = annotationOprObj;
+        let codeDivs = [];
+        container.empty();
+        for(let i = 0, len = codes.length; i < len; i++){
+            codeDivs.push({code: codes[i], attr: 'checked'});
+        }
+        for(let i = 0, len = rationItems.length; i < len; i++){
+            if(codes.indexOf(rationItems[i].code) === -1){
+                if(typeof rationItems[i].annotation !== 'undefined' && rationItems[i].annotation.toString().trim().length > 0){
+                    codeDivs.push({code: rationItems[i].code, attr: 'disabled'});
+                }
+                else{
+                    codeDivs.push({code: rationItems[i].code, attr: ''});
+                }
+            }
+        }
+        //排序
+        codeDivs.sort(function (a, b) {
+            let rst = 0;
+            if(a.code > b.code) rst = 1;
+            else if(a.code < b.code) rst = -1;
+            return rst;
+        });
+        for(let i = 0, len = codeDivs.length; i < len; i++){
+            container.append(me.buildCodeOption(codeDivs[i].code, codeDivs[i].attr));
+        }
+    },
+    //建勾选编码弹窗
+    buildCheckCodesCon: function (container, checkedCodes, disabledCodes) {
+        let me = annotationOprObj;
+        container.empty();
+        for(let i = 0, len = checkedCodes.length; i < len; i++){
+            let $codeDiv = me.buildCodeOption(checkedCodes[i], 'checked');
+            container.append($codeDiv);
+        }
+        for(let i = 0, len = disabledCodes.length; i < len; i++){
+            let $codeDiv = me.buildCodeOption(disabledCodes[i], 'disabled');
+            container.append($codeDiv);
+        }
+    },
+    getAddCodes: function (rationItems) {
+        let me = annotationOprObj;
+        let rst = {checkedCodes: [], disabledCodes: []};
+        for(let i = 0, len = rationItems.length; i < len; i++){
+            if(typeof rationItems[i].annotation !== 'undefined' && rationItems[i].annotation.toString().trim().length > 0){
+                rst.disabledCodes.push(rationItems[i].code);
+            }
+            else{
+                rst.checkedCodes.push(rationItems[i].code);
+            }
+        }
+        return rst;
+    },
+    //获取选择后的编码窗口的编码及状态
+    getCodesAfterS: function (checkNodes) {
+        let rst = {checked: [], unchecked: []};
+        for(let i = 0, len = checkNodes.length; i < len; i++){
+            if(checkNodes[i].checked){
+                rst.checked.push(checkNodes[i].value);
+            }
+            else if(!checkNodes[i].checked && !checkNodes[i].disabled){
+                rst.unchecked.push(checkNodes[i].value);
+            }
+        }
+        return rst;
+    },
+    setRadiosChecked: function (situation, radios) {
+        let me = annotationOprObj;
+        if(situation === me.situations.ALL){
+            radios[0].checked = true;
+            radios[1].checked = false;
+            $('#fzTxtareaAll').val(jobContentOprObj.currentRationItems.length > 0 ? jobContentOprObj.currentRationItems[0].annotation : '');
+            me.currentAnnotation = jobContentOprObj.currentRationItems.length > 0 ? jobContentOprObj.currentRationItems[0].annotation : '';
+            me.fzTableAll.show();
+            me.fzTablePartial.hide();
+        }
+        else if(situation === me.situations.PARTIAL){
+            radios[0].checked = false;
+            radios[1].checked = true;
+            me.fzTableAll.hide();
+            me.fzTablePartial.show();
+        }
+        else if(situation === me.situations.NONE){
+            radios[0].checked = false;
+            radios[1].checked = false;
+            me.fzTableAll.hide();
+            me.fzTablePartial.hide();
+        }
+    },
+    //radios是否可用,只有在定额章节树的底层节点才可用
+    setRadiosDisabled: function (val, radios) {
+        let me =annotationOprObj;
+        if(val){
+            radios[0].checked = false;
+            radios[1].checked = false;
+            me.currentSituation = me.situations.NONE;
+        }
+        radios.attr('disabled', val);
+    },
+    radiosChange: function (radios, tableAll, tablePartial) {
+        let me = annotationOprObj;
+        radios.change(function () {
+            let val = $("input[name = 'fzRadios']:checked").val();
+            let selectedNode = sectionTreeObj.tree.selected;
+            me.updateAnnoSituation(pageOprObj.rationLibId, selectedNode.getID(), val, function () {
+                selectedNode.data.annotationSituation = val;
+                me.currentSituation = val;
+                if(val === me.situations.ALL){
+                    let updateCodes = [];
+                    for(let i = 0, len = jobContentOprObj.currentRationItems.length; i < len; i++){
+                        updateCodes.push(jobContentOprObj.currentRationItems[i].code);
+                    }
+                    me.updateAnnotation(pageOprObj.rationLibId, me.getUpdateArr(updateCodes, ''), function () {
+                        me.currentAnnotation = '';
+                        $('#fzTxtareaAll').val('');
+                        tableAll.show();
+                        tablePartial.hide();
+                    });
+                }
+                else{
+                    me.buildTablePartial(me.fzTablePartial, me.getGroup(jobContentOprObj.currentRationItems));
+                    tableAll.hide();
+                    tablePartial.show();
+                }
+            });
+        });
+    },
+    setTextareaHeight: function (textarea, nodesCount) {
+        const perHeight = 21.6;
+        textarea.height(nodesCount * 21.6);
+    },
+    bindEvents: function (txtarea) {
+        let me = annotationOprObj;
+        txtarea.bind('change', function () {
+            let annotation = txtarea.val();
+            let jqNodes = txtarea.parent().parent().children()[1].children;
+            let updateCodes = me.getUpdateCodes(jqNodes);
+            txtarea.attr('disabled', true);
+            me.updateAnnotation(pageOprObj.rationLibId, me.getUpdateArr(updateCodes, annotation), function () {
+                txtarea.attr('disabled', false);
+            });
+        });
+    },
+    bindAllEvents: function (txtarea) {
+        let me = annotationOprObj;
+        txtarea.bind('change', function () {
+            let met = this;
+            let annotation = $(met).val();
+            $(met).attr('disabled', true);
+            let updateCodes = [];
+            for(let i = 0, len = jobContentOprObj.currentRationItems.length; i < len; i++){
+                updateCodes.push(jobContentOprObj.currentRationItems[i].code);
+                jobContentOprObj.currentRationItems[i].annotation = annotation;
+            }
+            me.currentAnnotation = annotation;
+            me.updateAnnotation(pageOprObj.rationLibId, me.getUpdateArr(updateCodes, annotation), function () {
+                $(met).attr('disabled', false);
+            });
+        });
+    },
+    unbindEvents: function (txtarea) {
+        txtarea.unbind();
+    },
+    //定额工作内容相关操作
+    rationAnnotationOpr: function (rationItems) {
+        let me = annotationOprObj;
+        me.setRadiosDisabled(rationItems.length > 0 ? false : true, me.radios);
+        me.setRadiosChecked(me.currentSituation, me.radios);
+        me.buildTablePartial(me.fzTablePartial, me.getGroup(rationItems));
+    },
+    getUpdateArr: function (updateCodes, annotation) {
+        let rst = [];
+        for(let i = 0, len = updateCodes.length; i < len; i++){
+            rst.push({code: updateCodes[i], annotation: annotation});
+        }
+        return rst;
+    },
+    bindAddConBtn: function () {
+        let me = annotationOprObj;
+        return function () {
+            let codesObj = me.getCodesAfterS(me.addCon.children().children().children());
+            let $tbody = $('#fzTablePartial tbody');
+            let lastEle = $tbody[0].lastElementChild;
+            let txtare = lastEle.lastElementChild.children[0];
+            if(me.currentAnnotation.trim().length > 0){//工作内容不为空才可添加编码
+                let updateArr = me.getUpdateArr(codesObj.checked, me.currentAnnotation);
+                me.updateAnnotation(pageOprObj.rationLibId, updateArr, function () {
+                    me.buildTablePartial(me.fzTablePartial, me.getGroup(jobContentOprObj.currentRationItems));
+                    $(txtare).val('');
+                });
+            }
+            else{
+                alert("附注不能为空!");
+            }
+        }
+    },
+    bindUpdateConBtn: function () {
+        let me = annotationOprObj;
+        return function () {
+            let codesObj = me.getCodesAfterS(me.updateCon.children().children().children());
+            let updateC = me.getUpdateArr(codesObj.checked, me.currentAnnotation),
+                updateUnC = me.getUpdateArr(codesObj.unchecked, ''),
+                updateArr = updateC.concat(updateUnC);
+            me.updateAnnotation(pageOprObj.rationLibId, updateArr, function () {
+                me.buildTablePartial(me.fzTablePartial, me.getGroup(jobContentOprObj.currentRationItems));
+            });
+        }
+    },
+    //更新缓存的定额
+    updateRationItem: function (rationItems, updateArr) {
+        for(let i = 0, len = rationItems.length; i < len; i++){
+            for(let j = 0, jLen = updateArr.length; j < jLen; j++){
+                if(rationItems[i].code === updateArr[j].code){
+                    rationItems[i].annotation = updateArr[j].annotation;
+                    break;
+                }
+            }
+        }
+    },
+    updateAnnotation: function (repId, updateArr, callback){
+        let me = annotationOprObj;
+        $.ajax({
+            type: 'post',
+            url: 'api/updateAnnotation',
+            data: {lastOpr: userAccount, repId: repId, updateArr: JSON.stringify(updateArr)},
+            dataType: 'json',
+            success: function (result) {
+                if(!result.error){
+                    me.updateRationItem(jobContentOprObj.currentRationItems, updateArr);
+                    callback();
+                }
+            }
+        });
+    },
+    updateAnnoSituation: function (repId, nodeId, situation, callback) {
+        let me = annotationOprObj;
+        $.ajax({
+            type: 'post',
+            url: 'api/updateAnnoSituation',
+            data: {lastOpr: userAccount, repId: repId, nodeId: nodeId, situation: situation},
+            dataType: 'json',
+            success: function (result) {
+                if(!result.error){
+                    if(callback){
+                        callback();
+                    }
+                }
+            }
+        })
+    }
+
+};

+ 95 - 0
web/maintain/ration_repository/js/explanatory.js

@@ -0,0 +1,95 @@
+/**
+ * Created by Zhong on 2017/12/20.
+ */
+//定额章节节点说明、计算规则
+let explanatoryOprObj = {
+    preTreeNode: null,
+    currentTreeNode: null,//定额章节树节点
+    currentExplanation: null,
+    currentRuleText: null,
+    setAttribute: function (preNode, currentNode, explanation, ruleText) {
+        let me = explanatoryOprObj;
+        me.preTreeNode = preNode;
+        me.currentTreeNode = currentNode;
+        me.currentExplanation = explanation;
+        me.currentRuleText = ruleText;
+    },
+    clickUpdate: function (exarea, ruarea) {//解决编辑完后在未失去焦点的时候直接定额章节树
+        let me = explanatoryOprObj;
+        if(exarea.is(':focus')){
+            let explanation = exarea.val();
+            if(explanation !== me.currentExplanation){
+                me.preTreeNode.data.explanation = explanation;
+                me.unbindEvents(exarea, ruarea);
+                exarea.blur();
+                me.updateExplanation(pageOprObj.rationLibId, me.preTreeNode.getID(), explanation, function () {
+                    me.bindEvents(exarea, ruarea);
+                });
+            }
+        }
+        if(ruarea.is(':focus')){
+            let ruleText = ruarea.val();
+            if(ruleText !== me.currentRuleText){
+                me.preTreeNode.data.ruleText = ruleText;
+                me.unbindEvents(exarea, ruarea);
+                ruarea.blur();
+                me.updateRuleText(pageOprObj.rationLibId, me.preTreeNode.getID(), ruleText, function () {
+                    me.bindEvents(exarea, ruarea);
+                });
+            }
+        }
+    },
+    unbindEvents: function (exarea, ruarea) {
+        exarea.unbind();
+        ruarea.unbind();
+    },
+    bindEvents: function (exarea, ruarea) {
+        let me = explanatoryOprObj;
+        exarea.bind('change', function () {
+            let explanation = exarea.val();
+            let node = me.currentTreeNode;
+            exarea.attr('disabled', true);
+            me.updateExplanation(pageOprObj.rationLibId, node.getID(), explanation, function () {
+                node.data.explanation = explanation;
+                exarea.attr('disabled', false);
+            });
+        });
+        ruarea.bind('change', function () {
+            let ruleText = ruarea.val();
+            let node = me.currentTreeNode;
+            ruarea.attr('disabled', true);
+            me.updateRuleText(pageOprObj.rationLibId, node.getID(), ruleText, function () {
+                node.data.ruleText = ruleText;
+                ruarea.attr('disabled', false);
+            });
+        });
+    },
+    showText: function (exarea, ruarea, explanation, ruleText) {
+        exarea.val(explanation && explanation !== 'undefined' ? explanation : '');
+        ruarea.val(ruleText && ruleText !== 'undefined' ? ruleText : '');
+    },
+    //更新说明
+    updateExplanation: function (repId, nodeId, explanation, callback) {
+        $.ajax({
+            type: 'post',
+            url: 'api/updateExplanation',
+            data: {lastOpr: userAccount, repId: pageOprObj.rationLibId, nodeId: nodeId, explanation: explanation},
+            dataType: 'json',
+            success: function () {
+                callback();
+            }
+        });
+    },
+    //更新计算规则
+    updateRuleText: function (repId, nodeId, explanation, callback) {
+        $.ajax({
+            type: 'post',
+            url: 'api/updateRuleText',
+            data: {lastOpr: userAccount, repId: pageOprObj.rationLibId, nodeId: nodeId, ruleText: explanation},
+            dataType: 'json',
+            success: function () {
+                callback();
+            }
+        });
+    }
+};

+ 1 - 0
web/maintain/ration_repository/js/global.js

@@ -11,6 +11,7 @@ function autoFlashHeight(){
     $(".form-list").height($(window).height()-headerHeight-50 );
     $(".main-data-top").height($(window).height()-headerHeight-toolsBar-bottomContentHeight-2);
     $(".main-data").height($(window).height()-headerHeight);
+    $(".main-side .tab-content").height($(window).height()-headerHeight-38);
 };
 $(window).resize(autoFlashHeight);
 /*全局自适应高度结束*/

+ 414 - 0
web/maintain/ration_repository/js/jobContent.js

@@ -0,0 +1,414 @@
+/**
+ * Created by Zhong on 2017/12/20.
+ */
+//工作内容
+let jobContentOprObj = {
+    situations: {ALL: 'ALL', PARTIAL: 'PARTIAL', NONE: 'NONE'},//所有ALL(包括未定义本项工作内容)、部分PARTIA,不可用NONE(无定额时)
+    currentSituation: null,//本项适用情况
+    currentTreeNode: null,
+    preTreeNode: null,
+    radios: $("input[name = 'optionsRadios']"),
+    tableAll: $('#tableAll'),
+    tablePartial: $('#tablePartial'),
+    currentOprTr: null,
+    currentJobContent: null,
+    currentRationItems: null,
+    addCon: $('#addCon'),//勾选编码模态框
+    updateCon: $('#updateCon'),//编辑编码模态框
+    setAttribute: function (preNode, currentNode) {
+        let me = jobContentOprObj;
+        me.preTreeNode = preNode;
+        me.currentTreeNode = currentNode;
+    },
+    clickUpdate: function (txtarea) {//解决编辑完后在未失去焦点的时候直接定额章节树
+        let me = jobContentOprObj;
+        if(txtarea.is(':focus')){
+            let jobContent = txtarea.val();
+            if(jobContent !== me.currentJobContent){
+                me.preTreeNode.data.jobContent = jobContent;
+                me.unbindEvents(txtarea);
+                txtarea.blur();
+                let updateCodes = [];
+                for(let i = 0, len = me.currentRationItems.length; i < len; i++){
+                    updateCodes.push(me.currentRationItems[i].code);
+                    me.currentRationItems[i].jobContent = jobContent;
+                }
+                me.updateJobContent(pageOprObj.rationLibId, me.getUpdateArr(updateCodes, jobContent), function () {
+                    me.bindAllEvents(txtarea);
+                })
+            }
+            else {
+                txtarea.blur();
+            }
+        }
+    },
+    getGroup: function (rationItems) {
+        let rst = [];//rst = [{jobContent: String, items: Array}]
+        for(let i = 0, len = rationItems.length; i < len; i++){
+            if(typeof rationItems[i].jobContent !== 'undefined' && rationItems[i].jobContent.toString().trim().length > 0){
+                let isExist = false;
+                for(let j = 0, jLen = rst.length; j < jLen; j++){
+                    if(rst[j].jobContent === rationItems[i].jobContent){
+                        isExist = true;
+                        rst[j].items.push(rationItems[i].code);
+                        break;
+                    }
+                }
+                if(!isExist){
+                    rst.push({jobContent: rationItems[i].jobContent, items: [rationItems[i].code]});
+                }
+            }
+        }
+        return rst;
+    },
+    hideTable: function (tableAll, tablePartial) {
+        if(tableAll){
+            tableAll.hide();
+        }
+        if(tablePartial){
+            tablePartial.hide();
+        }
+    },
+    //建table
+    buildTablePartial: function (table, group) {
+        let me = jobContentOprObj;
+        table.empty();
+        let $thead = $("<thead><tr><th></th><th>编码</th><th>工作内容</th>/tr></thead>");
+        let $tbody = $("<tbody></tbody>");
+        let count = 1;
+        for(let i = 0, len = group.length; i < len; i++){
+            let $newTr = me.getNewTr($tbody, group[i].items, group[i].jobContent);
+            $tbody.append($newTr);
+            count++;
+        }
+        let $trEnd = $("<tr><td>"+ count +"</td><td><a href data-toggle='modal' data-target='#editBianma' class='m-0'>点击勾选编码</a></td><td><textarea class='form-control'></textarea></td></tr>");//勾选行
+        $($trEnd.children().children()[0]).bind('click', function () {
+            me.onclickFuncAdd($(this));
+            me.currentOprTr = $trEnd;
+            me.currentJobContent = $(me.currentOprTr.children()[2]).children().val();
+        });
+        $tbody.append($trEnd);
+        table.append($thead);
+        table.append($tbody);
+    },
+    //新增一行tr
+    getNewTr: function (tbody, codes, jobContent) {
+        let me = jobContentOprObj;
+        let count = tbody.children().length > 0 ? tbody.children().length : 1;
+        let $textTd = $("<td></td>");
+        let $textarea = $("<textarea class='form-control'></textarea>");
+        $textarea.val(jobContent);
+        $textTd.append($textarea);
+        let $tr = $("<tr><td>" + count + "</td><td><a href data-toggle='modal' data-target='#editBianmaQ' class='m-0'>编辑编码</a></td></tr>");
+        $tr.children().children().bind('click', function () {
+            me.currentOprTr = $tr;
+            me.currentJobContent = $(me.currentOprTr.children()[2]).children().val();
+            me.onclickFuncEdit($(this));
+        });
+        //文本变化;
+        $textarea.bind('change', function () {
+            let codes = me.getUpdateCodes($($(this).parent().parent().children()[1]).children());
+            let jobContent = $(this).val();
+            me.updateJobContent(pageOprObj.rationLibId, me.getUpdateArr(codes, jobContent), function () {
+                if(jobContent.trim().length === 0){
+                    me.buildTablePartial(me.tablePartial, me.getGroup(me.currentRationItems));
+                }
+            });
+        });
+        $tr.append($textTd);
+        for(let i = 0, len = codes.length; i < len; i ++){
+            let $p = $("<p class='m-0'>" + codes[i] + "</p>");
+            $tr.children()[1].append($p[0]);
+        }
+        me.setTextareaHeight($textarea, codes.length + 1);
+        return $tr[0];
+    },
+    onclickFuncAdd: function (obj) {
+        let me = jobContentOprObj;
+        let txtarea = $(obj.parent().parent().children().children()[1]);
+        let jobContent = txtarea.val();
+        if(jobContent.trim().length > 0){//工作内容不为空才可添加编码
+            let codesObj = me.getAddCodes(me.currentRationItems);
+            me.buildCheckCodesCon(me.addCon, codesObj.checkedCodes, codesObj.disabledCodes)
+            obj.attr('data-target', '#editBianma');
+        }
+        else{
+            obj.attr('data-target', '');
+            alert("工作内容不能为空!");
+        }
+    },
+    onclickFuncEdit: function (obj) {
+        let me = jobContentOprObj;
+        me.buildEditableCodesCon(me.currentRationItems, me.updateCon, me.getUpdateCodes(obj));
+    },
+    //获取编码td中的编码
+    getUpdateCodes: function (jq) {
+        let rst = [];
+        let nodes = jq.parent().children();
+        for(let i = 1, len = nodes.length; i < len; i++){
+            rst.push(nodes[i].textContent);
+        }
+        return rst;
+    },
+    //建一个编码checkbox Div
+    buildCodeOption: function (code, attr) {
+        let $div = $("<div class='col'><label class='form-check-label'><input class='form-check-input' type='checkbox' value= "+ code +"> "+ code +"</label></div>");
+        let $checkBox = $div.children().children();
+        if(attr){
+            $checkBox.attr(attr, true);
+        }
+        return $div;
+    },
+    //建修改编码弹窗
+    buildEditableCodesCon: function (rationItems, container,codes) {
+        let me = jobContentOprObj;
+        let codeDivs = [];
+        container.empty();
+        for(let i = 0, len = codes.length; i < len; i++){
+            codeDivs.push({code: codes[i], attr: 'checked'});
+        }
+        for(let i = 0, len = rationItems.length; i < len; i++){
+            if(codes.indexOf(rationItems[i].code) === -1){
+                if(typeof rationItems[i].jobContent !== 'undefined' && rationItems[i].jobContent.toString().trim().length > 0){
+                    codeDivs.push({code: rationItems[i].code, attr: 'disabled'});
+                }
+                else{
+                    codeDivs.push({code: rationItems[i].code, attr: ''});
+                }
+            }
+        }
+        //排序
+        codeDivs.sort(function (a, b) {
+            let rst = 0;
+            if(a.code > b.code) rst = 1;
+            else if(a.code < b.code) rst = -1;
+            return rst;
+        });
+        for(let i = 0, len = codeDivs.length; i < len; i++){
+            container.append(me.buildCodeOption(codeDivs[i].code, codeDivs[i].attr));
+        }
+    },
+    //建勾选编码弹窗
+    buildCheckCodesCon: function (container, checkedCodes, disabledCodes) {
+        let me = jobContentOprObj;
+        container.empty();
+        for(let i = 0, len = checkedCodes.length; i < len; i++){
+            let $codeDiv = me.buildCodeOption(checkedCodes[i], 'checked');
+            container.append($codeDiv);
+        }
+        for(let i = 0, len = disabledCodes.length; i < len; i++){
+            let $codeDiv = me.buildCodeOption(disabledCodes[i], 'disabled');
+            container.append($codeDiv);
+        }
+    },
+    getAddCodes: function (rationItems) {
+        let me = jobContentOprObj;
+        let rst = {checkedCodes: [], disabledCodes: []};
+        for(let i = 0, len = rationItems.length; i < len; i++){
+            if(typeof rationItems[i].jobContent !== 'undefined' && rationItems[i].jobContent.toString().trim().length > 0){
+                rst.disabledCodes.push(rationItems[i].code);
+            }
+            else{
+                rst.checkedCodes.push(rationItems[i].code);
+            }
+        }
+        return rst;
+    },
+    //获取选择后的编码窗口的编码及状态
+    getCodesAfterS: function (checkNodes) {
+        let rst = {checked: [], unchecked: []};
+        for(let i = 0, len = checkNodes.length; i < len; i++){
+            if(checkNodes[i].checked){
+                rst.checked.push(checkNodes[i].value);
+            }
+            else if(!checkNodes[i].checked && !checkNodes[i].disabled){
+                rst.unchecked.push(checkNodes[i].value);
+            }
+        }
+        return rst;
+    },
+    setRadiosChecked: function (situation, radios) {
+        let me = jobContentOprObj;
+        if(situation === me.situations.ALL){
+            radios[0].checked = true;
+            radios[1].checked = false;
+            $('#txtareaAll').val(me.currentRationItems.length > 0 ? me.currentRationItems[0].jobContent : '');
+            me.currentJobContent = me.currentRationItems.length > 0 ? me.currentRationItems[0].jobContent : '';
+            me.tableAll.show();
+            me.tablePartial.hide();
+        }
+        else if(situation === me.situations.PARTIAL){
+            radios[0].checked = false;
+            radios[1].checked = true;
+            me.tableAll.hide();
+            me.tablePartial.show();
+        }
+        else if(situation === me.situations.NONE){
+            radios[0].checked = false;
+            radios[1].checked = false;
+            me.tableAll.hide();
+            me.tablePartial.hide();
+        }
+    },
+    //radios是否可用,只有在定额章节树的底层节点才可用
+    setRadiosDisabled: function (val, radios) {
+        let me =jobContentOprObj;
+        if(val){
+            radios[0].checked = false;
+            radios[1].checked = false;
+            me.currentSituation = me.situations.NONE;
+        }
+        radios.attr('disabled', val);
+    },
+    radiosChange: function (radios, tableAll, tablePartial) {
+        let me = jobContentOprObj;
+        radios.change(function () {
+            let val = $("input[name = 'optionsRadios']:checked").val();
+            let selectedNode = sectionTreeObj.tree.selected;
+            me.updateSituation(pageOprObj.rationLibId, selectedNode.getID(), val, function () {
+                selectedNode.data.jobContentSituation = val;
+                me.currentSituation = val;
+                if(val === me.situations.ALL){
+                    let updateCodes = [];
+                    for(let i = 0, len = me.currentRationItems.length; i < len; i++){
+                        updateCodes.push(me.currentRationItems[i].code);
+                    }
+                    me.updateJobContent(pageOprObj.rationLibId, me.getUpdateArr(updateCodes, ''), function () {
+                        me.currentJobContent = '';
+                        $('#txtareaAll').val('');
+                        tableAll.show();
+                        tablePartial.hide();
+                    });
+                }
+                else{
+                    me.buildTablePartial(me.tablePartial, me.getGroup(me.currentRationItems));
+                    tableAll.hide();
+                    tablePartial.show();
+                }
+            });
+        });
+    },
+    setTextareaHeight: function (textarea, nodesCount) {
+        const perHeight = 21.6;
+        textarea.height(nodesCount * 21.6);
+    },
+    bindEvents: function (txtarea) {
+        let me = jobContentOprObj;
+        txtarea.bind('change', function () {
+            let jobContent = txtarea.val();
+            let jqNodes = txtarea.parent().parent().children()[1].children;
+            let updateCodes = me.getUpdateCodes(jqNodes);
+            txtarea.attr('disabled', true);
+            me.updateJobContent(pageOprObj.rationLibId, me.getUpdateArr(updateCodes, jobContent), function () {
+                txtarea.attr('disabled', false);
+            });
+        });
+    },
+    bindAllEvents: function (txtarea) {
+        let me = jobContentOprObj;
+        txtarea.bind('change', function () {
+            let met = this;
+            let jobContent = $(met).val();
+            $(met).attr('disabled', true);
+            let updateCodes = [];
+            for(let i = 0, len = me.currentRationItems.length; i < len; i++){
+                updateCodes.push(me.currentRationItems[i].code);
+                me.currentRationItems[i].jobContent = jobContent;
+            }
+            me.currentJobContent = jobContent;
+            me.updateJobContent(pageOprObj.rationLibId, me.getUpdateArr(updateCodes, jobContent), function () {
+                $(met).attr('disabled', false);
+            });
+        });
+    },
+    unbindEvents: function (txtarea) {
+        txtarea.unbind();
+    },
+    //定额工作内容相关操作
+    rationJobContentOpr: function (rationItems) {
+        let me = jobContentOprObj;
+        me.setRadiosDisabled(me.currentRationItems.length > 0 ? false : true, me.radios);
+        me.setRadiosChecked(me.currentSituation, me.radios);
+        me.buildTablePartial(me.tablePartial, me.getGroup(rationItems));
+    },
+    getUpdateArr: function (updateCodes, jobContent) {
+        let rst = [];
+        for(let i = 0, len = updateCodes.length; i < len; i++){
+            rst.push({code: updateCodes[i], jobContent: jobContent});
+        }
+        return rst;
+    },
+    bindAddConBtn: function () {
+        let me = jobContentOprObj;
+        return function () {
+            let codesObj = me.getCodesAfterS(me.addCon.children().children().children());
+            let $tbody = $('#tablePartial tbody');
+            let lastEle = $tbody[0].lastElementChild;
+            let txtare = lastEle.lastElementChild.children[0];
+            if(me.currentJobContent.trim().length > 0){//工作内容不为空才可添加编码
+                let updateArr = me.getUpdateArr(codesObj.checked, me.currentJobContent);
+                me.updateJobContent(pageOprObj.rationLibId, updateArr, function () {
+                    me.buildTablePartial(me.tablePartial, me.getGroup(me.currentRationItems));
+                    $(txtare).val('');
+                });
+            }
+            else{
+                alert("工作内容不能为空!");
+            }
+        }
+    },
+    bindUpdateConBtn: function () {
+        let me = jobContentOprObj;
+        return function () {
+            let codesObj = me.getCodesAfterS(me.updateCon.children().children().children());
+            let updateC = me.getUpdateArr(codesObj.checked, me.currentJobContent),
+                updateUnC = me.getUpdateArr(codesObj.unchecked, ''),
+                updateArr = updateC.concat(updateUnC);
+            me.updateJobContent(pageOprObj.rationLibId, updateArr, function () {
+                me.buildTablePartial(me.tablePartial, me.getGroup(me.currentRationItems));
+            });
+        }
+    },
+    //更新缓存的定额
+    updateRationItem: function (rationItems, updateArr) {
+        for(let i = 0, len = rationItems.length; i < len; i++){
+            for(let j = 0, jLen = updateArr.length; j < jLen; j++){
+                if(rationItems[i].code === updateArr[j].code){
+                    rationItems[i].jobContent = updateArr[j].jobContent;
+                    break;
+                }
+            }
+        }
+    },
+    updateJobContent: function (repId, updateArr, callback){
+        let me = jobContentOprObj;
+        $.ajax({
+            type: 'post',
+            url: 'api/updateJobContent',
+            data: {lastOpr: userAccount, repId: pageOprObj.rationLibId, updateArr: JSON.stringify(updateArr)},
+            dataType: 'json',
+            success: function (result) {
+                if(!result.error){
+                    me.updateRationItem(jobContentOprObj.currentRationItems, updateArr);
+                    callback();
+                }
+            }
+        });
+    },
+    updateSituation: function (repId, nodeId, situation, callback) {
+        let me = jobContentOprObj;
+        $.ajax({
+            type: 'post',
+            url: 'api/updateSituation',
+            data: {lastOpr: userAccount, repId: pageOprObj.rationLibId, nodeId: nodeId, situation: situation},
+            dataType: 'json',
+            success: function (result) {
+                if(!result.error){
+                    if(callback){
+                        callback();
+                    }
+                }
+            }
+        })
+    }
+};

+ 18 - 4
web/maintain/ration_repository/js/ration.js

@@ -55,6 +55,7 @@ let rationOprObj = {
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
         me.getRationsCodes(rationRepId);
         me.rationDelOpr();
+        me.setCombo(me.workBook.getSheet(0), 'dynamic');
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.LeaveCell, me.onLeaveCell);
@@ -63,6 +64,18 @@ let rationOprObj = {
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.SelectionChanged, me.onSelectionChanged);
     },
+    setCombo: function (sheet, combo) {
+        let me = rationOprObj;
+        sheet.suspendPaint();
+        sheet.suspendEvent();
+        if(combo){
+            combo = sheetCommonObj.getDynamicCombo();
+            combo.items(rationUnits).itemHeight(10).editable(true);
+        }
+        sheet.getRange(-1, me.setting.view.comboBox[0].col, -1, 1).cellType(combo);
+        sheet.resumePaint();
+        sheet.resumeEvent();
+    },
     onSelectionChanged: function (sender, info) {
         if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
             let row = info.newSelections[0].row;
@@ -524,7 +537,7 @@ let rationOprObj = {
                 $.ajax({
                     type:"POST",
                     url:"api/getRationItems",
-                    data:{"sectionID": sectionID},
+                    data:{"rationRepId": pageOprObj.rationLibId, "sectionID": sectionID},
                     dataType:"json",
                     cache:false,
                     timeout:10000,
@@ -559,7 +572,7 @@ let rationOprObj = {
                 sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, cacheSection);
                 //combo
                 //sheetCommonObj.setStaticCombo(me.workBook.getActiveSheet(), 0, 2, cacheSection.length, rationUnits, 10, false);
-                sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, 2, me.workBook.getActiveSheet().getRowCount(), rationUnits, 10, false);
+                //--sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, 2, me.workBook.getActiveSheet().getRowCount(), rationUnits, 10, false);
                 if(me.mixDel === 1){
                     let row = me.workBook.getSheet(0).getSelections()[0].row;
                     if (cacheSection && row < cacheSection.length) {
@@ -581,7 +594,7 @@ let rationOprObj = {
 
             } else {
                 sheetCommonObj.setDynamicCombo(sheetAss, 0, 5, sheetAss.getRowCount(), rationAssistOprObj.setting.comboItems, false, false);
-                sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, 2, me.workBook.getActiveSheet().getRowCount(), rationUnits, 10, false);
+                //--sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, 2, me.workBook.getActiveSheet().getRowCount(), rationUnits, 10, false);
                 //清除ration数据及工料机数据
                 rationGLJOprObj.currentRationItem = null;
                 sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
@@ -589,8 +602,9 @@ let rationOprObj = {
                 sheetCommonObj.cleanSheet(sheetCoe, settingCoe, -1);
                 sheetCommonObj.cleanSheet(sheetAss, settingAss, -1);
             }
-            me.workBook.focus(true);
+           //--- me.workBook.focus(true);
         }
+        sectionTreeObj.workBook.focus(true);
     },
     sortByCode: function(arr){
         function compare(){

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 433 - 1184
web/maintain/ration_repository/js/section_tree.js


+ 6 - 3
web/maintain/std_glj_lib/js/glj.js

@@ -386,7 +386,8 @@ let repositoryGljObj = {
         me.orgCode = me.workBook.getSheet(0).getValue(args.row, 0);
         if(args.row < me.currentCache.length){
             me.currentGlj = me.currentCache[args.row];
-            if(args.col === 0 || (args.col === 4 && me.allowComponent.indexOf(me.currentGlj.gljType) !== -1)
+            if(args.col === 0 || (args.col === 4 && me.allowComponent.indexOf(me.currentGlj.gljType) !== -1
+                && me.currentGlj.component.length > 0)
                 || (args.col === 6 && me.currentGlj.gljType !== 1 && me.currentGlj.gljType !== 303)){
                 args.cancel = true;
             }
@@ -864,7 +865,8 @@ let repositoryGljObj = {
                     resumeArr.push(info.cellRange.row + i);
                 }
             }
-            if(info.cellRange.colCount === me.setting.header.length){
+            //if(info.cellRange.colCount === me.setting.header.length){
+            if(info.cellRange.colCount >= me.setting.header.length - 1 && info.cellRange.colCount <= me.setting.header.length){
                 for(let i = updateCount ; i < items.length; i++){
                     if(me.isValidObj(items[i])){
                         items[i].component = [];
@@ -886,7 +888,8 @@ let repositoryGljObj = {
             }
         }
         else{
-            if(info.cellRange.colCount === me.setting.header.length && info.cellRange.col + info.cellRange.colCount - 1 >= 5){
+            //if(info.cellRange.colCount === me.setting.header.length && info.cellRange.col + info.cellRange.colCount - 1 >= 5){
+            if(info.cellRange.colCount >= me.setting.header.length - 1 && info.cellRange.colCount <= me.setting.header.length && info.cellRange.col + info.cellRange.colCount - 1 >= 5){
                 for(let i = 0; i < items.length; i++){
                     if(me.isValidObj(items[i])){
                         items[i].component = [];

+ 7 - 0
web/users/js/main_tree_col.js

@@ -14,6 +14,13 @@ let MainTreeCol = {
             } else if (node.sourceType === projectObj.project.ration_glj.getSourceType()) {
                 return '主';
             }
+        },
+        quantity:function (node) {
+            if(node.sourceType === projectObj.project.ration_glj.getSourceType()){
+                return gljOprObj.getTotalQuantity(node.data);
+            }else {
+                return node.data["quantity"];
+            }
         }
     },
     readOnly: {