@dazhicheng/ui 1.5.251 → 1.5.253

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.
@@ -33,7 +33,7 @@ function ce(e) {
33
33
  return u && a.unshift({
34
34
  type: "seq",
35
35
  title: "序号",
36
- width: 60,
36
+ width: 48,
37
37
  resizable: !1,
38
38
  align: "center",
39
39
  fixed: "left",
@@ -123,7 +123,7 @@ function fe({
123
123
  let p = W;
124
124
  h.length > 0 && (p = h.includes(s.field)), b.length > 0 && (p = !b.includes(s.field));
125
125
  let d = {
126
- minWidth: 140,
126
+ minWidth: 80,
127
127
  sortable: p,
128
128
  resizable: C,
129
129
  ...s
@@ -91,6 +91,28 @@ export type BasicDataCodeRegistryItem = {
91
91
  /** 拉取并归一化为 label/value 选项 */
92
92
  fetchOptions: (ctx?: BasicDataFetchContext) => Promise<BasicDataOption[]>;
93
93
  };
94
+ /**
95
+ * 地理层级(数字越大越细)。
96
+ * 更细层级的扁平字段已含上级 code/name,可去重派生上级,避免同页重复请求。
97
+ * 机场 → 城市/国家/区域/洲;城市 → 国家/区域/洲;国家 → 区域/洲;区域 → 洲
98
+ */
99
+ export declare const GEO_LEVEL_CODES: readonly ["continent", "region", "country", "city", "airport"];
100
+ export type GeoLevelCode = (typeof GEO_LEVEL_CODES)[number];
101
+ /** @deprecated 使用 GEO_LEVEL_CODES;保留兼容「从机场可派生」语义 */
102
+ export declare const GEO_CODES_DERIVABLE_FROM_AIRPORT: readonly ["continent", "region", "country", "city"];
103
+ export declare function isGeoLevelCode(code: BasicDataCode): code is GeoLevelCode;
104
+ export declare function isGeoCodeDerivableFromAirport(code: BasicDataCode): boolean;
105
+ /** source 是否可派生 target(source 更细) */
106
+ export declare function canDeriveGeoLevel(source: BasicDataCode, target: BasicDataCode): boolean;
107
+ /**
108
+ * 从任一地理层级 options 去重生成更粗层级 options。
109
+ * 扁平字段已含 continentCode / regionCode / countryCode / cityCode 等。
110
+ */
111
+ export declare function deriveRegionLevelOptionsFromGeoSource(sourceOptions: BasicDataOption[], targetCode: BasicDataCode): BasicDataOption[];
112
+ /** @deprecated 使用 deriveRegionLevelOptionsFromGeoSource */
113
+ export declare function deriveRegionLevelOptionsFromAirports(airports: BasicDataOption[], code: BasicDataCode): BasicDataOption[];
114
+ /** 在候选 code 中取最细的地理层级(机场 > 城市 > 国家 > 区域 > 洲) */
115
+ export declare function resolveHighestGeoLevelCode(codes: Iterable<BasicDataCode>): GeoLevelCode | undefined;
94
116
  /**
95
117
  * code → 接口与默认展示配置。
96
118
  * 后续扩展航线/舱位等,只需在此追加。
@@ -1,8 +1,8 @@
1
- import { getAllBasicAirline as E, getDictItemsByCodes as R, listChainByTypeAirportRegionLevel as C } from "../api/basicData.js";
2
- import { queryAllRoles as A, pageUser as O } from "../api/dataTypeContext.js";
3
- import { secondaryDropdownListLossReason as L, primaryDropdownListLossReason as S } from "../api/lossReason.js";
4
- import { listAllValidSupplierManage as _, getAllConfigListSupplierConfigManage as I } from "../api/supplier.js";
5
- const u = {
1
+ import { getAllBasicAirline as R, getDictItemsByCodes as O, listChainByTypeAirportRegionLevel as A } from "../api/basicData.js";
2
+ import { queryAllRoles as L, pageUser as I } from "../api/dataTypeContext.js";
3
+ import { secondaryDropdownListLossReason as _, primaryDropdownListLossReason as S } from "../api/lossReason.js";
4
+ import { listAllValidSupplierManage as T, getAllConfigListSupplierConfigManage as b } from "../api/supplier.js";
5
+ const o = {
6
6
  AIRLINE: "airline",
7
7
  CONTINENT: "continent",
8
8
  REGION: "region",
@@ -36,7 +36,7 @@ const u = {
36
36
  /** 按供应商名称(配置号) */
37
37
  SUPPLIER_MANAGE_NAME: "supplierManageName",
38
38
  PINYIN: "pinyin"
39
- }, b = {
39
+ }, g = {
40
40
  [d.CONTINENT]: { codeKey: "continentCode", nameKey: "continentName" },
41
41
  [d.REGION]: { codeKey: "regionCode", nameKey: "regionName" },
42
42
  [d.COUNTRY]: { codeKey: "countryCode", nameKey: "countryName" },
@@ -47,186 +47,226 @@ const u = {
47
47
  nameKey: "supplierManageName",
48
48
  labelMode: "name"
49
49
  }
50
- }, g = {
50
+ }, P = {
51
51
  TICKETING: "出票",
52
52
  REFUND: "退票",
53
53
  REBOOK: "改签"
54
54
  };
55
- function k(a, e) {
55
+ function H(a, e) {
56
56
  if (!Array.isArray(a) || !a.length) return a || [];
57
57
  if (e === d.PINYIN) return a;
58
- const n = b[e];
59
- if (!n) return a;
60
- const r = /* @__PURE__ */ new Map(), s = [], l = n.labelMode || "codeName";
61
- return a.forEach((t) => {
62
- const o = t[n.codeKey], f = o != null && o !== "", i = f ? String(o) : "__unknown__";
63
- if (!r.has(i)) {
58
+ const r = g[e];
59
+ if (!r) return a;
60
+ const l = /* @__PURE__ */ new Map(), s = [], n = r.labelMode || "codeName";
61
+ return a.forEach((u) => {
62
+ const t = u[r.codeKey], c = t != null && t !== "", i = c ? String(t) : "__unknown__";
63
+ if (!l.has(i)) {
64
64
  s.push(i);
65
- const c = t[n.nameKey];
66
- let y = "未知";
67
- f && (l === "name" ? y = c != null && String(c) !== "" ? String(c) : String(o) : y = `${o}(${c || ""})`), r.set(i, {
68
- label: y,
69
- value: f ? o : "__unknown__",
65
+ const f = u[r.nameKey];
66
+ let E = "未知";
67
+ c && (n === "name" ? E = f != null && String(f) !== "" ? String(f) : String(t) : E = `${t}(${f || ""})`), l.set(i, {
68
+ label: E,
69
+ value: c ? t : "__unknown__",
70
70
  children: []
71
71
  });
72
72
  }
73
- r.get(i).children.push(t);
74
- }), s.map((t) => r.get(t));
73
+ l.get(i).children.push(u);
74
+ }), s.map((u) => l.get(u));
75
75
  }
76
- function V(a, e) {
77
- return e || (a === u.AIRPORT ? d.COUNTRY : a === u.LOSS_REASON ? d.BUSINESS_TYPE : a === u.LOSS_REASON_SECONDARY ? d.PRIMARY_REASON : a === u.SUPPLIER_CONFIG ? d.SUPPLIER_MANAGE_NAME : d.PINYIN);
76
+ function W(a, e) {
77
+ return e || (a === o.AIRPORT ? d.COUNTRY : a === o.LOSS_REASON ? d.BUSINESS_TYPE : a === o.LOSS_REASON_SECONDARY ? d.PRIMARY_REASON : a === o.SUPPLIER_CONFIG ? d.SUPPLIER_MANAGE_NAME : d.PINYIN);
78
78
  }
79
- const P = {
79
+ const h = {
80
80
  1: { codeKey: "continentCode", nameKey: "continentName", statusKey: "continentStatus" },
81
81
  2: { codeKey: "regionCode", nameKey: "regionName", statusKey: "regionStatus" },
82
82
  3: { codeKey: "countryCode", nameKey: "countryName", statusKey: "countryStatus" },
83
83
  4: { codeKey: "cityCode", nameKey: "cityName", statusKey: "cityStatus" },
84
84
  5: { codeKey: "airportCode", nameKey: "airportName", statusKey: "airportStatus" }
85
85
  };
86
- function T(a = []) {
86
+ function v(a = []) {
87
87
  return (Array.isArray(a) ? a : []).filter((e) => e == null ? void 0 : e.airlineCode).map((e) => ({
88
88
  ...e,
89
89
  label: `${e.airlineCode}(${e.airlineNameCn || ""})`,
90
90
  value: e.airlineCode
91
91
  }));
92
92
  }
93
- function h(a) {
93
+ function K(a) {
94
94
  if (!a || typeof a != "object" || Array.isArray(a))
95
95
  return a || {};
96
- const e = a.continentCode || a.regionCode || a.countryCode || a.cityCode || a.airportCode, n = [1, 2, 3, 4, 5].some((t) => a[String(t)] || a[t]);
97
- if (e && !n)
96
+ const e = a.continentCode || a.regionCode || a.countryCode || a.cityCode || a.airportCode, r = [1, 2, 3, 4, 5].some((u) => a[String(u)] || a[u]);
97
+ if (e && !r)
98
98
  return a;
99
- let r = {}, s = 0;
100
- for (const t of [1, 2, 3, 4, 5]) {
101
- const o = a[String(t)] || a[t];
102
- if (!o || typeof o != "object") continue;
103
- const f = Number(o.type ?? t);
104
- f >= s && (s = f, r = o);
99
+ let l = {}, s = 0;
100
+ for (const u of [1, 2, 3, 4, 5]) {
101
+ const t = a[String(u)] || a[u];
102
+ if (!t || typeof t != "object") continue;
103
+ const c = Number(t.type ?? u);
104
+ c >= s && (s = c, l = t);
105
105
  }
106
- const l = { ...r };
107
- for (const t of [1, 2, 3, 4, 5]) {
108
- const o = a[String(t)] || a[t];
109
- if (!o || typeof o != "object") continue;
110
- const { codeKey: f, nameKey: i, statusKey: c } = P[t];
111
- o.code !== void 0 && o.code !== null && o.code !== "" && (l[f] = o.code), o.name !== void 0 && (l[i] = o.name), o.status !== void 0 && (l[c] = o.status);
106
+ const n = { ...l };
107
+ for (const u of [1, 2, 3, 4, 5]) {
108
+ const t = a[String(u)] || a[u];
109
+ if (!t || typeof t != "object") continue;
110
+ const { codeKey: c, nameKey: i, statusKey: f } = h[u];
111
+ t.code !== void 0 && t.code !== null && t.code !== "" && (n[c] = t.code), t.name !== void 0 && (n[i] = t.name), t.status !== void 0 && (n[f] = t.status);
112
112
  }
113
- return l;
113
+ return n;
114
114
  }
115
115
  function M(a) {
116
- return (Array.isArray(a) ? a : []).map((n) => h(n || {}));
116
+ return (Array.isArray(a) ? a : []).map((r) => K(r || {}));
117
117
  }
118
- function v(a = [], e, n) {
119
- return (Array.isArray(a) ? a : []).filter((r) => r == null ? void 0 : r[e]).map((r) => ({
120
- ...r,
121
- label: `${r[e]}(${r[n] || ""})`,
122
- value: r[e]
118
+ function w(a = [], e, r) {
119
+ return (Array.isArray(a) ? a : []).filter((l) => l == null ? void 0 : l[e]).map((l) => ({
120
+ ...l,
121
+ label: `${l[e]}(${l[r] || ""})`,
122
+ value: l[e]
123
123
  }));
124
124
  }
125
- function p(a, e, n) {
125
+ const Y = [o.CONTINENT, o.REGION, o.COUNTRY, o.CITY, o.AIRPORT], y = {
126
+ [o.CONTINENT]: 1,
127
+ [o.REGION]: 2,
128
+ [o.COUNTRY]: 3,
129
+ [o.CITY]: 4,
130
+ [o.AIRPORT]: 5
131
+ }, U = {
132
+ [o.CONTINENT]: { codeKey: "continentCode", nameKey: "continentName" },
133
+ [o.REGION]: { codeKey: "regionCode", nameKey: "regionName" },
134
+ [o.COUNTRY]: { codeKey: "countryCode", nameKey: "countryName" },
135
+ [o.CITY]: { codeKey: "cityCode", nameKey: "cityName" },
136
+ [o.AIRPORT]: { codeKey: "airportCode", nameKey: "airportName" }
137
+ };
138
+ o.CONTINENT, o.REGION, o.COUNTRY, o.CITY;
139
+ function N(a) {
140
+ return Y.includes(a);
141
+ }
142
+ function J(a, e) {
143
+ return !N(a) || !N(e) ? !1 : y[a] > y[e];
144
+ }
145
+ function Q(a, e) {
146
+ if (!N(e)) return [];
147
+ const { codeKey: r, nameKey: l } = U[e], s = /* @__PURE__ */ new Map();
148
+ return (Array.isArray(a) ? a : []).forEach((n) => {
149
+ const u = n == null ? void 0 : n[r];
150
+ if (u == null || u === "") return;
151
+ const t = String(u);
152
+ s.has(t) || s.set(t, {
153
+ ...n,
154
+ label: `${u}(${n[l] || ""})`,
155
+ value: u
156
+ });
157
+ }), Array.from(s.values());
158
+ }
159
+ function X(a) {
160
+ let e;
161
+ for (const r of a)
162
+ N(r) && (!e || y[r] > y[e]) && (e = r);
163
+ return e;
164
+ }
165
+ function p(a, e, r) {
126
166
  return async () => {
127
167
  try {
128
- const r = await C({ type: a });
129
- return v(M(r), e, n);
168
+ const l = await A({ type: a });
169
+ return w(M(l), e, r);
130
170
  } catch {
131
171
  return [];
132
172
  }
133
173
  };
134
174
  }
135
- function w(a = []) {
175
+ function D(a = []) {
136
176
  return (Array.isArray(a) ? a : []).filter((e) => (e == null ? void 0 : e.itemCode) !== void 0 && (e == null ? void 0 : e.itemCode) !== null && (e == null ? void 0 : e.itemCode) !== "").map((e) => ({
137
177
  ...e,
138
178
  label: e.itemName || "",
139
179
  value: e.itemCode
140
180
  }));
141
181
  }
142
- function K(a = []) {
143
- const e = Array.isArray(a) ? a : [], n = new Set(
144
- e.map((l) => l.parentItemCode).filter((l) => l != null && String(l) !== "").map(String)
145
- ), r = new Set(
146
- e.filter((l) => (l == null ? void 0 : l.itemCode) !== void 0 && (l == null ? void 0 : l.itemCode) !== null && (l == null ? void 0 : l.itemCode) !== "").map((l) => String(l.itemCode))
147
- ), s = e.filter((l) => (l == null ? void 0 : l.itemCode) !== void 0 && (l == null ? void 0 : l.itemCode) !== null && (l == null ? void 0 : l.itemCode) !== "").map((l) => {
148
- const t = String(l.itemCode), o = l.itemName || "";
182
+ function F(a = []) {
183
+ const e = Array.isArray(a) ? a : [], r = new Set(
184
+ e.map((n) => n.parentItemCode).filter((n) => n != null && String(n) !== "").map(String)
185
+ ), l = new Set(
186
+ e.filter((n) => (n == null ? void 0 : n.itemCode) !== void 0 && (n == null ? void 0 : n.itemCode) !== null && (n == null ? void 0 : n.itemCode) !== "").map((n) => String(n.itemCode))
187
+ ), s = e.filter((n) => (n == null ? void 0 : n.itemCode) !== void 0 && (n == null ? void 0 : n.itemCode) !== null && (n == null ? void 0 : n.itemCode) !== "").map((n) => {
188
+ const u = String(n.itemCode), t = n.itemName || "";
149
189
  return {
150
- ...l,
151
- label: n.has(t) ? `${t}(${o})` : o,
152
- value: t
190
+ ...n,
191
+ label: r.has(u) ? `${u}(${t})` : t,
192
+ value: u
153
193
  };
154
194
  });
155
- return n.forEach((l) => {
156
- r.has(l) || s.push({
157
- itemCode: l,
158
- itemName: l,
159
- label: l,
160
- value: l,
195
+ return r.forEach((n) => {
196
+ l.has(n) || s.push({
197
+ itemCode: n,
198
+ itemName: n,
199
+ label: n,
200
+ value: n,
161
201
  parentItemCode: null
162
202
  });
163
203
  }), s;
164
204
  }
165
- function N(a, e = w) {
166
- return async (n) => {
205
+ function C(a, e = D) {
206
+ return async (r) => {
167
207
  try {
168
- const r = await R({
208
+ const l = await O({
169
209
  dictCodeList: [a],
170
- permissionOnlyCode: n == null ? void 0 : n.permissionOnlyCode
171
- }), s = (r == null ? void 0 : r[a]) || [];
210
+ permissionOnlyCode: r == null ? void 0 : r.permissionOnlyCode
211
+ }), s = (l == null ? void 0 : l[a]) || [];
172
212
  return e(s);
173
213
  } catch {
174
214
  return [];
175
215
  }
176
216
  };
177
217
  }
178
- function Y(a = []) {
218
+ function G(a = []) {
179
219
  return (Array.isArray(a) ? a : []).filter((e) => (e == null ? void 0 : e.id) !== void 0 && (e == null ? void 0 : e.id) !== null).map((e) => ({
180
220
  ...e,
181
221
  label: e.fullName || e.username || String(e.id),
182
222
  value: e.id
183
223
  }));
184
224
  }
185
- function F(a = []) {
225
+ function m(a = []) {
186
226
  return (Array.isArray(a) ? a : []).filter((e) => (e == null ? void 0 : e.id) !== void 0 && (e == null ? void 0 : e.id) !== null).map((e) => ({
187
227
  ...e,
188
228
  label: e.roleName || e.roleCode || String(e.id),
189
229
  value: e.id
190
230
  }));
191
231
  }
192
- function D(a = []) {
232
+ function x(a = []) {
193
233
  return (Array.isArray(a) ? a : []).filter((e) => (e == null ? void 0 : e.id) !== void 0 && (e == null ? void 0 : e.id) !== null).map((e) => {
194
- const n = e.businessType || "";
234
+ const r = e.businessType || "";
195
235
  return {
196
236
  ...e,
197
- businessTypeName: g[n] || n,
237
+ businessTypeName: P[r] || r,
198
238
  label: e.reasonName || "",
199
239
  value: e.id
200
240
  };
201
241
  });
202
242
  }
203
- function U(a = [], e = /* @__PURE__ */ new Map()) {
204
- return (Array.isArray(a) ? a : []).filter((n) => (n == null ? void 0 : n.id) !== void 0 && (n == null ? void 0 : n.id) !== null).map((n) => {
205
- const r = n.primaryReasonId, s = (r != null ? e.get(r) : void 0) || (r != null ? String(r) : "");
243
+ function B(a = [], e = /* @__PURE__ */ new Map()) {
244
+ return (Array.isArray(a) ? a : []).filter((r) => (r == null ? void 0 : r.id) !== void 0 && (r == null ? void 0 : r.id) !== null).map((r) => {
245
+ const l = r.primaryReasonId, s = (l != null ? e.get(l) : void 0) || (l != null ? String(l) : "");
206
246
  return {
207
- ...n,
247
+ ...r,
208
248
  primaryReasonName: s,
209
- label: n.reasonName || "",
210
- value: n.id
249
+ label: r.reasonName || "",
250
+ value: r.id
211
251
  };
212
252
  });
213
253
  }
214
- function G(a = []) {
254
+ function $(a = []) {
215
255
  return (Array.isArray(a) ? a : []).filter((e) => e == null ? void 0 : e.supplierConfigPcc).map((e) => ({
216
256
  ...e,
217
257
  label: e.supplierConfigPcc,
218
258
  value: e.supplierConfigPcc
219
259
  }));
220
260
  }
221
- function x(a = []) {
261
+ function V(a = []) {
222
262
  return (Array.isArray(a) ? a : []).filter((e) => e == null ? void 0 : e.supplierCode).map((e) => ({
223
263
  ...e,
224
264
  label: e.supplierName || e.supplierCode,
225
265
  value: e.supplierCode
226
266
  }));
227
267
  }
228
- const q = {
229
- [u.AIRLINE]: {
268
+ const Z = {
269
+ [o.AIRLINE]: {
230
270
  defaultFieldName: "airlineCodes",
231
271
  defaultLabel: "航司",
232
272
  defaultExcludeLabel: "排除航司",
@@ -234,14 +274,14 @@ const q = {
234
274
  defaultShowAll: !0,
235
275
  async fetchOptions() {
236
276
  try {
237
- const a = await E();
238
- return T(a || []);
277
+ const a = await R();
278
+ return v(a || []);
239
279
  } catch {
240
280
  return [];
241
281
  }
242
282
  }
243
283
  },
244
- [u.CONTINENT]: {
284
+ [o.CONTINENT]: {
245
285
  defaultFieldName: "continentCodes",
246
286
  defaultLabel: "洲",
247
287
  defaultExcludeLabel: "排除洲",
@@ -249,7 +289,7 @@ const q = {
249
289
  defaultShowAll: !1,
250
290
  fetchOptions: p(1, "continentCode", "continentName")
251
291
  },
252
- [u.REGION]: {
292
+ [o.REGION]: {
253
293
  defaultFieldName: "regionCodes",
254
294
  defaultLabel: "区域",
255
295
  defaultExcludeLabel: "排除区域",
@@ -257,7 +297,7 @@ const q = {
257
297
  defaultShowAll: !1,
258
298
  fetchOptions: p(2, "regionCode", "regionName")
259
299
  },
260
- [u.COUNTRY]: {
300
+ [o.COUNTRY]: {
261
301
  defaultFieldName: "countryCodes",
262
302
  defaultLabel: "国家",
263
303
  defaultExcludeLabel: "排除国家",
@@ -265,7 +305,7 @@ const q = {
265
305
  defaultShowAll: !1,
266
306
  fetchOptions: p(3, "countryCode", "countryName")
267
307
  },
268
- [u.CITY]: {
308
+ [o.CITY]: {
269
309
  defaultFieldName: "cityCodes",
270
310
  defaultLabel: "城市",
271
311
  defaultExcludeLabel: "排除城市",
@@ -273,7 +313,7 @@ const q = {
273
313
  defaultShowAll: !1,
274
314
  fetchOptions: p(4, "cityCode", "cityName")
275
315
  },
276
- [u.AIRPORT]: {
316
+ [o.AIRPORT]: {
277
317
  defaultFieldName: "airportCodes",
278
318
  defaultLabel: "机场",
279
319
  defaultExcludeLabel: "排除机场",
@@ -281,7 +321,7 @@ const q = {
281
321
  defaultShowAll: !1,
282
322
  fetchOptions: p(5, "airportCode", "airportName")
283
323
  },
284
- [u.SALES_ORDER_TYPE]: {
324
+ [o.SALES_ORDER_TYPE]: {
285
325
  defaultFieldName: "orderType",
286
326
  defaultLabel: "订单类型",
287
327
  defaultExcludeLabel: "排除订单类型",
@@ -294,9 +334,9 @@ const q = {
294
334
  valueField: "value",
295
335
  parentField: "parentItemCode"
296
336
  },
297
- fetchOptions: N(u.SALES_ORDER_TYPE, K)
337
+ fetchOptions: C(o.SALES_ORDER_TYPE, F)
298
338
  },
299
- [u.SALES_ORDER_PRODUCT_TYPE]: {
339
+ [o.SALES_ORDER_PRODUCT_TYPE]: {
300
340
  defaultFieldName: "productType",
301
341
  defaultLabel: "产品类型",
302
342
  defaultExcludeLabel: "排除产品类型",
@@ -308,9 +348,9 @@ const q = {
308
348
  valueField: "itemCode",
309
349
  parentField: "parentItemCode"
310
350
  },
311
- fetchOptions: N(u.SALES_ORDER_PRODUCT_TYPE)
351
+ fetchOptions: C(o.SALES_ORDER_PRODUCT_TYPE)
312
352
  },
313
- [u.USER]: {
353
+ [o.USER]: {
314
354
  defaultFieldName: "userIds",
315
355
  defaultLabel: "用户",
316
356
  defaultExcludeLabel: "排除用户",
@@ -318,14 +358,14 @@ const q = {
318
358
  defaultShowAll: !1,
319
359
  async fetchOptions() {
320
360
  try {
321
- const a = await O({ pageNo: 1, pageSize: 9999 });
322
- return Y((a == null ? void 0 : a.records) || []);
361
+ const a = await I({ pageNo: 1, pageSize: 9999 });
362
+ return G((a == null ? void 0 : a.records) || []);
323
363
  } catch {
324
364
  return [];
325
365
  }
326
366
  }
327
367
  },
328
- [u.ROLE]: {
368
+ [o.ROLE]: {
329
369
  defaultFieldName: "roleIds",
330
370
  defaultLabel: "角色",
331
371
  defaultExcludeLabel: "排除角色",
@@ -333,14 +373,14 @@ const q = {
333
373
  defaultShowAll: !1,
334
374
  async fetchOptions() {
335
375
  try {
336
- const a = await A();
337
- return F(a || []);
376
+ const a = await L();
377
+ return m(a || []);
338
378
  } catch {
339
379
  return [];
340
380
  }
341
381
  }
342
382
  },
343
- [u.LOSS_REASON]: {
383
+ [o.LOSS_REASON]: {
344
384
  defaultFieldName: "lossReasonIds",
345
385
  defaultLabel: "亏损原因",
346
386
  defaultExcludeLabel: "排除亏损原因",
@@ -349,13 +389,13 @@ const q = {
349
389
  async fetchOptions() {
350
390
  try {
351
391
  const a = await S();
352
- return D(a || []);
392
+ return x(a || []);
353
393
  } catch {
354
394
  return [];
355
395
  }
356
396
  }
357
397
  },
358
- [u.LOSS_REASON_SECONDARY]: {
398
+ [o.LOSS_REASON_SECONDARY]: {
359
399
  defaultFieldName: "lossReasonSecondaryIds",
360
400
  defaultLabel: "亏损原因细类",
361
401
  defaultExcludeLabel: "排除亏损原因细类",
@@ -364,18 +404,18 @@ const q = {
364
404
  async fetchOptions() {
365
405
  try {
366
406
  const [a, e] = await Promise.all([
367
- L(),
407
+ _(),
368
408
  S()
369
- ]), n = /* @__PURE__ */ new Map();
370
- return (e || []).forEach((r) => {
371
- (r == null ? void 0 : r.id) !== void 0 && (r == null ? void 0 : r.id) !== null && n.set(r.id, r.reasonName || String(r.id));
372
- }), U(a || [], n);
409
+ ]), r = /* @__PURE__ */ new Map();
410
+ return (e || []).forEach((l) => {
411
+ (l == null ? void 0 : l.id) !== void 0 && (l == null ? void 0 : l.id) !== null && r.set(l.id, l.reasonName || String(l.id));
412
+ }), B(a || [], r);
373
413
  } catch {
374
414
  return [];
375
415
  }
376
416
  }
377
417
  },
378
- [u.SUPPLIER_CONFIG]: {
418
+ [o.SUPPLIER_CONFIG]: {
379
419
  defaultFieldName: "supplierConfigPccs",
380
420
  defaultLabel: "配置号",
381
421
  defaultExcludeLabel: "排除配置号",
@@ -383,14 +423,14 @@ const q = {
383
423
  defaultShowAll: !1,
384
424
  async fetchOptions() {
385
425
  try {
386
- const a = await I({});
387
- return G(a || []);
426
+ const a = await b({});
427
+ return $(a || []);
388
428
  } catch {
389
429
  return [];
390
430
  }
391
431
  }
392
432
  },
393
- [u.SUPPLIER]: {
433
+ [o.SUPPLIER]: {
394
434
  defaultFieldName: "supplierCodes",
395
435
  defaultLabel: "供应商",
396
436
  defaultExcludeLabel: "排除供应商",
@@ -398,8 +438,8 @@ const q = {
398
438
  defaultShowAll: !1,
399
439
  async fetchOptions() {
400
440
  try {
401
- const a = await _();
402
- return x(a || []);
441
+ const a = await T();
442
+ return V(a || []);
403
443
  } catch {
404
444
  return [];
405
445
  }
@@ -407,9 +447,14 @@ const q = {
407
447
  }
408
448
  };
409
449
  export {
410
- u as CODES,
411
- q as CODE_REGISTRY,
450
+ o as CODES,
451
+ Z as CODE_REGISTRY,
452
+ Y as GEO_LEVEL_CODES,
412
453
  d as GROUP_BY,
413
- k as groupBasicDataOptions,
414
- V as resolveDefaultGroupBy
454
+ J as canDeriveGeoLevel,
455
+ Q as deriveRegionLevelOptionsFromGeoSource,
456
+ H as groupBasicDataOptions,
457
+ N as isGeoLevelCode,
458
+ W as resolveDefaultGroupBy,
459
+ X as resolveHighestGeoLevelCode
415
460
  };
@@ -9,6 +9,7 @@ export interface UseBasicDataOptionsParams {
9
9
  /**
10
10
  * 按基础数据 code 拉取并缓存 options。
11
11
  * 接口失败或返回非数组时兜底为空数组,不影响表单 schema 生成与渲染。
12
+ * 同页已有更细地理层级时,上级(洲/区域/国家/城市)由其扁平字段派生,避免重复 listChainByType。
12
13
  *
13
14
  * @example
14
15
  * ```ts
@@ -1,112 +1,147 @@
1
- import { ref as P, watchEffect as R, unref as D, watch as q, computed as x } from "vue";
2
- import { useRoute as M } from "vue-router";
3
- import { CODE_REGISTRY as b } from "./basicDataCodes.js";
4
- const n = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
5
- function p(c) {
6
- return Array.isArray(c) ? c : [];
1
+ import { ref as A, watchEffect as M, unref as C, watch as _, computed as F } from "vue";
2
+ import { useRoute as K } from "vue-router";
3
+ import { GEO_LEVEL_CODES as E, canDeriveGeoLevel as R, deriveRegionLevelOptionsFromGeoSource as T, resolveHighestGeoLevelCode as L, isGeoLevelCode as G, CODE_REGISTRY as V } from "./basicDataCodes.js";
4
+ const o = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
5
+ function v(t) {
6
+ return Array.isArray(t) ? t : [];
7
7
  }
8
- function E(c) {
9
- return c.reduce((u, y) => (u[y] = [], u), {});
8
+ function b(t) {
9
+ return t.reduce((n, l) => (n[l] = [], n), {});
10
10
  }
11
- function _(c) {
12
- const u = M(), y = P({});
13
- function i(r = {}) {
14
- y.value = c.codes.reduce(
15
- (e, t) => (e[t] = p(r[t]), e),
11
+ function O(t, n) {
12
+ return Object.prototype.hasOwnProperty.call(t, n);
13
+ }
14
+ function q(t) {
15
+ return L(E.filter((n) => O(t, n)));
16
+ }
17
+ function y(t) {
18
+ const n = q(t);
19
+ if (!n) return t;
20
+ const l = t[n];
21
+ if (!Array.isArray(l)) return t;
22
+ const u = { ...t };
23
+ let d = !1;
24
+ return E.forEach((i) => {
25
+ R(n, i) && (O(u, i) || (u[i] = T(l, i), d = !0));
26
+ }), d ? u : t;
27
+ }
28
+ function j(t, n) {
29
+ const l = q(n), u = t.filter(G), d = l || L(u) || void 0;
30
+ return d ? t.filter((i) => G(i) ? !(R(d, i) || i === d && O(n, d)) : !0) : t;
31
+ }
32
+ function k(t) {
33
+ const n = K(), l = A({});
34
+ function u(s = {}) {
35
+ l.value = t.codes.reduce(
36
+ (e, r) => (e[r] = v(s[r]), e),
16
37
  {}
17
38
  );
18
39
  }
19
- i();
20
- async function O(r) {
21
- var s;
22
- const e = (s = u.meta) == null ? void 0 : s.permissionOnlyCode;
40
+ u();
41
+ async function d(s) {
42
+ var h;
43
+ const e = (h = n.meta) == null ? void 0 : h.permissionOnlyCode;
23
44
  return (await Promise.allSettled(
24
- r.map(async (a) => {
45
+ s.map(async (c) => {
25
46
  try {
26
- const f = await b[a].fetchOptions({ permissionOnlyCode: e });
27
- return [a, p(f)];
47
+ const p = await V[c].fetchOptions({ permissionOnlyCode: e });
48
+ return [c, v(p)];
28
49
  } catch {
29
- return [a, []];
50
+ return [c, []];
30
51
  }
31
52
  })
32
- )).reduce((a, o, f) => {
33
- const l = r[f];
34
- return o.status === "fulfilled" ? a[o.value[0]] = p(o.value[1]) : a[l] = [], a;
53
+ )).reduce((c, f, p) => {
54
+ const S = s[p];
55
+ return f.status === "fulfilled" ? c[f.value[0]] = v(f.value[1]) : c[S] = [], c;
35
56
  }, {});
36
57
  }
37
- async function w(r = !1) {
38
- const e = u.path;
39
- let t = [];
58
+ async function i(s = !1) {
59
+ const e = n.path;
60
+ let r = [];
40
61
  try {
41
- const s = D(c.dataSource);
42
- if (s) {
43
- const m = { ...n.get(e) || {}, ...s };
44
- n.set(e, m), i(m);
62
+ const h = C(t.dataSource);
63
+ if (h) {
64
+ let a = { ...o.get(e) || {}, ...h };
65
+ a = y(a), o.set(e, a), u(a);
45
66
  return;
46
67
  }
47
- const a = n.get(e) || {};
48
- if (t = r ? [...c.codes] : c.codes.filter((d) => !Object.prototype.hasOwnProperty.call(a, d)), !t.length) {
49
- i(a);
68
+ let c = y(o.get(e) || {});
69
+ if (c !== (o.get(e) || {}) && o.set(e, c), r = s ? [...t.codes] : t.codes.filter((a) => !O(c, a)), !r.length) {
70
+ u(c);
50
71
  return;
51
72
  }
52
- const o = r ? void 0 : C.get(e);
53
- if (o)
73
+ const f = s ? void 0 : D.get(e);
74
+ if (f)
54
75
  try {
55
- const d = await o, h = { ...n.get(e) || {}, ...d };
56
- if (n.set(e, h), t = c.codes.filter((v) => !Object.prototype.hasOwnProperty.call(h, v)), !t.length) {
57
- i(h);
76
+ const a = await f, g = y({
77
+ ...o.get(e) || {},
78
+ ...a
79
+ });
80
+ if (o.set(e, g), r = t.codes.filter((P) => !O(g, P)), !r.length) {
81
+ u(g);
58
82
  return;
59
83
  }
84
+ c = g;
60
85
  } catch {
61
86
  }
62
- const f = O(t), l = (g.get(e) || 0) + 1;
63
- g.set(e, l), C.set(e, f);
87
+ const p = j(r, c);
88
+ if (!p.length) {
89
+ const a = y(c);
90
+ o.set(e, a), u(a);
91
+ return;
92
+ }
93
+ const S = d(p), w = (m.get(e) || 0) + 1;
94
+ m.set(e, w), D.set(e, S);
64
95
  try {
65
- const d = await f;
66
- if (g.get(e) !== l) return;
67
- const h = { ...n.get(e) || {}, ...d };
68
- n.set(e, h), i(h);
96
+ const a = await S;
97
+ if (m.get(e) !== w) return;
98
+ let g = {
99
+ ...o.get(e) || {},
100
+ ...a
101
+ };
102
+ g = y(g), o.set(e, g), u(g);
69
103
  } finally {
70
- g.get(e) === l && C.delete(e);
104
+ m.get(e) === w && D.delete(e);
71
105
  }
72
106
  } catch {
73
- const s = E(t.length ? t : c.codes), o = { ...n.get(e) || {}, ...s };
74
- n.set(e, o), i(o);
107
+ const h = b(r.length ? r : t.codes), f = { ...o.get(e) || {}, ...h };
108
+ o.set(e, f), u(f);
75
109
  }
76
110
  }
77
- async function S() {
78
- const r = u.path;
79
- C.clear(), n.clear(), g.clear(), n.delete(r), await w(!0);
111
+ async function x() {
112
+ const s = n.path;
113
+ D.clear(), o.clear(), m.clear(), o.delete(s), await i(!0);
80
114
  }
81
- return R(() => {
82
- const r = D(c.dataSource);
83
- if (!r) return;
84
- const e = u.path, s = { ...n.get(e) || {}, ...r };
85
- n.set(e, s), i(s);
86
- }), q(
87
- () => u.path,
115
+ return M(() => {
116
+ const s = C(t.dataSource);
117
+ if (!s) return;
118
+ const e = n.path;
119
+ let r = { ...o.get(e) || {}, ...s };
120
+ r = y(r), o.set(e, r), u(r);
121
+ }), _(
122
+ () => n.path,
88
123
  () => {
89
- w();
124
+ i();
90
125
  },
91
126
  { immediate: !0 }
92
127
  ), {
93
- dataSource: x(() => {
94
- const r = c.codes.reduce(
95
- (e, t) => (e[t] = p(y.value[t]), e),
128
+ dataSource: F(() => {
129
+ const s = t.codes.reduce(
130
+ (e, r) => (e[r] = v(l.value[r]), e),
96
131
  {}
97
132
  );
98
- return new Proxy(r, {
99
- get(e, t) {
100
- return typeof t != "string" ? [] : p(r[t]);
133
+ return new Proxy(s, {
134
+ get(e, r) {
135
+ return typeof r != "string" ? [] : v(s[r]);
101
136
  },
102
137
  set() {
103
138
  return !1;
104
139
  }
105
140
  });
106
141
  }),
107
- reload: S
142
+ reload: x
108
143
  };
109
144
  }
110
145
  export {
111
- _ as useBasicDataOptions
146
+ k as useBasicDataOptions
112
147
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dazhicheng/ui",
3
- "version": "1.5.251",
3
+ "version": "1.5.253",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",