Browse Source

导入ybp相关

MaiXinRong 6 months ago
parent
commit
7c88ca2b7b
3 changed files with 13 additions and 10 deletions
  1. 5 5
      app/lib/ybp_tree.js
  2. 6 3
      app/public/js/shares/dsk.js
  3. 2 2
      app/service/ledger.js

+ 5 - 5
app/lib/ybp_tree.js

@@ -37,7 +37,7 @@ class YbpTree {
 
     sortChildren(children, recursive) {
         const setting = this.setting;
-        children.sort((x, y) => { return x[setting.order] > y[setting.order]; });
+        children.sort((x, y) => { return x[setting.order] - y[setting.order]; });
 
         if (!recursive) return;
         for (const c of children) {
@@ -224,8 +224,8 @@ class YbpImportTree {
         }
     }
 
-    sortChildren(children, recursive) {
-        children.sort((x, y) => {
+    sortChildren(children, recursive, resort) {
+        resort && children.sort((x, y) => {
             return x.kind === YbpNodeKind.bill
                 ? (x.b_code ? (y.b_code ? x.b_code.localeCompare(y.b_code) : 1) : -1)
                 : (x.code ? (y.code ? x.code.localeCompare(y.code) : -1) : 1);
@@ -249,8 +249,8 @@ class YbpImportTree {
             _loadNode(child);
         }
     }
-    sort() {
-        this.sortChildren(this.children, true);
+    sort(sortChildren) {
+        this.sortChildren(this.children, true, sortChildren);
         this.generateSortNodes();
     }
     _mapTreeNode() {

+ 6 - 3
app/public/js/shares/dsk.js

@@ -4,8 +4,8 @@ const dsk = (function () {
     const projectType = [
         { key: 'folder', value: 1, name: '文件夹' },
         { key: 'project', value: 2, name: '建设项目' },
-        { key: 'unit', value: 3, name: '单位工程' },
-        { key: 'item', value: 4, name: '单项工程' },
+        { key: 'item', value: 3, name: '单项工程' },
+        { key: 'unit', value: 4, name: '单位工程' },
     ];
     const projectTypeKey = (function(arr) {
         const result = {};
@@ -167,6 +167,8 @@ const dsk = (function () {
                     })
                 }
                 if (data.type === projectTypeKey.project) {
+                    const top = data.subjects.find(x => { return x.ID === data.ID; });
+                    top.parentID = "-1";
                     projectTree.loadDatas(data.subjects);
                     cur.project_id = data.ID;
                     projectTree.children.forEach(c => {
@@ -187,6 +189,7 @@ const dsk = (function () {
             if (!compilation.subjectTree) {
                 for (const p of compilation.project) {
                     if (p.type === projectTypeKey.project) p.subjects = await loadProjectTree(compilation.ID, p.ID, false);
+                    console.log(p.subjects);
                 }
                 this.analysisSubjectTree(compilation);
             }
@@ -197,7 +200,7 @@ const dsk = (function () {
             const tree = this.subjectSheet.zh_tree;
             if (!tree) return [];
 
-            return tree.datas.filter(x => { return x.type === projectTypeKey.item && x.selected; }).map(x => { return { compilationId: x.compilation_id, subjectId: x.dsk_id }; });
+            return tree.datas.filter(x => { return x.type === projectTypeKey.unit && x.selected; }).map(x => { return { compilationId: x.compilation_id, subjectId: x.dsk_id }; });
         },
         csButtonClicked: function(e, info) {
             if (!info.sheet.zh_setting) return;

+ 2 - 2
app/service/ledger.js

@@ -752,7 +752,7 @@ module.exports = app => {
                 };
                 gatherTree.importTree(ybpTree, subject.project.name, loadRelaFun);
             }
-            gatherTree.sort();
+            gatherTree.sort(false);
             gatherTree.calculateAll();
 
             const bills = [], glj = [];
@@ -813,7 +813,7 @@ module.exports = app => {
             const ybpAnalysis = new YBP(this.ctx);
             const ybpData = ybpAnalysis.decryptBuffer(ybp);
 
-            await this.importYbpData(tender, ybpData);
+            return await this.importYbpData(tender, ybpData);
         }
 
         async sumLoad(lid, tenders) {