@dazhicheng/ui 1.5.244 → 1.5.245

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.
@@ -4,8 +4,16 @@ export type BasicAirlineItem = {
4
4
  airlineNameCn?: string;
5
5
  [key: string]: any;
6
6
  };
7
- /** 机场区域完整信息 */
7
+ /** 机场区域完整信息(洲/区域/国家/城市/机场) */
8
8
  export type AirportRegionItem = {
9
+ continentCode?: string;
10
+ continentName?: string;
11
+ regionCode?: string;
12
+ regionName?: string;
13
+ countryCode?: string;
14
+ countryName?: string;
15
+ cityCode?: string;
16
+ cityName?: string;
9
17
  airportCode?: string;
10
18
  airportName?: string;
11
19
  [key: string]: any;
@@ -14,10 +22,12 @@ export type AirportRegionItem = {
14
22
  export declare function getAllBasicAirline(options?: {
15
23
  [key: string]: any;
16
24
  }): Promise<BasicAirlineItem[]>;
17
- /** 根据代码查询区域机场完整层级信息 POST /airportRegionLevel/getByCode */
18
- export declare function getByCodeAirportRegionLevel(body: {
19
- type?: number;
20
- codes?: string[];
25
+ /**
26
+ * 按类型查询区域机场链路列表 GET /airportRegionLevel/listChainByType
27
+ * type:1-洲,2-区域,3-国家,4-城市,5-机场
28
+ */
29
+ export declare function listChainByTypeAirportRegionLevel(params: {
30
+ type: number;
21
31
  }, options?: {
22
32
  [key: string]: any;
23
33
  }): Promise<AirportRegionItem[]>;
@@ -1,16 +1,16 @@
1
- import { request as t } from "../utils/xhr.js";
2
- async function r(e) {
3
- return t.get({
1
+ import { request as e } from "../utils/xhr.js";
2
+ async function r(i) {
3
+ return e.get({
4
4
  url: "/basic/basicAirline/getAll"
5
5
  });
6
6
  }
7
- async function n(e, i) {
8
- return t.post({
9
- url: "/basic/airportRegionLevel/getByCode",
10
- data: e
7
+ async function o(i, t) {
8
+ return e.get({
9
+ url: "/basic/airportRegionLevel/listChainByType",
10
+ params: i
11
11
  });
12
12
  }
13
13
  export {
14
14
  r as getAllBasicAirline,
15
- n as getByCodeAirportRegionLevel
15
+ o as listChainByTypeAirportRegionLevel
16
16
  };
@@ -1,16 +1,41 @@
1
1
  /**
2
2
  * 基础数据 code 常量,页面传入 hooks 时使用。
3
+ * 区域层级 type:1-洲,2-区域,3-国家,4-城市,5-机场
3
4
  */
4
5
  export declare const CODES: {
5
6
  readonly AIRLINE: "airline";
7
+ readonly CONTINENT: "continent";
8
+ readonly REGION: "region";
9
+ readonly COUNTRY: "country";
10
+ readonly CITY: "city";
6
11
  readonly AIRPORT: "airport";
7
12
  };
8
13
  export type BasicDataCode = (typeof CODES)[keyof typeof CODES];
9
14
  export type BasicDataOption = {
10
15
  label: string;
11
16
  value: string | number;
17
+ children?: BasicDataOption[];
12
18
  [key: string]: any;
13
19
  };
20
+ /**
21
+ * PanelSelect 分组方式。
22
+ * - continent / region / country:按洲 / 区域 / 国家树形分组
23
+ * - pinyin:按拼音首字母分组(TtPanelSelect showPinyinMode)
24
+ */
25
+ export declare const GROUP_BY: {
26
+ readonly CONTINENT: "continent";
27
+ readonly REGION: "region";
28
+ readonly COUNTRY: "country";
29
+ readonly PINYIN: "pinyin";
30
+ };
31
+ export type PanelSelectGroupBy = (typeof GROUP_BY)[keyof typeof GROUP_BY];
32
+ /**
33
+ * 将扁平 options 按洲/区域/国家转为树形(父节点 + children)。
34
+ * `pinyin` 或不支持的分组原样返回,交由组件拼音模式处理。
35
+ */
36
+ export declare function groupBasicDataOptions(options: BasicDataOption[], groupBy: PanelSelectGroupBy): BasicDataOption[];
37
+ /** 机场默认按国家分组;其余默认拼音 */
38
+ export declare function resolveDefaultGroupBy(code: BasicDataCode, groupBy?: PanelSelectGroupBy): PanelSelectGroupBy;
14
39
  export type BasicDataCodeRegistryItem = {
15
40
  /** 默认表单字段名 */
16
41
  defaultFieldName: string;
@@ -1,47 +1,161 @@
1
- import { getByCodeAirportRegionLevel as r, getAllBasicAirline as t } from "../api/basicData.js";
2
- const a = {
1
+ import { getAllBasicAirline as N, listChainByTypeAirportRegionLevel as C } from "../api/basicData.js";
2
+ const d = {
3
3
  AIRLINE: "airline",
4
+ CONTINENT: "continent",
5
+ REGION: "region",
6
+ COUNTRY: "country",
7
+ CITY: "city",
4
8
  AIRPORT: "airport"
9
+ }, i = {
10
+ CONTINENT: "continent",
11
+ REGION: "region",
12
+ COUNTRY: "country",
13
+ PINYIN: "pinyin"
14
+ }, p = {
15
+ [i.CONTINENT]: { codeKey: "continentCode", nameKey: "continentName" },
16
+ [i.REGION]: { codeKey: "regionCode", nameKey: "regionName" },
17
+ [i.COUNTRY]: { codeKey: "countryCode", nameKey: "countryName" }
5
18
  };
6
- function o(l = []) {
7
- return (l || []).filter((e) => e == null ? void 0 : e.airlineCode).map((e) => ({
8
- ...e,
9
- label: `${e.airlineCode}(${e.airlineNameCn || ""})`,
10
- value: e.airlineCode
19
+ function R(e, t) {
20
+ if (!Array.isArray(e) || !e.length) return e || [];
21
+ if (t === i.PINYIN) return e;
22
+ const r = p[t];
23
+ if (!r) return e;
24
+ const o = /* @__PURE__ */ new Map(), c = [];
25
+ return e.forEach((l) => {
26
+ const a = l[r.codeKey], n = a != null && a !== "", u = n ? String(a) : "__unknown__";
27
+ if (!o.has(u)) {
28
+ c.push(u);
29
+ const f = l[r.nameKey];
30
+ o.set(u, {
31
+ label: n ? `${a}(${f || ""})` : "未知",
32
+ value: n ? a : "__unknown__",
33
+ children: []
34
+ });
35
+ }
36
+ o.get(u).children.push(l);
37
+ }), c.map((l) => o.get(l));
38
+ }
39
+ function L(e, t) {
40
+ return t || (e === d.AIRPORT ? i.COUNTRY : i.PINYIN);
41
+ }
42
+ const m = {
43
+ 1: { codeKey: "continentCode", nameKey: "continentName", statusKey: "continentStatus" },
44
+ 2: { codeKey: "regionCode", nameKey: "regionName", statusKey: "regionStatus" },
45
+ 3: { codeKey: "countryCode", nameKey: "countryName", statusKey: "countryStatus" },
46
+ 4: { codeKey: "cityCode", nameKey: "cityName", statusKey: "cityStatus" },
47
+ 5: { codeKey: "airportCode", nameKey: "airportName", statusKey: "airportStatus" }
48
+ };
49
+ function O(e = []) {
50
+ return (Array.isArray(e) ? e : []).filter((t) => t == null ? void 0 : t.airlineCode).map((t) => ({
51
+ ...t,
52
+ label: `${t.airlineCode}(${t.airlineNameCn || ""})`,
53
+ value: t.airlineCode
11
54
  }));
12
55
  }
13
- function n(l = []) {
14
- return (l || []).filter((e) => e == null ? void 0 : e.airportCode).map((e) => ({
15
- ...e,
16
- label: `${e.airportCode}(${e.airportName || ""})`,
17
- value: e.airportCode
56
+ function I(e) {
57
+ if (!e || typeof e != "object" || Array.isArray(e))
58
+ return e || {};
59
+ const t = e.continentCode || e.regionCode || e.countryCode || e.cityCode || e.airportCode, r = [1, 2, 3, 4, 5].some((a) => e[String(a)] || e[a]);
60
+ if (t && !r)
61
+ return e;
62
+ let o = {}, c = 0;
63
+ for (const a of [1, 2, 3, 4, 5]) {
64
+ const n = e[String(a)] || e[a];
65
+ if (!n || typeof n != "object") continue;
66
+ const u = Number(n.type ?? a);
67
+ u >= c && (c = u, o = n);
68
+ }
69
+ const l = { ...o };
70
+ for (const a of [1, 2, 3, 4, 5]) {
71
+ const n = e[String(a)] || e[a];
72
+ if (!n || typeof n != "object") continue;
73
+ const { codeKey: u, nameKey: f, statusKey: y } = m[a];
74
+ n.code !== void 0 && n.code !== null && n.code !== "" && (l[u] = n.code), n.name !== void 0 && (l[f] = n.name), n.status !== void 0 && (l[y] = n.status);
75
+ }
76
+ return l;
77
+ }
78
+ function A(e) {
79
+ return (Array.isArray(e) ? e : []).map((r) => I(r || {}));
80
+ }
81
+ function E(e = [], t, r) {
82
+ return (Array.isArray(e) ? e : []).filter((o) => o == null ? void 0 : o[t]).map((o) => ({
83
+ ...o,
84
+ label: `${o[t]}(${o[r] || ""})`,
85
+ value: o[t]
18
86
  }));
19
87
  }
20
- const u = {
21
- [a.AIRLINE]: {
88
+ function s(e, t, r) {
89
+ return async () => {
90
+ try {
91
+ const o = await C({ type: e });
92
+ return E(A(o), t, r);
93
+ } catch {
94
+ return [];
95
+ }
96
+ };
97
+ }
98
+ const g = {
99
+ [d.AIRLINE]: {
22
100
  defaultFieldName: "airlineCodes",
23
101
  defaultLabel: "航司",
24
102
  defaultExcludeLabel: "排除航司",
25
103
  defaultMultiple: !0,
26
104
  defaultShowAll: !0,
27
105
  async fetchOptions() {
28
- const l = await t();
29
- return o(l || []);
106
+ try {
107
+ const e = await N();
108
+ return O(e || []);
109
+ } catch {
110
+ return [];
111
+ }
30
112
  }
31
113
  },
32
- [a.AIRPORT]: {
114
+ [d.CONTINENT]: {
115
+ defaultFieldName: "continentCodes",
116
+ defaultLabel: "洲",
117
+ defaultExcludeLabel: "排除洲",
118
+ defaultMultiple: !0,
119
+ defaultShowAll: !1,
120
+ fetchOptions: s(1, "continentCode", "continentName")
121
+ },
122
+ [d.REGION]: {
123
+ defaultFieldName: "regionCodes",
124
+ defaultLabel: "区域",
125
+ defaultExcludeLabel: "排除区域",
126
+ defaultMultiple: !0,
127
+ defaultShowAll: !1,
128
+ fetchOptions: s(2, "regionCode", "regionName")
129
+ },
130
+ [d.COUNTRY]: {
131
+ defaultFieldName: "countryCodes",
132
+ defaultLabel: "国家",
133
+ defaultExcludeLabel: "排除国家",
134
+ defaultMultiple: !0,
135
+ defaultShowAll: !1,
136
+ fetchOptions: s(3, "countryCode", "countryName")
137
+ },
138
+ [d.CITY]: {
139
+ defaultFieldName: "cityCodes",
140
+ defaultLabel: "城市",
141
+ defaultExcludeLabel: "排除城市",
142
+ defaultMultiple: !0,
143
+ defaultShowAll: !1,
144
+ fetchOptions: s(4, "cityCode", "cityName")
145
+ },
146
+ [d.AIRPORT]: {
33
147
  defaultFieldName: "airportCodes",
34
148
  defaultLabel: "机场",
35
149
  defaultExcludeLabel: "排除机场",
36
150
  defaultMultiple: !0,
37
151
  defaultShowAll: !1,
38
- async fetchOptions() {
39
- const l = await r({ type: 5 });
40
- return n(l || []);
41
- }
152
+ fetchOptions: s(5, "airportCode", "airportName")
42
153
  }
43
154
  };
44
155
  export {
45
- a as CODES,
46
- u as CODE_REGISTRY
156
+ d as CODES,
157
+ g as CODE_REGISTRY,
158
+ i as GROUP_BY,
159
+ R as groupBasicDataOptions,
160
+ L as resolveDefaultGroupBy
47
161
  };
@@ -8,6 +8,7 @@ export interface UseBasicDataOptionsParams {
8
8
  }
9
9
  /**
10
10
  * 按基础数据 code 拉取并缓存 options。
11
+ * 接口失败或返回非数组时兜底为空数组,不影响表单 schema 生成与渲染。
11
12
  *
12
13
  * @example
13
14
  * ```ts
@@ -1,82 +1,101 @@
1
- import { ref as P, watchEffect as R, unref as D, watch as q, computed as v } from "vue";
2
- import { useRoute as x } from "vue-router";
3
- import { CODE_REGISTRY as E } from "./basicDataCodes.js";
4
- const c = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
5
- function V(s) {
6
- const d = x(), y = P({});
7
- function i(r = {}) {
8
- y.value = s.codes.reduce(
9
- (e, t) => (e[t] = r[t] || [], e),
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(), y = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
5
+ function g(c) {
6
+ return Array.isArray(c) ? c : [];
7
+ }
8
+ function E(c) {
9
+ return c.reduce((s, l) => (s[l] = [], s), {});
10
+ }
11
+ function _(c) {
12
+ const s = M(), l = P({});
13
+ function u(r = {}) {
14
+ l.value = c.codes.reduce(
15
+ (e, t) => (e[t] = g(r[t]), e),
10
16
  {}
11
17
  );
12
18
  }
13
- async function C(r) {
19
+ u();
20
+ async function O(r) {
14
21
  return (await Promise.allSettled(
15
22
  r.map(async (t) => {
16
- const a = await E[t].fetchOptions();
17
- return [t, a];
23
+ try {
24
+ const o = await b[t].fetchOptions();
25
+ return [t, g(o)];
26
+ } catch {
27
+ return [t, []];
28
+ }
18
29
  })
19
- )).reduce((t, n, a) => {
20
- const l = r[a];
21
- return n.status === "fulfilled" ? t[n.value[0]] = n.value[1] : t[l] = [], t;
30
+ )).reduce((t, a, o) => {
31
+ const i = r[o];
32
+ return a.status === "fulfilled" ? t[a.value[0]] = g(a.value[1]) : t[i] = [], t;
22
33
  }, {});
23
34
  }
24
- async function m(r = !1) {
25
- const e = d.path, t = D(s.dataSource);
26
- if (t) {
27
- const g = { ...c.get(e) || {}, ...t };
28
- c.set(e, g), i(g);
29
- return;
30
- }
31
- const n = c.get(e) || {};
32
- let a = r ? [...s.codes] : s.codes.filter((u) => !Object.prototype.hasOwnProperty.call(n, u));
33
- if (!a.length) {
34
- i(n);
35
- return;
36
- }
37
- const l = r ? void 0 : h.get(e);
38
- if (l) {
39
- const u = await l, o = { ...c.get(e) || {}, ...u };
40
- if (c.set(e, o), a = s.codes.filter((O) => !Object.prototype.hasOwnProperty.call(o, O)), !a.length) {
41
- i(o);
35
+ async function w(r = !1) {
36
+ const e = s.path;
37
+ let t = [];
38
+ try {
39
+ const a = D(c.dataSource);
40
+ if (a) {
41
+ const p = { ...n.get(e) || {}, ...a };
42
+ n.set(e, p), u(p);
42
43
  return;
43
44
  }
44
- }
45
- const w = C(a), p = (f.get(e) || 0) + 1;
46
- f.set(e, p), h.set(e, w);
47
- try {
48
- const u = await w;
49
- if (f.get(e) !== p) return;
50
- const o = { ...c.get(e) || {}, ...u };
51
- c.set(e, o), i(o);
52
- } finally {
53
- f.get(e) === p && h.delete(e);
45
+ const o = n.get(e) || {};
46
+ if (t = r ? [...c.codes] : c.codes.filter((f) => !Object.prototype.hasOwnProperty.call(o, f)), !t.length) {
47
+ u(o);
48
+ return;
49
+ }
50
+ const i = r ? void 0 : y.get(e);
51
+ if (i)
52
+ try {
53
+ const f = await i, d = { ...n.get(e) || {}, ...f };
54
+ if (n.set(e, d), t = c.codes.filter((v) => !Object.prototype.hasOwnProperty.call(d, v)), !t.length) {
55
+ u(d);
56
+ return;
57
+ }
58
+ } catch {
59
+ }
60
+ const C = O(t), m = (h.get(e) || 0) + 1;
61
+ h.set(e, m), y.set(e, C);
62
+ try {
63
+ const f = await C;
64
+ if (h.get(e) !== m) return;
65
+ const d = { ...n.get(e) || {}, ...f };
66
+ n.set(e, d), u(d);
67
+ } finally {
68
+ h.get(e) === m && y.delete(e);
69
+ }
70
+ } catch {
71
+ const a = E(t.length ? t : c.codes), i = { ...n.get(e) || {}, ...a };
72
+ n.set(e, i), u(i);
54
73
  }
55
74
  }
56
75
  async function S() {
57
- const r = d.path;
58
- h.clear(), c.clear(), f.clear(), c.delete(r), await m(!0);
76
+ const r = s.path;
77
+ y.clear(), n.clear(), h.clear(), n.delete(r), await w(!0);
59
78
  }
60
79
  return R(() => {
61
- const r = D(s.dataSource);
80
+ const r = D(c.dataSource);
62
81
  if (!r) return;
63
- const e = d.path, n = { ...c.get(e) || {}, ...r };
64
- c.set(e, n), i(n);
82
+ const e = s.path, a = { ...n.get(e) || {}, ...r };
83
+ n.set(e, a), u(a);
65
84
  }), q(
66
- () => d.path,
85
+ () => s.path,
67
86
  () => {
68
- m();
87
+ w();
69
88
  },
70
89
  { immediate: !0 }
71
90
  ), {
72
- dataSource: v(() => {
73
- const r = s.codes.reduce(
74
- (e, t) => (e[t] = y.value[t] || [], e),
91
+ dataSource: x(() => {
92
+ const r = c.codes.reduce(
93
+ (e, t) => (e[t] = g(l.value[t]), e),
75
94
  {}
76
95
  );
77
96
  return new Proxy(r, {
78
97
  get(e, t) {
79
- return typeof t != "string" ? [] : r[t] || [];
98
+ return typeof t != "string" ? [] : g(r[t]);
80
99
  },
81
100
  set() {
82
101
  return !1;
@@ -87,5 +106,5 @@ function V(s) {
87
106
  };
88
107
  }
89
108
  export {
90
- V as useBasicDataOptions
109
+ _ as useBasicDataOptions
91
110
  };
@@ -1,7 +1,7 @@
1
1
  import { TtFormSchema } from '../components/tt-form';
2
2
  import { Recordable } from '../../../utils/src';
3
3
  import { MaybeRef, Ref } from 'vue';
4
- import { BasicDataCode, BasicDataOption } from './basicDataCodes';
4
+ import { BasicDataCode, BasicDataOption, PanelSelectGroupBy } from './basicDataCodes';
5
5
  import { BasicDataOptionsMap } from './useBasicDataOptions';
6
6
  type FieldComponentProps = Recordable | ((values: Recordable, actions: any, options: BasicDataOption[]) => Recordable);
7
7
  export interface PanelSelectFieldOnChangeContext {
@@ -30,7 +30,10 @@ export interface PanelSelectExcludeConfig {
30
30
  }
31
31
  export interface PanelSelectFieldConfig {
32
32
  code: BasicDataCode;
33
- /** 返回解构名,默认用 code;同 code 多字段时必传不同 key */
33
+ /**
34
+ * 返回解构名。
35
+ * 默认:唯一 code 用 code;同 code 多字段时用 fieldName(缺省则用 registry 默认 fieldName)。
36
+ */
34
37
  key?: string;
35
38
  fieldName?: string;
36
39
  label?: string;
@@ -45,7 +48,14 @@ export interface PanelSelectFieldConfig {
45
48
  mutexWith?: string;
46
49
  /** 同 code 数据源的排除字段联动 */
47
50
  exclude?: PanelSelectExcludeConfig;
48
- /** 自定义过滤完整 options */
51
+ /**
52
+ * 分组方式。
53
+ * - 机场默认 `country`(按国家)
54
+ * - 可传 `continent` / `region` / `country` / `pinyin`
55
+ * - 也可用 `GROUP_BY.CONTINENT` 等常量
56
+ */
57
+ groupBy?: PanelSelectGroupBy;
58
+ /** 自定义过滤完整 options(过滤在分组前执行,入参为扁平 options) */
49
59
  customOptions?: (values: Recordable, options: BasicDataOption[]) => BasicDataOption[];
50
60
  }
51
61
  export interface UsePanelSelectSchemasOptions {
@@ -54,9 +64,10 @@ export interface UsePanelSelectSchemasOptions {
54
64
  /**
55
65
  * 基础数据 PanelSelect schema hooks。
56
66
  *
57
- * - 按 CODES 拉取 options
67
+ * - 按 CODES 拉取 options;接口失败时兜底空数组,不影响 schema 生成
58
68
  * - 默认组件 TtPanelSelect
59
69
  * - 支持 exclude 排除联动、mutexWith 互斥过滤
70
+ * - 同 code 多字段时自动用 fieldName 作为返回解构名,避免互相覆盖
60
71
  *
61
72
  * @example
62
73
  * ```ts
@@ -68,14 +79,12 @@ export interface UsePanelSelectSchemasOptions {
68
79
  * },
69
80
  * {
70
81
  * code: CODES.AIRPORT,
71
- * key: 'depAirport',
72
82
  * fieldName: 'depAirport',
73
83
  * label: '出发',
74
84
  * mutexWith: 'arrAirport',
75
85
  * },
76
86
  * {
77
87
  * code: CODES.AIRPORT,
78
- * key: 'arrAirport',
79
88
  * fieldName: 'arrAirport',
80
89
  * label: '到达',
81
90
  * mutexWith: 'depAirport',
@@ -1,6 +1,6 @@
1
1
  import "axios";
2
2
  import "element-plus";
3
- import { isFunction as R } from "../packages/utils/src/is.js";
3
+ import { isFunction as j } from "../packages/utils/src/is.js";
4
4
  import "vue";
5
5
  import "xe-utils";
6
6
  import "dayjs";
@@ -11,111 +11,119 @@ import "../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js";
11
11
  import "../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js";
12
12
  import "../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
13
13
  import "../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js";
14
- import { omit as N } from "lodash-es";
15
- import { CODE_REGISTRY as H } from "./basicDataCodes.js";
16
- import { useBasicDataOptions as J } from "./useBasicDataOptions.js";
17
- const g = "all";
18
- function h(t) {
14
+ import { omit as L } from "lodash-es";
15
+ import { CODE_REGISTRY as C, resolveDefaultGroupBy as ee, GROUP_BY as te, groupBasicDataOptions as U } from "./basicDataCodes.js";
16
+ import { useBasicDataOptions as ne } from "./useBasicDataOptions.js";
17
+ const N = "all";
18
+ function d(t) {
19
19
  return Array.isArray(t) ? t : t == null || t === "" ? [] : [t];
20
20
  }
21
- function Q(t, n = g) {
21
+ function oe(t, n = N) {
22
22
  return t === n ? !0 : typeof t == "string" && typeof n == "string" && t.toLowerCase() === String(n).toLowerCase();
23
23
  }
24
- function X(t, n = g) {
25
- return h(t).some((r) => Q(r, n));
24
+ function re(t, n = N) {
25
+ return d(t).some((r) => oe(r, n));
26
26
  }
27
- function v(t) {
27
+ function se(t) {
28
28
  return t.replace(/[-_]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").split(/\s+/).filter(Boolean).map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join("");
29
29
  }
30
30
  function W(t, n, r, s) {
31
- return t ? R(t) ? t(n, r, s) : t : {};
31
+ return t ? j(t) ? t(n, r, s) : t : {};
32
32
  }
33
- function $(t, n, r, s) {
34
- const l = new Set(r.map((c) => c.value)), e = t[n];
33
+ function Y(t, n, r, s) {
34
+ const p = new Set(r.map((e) => e.value)), l = t[n];
35
35
  if (s) {
36
- const c = h(e).filter((p) => l.has(p)), u = h(e);
37
- (c.length !== u.length || c.some((p, S) => p !== u[S])) && (t[n] = c);
36
+ const e = d(l).filter((u) => p.has(u)), c = d(l);
37
+ (e.length !== c.length || e.some((u, S) => u !== c[S])) && (t[n] = e);
38
38
  return;
39
39
  }
40
- e == null || e === "" || l.has(e) || (t[n] = void 0);
40
+ l == null || l === "" || p.has(l) || (t[n] = void 0);
41
41
  }
42
- function z(t, n, r, s, l, e) {
43
- const c = e ? l.filter((u) => h(r[n]).includes(u.value)) : l.find((u) => u.value === r[n]);
42
+ function $(t, n, r, s, p, l) {
43
+ const e = l ? p.filter((c) => d(r[n]).includes(c.value)) : p.find((c) => c.value === r[n]);
44
44
  return {
45
45
  values: r,
46
46
  actions: s,
47
47
  fieldName: n,
48
48
  code: t,
49
- options: l,
50
- currentOption: c
49
+ options: p,
50
+ currentOption: e
51
51
  };
52
52
  }
53
- function B(t, n, r) {
54
- const s = h(t);
53
+ function z(t, n, r) {
54
+ const s = d(t);
55
55
  if (!s.length) return [];
56
- if (X(t, r)) return n;
57
- const l = new Set(s);
58
- return n.filter((e) => l.has(e.value));
56
+ if (re(t, r)) return n;
57
+ const p = new Set(s);
58
+ return n.filter((l) => p.has(l.value));
59
59
  }
60
60
  function K(t, n) {
61
- const r = new Set(h(t));
61
+ const r = new Set(d(t));
62
62
  return r.size ? n.filter((s) => !r.has(s.value)) : n;
63
63
  }
64
- function xe(t, n = {}) {
65
- const r = [...new Set(t.map((e) => e.code))], { dataSource: s } = J({
64
+ function V(t, n) {
65
+ var s;
66
+ const r = (s = t.value) == null ? void 0 : s[n];
67
+ return Array.isArray(r) ? r : [];
68
+ }
69
+ function ge(t, n = {}) {
70
+ const r = [...new Set(t.map((e) => e.code))], s = t.reduce(
71
+ (e, c) => (e[c.code] = (e[c.code] || 0) + 1, e),
72
+ {}
73
+ ), { dataSource: p } = ne({
66
74
  codes: r,
67
75
  dataSource: n.dataSource
68
76
  }), l = {};
69
77
  return t.forEach((e) => {
70
- var D;
71
- const c = H[e.code], u = e.key || e.code, p = e.fieldName || c.defaultFieldName, S = e.label || c.defaultLabel, L = e.multiple ?? c.defaultMultiple, U = e.showAll ?? c.defaultShowAll, O = e.showAllField ?? g, x = e.mutexWith, V = [
72
- ...x ? [x] : [],
73
- ...((D = e.dependencies) == null ? void 0 : D.triggerFields) || []
74
- ], T = [...new Set(V)], j = N(e.dependencies || {}, ["triggerFields"]), q = T.length ? {
75
- ...j,
76
- triggerFields: T
77
- } : e.dependencies, b = {
78
+ var G;
79
+ const c = C[e.code], u = e.fieldName || c.defaultFieldName, S = e.key || ((s[e.code] || 0) > 1 ? u : e.code), T = e.label || c.defaultLabel, _ = e.multiple ?? c.defaultMultiple, q = e.showAll ?? c.defaultShowAll, b = e.showAllField ?? N, m = e.mutexWith, E = ee(e.code, e.groupBy), F = E !== te.PINYIN, Z = [
80
+ ...m ? [m] : [],
81
+ ...((G = e.dependencies) == null ? void 0 : G.triggerFields) || []
82
+ ], k = [...new Set(Z)], H = L(e.dependencies || {}, ["triggerFields"]), J = k.length ? {
83
+ ...H,
84
+ triggerFields: k
85
+ } : e.dependencies, M = {
78
86
  component: "TtPanelSelect",
79
- fieldName: p,
80
- label: S,
87
+ fieldName: u,
88
+ label: T,
81
89
  rules: e.rules,
82
- dependencies: q,
83
- componentProps: (o, w) => {
84
- const A = s.value[e.code] || [];
85
- let a = x ? K(o[x], A) : A;
86
- R(e.customOptions) && (a = e.customOptions(o, a));
87
- const P = W(e.componentProps, o, w, a), { onChange: k, ...E } = P;
90
+ dependencies: J,
91
+ componentProps: (o, x) => {
92
+ const A = V(p, e.code);
93
+ let a = m ? K(o[m], A) : A;
94
+ j(e.customOptions) && (a = e.customOptions(o, a) || []);
95
+ const O = F ? U(a, E) : a, B = W(e.componentProps, o, x, a), { onChange: I, ...P } = B;
88
96
  return {
89
- multiple: L,
90
- showAll: U,
91
- showAllField: O,
97
+ multiple: _,
98
+ showAll: q,
99
+ showAllField: b,
92
100
  showNav: !1,
93
101
  showOriginMode: !1,
94
- showPinyinMode: !0,
95
- ...E,
96
- options: a,
97
- onChange(d) {
98
- var F;
99
- if (x) {
100
- const m = Array.isArray(o[x]), i = K(d, A);
101
- $(o, x, i, m);
102
+ showPinyinMode: !F,
103
+ ...P,
104
+ options: O,
105
+ onChange(w) {
106
+ var y;
107
+ if (m) {
108
+ const i = Array.isArray(o[m]), h = K(w, A);
109
+ Y(o, m, h, i);
102
110
  }
103
111
  if (e.exclude) {
104
- const m = e.exclude.fieldName, i = e.exclude.multiple ?? !0, y = B(d, A, O);
105
- h(d).length ? $(o, m, y, i) : o[m] = i ? [] : void 0;
112
+ const i = e.exclude.fieldName, h = e.exclude.multiple ?? !0, D = z(w, A, b);
113
+ d(w).length ? Y(o, i, D, h) : o[i] = h ? [] : void 0;
106
114
  }
107
- (F = e.onChange) == null || F.call(
115
+ (y = e.onChange) == null || y.call(
108
116
  e,
109
- d,
110
- z(e.code, p, o, w, a, L)
117
+ w,
118
+ $(e.code, u, o, x, a, _)
111
119
  );
112
120
  }
113
121
  };
114
122
  }
115
123
  };
116
- if (l[u] = {
117
- ...b,
118
- ...N(e, [
124
+ if (l[S] = {
125
+ ...M,
126
+ ...L(e, [
119
127
  "code",
120
128
  "key",
121
129
  "fieldName",
@@ -129,50 +137,51 @@ function xe(t, n = {}) {
129
137
  "rules",
130
138
  "mutexWith",
131
139
  "exclude",
140
+ "groupBy",
132
141
  "customOptions"
133
142
  ]),
134
- fieldName: p,
135
- label: S,
143
+ fieldName: u,
144
+ label: T,
136
145
  rules: e.rules,
137
- dependencies: b.dependencies,
138
- componentProps: b.componentProps,
146
+ dependencies: M.dependencies,
147
+ componentProps: M.componentProps,
139
148
  component: "TtPanelSelect"
140
149
  }, e.exclude) {
141
- const o = e.exclude, w = o.fieldName, A = o.key || `exclude${v(u)}`, a = o.label || c.defaultExcludeLabel, P = o.multiple ?? !0, k = o.showAll ?? !1, E = o.showAllField ?? g, d = o.dependencies || {}, F = {
142
- ...d,
143
- triggerFields: d.triggerFields ?? [p],
144
- if: d.if ?? ((i) => h(i[p]).length > 0)
145
- }, m = {
150
+ const o = e.exclude, x = o.fieldName, A = o.key || `exclude${se(S)}`, a = o.label || c.defaultExcludeLabel, O = o.multiple ?? !0, B = o.showAll ?? !1, I = o.showAllField ?? N, P = o.dependencies || {}, w = {
151
+ ...P,
152
+ triggerFields: P.triggerFields ?? [u],
153
+ if: P.if ?? ((i) => d(i[u]).length > 0)
154
+ }, y = {
146
155
  component: "TtPanelSelect",
147
- fieldName: w,
156
+ fieldName: x,
148
157
  label: a,
149
158
  rules: o.rules,
150
- dependencies: F,
151
- componentProps: (i, y) => {
152
- const G = s.value[e.code] || [], M = B(i[p], G, O), I = W(o.componentProps, i, y, M), { onChange: f, ...Y } = I;
159
+ dependencies: w,
160
+ componentProps: (i, h) => {
161
+ const D = V(p, e.code), g = z(i[u], D, b), Q = F ? U(g, E) : g, X = W(o.componentProps, i, h, g), { onChange: ce, ...v } = X;
153
162
  return {
154
- multiple: P,
155
- showAll: k,
156
- showAllField: E,
163
+ multiple: O,
164
+ showAll: B,
165
+ showAllField: I,
157
166
  showNav: !1,
158
167
  showOriginMode: !1,
159
- showPinyinMode: !0,
160
- ...Y,
161
- options: M,
162
- onChange(Z) {
163
- var _;
164
- (_ = o.onChange) == null || _.call(
168
+ showPinyinMode: !F,
169
+ ...v,
170
+ options: Q,
171
+ onChange(f) {
172
+ var R;
173
+ (R = o.onChange) == null || R.call(
165
174
  o,
166
- Z,
167
- z(e.code, w, i, y, M, P)
175
+ f,
176
+ $(e.code, x, i, h, g, O)
168
177
  );
169
178
  }
170
179
  };
171
180
  }
172
181
  };
173
182
  l[A] = {
174
- ...m,
175
- ...N(o, [
183
+ ...y,
184
+ ...L(o, [
176
185
  "fieldName",
177
186
  "label",
178
187
  "key",
@@ -184,19 +193,19 @@ function xe(t, n = {}) {
184
193
  "onChange",
185
194
  "rules"
186
195
  ]),
187
- fieldName: w,
196
+ fieldName: x,
188
197
  label: a,
189
198
  rules: o.rules,
190
- dependencies: m.dependencies,
191
- componentProps: m.componentProps,
199
+ dependencies: y.dependencies,
200
+ componentProps: y.componentProps,
192
201
  component: "TtPanelSelect"
193
202
  };
194
203
  }
195
204
  }), {
196
205
  ...l,
197
- dataSource: s
206
+ dataSource: p
198
207
  };
199
208
  }
200
209
  export {
201
- xe as usePanelSelectSchemas
210
+ ge as usePanelSelectSchemas
202
211
  };
package/dist/index.d.ts CHANGED
@@ -26,7 +26,7 @@ export { useFormSchemasLink } from './hooks/useFormSchemasLink';
26
26
  export { useDataPermissionOptions } from './hooks/useDataPermissionOptions';
27
27
  export { useBasicDataOptions } from './hooks/useBasicDataOptions';
28
28
  export { usePanelSelectSchemas, type PanelSelectFieldConfig, type PanelSelectExcludeConfig, } from './hooks/usePanelSelectSchemas';
29
- export { CODES, type BasicDataCode } from './hooks/basicDataCodes';
29
+ export { CODES, GROUP_BY, type BasicDataCode, type PanelSelectGroupBy } from './hooks/basicDataCodes';
30
30
  export { useFormat } from './hooks/useFormat';
31
31
  export { useLoading } from './hooks/useLoading';
32
32
  export { useScreenshotOss, type ScreenshotOssComponentOptions, type ScreenshotOssDataUrlResult, type ScreenshotOssOptions, type ScreenshotOssResult, } from './hooks/useScreenshotOss';
package/dist/index.js CHANGED
@@ -11,8 +11,8 @@ import { RenderModal as c } from "./components/tt-modal/index.js";
11
11
  import { TtModal as pr } from "./components/tt-modal/index.js";
12
12
  import { TtSelect as b } from "./components/tt-select/index.js";
13
13
  import { TtText as w } from "./components/tt-text/index.js";
14
- import { TtUpload as h } from "./components/tt-upload/index.js";
15
- import { TtNavAnchor as R } from "./components/tt-nav-anchor/index.js";
14
+ import { TtUpload as R } from "./components/tt-upload/index.js";
15
+ import { TtNavAnchor as h } from "./components/tt-nav-anchor/index.js";
16
16
  import { TtApiComponent as g } from "./components/tt-api-component/index.js";
17
17
  import * as e from "./directives/index.js";
18
18
  import { setup as M } from "./hooks/useSetup.js";
@@ -27,36 +27,36 @@ import { setXHR as ir } from "./utils/xhr.js";
27
27
  import { default as xr } from "./components/tt-area/TtArea.vue.js";
28
28
  import { useModalForm as ur } from "./components/tt-modal-form/useModalForm.js";
29
29
  import { TtLoading as nr } from "./components/tt-loading/index.js";
30
- import { TtTable as br, TtTableAction as wr, TtTableButton as hr } from "./components/tt-table/index.js";
30
+ import { TtTable as br, TtTableAction as wr, TtTableButton as Rr } from "./components/tt-table/index.js";
31
31
  import { useFormSchemasLink as gr } from "./hooks/useFormSchemasLink.js";
32
32
  import { useDataPermissionOptions as Sr } from "./hooks/useDataPermissionOptions.js";
33
33
  import { useBasicDataOptions as Cr } from "./hooks/useBasicDataOptions.js";
34
34
  import { usePanelSelectSchemas as Fr } from "./hooks/usePanelSelectSchemas.js";
35
- import { CODES as Or } from "./hooks/basicDataCodes.js";
36
- import { useFormat as Er } from "./hooks/useFormat.js";
35
+ import { CODES as Pr, GROUP_BY as Lr } from "./hooks/basicDataCodes.js";
36
+ import { useFormat as Ir } from "./hooks/useFormat.js";
37
37
  import { useLoading as vr } from "./hooks/useLoading.js";
38
- import { useScreenshotOss as Br } from "./hooks/useScreenshotOss.js";
38
+ import { useScreenshotOss as Nr } from "./hooks/useScreenshotOss.js";
39
39
  import { setupDrawer as D } from "./components/tt-drawer/src/index.js";
40
- import { useShowDrawer as kr } from "./components/tt-drawer/src/index.js";
40
+ import { useShowDrawer as Ur } from "./components/tt-drawer/src/index.js";
41
41
  import { setupModal as F } from "./components/tt-modal/src/index.js";
42
- import { useShowModal as Ur } from "./components/tt-modal/src/index.js";
42
+ import { useShowModal as _r } from "./components/tt-modal/src/index.js";
43
43
  import { default as jr } from "./directives/disabled-tip/index.js";
44
44
  import { default as Hr } from "./directives/auto-tip/index.js";
45
- import { showTtDrawer as Xr, useDrawerRender as Zr } from "./components/tt-drawer/src/hooks/useDrawerRender.js";
45
+ import { showTtDrawer as Xr, useDrawerRender as Yr } from "./components/tt-drawer/src/hooks/useDrawerRender.js";
46
46
  import { useDrawerResizable as qr } from "./components/tt-drawer/src/hooks/useResizable.js";
47
47
  import { showTtModal as Kr, useModalRender as Qr } from "./components/tt-modal/src/hooks/useModalRender.js";
48
- import { default as Yr } from "./directives/dialog-resize/index.js";
48
+ import { default as ro } from "./directives/dialog-resize/index.js";
49
49
  import * as rr from "zod";
50
- import { useGroupForm as oo } from "./components/tt-form/src/group-form/useGroupForm.js";
51
- import { COMPONENT_MAP as to } from "./components/tt-form/src/config.js";
52
- import { useForm as ao } from "./components/tt-form/src/useForm.js";
53
- import { TtImageViewer as po } from "./components/tt-image/src/components/ImageViewer.js";
54
- import { vTtLoading as io } from "./components/tt-loading/src/directive.js";
55
- import { Loading as To } from "./components/tt-loading/src/service.js";
56
- import { useTableContext as lo, useTableFormContext as no } from "./components/tt-table/src/hooks/useTableContext.js";
57
- import { useTableFormRender as bo, useTableRender as wo } from "./components/tt-table/src/hooks/useTableRender.js";
58
- import { ttUploadProps as Ro } from "./components/tt-upload/src/typing.js";
59
- const L = [
50
+ import { useGroupForm as eo } from "./components/tt-form/src/group-form/useGroupForm.js";
51
+ import { COMPONENT_MAP as mo } from "./components/tt-form/src/config.js";
52
+ import { useForm as fo } from "./components/tt-form/src/useForm.js";
53
+ import { TtImageViewer as so } from "./components/tt-image/src/components/ImageViewer.js";
54
+ import { vTtLoading as xo } from "./components/tt-loading/src/directive.js";
55
+ import { Loading as uo } from "./components/tt-loading/src/service.js";
56
+ import { useTableContext as no, useTableFormContext as co } from "./components/tt-table/src/hooks/useTableContext.js";
57
+ import { useTableFormRender as wo, useTableRender as Ro } from "./components/tt-table/src/hooks/useTableRender.js";
58
+ import { ttUploadProps as go } from "./components/tt-upload/src/typing.js";
59
+ const O = [
60
60
  a,
61
61
  n,
62
62
  c,
@@ -67,16 +67,16 @@ const L = [
67
67
  f,
68
68
  d,
69
69
  l,
70
- h,
71
70
  R,
71
+ h,
72
72
  T,
73
73
  u,
74
74
  g,
75
75
  S,
76
76
  A,
77
77
  C
78
- ], O = (r) => {
79
- L.forEach((o) => r.use(o)), Object.keys(e).forEach((o) => {
78
+ ], P = (r) => {
79
+ O.forEach((o) => r.use(o)), Object.keys(e).forEach((o) => {
80
80
  const t = e[o], m = o.replace(/([A-Z])/g, "-$1").toLowerCase();
81
81
  r.directive(m, t);
82
82
  }), D(r), F(r);
@@ -89,7 +89,7 @@ const er = {
89
89
  * 安装组件
90
90
  * @param app Vue 应用实例
91
91
  */
92
- install: O,
92
+ install: P,
93
93
  /**
94
94
  * 全局参数设置
95
95
  * @param options 全局参数
@@ -98,9 +98,10 @@ const er = {
98
98
  setup: M
99
99
  };
100
100
  export {
101
- Or as CODES,
102
- to as COMPONENT_MAP,
103
- To as Loading,
101
+ Pr as CODES,
102
+ mo as COMPONENT_MAP,
103
+ Lr as GROUP_BY,
104
+ uo as Loading,
104
105
  n as RenderDrawer,
105
106
  c as RenderModal,
106
107
  ar as TtAddButton,
@@ -112,24 +113,24 @@ export {
112
113
  p as TtEmpty,
113
114
  x as TtIcon,
114
115
  l as TtImage,
115
- po as TtImageViewer,
116
+ so as TtImageViewer,
116
117
  nr as TtLoading,
117
118
  S as TtLog,
118
119
  pr as TtModal,
119
- R as TtNavAnchor,
120
+ h as TtNavAnchor,
120
121
  A as TtPanelSelect,
121
122
  C as TtRadioGroup,
122
123
  b as TtSelect,
123
124
  u as TtSubIcon,
124
125
  br as TtTable,
125
126
  wr as TtTableAction,
126
- hr as TtTableButton,
127
+ Rr as TtTableButton,
127
128
  w as TtText,
128
- h as TtUpload,
129
+ R as TtUpload,
129
130
  s as addComponent,
130
131
  Hr as autoTip,
131
132
  er as default,
132
- Yr as dialogResize,
133
+ ro as dialogResize,
133
134
  jr as disabledTip,
134
135
  or as formAdapter,
135
136
  i as setConfig,
@@ -138,26 +139,26 @@ export {
138
139
  F as setupModal,
139
140
  Xr as showTtDrawer,
140
141
  Kr as showTtModal,
141
- Ro as ttUploadProps,
142
+ go as ttUploadProps,
142
143
  Cr as useBasicDataOptions,
143
144
  Sr as useDataPermissionOptions,
144
- Zr as useDrawerRender,
145
+ Yr as useDrawerRender,
145
146
  qr as useDrawerResizable,
146
- ao as useForm,
147
+ fo as useForm,
147
148
  gr as useFormSchemasLink,
148
- Er as useFormat,
149
- oo as useGroupForm,
149
+ Ir as useFormat,
150
+ eo as useGroupForm,
150
151
  vr as useLoading,
151
152
  ur as useModalForm,
152
153
  Qr as useModalRender,
153
154
  Fr as usePanelSelectSchemas,
154
- Br as useScreenshotOss,
155
- kr as useShowDrawer,
156
- Ur as useShowModal,
157
- lo as useTableContext,
158
- no as useTableFormContext,
159
- bo as useTableFormRender,
160
- wo as useTableRender,
161
- io as vTtLoading,
155
+ Nr as useScreenshotOss,
156
+ Ur as useShowDrawer,
157
+ _r as useShowModal,
158
+ no as useTableContext,
159
+ co as useTableFormContext,
160
+ wo as useTableFormRender,
161
+ Ro as useTableRender,
162
+ xo as vTtLoading,
162
163
  rr as z
163
164
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dazhicheng/ui",
3
- "version": "1.5.244",
3
+ "version": "1.5.245",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",