Browse Source

所有选择标段,根据分类值排序显示

MaiXinRong 4 years ago
parent
commit
8c67cd0e75
2 changed files with 9 additions and 16 deletions
  1. 7 15
      app/public/js/path_tree.js
  2. 2 1
      app/public/js/shares/tenders2tree.js

+ 7 - 15
app/public/js/path_tree.js

@@ -307,9 +307,7 @@ const createNewPathTree = function (type, setting) {
                     if (!isResort) {
                         nodes[i].children = self.getChildren(nodes[i]);
                     } else {
-                        nodes[i].children.sort(function (a, b) {
-                            return a.order - b.order;
-                        })
+                        nodes[i].children.sort((a, b) => { return a[self.setting.order] - b[self.setting.order]; })
                     }
                     addSortNodes(nodes[i].children);
                 }
@@ -318,9 +316,7 @@ const createNewPathTree = function (type, setting) {
             if (!isResort) {
                 this.children = this.getChildren();
             } else {
-                this.children.sort(function (a, b) {
-                    return a.order - b.order;
-                })
+                this.children.sort((a, b) => { return a[self.setting.order] - b[self.setting.order]; });
             }
             addSortNodes(this.children);
         }
@@ -329,7 +325,7 @@ const createNewPathTree = function (type, setting) {
          * @param datas
          */
         loadDatas(datas) {
-            self = this;
+            const self = this;
             // 清空旧数据
             this.items = {};
             this.nodes = [];
@@ -358,9 +354,7 @@ const createNewPathTree = function (type, setting) {
                     }
                 }
             }
-            this.children.sort(function (a, b) {
-                return a.order - b.order;
-            });
+            this.children.sort((a, b) => { return a[self.setting.order] - b[self.setting.order]; });
             this.sortTreeNode(true);
             if (this.hasMark) {
                 if (this.setting.markExpandKey) {
@@ -477,9 +471,7 @@ const createNewPathTree = function (type, setting) {
             const children = this.datas.filter(function (x) {
                 return x[setting.pid] === pid;
             });
-            children.sort(function (a, b) {
-                return a.order - b.order;
-            });
+            children.sort((a, b) => { return a[setting.order] - b[setting.order]; });
             return children;
         };
 
@@ -524,7 +516,7 @@ const createNewPathTree = function (type, setting) {
          */
         isLastSibling(node) {
             const siblings = this.getChildren(this.getParent(node));
-            return (siblings && siblings.length > 0) ? node.order === siblings[siblings.length - 1].order : false;
+            return (siblings && siblings.length > 0) ? node[this.setting.order] === siblings[siblings.length - 1][this.setting.order] : false;
         };
 
         /**
@@ -1546,7 +1538,7 @@ const createNewPathTree = function (type, setting) {
                     return fun(a[field], b[field]);
                 });
                 for (const [i, node] of nodes.entries()) {
-                    node.order = i + 1;
+                    node[self.setting.order] = i + 1;
                 }
             };
             const addSortNodes = function (nodes) {

+ 2 - 1
app/public/js/shares/tenders2tree.js

@@ -48,6 +48,7 @@ const Tender2Tree = (function () {
                 vid: value,
                 name: cateValue.value,
             }, parent);
+            if (cateValue.sort) cate.sort = cateValue.sort;
         }
         return cate;
     }
@@ -92,7 +93,7 @@ const Tender2Tree = (function () {
             }
             tenderTree.addNode(node, parent);
         }
-        tenderTree.sortTreeNode(false);
+        tenderTree.sortTreeNode(true);
         return tenderTree;
     }
     return { convert }