gcs-ui-lib 1.2.35 → 1.2.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gcs-ui-lib",
3
- "version": "1.2.35",
3
+ "version": "1.2.37",
4
4
  "private": false,
5
5
  "main": "./lib/gcs-ui-lib.common.js",
6
6
  "scripts": {
@@ -19,8 +19,9 @@
19
19
  </template>
20
20
 
21
21
  <script>
22
- import { getCashflow, getPaymentCategory, getRecUnit } from "@/api/common";
23
- import { SelectTree } from "n20-common-lib";
22
+ import {getCashflow, getPaymentCategory, getRecUnit} from "@/api/common";
23
+ import {SelectTree} from "n20-common-lib";
24
+
24
25
  export default {
25
26
  props: {
26
27
  value: {
@@ -197,10 +198,34 @@ export default {
197
198
  }
198
199
  let res = await this.Api(params);
199
200
  res = this.tranData(res);
200
- this.type == "cashflow" && this.handleData(res);
201
- this.treeData = res;
201
+ if (this.type === "paymentCategory"){
202
+ const res1 = await getPaymentCategory({ ...params, direction: "2" })
203
+ this.treeData = this.mergeTree(res, res1);
204
+ } else {
205
+ this.type == "cashflow" && this.handleData(res);
206
+ this.treeData = res;
207
+ }
202
208
  },
203
209
 
210
+ // 递归合并两棵款项类别树(按paymentCategoryNo去重)
211
+ mergeTree(arr1, arr2) {
212
+ const map = new Map();
213
+ arr1?.forEach((item) => {
214
+ map.set(item.paymentCategoryNo, item);
215
+ });
216
+ arr2?.forEach((item) => {
217
+ if (map.has(item.paymentCategoryNo)) {
218
+ const existing = map.get(item.paymentCategoryNo);
219
+ existing.children = this.mergeTree(
220
+ existing.children,
221
+ item.children
222
+ );
223
+ } else {
224
+ map.set(item.paymentCategoryNo, item);
225
+ }
226
+ });
227
+ return Array.from(map.values());
228
+ },
204
229
  tranData(res) {
205
230
  const eachItem = (parent, list) => {
206
231
  list.forEach((item) => {
@@ -14,6 +14,7 @@
14
14
  >
15
15
  <div
16
16
  slot-scope="{ node, data }"
17
+ :class="data.disabled ? 'nstc-tree-disabled' : ''"
17
18
  class="flex-box flex-lr flex-v w-100p cl-tree-item"
18
19
  @mouseenter="mouseenterTree(node, data)"
19
20
  @mouseleave="checkFlag = false"
@@ -626,10 +626,14 @@ export default {
626
626
  // } else {
627
627
  this.getTreeData("1", { resolve, expandFlag: true });
628
628
  // }
629
- }).then((data) => {
630
- if (data) {
631
- //默认展开节点
632
- this.defaultExpandedKeys = [data.id];
629
+ }).then(() => {
630
+ if (this.searchKey) {
631
+ //搜索时展开所有有子节点的父级路径
632
+ let expandKeys = [];
633
+ this.collectExpandKeys(this.data, expandKeys);
634
+ this.defaultExpandedKeys = expandKeys;
635
+ } else {
636
+ this.defaultExpandedKeys = [];
633
637
  }
634
638
  });
635
639
  }
@@ -1135,6 +1139,15 @@ export default {
1135
1139
  }
1136
1140
  });
1137
1141
  },
1142
+ collectExpandKeys(arr, keys) {
1143
+ if (!arr) return;
1144
+ arr.forEach((a) => {
1145
+ if (a.children && Array.isArray(a.children) && a.children.length > 0) {
1146
+ keys.push(a.id);
1147
+ this.collectExpandKeys(a.children, keys);
1148
+ }
1149
+ });
1150
+ },
1138
1151
  },
1139
1152
  };
1140
1153
  </script>
@@ -613,10 +613,14 @@ export default {
613
613
  } else {
614
614
  this.getTreeData("1", { resolve, expandFlag: true });
615
615
  }
616
- }).then((data) => {
617
- if (data) {
618
- //默认展开节点
619
- this.defaultExpandedKeys = [data.id];
616
+ }).then(() => {
617
+ if (this.searchKey) {
618
+ //搜索时展开所有有子节点的父级路径
619
+ let expandKeys = [];
620
+ this.collectExpandKeys(this.data, expandKeys);
621
+ this.defaultExpandedKeys = expandKeys;
622
+ } else {
623
+ this.defaultExpandedKeys = [];
620
624
  }
621
625
  });
622
626
  }
@@ -907,6 +911,15 @@ export default {
907
911
  }
908
912
  });
909
913
  },
914
+ collectExpandKeys(arr, keys) {
915
+ if (!arr) return;
916
+ arr.forEach((a) => {
917
+ if (a.children && Array.isArray(a.children) && a.children.length > 0) {
918
+ keys.push(a.id);
919
+ this.collectExpandKeys(a.children, keys);
920
+ }
921
+ });
922
+ },
910
923
  nodeClick(data) {
911
924
  this.$refs.tree.showDropMenu = null;
912
925
  //单选才会进入