@dazhicheng/ui 1.5.245 → 1.5.247
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/dist/api/basicData.d.ts +25 -0
- package/dist/api/basicData.js +12 -5
- package/dist/hooks/basicDataCodes.d.ts +23 -1
- package/dist/hooks/basicDataCodes.js +151 -75
- package/dist/hooks/useBasicDataOptions.js +46 -44
- package/dist/hooks/usePanelSelectSchemas.d.ts +2 -0
- package/dist/hooks/usePanelSelectSchemas.js +87 -78
- package/package.json +3 -3
package/dist/api/basicData.d.ts
CHANGED
|
@@ -31,3 +31,28 @@ export declare function listChainByTypeAirportRegionLevel(params: {
|
|
|
31
31
|
}, options?: {
|
|
32
32
|
[key: string]: any;
|
|
33
33
|
}): Promise<AirportRegionItem[]>;
|
|
34
|
+
/** 系统字典项 */
|
|
35
|
+
export type SysDictItem = {
|
|
36
|
+
id?: number;
|
|
37
|
+
dictCode?: string;
|
|
38
|
+
itemCode?: string;
|
|
39
|
+
itemName?: string;
|
|
40
|
+
itemOrder?: number;
|
|
41
|
+
parentItemCode?: string;
|
|
42
|
+
status?: number;
|
|
43
|
+
remark?: string;
|
|
44
|
+
[key: string]: any;
|
|
45
|
+
};
|
|
46
|
+
/** 按字典编码批量查询字典项入参 */
|
|
47
|
+
export type SysDictItemByCodesQry = {
|
|
48
|
+
permissionOnlyCode?: string;
|
|
49
|
+
dictCodeList?: string[];
|
|
50
|
+
status?: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* 根据权限编码和多个字典编码获取系统字典枚举项
|
|
54
|
+
* POST /sysDictItem/getDictItemsByCodes
|
|
55
|
+
*/
|
|
56
|
+
export declare function getDictItemsByCodes(body: SysDictItemByCodesQry, options?: {
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
}): Promise<Record<string, SysDictItem[]>>;
|
package/dist/api/basicData.js
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { request as e } from "../utils/xhr.js";
|
|
2
|
-
async function
|
|
2
|
+
async function n(t) {
|
|
3
3
|
return e.get({
|
|
4
4
|
url: "/basic/basicAirline/getAll"
|
|
5
5
|
});
|
|
6
6
|
}
|
|
7
|
-
async function
|
|
7
|
+
async function r(t, i) {
|
|
8
8
|
return e.get({
|
|
9
9
|
url: "/basic/airportRegionLevel/listChainByType",
|
|
10
|
-
params:
|
|
10
|
+
params: t
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
async function o(t, i) {
|
|
14
|
+
return e.post({
|
|
15
|
+
url: "/basic/sysDictItem/getDictItemsByCodes",
|
|
16
|
+
params: t
|
|
11
17
|
});
|
|
12
18
|
}
|
|
13
19
|
export {
|
|
14
|
-
|
|
15
|
-
o as
|
|
20
|
+
n as getAllBasicAirline,
|
|
21
|
+
o as getDictItemsByCodes,
|
|
22
|
+
r as listChainByTypeAirportRegionLevel
|
|
16
23
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 基础数据 code 常量,页面传入 hooks 时使用。
|
|
3
3
|
* 区域层级 type:1-洲,2-区域,3-国家,4-城市,5-机场
|
|
4
|
+
* 字典类:SALES_ORDER_TYPE / SALES_ORDER_PRODUCT_TYPE 对应 sysDictItem 字典编码
|
|
4
5
|
*/
|
|
5
6
|
export declare const CODES: {
|
|
6
7
|
readonly AIRLINE: "airline";
|
|
@@ -9,6 +10,10 @@ export declare const CODES: {
|
|
|
9
10
|
readonly COUNTRY: "country";
|
|
10
11
|
readonly CITY: "city";
|
|
11
12
|
readonly AIRPORT: "airport";
|
|
13
|
+
/** 订单类型(字典 SALES_ORDER_TYPE) */
|
|
14
|
+
readonly SALES_ORDER_TYPE: "SALES_ORDER_TYPE";
|
|
15
|
+
/** 产品类型(字典 SALES_ORDER_PRODUCT_TYPE) */
|
|
16
|
+
readonly SALES_ORDER_PRODUCT_TYPE: "SALES_ORDER_PRODUCT_TYPE";
|
|
12
17
|
};
|
|
13
18
|
export type BasicDataCode = (typeof CODES)[keyof typeof CODES];
|
|
14
19
|
export type BasicDataOption = {
|
|
@@ -36,6 +41,19 @@ export type PanelSelectGroupBy = (typeof GROUP_BY)[keyof typeof GROUP_BY];
|
|
|
36
41
|
export declare function groupBasicDataOptions(options: BasicDataOption[], groupBy: PanelSelectGroupBy): BasicDataOption[];
|
|
37
42
|
/** 机场默认按国家分组;其余默认拼音 */
|
|
38
43
|
export declare function resolveDefaultGroupBy(code: BasicDataCode, groupBy?: PanelSelectGroupBy): PanelSelectGroupBy;
|
|
44
|
+
export type BasicDataFetchContext = {
|
|
45
|
+
/** 当前路由 permissionOnlyCode,字典接口按权限过滤时使用 */
|
|
46
|
+
permissionOnlyCode?: string;
|
|
47
|
+
};
|
|
48
|
+
export type BasicDataTreeConfig = {
|
|
49
|
+
transform?: boolean;
|
|
50
|
+
labelField?: string;
|
|
51
|
+
valueField?: string;
|
|
52
|
+
parentField?: string;
|
|
53
|
+
childrenField?: string;
|
|
54
|
+
disabledField?: string;
|
|
55
|
+
rootParentValue?: string | number | null;
|
|
56
|
+
};
|
|
39
57
|
export type BasicDataCodeRegistryItem = {
|
|
40
58
|
/** 默认表单字段名 */
|
|
41
59
|
defaultFieldName: string;
|
|
@@ -47,8 +65,12 @@ export type BasicDataCodeRegistryItem = {
|
|
|
47
65
|
defaultMultiple: boolean;
|
|
48
66
|
/** 默认是否展示「全部」 */
|
|
49
67
|
defaultShowAll: boolean;
|
|
68
|
+
/** 默认是否展示左侧导航 */
|
|
69
|
+
defaultShowNav?: boolean;
|
|
70
|
+
/** 默认树配置(如产品类型父子字典);有值时关闭拼音分组 */
|
|
71
|
+
defaultTreeConfig?: BasicDataTreeConfig;
|
|
50
72
|
/** 拉取并归一化为 label/value 选项 */
|
|
51
|
-
fetchOptions: () => Promise<BasicDataOption[]>;
|
|
73
|
+
fetchOptions: (ctx?: BasicDataFetchContext) => Promise<BasicDataOption[]>;
|
|
52
74
|
};
|
|
53
75
|
/**
|
|
54
76
|
* code → 接口与默认展示配置。
|
|
@@ -1,102 +1,149 @@
|
|
|
1
|
-
import { getAllBasicAirline as N, listChainByTypeAirportRegionLevel as
|
|
2
|
-
const
|
|
1
|
+
import { getAllBasicAirline as p, getDictItemsByCodes as N, listChainByTypeAirportRegionLevel as E } from "../api/basicData.js";
|
|
2
|
+
const u = {
|
|
3
3
|
AIRLINE: "airline",
|
|
4
4
|
CONTINENT: "continent",
|
|
5
5
|
REGION: "region",
|
|
6
6
|
COUNTRY: "country",
|
|
7
7
|
CITY: "city",
|
|
8
|
-
AIRPORT: "airport"
|
|
8
|
+
AIRPORT: "airport",
|
|
9
|
+
/** 订单类型(字典 SALES_ORDER_TYPE) */
|
|
10
|
+
SALES_ORDER_TYPE: "SALES_ORDER_TYPE",
|
|
11
|
+
/** 产品类型(字典 SALES_ORDER_PRODUCT_TYPE) */
|
|
12
|
+
SALES_ORDER_PRODUCT_TYPE: "SALES_ORDER_PRODUCT_TYPE"
|
|
9
13
|
}, i = {
|
|
10
14
|
CONTINENT: "continent",
|
|
11
15
|
REGION: "region",
|
|
12
16
|
COUNTRY: "country",
|
|
13
17
|
PINYIN: "pinyin"
|
|
14
|
-
},
|
|
18
|
+
}, O = {
|
|
15
19
|
[i.CONTINENT]: { codeKey: "continentCode", nameKey: "continentName" },
|
|
16
20
|
[i.REGION]: { codeKey: "regionCode", nameKey: "regionName" },
|
|
17
21
|
[i.COUNTRY]: { codeKey: "countryCode", nameKey: "countryName" }
|
|
18
22
|
};
|
|
19
|
-
function
|
|
20
|
-
if (!Array.isArray(
|
|
21
|
-
if (
|
|
22
|
-
const r =
|
|
23
|
-
if (!r) return
|
|
24
|
-
const
|
|
25
|
-
return
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
label:
|
|
32
|
-
value:
|
|
23
|
+
function g(t, a) {
|
|
24
|
+
if (!Array.isArray(t) || !t.length) return t || [];
|
|
25
|
+
if (a === i.PINYIN) return t;
|
|
26
|
+
const r = O[a];
|
|
27
|
+
if (!r) return t;
|
|
28
|
+
const n = /* @__PURE__ */ new Map(), d = [];
|
|
29
|
+
return t.forEach((e) => {
|
|
30
|
+
const l = e[r.codeKey], o = l != null && l !== "", s = o ? String(l) : "__unknown__";
|
|
31
|
+
if (!n.has(s)) {
|
|
32
|
+
d.push(s);
|
|
33
|
+
const c = e[r.nameKey];
|
|
34
|
+
n.set(s, {
|
|
35
|
+
label: o ? `${l}(${c || ""})` : "未知",
|
|
36
|
+
value: o ? l : "__unknown__",
|
|
33
37
|
children: []
|
|
34
38
|
});
|
|
35
39
|
}
|
|
36
|
-
|
|
37
|
-
}),
|
|
40
|
+
n.get(s).children.push(e);
|
|
41
|
+
}), d.map((e) => n.get(e));
|
|
38
42
|
}
|
|
39
|
-
function
|
|
40
|
-
return
|
|
43
|
+
function h(t, a) {
|
|
44
|
+
return a || (t === u.AIRPORT ? i.COUNTRY : i.PINYIN);
|
|
41
45
|
}
|
|
42
|
-
const
|
|
46
|
+
const R = {
|
|
43
47
|
1: { codeKey: "continentCode", nameKey: "continentName", statusKey: "continentStatus" },
|
|
44
48
|
2: { codeKey: "regionCode", nameKey: "regionName", statusKey: "regionStatus" },
|
|
45
49
|
3: { codeKey: "countryCode", nameKey: "countryName", statusKey: "countryStatus" },
|
|
46
50
|
4: { codeKey: "cityCode", nameKey: "cityName", statusKey: "cityStatus" },
|
|
47
51
|
5: { codeKey: "airportCode", nameKey: "airportName", statusKey: "airportStatus" }
|
|
48
52
|
};
|
|
49
|
-
function
|
|
50
|
-
return (Array.isArray(
|
|
51
|
-
...
|
|
52
|
-
label: `${
|
|
53
|
-
value:
|
|
53
|
+
function S(t = []) {
|
|
54
|
+
return (Array.isArray(t) ? t : []).filter((a) => a == null ? void 0 : a.airlineCode).map((a) => ({
|
|
55
|
+
...a,
|
|
56
|
+
label: `${a.airlineCode}(${a.airlineNameCn || ""})`,
|
|
57
|
+
value: a.airlineCode
|
|
54
58
|
}));
|
|
55
59
|
}
|
|
56
|
-
function
|
|
57
|
-
if (!
|
|
58
|
-
return
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
return
|
|
62
|
-
let
|
|
63
|
-
for (const
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
66
|
-
const
|
|
67
|
-
|
|
60
|
+
function A(t) {
|
|
61
|
+
if (!t || typeof t != "object" || Array.isArray(t))
|
|
62
|
+
return t || {};
|
|
63
|
+
const a = t.continentCode || t.regionCode || t.countryCode || t.cityCode || t.airportCode, r = [1, 2, 3, 4, 5].some((l) => t[String(l)] || t[l]);
|
|
64
|
+
if (a && !r)
|
|
65
|
+
return t;
|
|
66
|
+
let n = {}, d = 0;
|
|
67
|
+
for (const l of [1, 2, 3, 4, 5]) {
|
|
68
|
+
const o = t[String(l)] || t[l];
|
|
69
|
+
if (!o || typeof o != "object") continue;
|
|
70
|
+
const s = Number(o.type ?? l);
|
|
71
|
+
s >= d && (d = s, n = o);
|
|
68
72
|
}
|
|
69
|
-
const
|
|
70
|
-
for (const
|
|
71
|
-
const
|
|
72
|
-
if (!
|
|
73
|
-
const { codeKey:
|
|
74
|
-
|
|
73
|
+
const e = { ...n };
|
|
74
|
+
for (const l of [1, 2, 3, 4, 5]) {
|
|
75
|
+
const o = t[String(l)] || t[l];
|
|
76
|
+
if (!o || typeof o != "object") continue;
|
|
77
|
+
const { codeKey: s, nameKey: c, statusKey: C } = R[l];
|
|
78
|
+
o.code !== void 0 && o.code !== null && o.code !== "" && (e[s] = o.code), o.name !== void 0 && (e[c] = o.name), o.status !== void 0 && (e[C] = o.status);
|
|
75
79
|
}
|
|
76
|
-
return
|
|
80
|
+
return e;
|
|
77
81
|
}
|
|
78
|
-
function
|
|
79
|
-
return (Array.isArray(
|
|
82
|
+
function T(t) {
|
|
83
|
+
return (Array.isArray(t) ? t : []).map((r) => A(r || {}));
|
|
80
84
|
}
|
|
81
|
-
function
|
|
82
|
-
return (Array.isArray(
|
|
83
|
-
...
|
|
84
|
-
label: `${
|
|
85
|
-
value:
|
|
85
|
+
function L(t = [], a, r) {
|
|
86
|
+
return (Array.isArray(t) ? t : []).filter((n) => n == null ? void 0 : n[a]).map((n) => ({
|
|
87
|
+
...n,
|
|
88
|
+
label: `${n[a]}(${n[r] || ""})`,
|
|
89
|
+
value: n[a]
|
|
86
90
|
}));
|
|
87
91
|
}
|
|
88
|
-
function
|
|
92
|
+
function f(t, a, r) {
|
|
89
93
|
return async () => {
|
|
90
94
|
try {
|
|
91
|
-
const
|
|
92
|
-
return
|
|
95
|
+
const n = await E({ type: t });
|
|
96
|
+
return L(T(n), a, r);
|
|
93
97
|
} catch {
|
|
94
98
|
return [];
|
|
95
99
|
}
|
|
96
100
|
};
|
|
97
101
|
}
|
|
98
|
-
|
|
99
|
-
[
|
|
102
|
+
function _(t = []) {
|
|
103
|
+
return (Array.isArray(t) ? t : []).filter((a) => (a == null ? void 0 : a.itemCode) !== void 0 && (a == null ? void 0 : a.itemCode) !== null && (a == null ? void 0 : a.itemCode) !== "").map((a) => ({
|
|
104
|
+
...a,
|
|
105
|
+
label: a.itemName || "",
|
|
106
|
+
value: a.itemCode
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
function I(t = []) {
|
|
110
|
+
const a = Array.isArray(t) ? t : [], r = new Set(
|
|
111
|
+
a.map((e) => e.parentItemCode).filter((e) => e != null && String(e) !== "").map(String)
|
|
112
|
+
), n = new Set(
|
|
113
|
+
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) => String(e.itemCode))
|
|
114
|
+
), d = 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) => {
|
|
115
|
+
const l = String(e.itemCode), o = e.itemName || "";
|
|
116
|
+
return {
|
|
117
|
+
...e,
|
|
118
|
+
label: r.has(l) ? `${l}(${o})` : o,
|
|
119
|
+
value: l
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
return r.forEach((e) => {
|
|
123
|
+
n.has(e) || d.push({
|
|
124
|
+
itemCode: e,
|
|
125
|
+
itemName: e,
|
|
126
|
+
label: e,
|
|
127
|
+
value: e,
|
|
128
|
+
parentItemCode: null
|
|
129
|
+
});
|
|
130
|
+
}), d;
|
|
131
|
+
}
|
|
132
|
+
function y(t, a = _) {
|
|
133
|
+
return async (r) => {
|
|
134
|
+
try {
|
|
135
|
+
const n = await N({
|
|
136
|
+
dictCodeList: [t],
|
|
137
|
+
permissionOnlyCode: r == null ? void 0 : r.permissionOnlyCode
|
|
138
|
+
}), d = (n == null ? void 0 : n[t]) || [];
|
|
139
|
+
return a(d);
|
|
140
|
+
} catch {
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const m = {
|
|
146
|
+
[u.AIRLINE]: {
|
|
100
147
|
defaultFieldName: "airlineCodes",
|
|
101
148
|
defaultLabel: "航司",
|
|
102
149
|
defaultExcludeLabel: "排除航司",
|
|
@@ -104,58 +151,87 @@ const g = {
|
|
|
104
151
|
defaultShowAll: !0,
|
|
105
152
|
async fetchOptions() {
|
|
106
153
|
try {
|
|
107
|
-
const
|
|
108
|
-
return
|
|
154
|
+
const t = await p();
|
|
155
|
+
return S(t || []);
|
|
109
156
|
} catch {
|
|
110
157
|
return [];
|
|
111
158
|
}
|
|
112
159
|
}
|
|
113
160
|
},
|
|
114
|
-
[
|
|
161
|
+
[u.CONTINENT]: {
|
|
115
162
|
defaultFieldName: "continentCodes",
|
|
116
163
|
defaultLabel: "洲",
|
|
117
164
|
defaultExcludeLabel: "排除洲",
|
|
118
165
|
defaultMultiple: !0,
|
|
119
166
|
defaultShowAll: !1,
|
|
120
|
-
fetchOptions:
|
|
167
|
+
fetchOptions: f(1, "continentCode", "continentName")
|
|
121
168
|
},
|
|
122
|
-
[
|
|
169
|
+
[u.REGION]: {
|
|
123
170
|
defaultFieldName: "regionCodes",
|
|
124
171
|
defaultLabel: "区域",
|
|
125
172
|
defaultExcludeLabel: "排除区域",
|
|
126
173
|
defaultMultiple: !0,
|
|
127
174
|
defaultShowAll: !1,
|
|
128
|
-
fetchOptions:
|
|
175
|
+
fetchOptions: f(2, "regionCode", "regionName")
|
|
129
176
|
},
|
|
130
|
-
[
|
|
177
|
+
[u.COUNTRY]: {
|
|
131
178
|
defaultFieldName: "countryCodes",
|
|
132
179
|
defaultLabel: "国家",
|
|
133
180
|
defaultExcludeLabel: "排除国家",
|
|
134
181
|
defaultMultiple: !0,
|
|
135
182
|
defaultShowAll: !1,
|
|
136
|
-
fetchOptions:
|
|
183
|
+
fetchOptions: f(3, "countryCode", "countryName")
|
|
137
184
|
},
|
|
138
|
-
[
|
|
185
|
+
[u.CITY]: {
|
|
139
186
|
defaultFieldName: "cityCodes",
|
|
140
187
|
defaultLabel: "城市",
|
|
141
188
|
defaultExcludeLabel: "排除城市",
|
|
142
189
|
defaultMultiple: !0,
|
|
143
190
|
defaultShowAll: !1,
|
|
144
|
-
fetchOptions:
|
|
191
|
+
fetchOptions: f(4, "cityCode", "cityName")
|
|
145
192
|
},
|
|
146
|
-
[
|
|
193
|
+
[u.AIRPORT]: {
|
|
147
194
|
defaultFieldName: "airportCodes",
|
|
148
195
|
defaultLabel: "机场",
|
|
149
196
|
defaultExcludeLabel: "排除机场",
|
|
150
197
|
defaultMultiple: !0,
|
|
151
198
|
defaultShowAll: !1,
|
|
152
|
-
fetchOptions:
|
|
199
|
+
fetchOptions: f(5, "airportCode", "airportName")
|
|
200
|
+
},
|
|
201
|
+
[u.SALES_ORDER_TYPE]: {
|
|
202
|
+
defaultFieldName: "orderType",
|
|
203
|
+
defaultLabel: "订单类型",
|
|
204
|
+
defaultExcludeLabel: "排除订单类型",
|
|
205
|
+
defaultMultiple: !1,
|
|
206
|
+
defaultShowAll: !1,
|
|
207
|
+
defaultShowNav: !0,
|
|
208
|
+
defaultTreeConfig: {
|
|
209
|
+
transform: !0,
|
|
210
|
+
labelField: "label",
|
|
211
|
+
valueField: "value",
|
|
212
|
+
parentField: "parentItemCode"
|
|
213
|
+
},
|
|
214
|
+
fetchOptions: y(u.SALES_ORDER_TYPE, I)
|
|
215
|
+
},
|
|
216
|
+
[u.SALES_ORDER_PRODUCT_TYPE]: {
|
|
217
|
+
defaultFieldName: "productType",
|
|
218
|
+
defaultLabel: "产品类型",
|
|
219
|
+
defaultExcludeLabel: "排除产品类型",
|
|
220
|
+
defaultMultiple: !1,
|
|
221
|
+
defaultShowAll: !1,
|
|
222
|
+
defaultTreeConfig: {
|
|
223
|
+
transform: !0,
|
|
224
|
+
labelField: "itemName",
|
|
225
|
+
valueField: "itemCode",
|
|
226
|
+
parentField: "parentItemCode"
|
|
227
|
+
},
|
|
228
|
+
fetchOptions: y(u.SALES_ORDER_PRODUCT_TYPE)
|
|
153
229
|
}
|
|
154
230
|
};
|
|
155
231
|
export {
|
|
156
|
-
|
|
157
|
-
|
|
232
|
+
u as CODES,
|
|
233
|
+
m as CODE_REGISTRY,
|
|
158
234
|
i as GROUP_BY,
|
|
159
|
-
|
|
160
|
-
|
|
235
|
+
g as groupBasicDataOptions,
|
|
236
|
+
h as resolveDefaultGroupBy
|
|
161
237
|
};
|
|
@@ -1,88 +1,90 @@
|
|
|
1
1
|
import { ref as P, watchEffect as R, unref as D, watch as q, computed as x } from "vue";
|
|
2
2
|
import { useRoute as M } from "vue-router";
|
|
3
3
|
import { CODE_REGISTRY as b } from "./basicDataCodes.js";
|
|
4
|
-
const n = /* @__PURE__ */ new Map(),
|
|
5
|
-
function
|
|
4
|
+
const n = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
|
|
5
|
+
function p(c) {
|
|
6
6
|
return Array.isArray(c) ? c : [];
|
|
7
7
|
}
|
|
8
8
|
function E(c) {
|
|
9
|
-
return c.reduce((
|
|
9
|
+
return c.reduce((u, y) => (u[y] = [], u), {});
|
|
10
10
|
}
|
|
11
11
|
function _(c) {
|
|
12
|
-
const
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
(e, t) => (e[t] =
|
|
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),
|
|
16
16
|
{}
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
i();
|
|
20
20
|
async function O(r) {
|
|
21
|
+
var s;
|
|
22
|
+
const e = (s = u.meta) == null ? void 0 : s.permissionOnlyCode;
|
|
21
23
|
return (await Promise.allSettled(
|
|
22
|
-
r.map(async (
|
|
24
|
+
r.map(async (a) => {
|
|
23
25
|
try {
|
|
24
|
-
const
|
|
25
|
-
return [
|
|
26
|
+
const f = await b[a].fetchOptions({ permissionOnlyCode: e });
|
|
27
|
+
return [a, p(f)];
|
|
26
28
|
} catch {
|
|
27
|
-
return [
|
|
29
|
+
return [a, []];
|
|
28
30
|
}
|
|
29
31
|
})
|
|
30
|
-
)).reduce((
|
|
31
|
-
const
|
|
32
|
-
return
|
|
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;
|
|
33
35
|
}, {});
|
|
34
36
|
}
|
|
35
37
|
async function w(r = !1) {
|
|
36
|
-
const e =
|
|
38
|
+
const e = u.path;
|
|
37
39
|
let t = [];
|
|
38
40
|
try {
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
42
|
-
n.set(e,
|
|
41
|
+
const s = D(c.dataSource);
|
|
42
|
+
if (s) {
|
|
43
|
+
const m = { ...n.get(e) || {}, ...s };
|
|
44
|
+
n.set(e, m), i(m);
|
|
43
45
|
return;
|
|
44
46
|
}
|
|
45
|
-
const
|
|
46
|
-
if (t = r ? [...c.codes] : c.codes.filter((
|
|
47
|
-
|
|
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);
|
|
48
50
|
return;
|
|
49
51
|
}
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
+
const o = r ? void 0 : C.get(e);
|
|
53
|
+
if (o)
|
|
52
54
|
try {
|
|
53
|
-
const
|
|
54
|
-
if (n.set(e,
|
|
55
|
-
|
|
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);
|
|
56
58
|
return;
|
|
57
59
|
}
|
|
58
60
|
} catch {
|
|
59
61
|
}
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
+
const f = O(t), l = (g.get(e) || 0) + 1;
|
|
63
|
+
g.set(e, l), C.set(e, f);
|
|
62
64
|
try {
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
65
|
-
const
|
|
66
|
-
n.set(e,
|
|
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);
|
|
67
69
|
} finally {
|
|
68
|
-
|
|
70
|
+
g.get(e) === l && C.delete(e);
|
|
69
71
|
}
|
|
70
72
|
} catch {
|
|
71
|
-
const
|
|
72
|
-
n.set(e,
|
|
73
|
+
const s = E(t.length ? t : c.codes), o = { ...n.get(e) || {}, ...s };
|
|
74
|
+
n.set(e, o), i(o);
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
async function S() {
|
|
76
|
-
const r =
|
|
77
|
-
|
|
78
|
+
const r = u.path;
|
|
79
|
+
C.clear(), n.clear(), g.clear(), n.delete(r), await w(!0);
|
|
78
80
|
}
|
|
79
81
|
return R(() => {
|
|
80
82
|
const r = D(c.dataSource);
|
|
81
83
|
if (!r) return;
|
|
82
|
-
const e =
|
|
83
|
-
n.set(e,
|
|
84
|
+
const e = u.path, s = { ...n.get(e) || {}, ...r };
|
|
85
|
+
n.set(e, s), i(s);
|
|
84
86
|
}), q(
|
|
85
|
-
() =>
|
|
87
|
+
() => u.path,
|
|
86
88
|
() => {
|
|
87
89
|
w();
|
|
88
90
|
},
|
|
@@ -90,12 +92,12 @@ function _(c) {
|
|
|
90
92
|
), {
|
|
91
93
|
dataSource: x(() => {
|
|
92
94
|
const r = c.codes.reduce(
|
|
93
|
-
(e, t) => (e[t] =
|
|
95
|
+
(e, t) => (e[t] = p(y.value[t]), e),
|
|
94
96
|
{}
|
|
95
97
|
);
|
|
96
98
|
return new Proxy(r, {
|
|
97
99
|
get(e, t) {
|
|
98
|
-
return typeof t != "string" ? [] :
|
|
100
|
+
return typeof t != "string" ? [] : p(r[t]);
|
|
99
101
|
},
|
|
100
102
|
set() {
|
|
101
103
|
return !1;
|
|
@@ -44,6 +44,8 @@ export interface PanelSelectFieldConfig {
|
|
|
44
44
|
dependencies?: TtFormSchema["dependencies"];
|
|
45
45
|
onChange?: (value: unknown, context: PanelSelectFieldOnChangeContext) => void;
|
|
46
46
|
rules?: TtFormSchema["rules"];
|
|
47
|
+
/** 表单项描述,透传到 TtFormSchema.description */
|
|
48
|
+
description?: TtFormSchema["description"];
|
|
47
49
|
/** 与另一字段互斥:填对方的 fieldName */
|
|
48
50
|
mutexWith?: string;
|
|
49
51
|
/** 同 code 数据源的排除字段联动 */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "axios";
|
|
2
2
|
import "element-plus";
|
|
3
|
-
import { isFunction as
|
|
3
|
+
import { isFunction as Q } from "../packages/utils/src/is.js";
|
|
4
4
|
import "vue";
|
|
5
5
|
import "xe-utils";
|
|
6
6
|
import "dayjs";
|
|
@@ -11,35 +11,39 @@ 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
|
|
15
|
-
import { CODE_REGISTRY as
|
|
16
|
-
import { useBasicDataOptions as
|
|
14
|
+
import { omit as _ } from "lodash-es";
|
|
15
|
+
import { CODE_REGISTRY as oe, resolveDefaultGroupBy as re, GROUP_BY as se, groupBasicDataOptions as z } from "./basicDataCodes.js";
|
|
16
|
+
import { useBasicDataOptions as ce } from "./useBasicDataOptions.js";
|
|
17
17
|
const N = "all";
|
|
18
18
|
function d(t) {
|
|
19
19
|
return Array.isArray(t) ? t : t == null || t === "" ? [] : [t];
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function le(t, n = N) {
|
|
22
22
|
return t === n ? !0 : typeof t == "string" && typeof n == "string" && t.toLowerCase() === String(n).toLowerCase();
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
return d(t).some((r) =>
|
|
24
|
+
function pe(t, n = N) {
|
|
25
|
+
return d(t).some((r) => le(r, n));
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function ue(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
|
-
function
|
|
31
|
-
|
|
30
|
+
function K(t, n) {
|
|
31
|
+
const r = "支持多选和全选", s = typeof t == "string" && t.trim() ? t.trim().replace(/[,,]\s*$/, "") : "请选择";
|
|
32
|
+
return s.includes(r) ? s : `${s},${r}`;
|
|
33
|
+
}
|
|
34
|
+
function V(t, n, r, s) {
|
|
35
|
+
return t ? Q(t) ? t(n, r, s) : t : {};
|
|
32
36
|
}
|
|
33
|
-
function
|
|
37
|
+
function j(t, n, r, s) {
|
|
34
38
|
const p = new Set(r.map((e) => e.value)), l = t[n];
|
|
35
39
|
if (s) {
|
|
36
40
|
const e = d(l).filter((u) => p.has(u)), c = d(l);
|
|
37
|
-
(e.length !== c.length || e.some((u,
|
|
41
|
+
(e.length !== c.length || e.some((u, F) => u !== c[F])) && (t[n] = e);
|
|
38
42
|
return;
|
|
39
43
|
}
|
|
40
44
|
l == null || l === "" || p.has(l) || (t[n] = void 0);
|
|
41
45
|
}
|
|
42
|
-
function
|
|
46
|
+
function q(t, n, r, s, p, l) {
|
|
43
47
|
const e = l ? p.filter((c) => d(r[n]).includes(c.value)) : p.find((c) => c.value === r[n]);
|
|
44
48
|
return {
|
|
45
49
|
values: r,
|
|
@@ -50,80 +54,82 @@ function $(t, n, r, s, p, l) {
|
|
|
50
54
|
currentOption: e
|
|
51
55
|
};
|
|
52
56
|
}
|
|
53
|
-
function
|
|
57
|
+
function Z(t, n, r) {
|
|
54
58
|
const s = d(t);
|
|
55
59
|
if (!s.length) return [];
|
|
56
|
-
if (
|
|
60
|
+
if (pe(t, r)) return n;
|
|
57
61
|
const p = new Set(s);
|
|
58
62
|
return n.filter((l) => p.has(l.value));
|
|
59
63
|
}
|
|
60
|
-
function
|
|
64
|
+
function H(t, n) {
|
|
61
65
|
const r = new Set(d(t));
|
|
62
66
|
return r.size ? n.filter((s) => !r.has(s.value)) : n;
|
|
63
67
|
}
|
|
64
|
-
function
|
|
68
|
+
function J(t, n) {
|
|
65
69
|
var s;
|
|
66
70
|
const r = (s = t.value) == null ? void 0 : s[n];
|
|
67
71
|
return Array.isArray(r) ? r : [];
|
|
68
72
|
}
|
|
69
|
-
function
|
|
73
|
+
function Me(t, n = {}) {
|
|
70
74
|
const r = [...new Set(t.map((e) => e.code))], s = t.reduce(
|
|
71
75
|
(e, c) => (e[c.code] = (e[c.code] || 0) + 1, e),
|
|
72
76
|
{}
|
|
73
|
-
), { dataSource: p } =
|
|
77
|
+
), { dataSource: p } = ce({
|
|
74
78
|
codes: r,
|
|
75
79
|
dataSource: n.dataSource
|
|
76
80
|
}), l = {};
|
|
77
81
|
return t.forEach((e) => {
|
|
78
|
-
var
|
|
79
|
-
const c =
|
|
82
|
+
var R;
|
|
83
|
+
const c = oe[e.code], u = e.fieldName || c.defaultFieldName, F = e.key || ((s[e.code] || 0) > 1 ? u : e.code), $ = e.label || c.defaultLabel, E = e.multiple ?? c.defaultMultiple, X = e.showAll ?? c.defaultShowAll, M = e.showAllField ?? N, m = e.mutexWith, T = re(e.code, e.groupBy), O = T !== se.PINYIN, S = c.defaultTreeConfig, k = !!S, G = c.defaultShowNav ?? !1, f = [
|
|
80
84
|
...m ? [m] : [],
|
|
81
|
-
...((
|
|
82
|
-
],
|
|
83
|
-
...
|
|
84
|
-
triggerFields:
|
|
85
|
-
} : e.dependencies,
|
|
85
|
+
...((R = e.dependencies) == null ? void 0 : R.triggerFields) || []
|
|
86
|
+
], I = [...new Set(f)], v = _(e.dependencies || {}, ["triggerFields"]), C = I.length ? {
|
|
87
|
+
...v,
|
|
88
|
+
triggerFields: I
|
|
89
|
+
} : e.dependencies, B = {
|
|
86
90
|
component: "TtPanelSelect",
|
|
87
91
|
fieldName: u,
|
|
88
|
-
label:
|
|
92
|
+
label: $,
|
|
89
93
|
rules: e.rules,
|
|
90
|
-
dependencies:
|
|
94
|
+
dependencies: C,
|
|
91
95
|
componentProps: (o, x) => {
|
|
92
|
-
const A =
|
|
93
|
-
let a = m ?
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
+
const A = J(p, e.code);
|
|
97
|
+
let a = m ? H(o[m], A) : A;
|
|
98
|
+
Q(e.customOptions) && (a = e.customOptions(o, a) || []);
|
|
99
|
+
const g = O ? z(a, T) : a, D = V(e.componentProps, o, x, a), { onChange: U, ...w } = D;
|
|
96
100
|
return {
|
|
97
|
-
multiple:
|
|
98
|
-
showAll:
|
|
99
|
-
showAllField:
|
|
100
|
-
showNav:
|
|
101
|
+
multiple: E,
|
|
102
|
+
showAll: X,
|
|
103
|
+
showAllField: M,
|
|
104
|
+
showNav: G,
|
|
101
105
|
showOriginMode: !1,
|
|
102
|
-
showPinyinMode: !
|
|
103
|
-
...
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
showPinyinMode: k ? !1 : !O,
|
|
107
|
+
...S ? { treeConfig: S } : {},
|
|
108
|
+
...w,
|
|
109
|
+
...E ? { placeholder: K(w.placeholder) } : {},
|
|
110
|
+
options: g,
|
|
111
|
+
onChange(y) {
|
|
112
|
+
var P;
|
|
107
113
|
if (m) {
|
|
108
|
-
const i = Array.isArray(o[m]), h =
|
|
109
|
-
|
|
114
|
+
const i = Array.isArray(o[m]), h = H(y, A);
|
|
115
|
+
j(o, m, h, i);
|
|
110
116
|
}
|
|
111
117
|
if (e.exclude) {
|
|
112
|
-
const i = e.exclude.fieldName, h = e.exclude.multiple ?? !0,
|
|
113
|
-
d(
|
|
118
|
+
const i = e.exclude.fieldName, h = e.exclude.multiple ?? !0, L = Z(y, A, M);
|
|
119
|
+
d(y).length ? j(o, i, L, h) : o[i] = h ? [] : void 0;
|
|
114
120
|
}
|
|
115
|
-
(
|
|
121
|
+
(P = e.onChange) == null || P.call(
|
|
116
122
|
e,
|
|
117
|
-
|
|
118
|
-
|
|
123
|
+
y,
|
|
124
|
+
q(e.code, u, o, x, a, E)
|
|
119
125
|
);
|
|
120
126
|
}
|
|
121
127
|
};
|
|
122
128
|
}
|
|
123
129
|
};
|
|
124
|
-
if (l[
|
|
125
|
-
...
|
|
126
|
-
...
|
|
130
|
+
if (l[F] = {
|
|
131
|
+
...B,
|
|
132
|
+
..._(e, [
|
|
127
133
|
"code",
|
|
128
134
|
"key",
|
|
129
135
|
"fieldName",
|
|
@@ -141,47 +147,50 @@ function ge(t, n = {}) {
|
|
|
141
147
|
"customOptions"
|
|
142
148
|
]),
|
|
143
149
|
fieldName: u,
|
|
144
|
-
label:
|
|
150
|
+
label: $,
|
|
145
151
|
rules: e.rules,
|
|
146
|
-
|
|
147
|
-
|
|
152
|
+
description: e.description,
|
|
153
|
+
dependencies: B.dependencies,
|
|
154
|
+
componentProps: B.componentProps,
|
|
148
155
|
component: "TtPanelSelect"
|
|
149
156
|
}, e.exclude) {
|
|
150
|
-
const o = e.exclude, x = o.fieldName, A = o.key || `exclude${
|
|
151
|
-
...
|
|
152
|
-
triggerFields:
|
|
153
|
-
if:
|
|
154
|
-
},
|
|
157
|
+
const o = e.exclude, x = o.fieldName, A = o.key || `exclude${ue(F)}`, a = o.label || c.defaultExcludeLabel, g = o.multiple ?? !0, D = o.showAll ?? !1, U = o.showAllField ?? N, w = o.dependencies || {}, y = {
|
|
158
|
+
...w,
|
|
159
|
+
triggerFields: w.triggerFields ?? [u],
|
|
160
|
+
if: w.if ?? ((i) => d(i[u]).length > 0)
|
|
161
|
+
}, P = {
|
|
155
162
|
component: "TtPanelSelect",
|
|
156
163
|
fieldName: x,
|
|
157
164
|
label: a,
|
|
158
165
|
rules: o.rules,
|
|
159
|
-
dependencies:
|
|
166
|
+
dependencies: y,
|
|
160
167
|
componentProps: (i, h) => {
|
|
161
|
-
const
|
|
168
|
+
const L = J(p, e.code), b = Z(i[u], L, M), ee = O ? z(b, T) : b, te = V(o.componentProps, i, h, b), { onChange: ie, ...W } = te;
|
|
162
169
|
return {
|
|
163
|
-
multiple:
|
|
164
|
-
showAll:
|
|
165
|
-
showAllField:
|
|
166
|
-
showNav:
|
|
170
|
+
multiple: g,
|
|
171
|
+
showAll: D,
|
|
172
|
+
showAllField: U,
|
|
173
|
+
showNav: G,
|
|
167
174
|
showOriginMode: !1,
|
|
168
|
-
showPinyinMode: !
|
|
169
|
-
...
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
175
|
+
showPinyinMode: k ? !1 : !O,
|
|
176
|
+
...S ? { treeConfig: S } : {},
|
|
177
|
+
...W,
|
|
178
|
+
...g ? { placeholder: K(W.placeholder) } : {},
|
|
179
|
+
options: ee,
|
|
180
|
+
onChange(ne) {
|
|
181
|
+
var Y;
|
|
182
|
+
(Y = o.onChange) == null || Y.call(
|
|
174
183
|
o,
|
|
175
|
-
|
|
176
|
-
|
|
184
|
+
ne,
|
|
185
|
+
q(e.code, x, i, h, b, g)
|
|
177
186
|
);
|
|
178
187
|
}
|
|
179
188
|
};
|
|
180
189
|
}
|
|
181
190
|
};
|
|
182
191
|
l[A] = {
|
|
183
|
-
...
|
|
184
|
-
...
|
|
192
|
+
...P,
|
|
193
|
+
..._(o, [
|
|
185
194
|
"fieldName",
|
|
186
195
|
"label",
|
|
187
196
|
"key",
|
|
@@ -196,8 +205,8 @@ function ge(t, n = {}) {
|
|
|
196
205
|
fieldName: x,
|
|
197
206
|
label: a,
|
|
198
207
|
rules: o.rules,
|
|
199
|
-
dependencies:
|
|
200
|
-
componentProps:
|
|
208
|
+
dependencies: P.dependencies,
|
|
209
|
+
componentProps: P.componentProps,
|
|
201
210
|
component: "TtPanelSelect"
|
|
202
211
|
};
|
|
203
212
|
}
|
|
@@ -207,5 +216,5 @@ function ge(t, n = {}) {
|
|
|
207
216
|
};
|
|
208
217
|
}
|
|
209
218
|
export {
|
|
210
|
-
|
|
219
|
+
Me as usePanelSelectSchemas
|
|
211
220
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dazhicheng/ui",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.247",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"vue-router": "^5.0.2",
|
|
68
68
|
"vxe-pc-ui": "^4.12.36",
|
|
69
69
|
"vxe-table": "^4.17.48",
|
|
70
|
-
"@dazhicheng/
|
|
71
|
-
"@dazhicheng/
|
|
70
|
+
"@dazhicheng/utils": "1.3.44",
|
|
71
|
+
"@dazhicheng/hooks": "1.4.47"
|
|
72
72
|
},
|
|
73
73
|
"files": [
|
|
74
74
|
"dist"
|