@dazhicheng/ui 1.5.243 → 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.
@@ -0,0 +1,33 @@
1
+ /** 航司基础信息 */
2
+ export type BasicAirlineItem = {
3
+ airlineCode?: string;
4
+ airlineNameCn?: string;
5
+ [key: string]: any;
6
+ };
7
+ /** 机场区域完整信息(洲/区域/国家/城市/机场) */
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;
17
+ airportCode?: string;
18
+ airportName?: string;
19
+ [key: string]: any;
20
+ };
21
+ /** 获取所有航司信息列表 GET /basicAirline/getAll */
22
+ export declare function getAllBasicAirline(options?: {
23
+ [key: string]: any;
24
+ }): Promise<BasicAirlineItem[]>;
25
+ /**
26
+ * 按类型查询区域机场链路列表 GET /airportRegionLevel/listChainByType
27
+ * type:1-洲,2-区域,3-国家,4-城市,5-机场
28
+ */
29
+ export declare function listChainByTypeAirportRegionLevel(params: {
30
+ type: number;
31
+ }, options?: {
32
+ [key: string]: any;
33
+ }): Promise<AirportRegionItem[]>;
@@ -0,0 +1,16 @@
1
+ import { request as e } from "../utils/xhr.js";
2
+ async function r(i) {
3
+ return e.get({
4
+ url: "/basic/basicAirline/getAll"
5
+ });
6
+ }
7
+ async function o(i, t) {
8
+ return e.get({
9
+ url: "/basic/airportRegionLevel/listChainByType",
10
+ params: i
11
+ });
12
+ }
13
+ export {
14
+ r as getAllBasicAirline,
15
+ o as listChainByTypeAirportRegionLevel
16
+ };
@@ -1,7 +1,7 @@
1
1
  import o from "./TtArea.vue3.js";
2
2
  /* empty css */
3
3
  import t from "../../_virtual/_plugin-vue_export-helper.js";
