Bläddra i källkod

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

Conflicts:
	web/building_saas/main/js/views/project_view.js
zhangweicheng 7 år sedan
förälder
incheckning
6c911709b4

+ 4 - 0
config/gulpConfig.js

@@ -133,7 +133,11 @@ module.exports = {
         'public/web/common_ajax.js',
         'public/web/treeDataHelper.js',
         'public/web/QueryParam.js',
+        'public/web/id_tree.js',
+        'public/web/tree_sheet/tree_sheet_controller.js',
+        'public/web/tree_sheet/tree_sheet_helper.js',
         'web/building_saas/complementary_glj_lib/js/glj.js',
+        'web/building_saas/complementary_glj_lib/js/gljClassTree.js',
         'web/building_saas/complementary_glj_lib/js/gljComponent.js',
         'web/building_saas/complementary_glj_lib/js/components.js',
         'public/web/ztree_common.js',

+ 25 - 23
public/web/tree_sheet/tree_sheet_helper.js

@@ -47,29 +47,31 @@ var TREE_SHEET_HELPER = {
         return style;
     },
     loadSheetHeader: function (setting, sheet) {
-        if (setting.frozenCols) {
-            sheet.frozenColumnCount(setting.frozenCols);
-        }
-        sheet.setColumnCount(setting.cols.length);
-        sheet.setRowCount(setting.headRows, GC.Spread.Sheets.SheetArea.colHeader);
-        setting.headRowHeight.forEach(function (rowHeight, index) {
-            sheet.setRowHeight(index, rowHeight, GC.Spread.Sheets.SheetArea.colHeader);
-        });
-        setting.cols.forEach(function (col, index) {
-            var i, iRow = 0, cell;
-            for (i = 0; i < col.head.spanCols.length; i++) {
-                if (col.head.spanCols[i] !== 0) {
-                    cell = sheet.getCell(iRow, index, GC.Spread.Sheets.SheetArea.colHeader);
-                    cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]).wordWrap(true);
-                }
-                if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
-                    sheet.addSpan(iRow, index, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.colHeader);
-                }
-                iRow += col.head.spanRows[i];
-            };
-            sheet.setColumnWidth(index, col.width);
-            sheet.setColumnVisible(index, col.visible && true);
-        });
+        this.massOperationSheet(sheet, function () {
+            if (setting.frozenCols) {
+                sheet.frozenColumnCount(setting.frozenCols);
+            }
+            sheet.setColumnCount(setting.cols.length);
+            sheet.setRowCount(setting.headRows, GC.Spread.Sheets.SheetArea.colHeader);
+            setting.headRowHeight.forEach(function (rowHeight, index) {
+                sheet.setRowHeight(index, rowHeight, GC.Spread.Sheets.SheetArea.colHeader);
+            });
+            setting.cols.forEach(function (col, index) {
+                var i, iRow = 0, cell;
+                for (i = 0; i < col.head.spanCols.length; i++) {
+                    if (col.head.spanCols[i] !== 0) {
+                        cell = sheet.getCell(iRow, index, GC.Spread.Sheets.SheetArea.colHeader);
+                        cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]).wordWrap(true);
+                    }
+                    if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
+                        sheet.addSpan(iRow, index, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.colHeader);
+                    }
+                    iRow += col.head.spanRows[i];
+                };
+                sheet.setColumnWidth(index, col.width);
+                sheet.setColumnVisible(index, col.visible && true);
+            });
+        });      
     },
     protectdSheet: function (sheet) {
         var option = {

+ 15 - 11
web/building_saas/complementary_glj_lib/html/tools-gongliaoji.html

@@ -64,20 +64,20 @@
         </div>
         <div class="content">
             <div class="container-fluid">
-              <div class="row">
-                <div class="col-lg-2 p-0">
-                  <div class="print-list">
-                    <div class="form-list">
-                      <ul id="repositoryTree" class="ztree"></ul>
+                <div class="row">
+                    <div class="col-lg-2 p-0">
+                        <div class="print-list">
+                            <div class="form-list">
+                                <div id="gljClassSpread" style="height: 100%; width: 100%;"></div>
+                            </div>
+                        </div>
                     </div>
-                  </div>
-                </div>
-                <div id="GLJListSheet" class="col-lg-7 p-0">
+                    <div id="GLJListSheet" class="col-lg-7 p-0">
 
+                    </div>
+                    <div id="gljComponentSheet" class="col-lg-3 p-0">
+                    </div>
                 </div>
-                <div id="gljComponentSheet" class="col-lg-3 p-0">
-                </div>
-              </div>
             </div>
         </div>
       </div>
@@ -194,7 +194,11 @@
     <script type="text/javascript" src="/public/web/common_ajax.js"></script>
     <script type="text/javascript" src="/public/web/treeDataHelper.js"></script>
     <script type="text/javascript" src="/public/web/QueryParam.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 type="text/javascript" src="/public/web/tree_sheet/tree_sheet_helper.js"></script>
     <script type="text/javascript" src="/web/building_saas/complementary_glj_lib/js/glj.js"></script>
+    <script type="text/javascript" src="/web/building_saas/complementary_glj_lib/js/gljClassTree.js"></script>
     <script type="text/javascript" src="/web/building_saas/complementary_glj_lib/js/gljComponent.js"></script>
     <script type="text/javascript" src="/web/building_saas/complementary_glj_lib/js/components.js"></script>
     <script type="text/javascript" src="/public/web/ztree_common.js"></script>

+ 29 - 4
web/building_saas/complementary_glj_lib/js/glj.js

@@ -18,8 +18,11 @@ let pageOprObj = {
         //repositoryGljObj.getRationGljIds(gljLibId);
         repositoryGljObj.getGljDistType(function () {
             repositoryGljObj.currentRepositoryId = me.stdGljLibId;
-            repositoryGljObj.getGljTree(stdGljLibId, function () {
+           /* repositoryGljObj.getGljTree(stdGljLibId, function () {
                 repositoryGljObj.getGljItems(me.stdGljLibId, me.userId, me.compilationId);
+            });*/
+            repositoryGljObj.getGljItems(me.stdGljLibId, me.userId, me.compilationId, function () {
+                gljClassTreeObj.getGljClassTree(stdGljLibId);
             });
         });
     }
@@ -116,7 +119,7 @@ let repositoryGljObj = {
             }
         });
     },
-    getGljItems: function(stdGljLibId, userId, compilationId) {
+    getGljItems: function(stdGljLibId, userId, compilationId, callback) {
         let me = this;
         CommonAjax.post('complementartGlj/api/getGljItems', {stdGljLibId: stdGljLibId, userId: userId, compilationId: compilationId}, function (rstData) {
             me.stdGljList = rstData.stdGljs;
@@ -125,12 +128,15 @@ let repositoryGljObj = {
             me.sortGlj(me.stdGljList);
             me.setProp('isStd', true, me.stdGljList);
             me.sortGlj(me.complementaryGljList);
-            let rootNode = me.treeObj.getNodes()[0];
+            if(callback){
+                callback();
+            }
+         /*   let rootNode = me.treeObj.getNodes()[0];
             if(rootNode && rootNode.isParent && rootNode.isFirstNode){
                 componentOprObj.rootNode = rootNode;
                 me.treeObj.selectNode(rootNode);
                 gljTypeTreeOprObj.onClick(null, 'repositoryTree', rootNode);
-            }
+            }*/
         });
     },
     showGljItems: function(data, type) {
@@ -1048,6 +1054,25 @@ let repositoryGljObj = {
         }
         //allgljs
     },
+    updateParentNodeIds: function (nodes, caller) {
+        let private_build_parentNodeIds = function(pNodeId, nodesArr){
+            let rst = [];
+            for (let i = 0; i < nodesArr.length; i++) {
+                if (nodesArr[i].children.length > 0) {
+                    rst = rst.concat(private_build_parentNodeIds(nodesArr[i].data.ID, nodesArr[i].children));
+                } else {
+                    rst.push(nodesArr[i].data.ID);
+                }
+            }
+            if (pNodeId && rst.length > 0) {
+                caller.parentNodeIds["_pNodeId_" + pNodeId] = rst;
+            }
+            return rst;
+        };
+        if (caller.parentNodeIds) {
+            private_build_parentNodeIds(null, nodes);
+        }
+    },
     setProp: function (prop, value, gljList) {
         let me = this;
         for(let i = 0, len = gljList.length; i < len; i++){

+ 180 - 0
web/building_saas/complementary_glj_lib/js/gljClassTree.js

@@ -0,0 +1,180 @@
+/**
+ * Created by Zhong on 2018/1/16.
+ */
+let gljClassTreeObj = {
+    cache: null,//ref to tree.items
+    tree: null,
+    controller: null,
+    workBook: null,
+    sheet: null,
+    setting: {
+        sheet: {
+            cols:[
+                {
+                    head: {
+                        titleNames: ['名称'],
+                        spanCols: [1],
+                        spanRows: [2],
+                        vAlign: [1, 1],
+                        hAlign: [1, 1],
+                        font: 'Arial'
+                    },
+                    data: {
+                        field: 'Name',
+                        vAlign: 1,
+                        hAlign: 0,
+                        font: 'Arial'
+                    },
+                    width: 400
+                }
+            ],
+            headRows: 1,
+            headRowHeight: [47],
+            emptyRows: 0,
+            treeCol: 0
+        },
+        tree: {
+            id: 'ID',
+            pid: 'ParentID',
+            nid: 'NextSiblingID',
+            rootId: -1
+        },
+        options: {
+            tabStripVisible:  false,
+            allowCopyPasteExcelStyle : false,
+            allowExtendPasteRange: false,
+            allowUserDragDrop : false,
+            allowUserDragFill: false,
+            scrollbarMaxAlign : true
+        }
+    },
+
+    isDef: function (v) {
+        return v !== undefined && v !== null;
+    },
+    isFunc: function (v) {
+        return this.isDef(v) && typeof v === 'function';
+    },
+    //sheet things
+    setOptions: function (workbook, opts) {
+        for(let opt in opts){
+            workbook.options[opt] = opts[opt];
+        }
+    },
+
+    renderFunc: function (sheet, func) {
+        sheet.suspendPaint();
+        sheet.suspendEvent();
+        if(this.isFunc(func)){
+            func();
+        }
+        sheet.resumePaint();
+        sheet.resumeEvent();
+    },
+
+    buildSheet: function () {
+        if(!this.isDef(this.workBook)){
+            this.workBook = new GC.Spread.Sheets.Workbook($('#gljClassSpread')[0], {sheetCount: 1});
+            this.sheet = this.workBook.getActiveSheet();
+            this.setOptions(this.workBook, this.setting.options);
+            this.sheet.options.clipBoardOptions = GC.Spread.Sheets.ClipboardPasteOptions.values;
+            this.bindEvents(this.sheet);
+        }
+    },
+
+    bindEvents: function (sheet) {
+        let me = gljClassTreeObj;
+        const Events = GC.Spread.Sheets.Events;
+        sheet.bind(Events.SelectionChanging, me.onSelectionChanged);
+        sheet.bind(Events.EditStarting, me.onEditStarting);
+        sheet.bind(Events.ClipboardPasting, me.onClipboardPasting);
+    },
+
+    onSelectionChanged: function (sender, info) {
+        let me = gljClassTreeObj;
+        if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
+            let row = info.newSelections[0].row;
+            let node = me.cache[row];
+            me.initSelection(node);
+        }
+    },
+
+    onEditStarting: function (sender, args) {
+        args.cancel = true;
+    },
+
+    onClipboardPasting: function (sender, info) {
+        info.cancel = true;
+    },
+
+    getGljClassTree: function (gljLibId, callback) {
+        let me = gljClassTreeObj;
+        let re = repositoryGljObj;
+        let url = 'complementartGlj/api/getGljTree';
+        let postData = {gljLibId: gljLibId};
+        let sucFunc = function (rstData) {
+            zTreeHelper.createTree(rstData, componentSetting, "componentTree", componentOprObj);
+            let rootNode = componentOprObj.treeObj.getNodes()[0];
+            if(rootNode && rootNode.isParent && rootNode.isFirstNode){
+                componentOprObj.rootNode = rootNode;
+            }
+            if (rstData && rstData.length > 0) {
+                me.gljCurTypeId = rstData[0].ID;
+            }
+            //init
+            me.buildSheet();
+            me.initTree(rstData);
+            me.cache = me.tree.items;
+            re.updateParentNodeIds(me.cache, re);
+            me.initController(me.tree, me.sheet, me.setting.sheet);
+            me.controller.showTreeData();
+            me.sheet.setFormatter(-1, 0, '@');
+            me.initSelection(me.tree.selected);
+            if(callback){
+                callback();
+            }
+        };
+        let errFunc = function () {
+
+        };
+        CommonAjax.post(url, postData, sucFunc, errFunc);
+    },
+
+    initTree: function (datas) {
+        this.tree = idTree.createNew(this.setting.tree);
+        this.tree.loadDatas(datas);
+        this.tree.selected = this.tree.items.length > 0 ? this.tree.items[0] : null;
+    },
+
+    initController: function (tree, sheet, setting) {
+        this.controller = TREE_SHEET_CONTROLLER.createNew(tree, sheet, setting);
+    },
+
+    gljClassTreeAjax: function (postData, scFunc, errFunc) {
+        CommonAjax.post('api/updateNodes', {updateData: postData, lastOpr: userAccount}, scFunc, errFunc);
+    },
+    //模仿默认点击
+    initSelection: function (node) {
+        let me = this,
+            re = repositoryGljObj,
+            that = gljComponentOprObj;
+        if(!re.isDef(node)){
+            return;
+        }
+
+        let gljTypeId = node.data.ID;
+        re.gljCurTypeId = node.data.ID;
+        re.addGljObj = null;
+        sheetOpr.cleanSheet(that.workBook.getSheet(0), that.setting, 5);
+        if (re.parentNodeIds["_pNodeId_" + gljTypeId]) {
+            re.currentOprParent = 1;
+            re.currentCache = re.getParentCache(re.parentNodeIds["_pNodeId_" + gljTypeId]);
+            re.workBook.getSheet(0).setRowCount(re.currentCache.length);
+        } else {
+            re.currentOprParent = 0;
+            re.currentCache = re.getCache();
+        }
+        re.showGljItems(re.complementaryGljList, gljTypeId);
+        me.workBook.focus(true);
+    }
+}

+ 5 - 2
web/building_saas/main/js/models/ration_glj.js

@@ -118,8 +118,11 @@ var ration_glj = {
                 gljOprObj.showRationGLJSheetData(true);
                 //add to mainTree;
                 me.addToMainTree(neRecodes);
-                let node = project.mainTree.selected;
-                project.calcProgram.calcAndSave(node);
+                let rationID = neRecodes[0].rationID;
+                let node = project.mainTree.nodes['id_' + rationID];
+                if(isDef(node)){
+                    project.calcProgram.calcAndSave(node);
+                }
                 if (activeSubSheetIs(subSheetIndex.ssiCalcProgram)) {
                     calcProgramObj.showData(node, false);
                 }

+ 21 - 0
web/building_saas/main/js/views/character_content_view.js

@@ -293,6 +293,7 @@ let characterOprObj = {
         sheet.bind(EVENTS.EditStarting, me.onEditStart);
         sheet.bind(EVENTS.ClipboardPasting, me.onClipboardPasting);
         sheet.bind(EVENTS.ClipboardPasted, me.onClipboardPasted);
+        workBook.bind(EVENTS.RangeChanged, me.onRangeChanged);
     },
     //将从清单库中添加的清单,把标准清单的项目特征转化成清单的项目特征
     buildItemCharactet: function (items) {//从清单库过来的默认不输出
@@ -562,6 +563,24 @@ let characterOprObj = {
         }
         me.save();
     },
+    onRangeChanged: function (sender, args) {
+        let me = characterOprObj;
+        let rangeCell = isDef(args.changedCells[0]) ? args.changedCells[0] : null;
+        if(!rangeCell){
+            return;
+        }
+        let rangeData = isDef(me.currentCache[rangeCell.row]) ? me.currentCache[rangeCell.row] : null;
+        if(!rangeData){
+            return;
+        }
+        if(rangeCell.col === 1){//特征值
+            rangeData.isChecked = false;
+            for(let value of rangeData.eigenvalue){
+                value.isSelected = false;
+            }
+        }
+        me.save();
+    },
     //复选框控制输出
     onButtonClicked: function (sender, args) {
         let me = characterOprObj, characterTxt;
@@ -833,6 +852,8 @@ let pageCCOprObj = {
             saveObj.push({field: index, value: updateData[index]});
         }
         saveObj.push({field: 'addRule', value: setting});
+        saveObj.push({field: 'jobContent', value: node.data.jobContent});
+        saveObj.push({field: 'itemCharacter', value: node.data.itemCharacter});
         // 更新到数据库
         pageCCOprObj.updateBill(findSet, saveObj, function(response) {
             self.refreshView(node, updateData);

+ 1 - 1
web/building_saas/main/js/views/glj_view.js

@@ -171,7 +171,7 @@ var gljOprObj = {
             onClick: function (event, treeId, treeNode) {
                 if (treeId == 'gljTree') {
                     let me = gljOprObj, gljTypeId = treeNode.ID;
-                    if (me.gljCurTypeId !== treeNode.ID) {
+                    if (treeNode.ID) {
                         me.gljCurTypeId = treeNode.ID;
                         me.filterLibGLJSheetData();
                         me.showLibGLJSheetData();

+ 0 - 3
web/building_saas/main/js/views/project_view.js

@@ -252,8 +252,6 @@ var projectObj = {
         }
     },
     updateCellValue: function (node, value, colSetting) {
-        console.log(`node`);
-        console.log(node);
         let project = projectObj.project, fieldName = colSetting.data.field;
         if(node.sourceType==project.ration_glj.getSourceType()){
             project.ration_glj.updateFromMainSpread(value,node,fieldName);
@@ -1116,7 +1114,6 @@ function isSingleSelect() {//是否选中造价书中的单行
     }
     return false;
 }
-
 function ifCanDelete() {
     let selections = projectObj.mainSpread.getActiveSheet().getSelections();
     let tree = projectObj.project.mainTree;

+ 8 - 0
web/building_saas/main/js/views/std_ration_lib.js

@@ -287,11 +287,19 @@ $('#rationSearch').click(function () {
         resultSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, rationLibObj.onRationSpreadCellDoubleClick);
     };
     CommonAjax.post('/complementaryRation/api/findRation', {'user_id': userID, 'rationRepId': rationLibID, 'keyword': keyword}, function (result) {
+        //sort
+        result.sort(function (a, b) {
+            let rst = 0;
+            if(a.code > b.code) rst = 1;
+            else if(a.code < b.code) rst = -1;
+            return rst;
+        });
         var resultObj = $('#rationSearchResult'), resultSpread = null;
         resultObj.empty();
         resultObj.append(getResultHtml(result));
         $('a', resultObj).click(function () {
             resultObj.hide();
+            $(".main-data-side-d").height($(window).height() - $(".header").height() - $(".toolsbar").height() -  $(".tools-bar-height-d").height() - 202);
             $(".main-data-side-search", resultObj).height(0);
         });
         resultObj.show();

+ 1 - 0
web/building_saas/main/js/views/sub_view.js

@@ -82,6 +82,7 @@ $("#linkGCLMX").click(function(){
 });
 
 $("#linkJSCX").click(function(){        // 计算程序
+    $.contextMenu( 'destroy', "#subSpread" );
     $("#subItems").children().hide();
     $("#subSpread").show();
     pageCCOprObj.active = false;

+ 6 - 10
web/building_saas/pm/js/pm_main.js

@@ -225,7 +225,6 @@ $(document).ready(function() {
                 updateObj.updateData.ID = fileDelObj.id;
             }
             updateObj.fileType = fileDelObj.fileType;
-            console.log(updateObj);
             a_updateFiles([updateObj], function () {
                 fileDelObj = null;
                 $('#fileDelCancel').click();
@@ -366,7 +365,7 @@ $(document).ready(function() {
         //获取建设项目
         let selected = Tree.selected();
         let projs = getProjs(selected);
-        setProjOptions(projs);
+        setProjOptions(projs, selected);
        $($("input[name='valuation_type']")[0]).click();
     });
 
@@ -432,7 +431,6 @@ $(document).ready(function() {
         let dialog = $('#del');
         if (Tree) {
             updateData = GetDeleteUpdateData(Tree.selected());
-            console.log(updateData);
             UpdateProjectData(updateData, function () {
                 dialog.modal('hide');
                 Tree.removeNode(Tree.selected());
@@ -487,7 +485,6 @@ $(document).ready(function() {
 
     // 移动到操作
     $('#move-to-confirm').click(function () {
-        console.log(111);
         let updateData = null;
         let dialog = $('#move-to-dialog');
         let target = GetTargetTreeNode($.fn.zTree.getZTreeObj('treeDemo'));
@@ -909,7 +906,6 @@ function AddSiblingsItem(selected, name, property, type, callback) {
                 datas.forEach(function (data) {
                     if (data.updateType === 'new') {
                         Tree.addNodeData(data.updateData, parent, next);
-                        console.log(selected);
                     }
                 });
                 callback();
@@ -1031,13 +1027,14 @@ function setFileOptions(projID){
 }
 
 //建设项目下拉框
-function setProjOptions(projs){
+function setProjOptions(projs, selected){
     $("#poj-name-list").empty();
     $("#poj-name").val("");
     if(projs.length > 0){
-        $("#poj-name").val(projs[0].data.name);
-        setFileOptions(projs[0].data.ID);
-        setEngOptions(projs[0].data.ID);
+        let firstProj = selected.data.projType === projectType.project ? selected: projs[0];
+        $("#poj-name").val(firstProj.data.name);
+        setFileOptions(firstProj.data.ID);
+        setEngOptions(firstProj.data.ID);
         for(let i = 0, len = projs.length; i < len; i++){
             let proj = $("<button>").val(projs[i].data.ID).text(projs[i].data.name);
             proj.addClass("dropdown-item");
@@ -1845,7 +1842,6 @@ function bindEvents_file_table(jqS, usedObj, targetBody, type){
                     $(jqS + ' div:eq(0)').show();
                     $(jqS + ' div:eq(1)').hide();
                 });
-                console.log(updateObj);
             }
             let newDispName = newName + postFix;
             $(jqS + ' div:eq(0)')[0].childNodes[0].textContent = newDispName;