gcs-ui-lib 1.2.35 → 1.2.36

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.36",
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) => {