4
- const m = /* @__PURE__ */ t(o, [["__scopeId", "data-v-116cb5cb"]]);
4
+ const m = /* @__PURE__ */ t(o, [["__scopeId", "data-v-b814e001"]]);
5
5
  export {
6
6
  m as default
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import r from "./DrawerHeader.vue2.js";
2
2
  /* empty css */
3
3
  import o from "../../../../_virtual/_plugin-vue_export-helper.js";
4
- const f = /* @__PURE__ */ o(r, [["__scopeId", "data-v-6cdf82e0"]]);
4
+ const c = /* @__PURE__ */ o(r, [["__scopeId", "data-v-9b698cc3"]]);
5
5
  export {
6
- f as default
6
+ c as default
7
7
  };
@@ -2,7 +2,7 @@ import o from "./index.vue2.js";
2
2
  /* empty css */
3
3
  /* empty css */
4
4
  import t from "../../_virtual/_plugin-vue_export-helper.js";
5
- const a = /* @__PURE__ */ t(o, [["__scopeId", "data-v-d731bb93"]]);
5
+ const _ = /* @__PURE__ */ t(o, [["__scopeId", "data-v-6dba01d4"]]);
6
6
  export {
7
- a as default
7
+ _ as default
8
8
  };
@@ -1,7 +1,7 @@
1
1
  import o from "./loading.vue2.js";
2
2
  /* empty css */
3
3
  import t from "../../../_virtual/_plugin-vue_export-helper.js";
4
- const r = /* @__PURE__ */ t(o, [["__scopeId", "data-v-7e6228e4"]]);
4
+ const a = /* @__PURE__ */ t(o, [["__scopeId", "data-v-5d760747"]]);
5
5
  export {
6
- r as default
6
+ a as default
7
7
  };
@@ -75,8 +75,8 @@ declare function __VLS_template(): {
75
75
  $refs: {
76
76
  [x: string]: unknown;
77
77
  } & {
78
- vxelist: (import('vxe-pc-ui').VxeListMethods<any> & {
79
- $props: import('vxe-pc-ui').VxeListProps<any> & import('vxe-pc-ui').VxeListEventProps<any>;
78
+ vxelist: (import('vxe-pc-ui').VxeListMethods & {
79
+ $props: import('vxe-pc-ui').VxeListProps<any> & import('vxe-pc-ui').VxeListEventProps;
80
80
  $slots: import('vxe-pc-ui').VxeListSlots;
81
81
  }) | null;
82
82
  table: HTMLTableElement;
@@ -570,8 +570,8 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
570
570
  $refs: {
571
571
  [x: string]: unknown;
572
572
  } & {
573
- vxelist: (import('vxe-pc-ui').VxeListMethods<any> & {
574
- $props: import('vxe-pc-ui').VxeListProps<any> & import('vxe-pc-ui').VxeListEventProps<any>;
573
+ vxelist: (import('vxe-pc-ui').VxeListMethods & {
574
+ $props: import('vxe-pc-ui').VxeListProps<any> & import('vxe-pc-ui').VxeListEventProps;
575
575
  $slots: import('vxe-pc-ui').VxeListSlots;
576
576
  }) | null;
577
577
  table: HTMLTableElement;
@@ -32,8 +32,8 @@ declare function __VLS_template(): {
32
32
  empty: () => VNode;
33
33
  };
34
34
  refs: {
35
- vxelist: (import('vxe-pc-ui').VxeListMethods<any> & {
36
- $props: VxeListProps<any> & import('vxe-pc-ui').VxeListEventProps<any>;
35
+ vxelist: (import('vxe-pc-ui').VxeListMethods & {
36
+ $props: VxeListProps<any> & import('vxe-pc-ui').VxeListEventProps;
37
37
  $slots: import('vxe-pc-ui').VxeListSlots;
38
38
  }) | null;
39
39
  table: HTMLTableElement;
@@ -234,8 +234,8 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
234
234
  hasNextPage: boolean;
235
235
  showCheckbox: boolean;
236
236
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
237
- vxelist: (import('vxe-pc-ui').VxeListMethods<any> & {
238
- $props: VxeListProps<any> & import('vxe-pc-ui').VxeListEventProps<any>;
237
+ vxelist: (import('vxe-pc-ui').VxeListMethods & {
238
+ $props: VxeListProps<any> & import('vxe-pc-ui').VxeListEventProps;
239
239
  $slots: import('vxe-pc-ui').VxeListSlots;
240
240
  }) | null;
241
241
  table: HTMLTableElement;
@@ -412,15 +412,14 @@ export declare const TtTable: import('../../../../utils/src').SFCWithInstall<{
412
412
  pagerConfig: import("vxe-table").VxeGridPropTypes.PagerConfig | undefined;
413
413
  showPager: any;
414
414
  showCheckbox: any;
415
- showRadio: any;
416
- radioConfig: import("vxe-table").VxeTablePropTypes.RadioConfig<import("vxe-table").VxeTablePropTypes.Row>;
417
- checkboxConfig: import("vxe-table").VxeTablePropTypes.CheckboxConfig<import("vxe-table").VxeTablePropTypes.Row>;
418
- menuConfig: import("vxe-table").VxeTablePropTypes.MenuConfig<any>;
419
415
  columns: import('vue').MaybeRef<import("vxe-table").VxeTableDefines.ColumnOptions<any>[]> | undefined;
420
416
  toolbarConfig: import("vxe-table").VxeGridPropTypes.ToolbarConfig | undefined;
421
417
  zoomConfig: import("vxe-table").VxeGridPropTypes.ZoomConfig | undefined;
422
418
  showOverflow: import("vxe-table").VxeTablePropTypes.ShowOverflow | undefined;
423
419
  showHeaderOverflow: import("vxe-table").VxeTablePropTypes.ShowOverflow | undefined;
420
+ radioConfig: import("vxe-table").VxeTablePropTypes.RadioConfig<import("vxe-table").VxeTablePropTypes.Row>;
421
+ checkboxConfig: import("vxe-table").VxeTablePropTypes.CheckboxConfig<import("vxe-table").VxeTablePropTypes.Row>;
422
+ menuConfig: import("vxe-table").VxeTablePropTypes.MenuConfig<any>;
424
423
  mouseConfig: import("vxe-table").VxeTablePropTypes.MouseConfig;
425
424
  keyboardConfig: import("vxe-table").VxeTablePropTypes.KeyboardConfig<any>;
426
425
  emptyText: string;
@@ -437,6 +436,7 @@ export declare const TtTable: import('../../../../utils/src').SFCWithInstall<{
437
436
  showRefresh: boolean;
438
437
  columnsKey: string | (() => string);
439
438
  showExpand: any;
439
+ showRadio: any;
440
440
  showIndex: any;
441
441
  isCellResize: any;
442
442
  isColumnsDrag: any;
@@ -1044,15 +1044,14 @@ export declare const TtTable: import('../../../../utils/src').SFCWithInstall<{
1044
1044
  pagerConfig: import("vxe-table").VxeGridPropTypes.PagerConfig | undefined;
1045
1045
  showPager: any;
1046
1046
  showCheckbox: any;
1047
- showRadio: any;
1048
- radioConfig: import("vxe-table").VxeTablePropTypes.RadioConfig<import("vxe-table").VxeTablePropTypes.Row>;
1049
- checkboxConfig: import("vxe-table").VxeTablePropTypes.CheckboxConfig<import("vxe-table").VxeTablePropTypes.Row>;
1050
- menuConfig: import("vxe-table").VxeTablePropTypes.MenuConfig<any>;
1051
1047
  columns: import('vue').MaybeRef<import("vxe-table").VxeTableDefines.ColumnOptions<any>[]> | undefined;
1052
1048
  toolbarConfig: import("vxe-table").VxeGridPropTypes.ToolbarConfig | undefined;
1053
1049
  zoomConfig: import("vxe-table").VxeGridPropTypes.ZoomConfig | undefined;
1054
1050
  showOverflow: import("vxe-table").VxeTablePropTypes.ShowOverflow | undefined;
1055
1051
  showHeaderOverflow: import("vxe-table").VxeTablePropTypes.ShowOverflow | undefined;
1052
+ radioConfig: import("vxe-table").VxeTablePropTypes.RadioConfig<import("vxe-table").VxeTablePropTypes.Row>;
1053
+ checkboxConfig: import("vxe-table").VxeTablePropTypes.CheckboxConfig<import("vxe-table").VxeTablePropTypes.Row>;
1054
+ menuConfig: import("vxe-table").VxeTablePropTypes.MenuConfig<any>;
1056
1055
  mouseConfig: import("vxe-table").VxeTablePropTypes.MouseConfig;
1057
1056
  keyboardConfig: import("vxe-table").VxeTablePropTypes.KeyboardConfig<any>;
1058
1057
  emptyText: string;
@@ -1069,6 +1068,7 @@ export declare const TtTable: import('../../../../utils/src').SFCWithInstall<{
1069
1068
  showRefresh: boolean;
1070
1069
  columnsKey: string | (() => string);
1071
1070
  showExpand: any;
1071
+ showRadio: any;
1072
1072
  showIndex: any;
1073
1073
  isCellResize: any;
1074
1074
  isColumnsDrag: any;
@@ -1409,15 +1409,14 @@ export declare const TtTable: import('../../../../utils/src').SFCWithInstall<{
1409
1409
  pagerConfig: import("vxe-table").VxeGridPropTypes.PagerConfig | undefined;
1410
1410
  showPager: any;
1411
1411
  showCheckbox: any;
1412
- showRadio: any;
1413
- radioConfig: import("vxe-table").VxeTablePropTypes.RadioConfig<import("vxe-table").VxeTablePropTypes.Row>;
1414
- checkboxConfig: import("vxe-table").VxeTablePropTypes.CheckboxConfig<import("vxe-table").VxeTablePropTypes.Row>;
1415
- menuConfig: import("vxe-table").VxeTablePropTypes.MenuConfig<any>;
1416
1412
  columns: import('vue').MaybeRef<import("vxe-table").VxeTableDefines.ColumnOptions<any>[]> | undefined;
1417
1413
  toolbarConfig: import("vxe-table").VxeGridPropTypes.ToolbarConfig | undefined;
1418
1414
  zoomConfig: import("vxe-table").VxeGridPropTypes.ZoomConfig | undefined;
1419
1415
  showOverflow: import("vxe-table").VxeTablePropTypes.ShowOverflow | undefined;
1420
1416
  showHeaderOverflow: import("vxe-table").VxeTablePropTypes.ShowOverflow | undefined;
1417
+ radioConfig: import("vxe-table").VxeTablePropTypes.RadioConfig<import("vxe-table").VxeTablePropTypes.Row>;
1418
+ checkboxConfig: import("vxe-table").VxeTablePropTypes.CheckboxConfig<import("vxe-table").VxeTablePropTypes.Row>;
1419
+ menuConfig: import("vxe-table").VxeTablePropTypes.MenuConfig<any>;
1421
1420
  mouseConfig: import("vxe-table").VxeTablePropTypes.MouseConfig;
1422
1421
  keyboardConfig: import("vxe-table").VxeTablePropTypes.KeyboardConfig<any>;
1423
1422
  emptyText: string;
@@ -1434,6 +1433,7 @@ export declare const TtTable: import('../../../../utils/src').SFCWithInstall<{
1434
1433
  showRefresh: boolean;
1435
1434
  columnsKey: string | (() => string);
1436
1435
  showExpand: any;
1436
+ showRadio: any;
1437
1437
  showIndex: any;
1438
1438
  isCellResize: any;
1439
1439
  isColumnsDrag: any;
@@ -58,14 +58,15 @@ import "../tt-log/index.js";
58
58
  /* empty css */
59
59
  import "../tt-loading/index.js";
60
60
  import "vue-router";
61
+ import "../../hooks/basicDataCodes.js";
61
62
  import "numeral";
62
63
  import "sortablejs";
63
64
  /* empty css */
64
65
  import "./src/emits.js";
65
66
  import "./src/props.js";
66
- const _t = t(o), ut = t(r), Bt = t(m);
67
+ const ut = t(o), Bt = t(r), ht = t(m);
67
68
  export {
68
- Bt as TtTable,
69
- _t as TtTableAction,
70
- ut as TtTableButton
69
+ ht as TtTable,
70
+ ut as TtTableAction,
71
+ Bt as TtTableButton
71
72
  };
@@ -809,15 +809,14 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
809
809
  pagerConfig: import("vxe-table").VxeGridPropTypes.PagerConfig | undefined;
810
810
  showPager: any;
811
811
  showCheckbox: any;
812
- showRadio: any;
813
- radioConfig: import("vxe-table").VxeTablePropTypes.RadioConfig<import("vxe-table").VxeTablePropTypes.Row>;
814
- checkboxConfig: import("vxe-table").VxeTablePropTypes.CheckboxConfig<import("vxe-table").VxeTablePropTypes.Row>;
815
- menuConfig: import("vxe-table").VxeTablePropTypes.MenuConfig<any>;
816
812
  columns: import('vue').MaybeRef<VxeTableDefines.ColumnOptions<any>[]> | undefined;
817
813
  toolbarConfig: import("vxe-table").VxeGridPropTypes.ToolbarConfig | undefined;
818
814
  zoomConfig: import("vxe-table").VxeGridPropTypes.ZoomConfig | undefined;
819
815
  showOverflow: import("vxe-table").VxeTablePropTypes.ShowOverflow | undefined;
820
816
  showHeaderOverflow: import("vxe-table").VxeTablePropTypes.ShowOverflow | undefined;
817
+ radioConfig: import("vxe-table").VxeTablePropTypes.RadioConfig<import("vxe-table").VxeTablePropTypes.Row>;
818
+ checkboxConfig: import("vxe-table").VxeTablePropTypes.CheckboxConfig<import("vxe-table").VxeTablePropTypes.Row>;
819
+ menuConfig: import("vxe-table").VxeTablePropTypes.MenuConfig<any>;
821
820
  mouseConfig: import("vxe-table").VxeTablePropTypes.MouseConfig;
822
821
  keyboardConfig: import("vxe-table").VxeTablePropTypes.KeyboardConfig<any>;
823
822
  emptyText: string;
@@ -834,6 +833,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
834
833
  showRefresh: boolean;
835
834
  columnsKey: string | (() => string);
836
835
  showExpand: any;
836
+ showRadio: any;
837
837
  showIndex: any;
838
838
  isCellResize: any;
839
839
  isColumnsDrag: any;
@@ -58,6 +58,7 @@ import "../../tt-log/index.js";
58
58
  import "../../tt-loading/index.js";
59
59
  import "../index.js";
60
60
  import "vue-router";
61
+ import "../../../hooks/basicDataCodes.js";
61
62
  import "numeral";
62
63
  import Ue from "./components/TableColumnModal.vue2.js";
63
64
  /* empty css */
@@ -73,7 +74,7 @@ import { useTableSlot as Ze } from "./hooks/useTableSlot.js";
73
74
  import { tableFormProps as et } from "./props.js";
74
75
  import { getDefaultState as tt } from "./utils/table-api.js";
75
76
  import { TableFormApi as ot } from "./utils/table-form-api.js";
76
- const rt = ["data-testid"], st = ["data-testid"], Mo = /* @__PURE__ */ Me({
77
+ const rt = ["data-testid"], st = ["data-testid"], Eo = /* @__PURE__ */ Me({
77
78
  name: "TtTableForm",
78
79
  __name: "TableForm",
79
80
  props: et,
@@ -380,5 +381,5 @@ const rt = ["data-testid"], st = ["data-testid"], Mo = /* @__PURE__ */ Me({
380
381
  }
381
382
  });
382
383
  export {
383
- Mo as default
384
+ Eo as default
384
385
  };
@@ -0,0 +1,57 @@
1
+ /**
2
+ * 基础数据 code 常量,页面传入 hooks 时使用。
3
+ * 区域层级 type:1-洲,2-区域,3-国家,4-城市,5-机场
4
+ */
5
+ export declare const CODES: {
6
+ readonly AIRLINE: "airline";
7
+ readonly CONTINENT: "continent";
8
+ readonly REGION: "region";
9
+ readonly COUNTRY: "country";
10
+ readonly CITY: "city";
11
+ readonly AIRPORT: "airport";
12
+ };
13
+ export type BasicDataCode = (typeof CODES)[keyof typeof CODES];
14
+ export type BasicDataOption = {
15
+ label: string;
16
+ value: string | number;
17
+ children?: BasicDataOption[];
18
+ [key: string]: any;
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;
39
+ export type BasicDataCodeRegistryItem = {
40
+ /** 默认表单字段名 */
41
+ defaultFieldName: string;
42
+ /** 默认标签 */
43
+ defaultLabel: string;
44
+ /** 排除字段默认标签 */
45
+ defaultExcludeLabel: string;
46
+ /** 默认是否多选 */
47
+ defaultMultiple: boolean;
48
+ /** 默认是否展示「全部」 */
49
+ defaultShowAll: boolean;
50
+ /** 拉取并归一化为 label/value 选项 */
51
+ fetchOptions: () => Promise<BasicDataOption[]>;
52
+ };
53
+ /**
54
+ * code → 接口与默认展示配置。
55
+ * 后续扩展航线/舱位等,只需在此追加。
56
+ */
57
+ export declare const CODE_REGISTRY: Record<BasicDataCode, BasicDataCodeRegistryItem>;
@@ -0,0 +1,161 @@
1
+ import { getAllBasicAirline as N, listChainByTypeAirportRegionLevel as C } from "../api/basicData.js";
2
+ const d = {
3
+ AIRLINE: "airline",
4
+ CONTINENT: "continent",
5
+ REGION: "region",
6
+ COUNTRY: "country",
7
+ CITY: "city",
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" }
18
+ };
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
54
+ }));
55
+ }
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]
86
+ }));
87
+ }
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]: {
100
+ defaultFieldName: "airlineCodes",
101
+ defaultLabel: "航司",
102
+ defaultExcludeLabel: "排除航司",
103
+ defaultMultiple: !0,
104
+ defaultShowAll: !0,
105
+ async fetchOptions() {
106
+ try {
107
+ const e = await N();
108
+ return O(e || []);
109
+ } catch {
110
+ return [];
111
+ }
112
+ }
113
+ },
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]: {
147
+ defaultFieldName: "airportCodes",
148
+ defaultLabel: "机场",
149
+ defaultExcludeLabel: "排除机场",
150
+ defaultMultiple: !0,
151
+ defaultShowAll: !1,
152
+ fetchOptions: s(5, "airportCode", "airportName")
153
+ }
154
+ };
155
+ export {
156
+ d as CODES,
157
+ g as CODE_REGISTRY,
158
+ i as GROUP_BY,
159
+ R as groupBasicDataOptions,
160
+ L as resolveDefaultGroupBy
161
+ };
@@ -0,0 +1,22 @@
1
+ import { MaybeRef, Ref } from 'vue';
2
+ import { BasicDataCode, BasicDataOption } from './basicDataCodes';
3
+ export type BasicDataOptionsMap = Partial<Record<BasicDataCode, BasicDataOption[]>>;
4
+ export interface UseBasicDataOptionsParams {
5
+ codes: BasicDataCode[];
6
+ /** 外部数据源。未传时按 codes 走 CODE_REGISTRY 请求。 */
7
+ dataSource?: MaybeRef<BasicDataOptionsMap | undefined>;
8
+ }
9
+ /**
10
+ * 按基础数据 code 拉取并缓存 options。
11
+ * 接口失败或返回非数组时兜底为空数组,不影响表单 schema 生成与渲染。
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const { dataSource } = useBasicDataOptions({ codes: [CODES.AIRLINE, CODES.AIRPORT] });
16
+ * dataSource.value.airline
17
+ * ```
18
+ */
19
+ export declare function useBasicDataOptions(options: UseBasicDataOptionsParams): {
20
+ dataSource: Ref<Record<BasicDataCode, BasicDataOption[]>>;
21
+ reload: () => Promise<void>;
22
+ };
@@ -0,0 +1,110 @@
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),
16
+ {}
17
+ );
18
+ }
19
+ u();
20
+ async function O(r) {
21
+ return (await Promise.allSettled(
22
+ r.map(async (t) => {
23
+ try {
24
+ const o = await b[t].fetchOptions();
25
+ return [t, g(o)];
26
+ } catch {
27
+ return [t, []];
28
+ }
29
+ })
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;
33
+ }, {});
34
+ }
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);
43
+ return;
44
+ }
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);
73
+ }
74
+ }
75
+ async function S() {
76
+ const r = s.path;
77
+ y.clear(), n.clear(), h.clear(), n.delete(r), await w(!0);
78
+ }
79
+ return R(() => {
80
+ const r = D(c.dataSource);
81
+ if (!r) return;
82
+ const e = s.path, a = { ...n.get(e) || {}, ...r };
83
+ n.set(e, a), u(a);
84
+ }), q(
85
+ () => s.path,
86
+ () => {
87
+ w();
88
+ },
89
+ { immediate: !0 }
90
+ ), {
91
+ dataSource: x(() => {
92
+ const r = c.codes.reduce(
93
+ (e, t) => (e[t] = g(l.value[t]), e),
94
+ {}
95
+ );
96
+ return new Proxy(r, {
97
+ get(e, t) {
98
+ return typeof t != "string" ? [] : g(r[t]);
99
+ },
100
+ set() {
101
+ return !1;
102
+ }
103
+ });
104
+ }),
105
+ reload: S
106
+ };
107
+ }
108
+ export {
109
+ _ as useBasicDataOptions
110
+ };