zhongzewei 7 роки тому
батько
коміт
dcd207087d

+ 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',

+ 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);
+    }
+}

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

@@ -299,6 +299,7 @@ $('#rationSearch').click(function () {
         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();