urit-qf-ui 0.1.11 → 0.2.0
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/components/UMenu.vue.d.ts +88 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1512 -1159
- package/dist/index.umd.cjs +2 -2
- package/dist/style.css +1 -1
- package/dist/ts/model.d.ts +35 -0
- package/dist/uform/FormContainer.vue.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
1
|
+
var Te = Object.defineProperty;
|
|
2
|
+
var Ve = (l, t, e) => t in l ? Te(l, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[t] = e;
|
|
3
|
+
var _ = (l, t, e) => Ve(l, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import Pe, { ElMessage as ge, ElMessageBox as fe } from "element-plus";
|
|
5
5
|
import "element-plus/dist/index.css";
|
|
6
|
-
import { ElInput as
|
|
6
|
+
import { ElInput as $e, ElInputNumber as Ie, ElSelect as ne, ElOption as ie, ElSwitch as Ee, ElDatePicker as Ae, ElMenu as Be, ElSubMenu as Re, ElMenuItem as Ue, ElIcon as ye, ElButton as Y, ElDialog as Me, ElForm as Le, ElTable as Fe, ElTableColumn as ze, ElPagination as qe, ElDrawer as Ne } from "element-plus/es";
|
|
7
7
|
import "element-plus/es/components/base/style/css";
|
|
8
8
|
import "element-plus/es/components/input/style/css";
|
|
9
|
-
import { defineComponent as
|
|
9
|
+
import { defineComponent as V, computed as y, openBlock as f, createElementBlock as h, normalizeClass as $, normalizeStyle as U, createTextVNode as B, toDisplayString as T, createElementVNode as x, createCommentVNode as D, createVNode as S, reactive as z, watch as F, withCtx as w, Fragment as I, renderList as M, createBlock as k, mergeProps as be, ref as q, markRaw as ve, onMounted as H, renderSlot as L, resolveDynamicComponent as O, toRefs as We, unref as R, withModifiers as me } from "vue";
|
|
10
10
|
import "element-plus/es/components/input-number/style/css";
|
|
11
11
|
import "element-plus/es/components/select/style/css";
|
|
12
12
|
import "element-plus/es/components/option/style/css";
|
|
13
|
-
import
|
|
13
|
+
import we from "axios";
|
|
14
14
|
import "element-plus/es/components/switch/style/css";
|
|
15
15
|
import "element-plus/es/components/date-picker/style/css";
|
|
16
16
|
import "element-plus/es/components/button/style/css";
|
|
17
|
+
import "element-plus/es/components/menu/style/css";
|
|
18
|
+
import "element-plus/es/components/sub-menu/style/css";
|
|
19
|
+
import "element-plus/es/components/menu-item/style/css";
|
|
20
|
+
import "element-plus/es/components/icon/style/css";
|
|
17
21
|
import "element-plus/es/components/form/style/css";
|
|
18
22
|
import "element-plus/es/components/dialog/style/css";
|
|
19
|
-
import "element-plus/
|
|
20
|
-
import { Loading as me } from "@element-plus/icons-vue";
|
|
23
|
+
import { Loading as pe } from "@element-plus/icons-vue";
|
|
21
24
|
import "element-plus/es/components/table/style/css";
|
|
22
25
|
import "element-plus/es/components/table-column/style/css";
|
|
23
26
|
import "element-plus/es/components/pagination/style/css";
|
|
24
27
|
import "element-plus/es/components/drawer/style/css";
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
const
|
|
28
|
+
import je from "mitt";
|
|
29
|
+
import Oe from "mqtt";
|
|
30
|
+
const Ye = /* @__PURE__ */ V({
|
|
28
31
|
__name: "UInput",
|
|
29
32
|
props: {
|
|
30
33
|
fieldLabel: {},
|
|
@@ -51,55 +54,55 @@ const Ne = /* @__PURE__ */ S({
|
|
|
51
54
|
maxlength: {}
|
|
52
55
|
},
|
|
53
56
|
emits: ["update:modelValue"],
|
|
54
|
-
setup(
|
|
55
|
-
const e =
|
|
56
|
-
const
|
|
57
|
-
return e.labelPosition === "left" && e.labelWidth && (
|
|
58
|
-
}),
|
|
57
|
+
setup(l, { emit: t }) {
|
|
58
|
+
const e = l, o = t, c = y(() => {
|
|
59
|
+
const d = {};
|
|
60
|
+
return e.labelPosition === "left" && e.labelWidth && (d.width = typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth), e.labelAlign && (d.textAlign = e.labelAlign), d;
|
|
61
|
+
}), r = y(() => ({
|
|
59
62
|
"u-input-label-left": e.labelPosition === "left",
|
|
60
63
|
"u-input-label-top": e.labelPosition === "top"
|
|
61
|
-
})),
|
|
62
|
-
onInput(
|
|
63
|
-
|
|
64
|
+
})), s = {
|
|
65
|
+
onInput(d) {
|
|
66
|
+
o("update:modelValue", d);
|
|
64
67
|
}
|
|
65
68
|
};
|
|
66
|
-
return (
|
|
67
|
-
const
|
|
68
|
-
return f(),
|
|
69
|
-
class:
|
|
69
|
+
return (d, a) => {
|
|
70
|
+
const i = $e;
|
|
71
|
+
return f(), h("div", {
|
|
72
|
+
class: $(["u-input", r.value])
|
|
70
73
|
}, [
|
|
71
|
-
|
|
74
|
+
l.fieldLabel ? (f(), h("div", {
|
|
72
75
|
key: 0,
|
|
73
76
|
class: "u-input-label",
|
|
74
|
-
style:
|
|
77
|
+
style: U(c.value)
|
|
75
78
|
}, [
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
class:
|
|
79
|
+
B(T(l.fieldLabel) + " ", 1),
|
|
80
|
+
x("span", {
|
|
81
|
+
class: $(["required-star", { "required-star--visible": l.required }])
|
|
79
82
|
}, "*", 2)
|
|
80
|
-
], 4)) :
|
|
81
|
-
|
|
82
|
-
class:
|
|
83
|
+
], 4)) : D("", !0),
|
|
84
|
+
x("div", {
|
|
85
|
+
class: $(["u-input-field", { "u-input-field--top": l.labelPosition === "top" }])
|
|
83
86
|
}, [
|
|
84
|
-
|
|
85
|
-
"model-value":
|
|
86
|
-
placeholder:
|
|
87
|
-
type:
|
|
88
|
-
disabled:
|
|
89
|
-
readonly:
|
|
90
|
-
maxlength:
|
|
91
|
-
"onUpdate:modelValue":
|
|
87
|
+
S(i, {
|
|
88
|
+
"model-value": l.modelValue,
|
|
89
|
+
placeholder: l.placeholder,
|
|
90
|
+
type: l.type,
|
|
91
|
+
disabled: l.disable,
|
|
92
|
+
readonly: l.readonly,
|
|
93
|
+
maxlength: l.maxlength,
|
|
94
|
+
"onUpdate:modelValue": s.onInput
|
|
92
95
|
}, null, 8, ["model-value", "placeholder", "type", "disabled", "readonly", "maxlength", "onUpdate:modelValue"])
|
|
93
96
|
], 2)
|
|
94
97
|
], 2);
|
|
95
98
|
};
|
|
96
99
|
}
|
|
97
|
-
}),
|
|
98
|
-
const e =
|
|
99
|
-
for (const [
|
|
100
|
-
e[
|
|
100
|
+
}), P = (l, t) => {
|
|
101
|
+
const e = l.__vccOpts || l;
|
|
102
|
+
for (const [o, c] of t)
|
|
103
|
+
e[o] = c;
|
|
101
104
|
return e;
|
|
102
|
-
},
|
|
105
|
+
}, K = /* @__PURE__ */ P(Ye, [["__scopeId", "data-v-ecf5177c"]]), Qe = { class: "u-input-number-field" }, Ge = /* @__PURE__ */ V({
|
|
103
106
|
__name: "UInputNumber",
|
|
104
107
|
props: {
|
|
105
108
|
fieldLabel: {},
|
|
@@ -126,172 +129,172 @@ const Ne = /* @__PURE__ */ S({
|
|
|
126
129
|
precision: {}
|
|
127
130
|
},
|
|
128
131
|
emits: ["update:modelValue"],
|
|
129
|
-
setup(
|
|
130
|
-
const e =
|
|
131
|
-
const
|
|
132
|
-
return e.labelPosition === "left" && e.labelWidth && (
|
|
133
|
-
}),
|
|
132
|
+
setup(l, { emit: t }) {
|
|
133
|
+
const e = l, o = t, c = y(() => {
|
|
134
|
+
const d = {};
|
|
135
|
+
return e.labelPosition === "left" && e.labelWidth && (d.width = typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth), e.labelAlign && (d.textAlign = e.labelAlign), d;
|
|
136
|
+
}), r = y(() => ({
|
|
134
137
|
"u-input-number-label-left": e.labelPosition === "left",
|
|
135
138
|
"u-input-number-label-top": e.labelPosition === "top"
|
|
136
|
-
})),
|
|
137
|
-
onUpdate(
|
|
138
|
-
|
|
139
|
+
})), s = {
|
|
140
|
+
onUpdate(d) {
|
|
141
|
+
o("update:modelValue", d === void 0 ? 0 : d);
|
|
139
142
|
}
|
|
140
143
|
};
|
|
141
|
-
return (
|
|
142
|
-
const
|
|
143
|
-
return f(),
|
|
144
|
-
class:
|
|
144
|
+
return (d, a) => {
|
|
145
|
+
const i = Ie;
|
|
146
|
+
return f(), h("div", {
|
|
147
|
+
class: $(["u-input-number", r.value])
|
|
145
148
|
}, [
|
|
146
|
-
|
|
149
|
+
l.fieldLabel ? (f(), h("div", {
|
|
147
150
|
key: 0,
|
|
148
151
|
class: "u-input-number-label",
|
|
149
|
-
style:
|
|
152
|
+
style: U(c.value)
|
|
150
153
|
}, [
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
class:
|
|
154
|
+
B(T(l.fieldLabel) + " ", 1),
|
|
155
|
+
x("span", {
|
|
156
|
+
class: $(["required-star", { "required-star--visible": l.required }])
|
|
154
157
|
}, "*", 2)
|
|
155
|
-
], 4)) :
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
"model-value":
|
|
159
|
-
placeholder:
|
|
160
|
-
disabled:
|
|
161
|
-
min:
|
|
162
|
-
max:
|
|
163
|
-
step:
|
|
164
|
-
precision:
|
|
158
|
+
], 4)) : D("", !0),
|
|
159
|
+
x("div", Qe, [
|
|
160
|
+
S(i, {
|
|
161
|
+
"model-value": l.modelValue,
|
|
162
|
+
placeholder: l.placeholder || "请输入数值",
|
|
163
|
+
disabled: l.disable,
|
|
164
|
+
min: l.min,
|
|
165
|
+
max: l.max,
|
|
166
|
+
step: l.step,
|
|
167
|
+
precision: l.precision,
|
|
165
168
|
controls: !0,
|
|
166
169
|
"controls-position": "right",
|
|
167
170
|
style: { width: "100%" },
|
|
168
|
-
onChange:
|
|
171
|
+
onChange: s.onUpdate
|
|
169
172
|
}, null, 8, ["model-value", "placeholder", "disabled", "min", "max", "step", "precision", "onChange"])
|
|
170
173
|
])
|
|
171
174
|
], 2);
|
|
172
175
|
};
|
|
173
176
|
}
|
|
174
|
-
}),
|
|
177
|
+
}), xe = /* @__PURE__ */ P(Ge, [["__scopeId", "data-v-cb70bd5b"]]), Q = we.create({
|
|
175
178
|
timeout: 3e4,
|
|
176
179
|
headers: {
|
|
177
180
|
"Content-Type": "application/json"
|
|
178
181
|
}
|
|
179
182
|
});
|
|
180
|
-
|
|
181
|
-
(
|
|
183
|
+
Q.interceptors.request.use(
|
|
184
|
+
(l) => {
|
|
182
185
|
const t = localStorage.getItem("token");
|
|
183
|
-
return t && (
|
|
186
|
+
return t && (l.headers.Authorization = `Bearer ${t}`), l;
|
|
184
187
|
},
|
|
185
|
-
(
|
|
188
|
+
(l) => Promise.reject(l)
|
|
186
189
|
);
|
|
187
|
-
|
|
188
|
-
(
|
|
189
|
-
const t =
|
|
190
|
+
Q.interceptors.response.use(
|
|
191
|
+
(l) => {
|
|
192
|
+
const t = l.data;
|
|
190
193
|
if (t && typeof t == "object" && !Array.isArray(t)) {
|
|
191
194
|
if (t.status === void 0 && t.code !== void 0) {
|
|
192
|
-
const e = t.code,
|
|
193
|
-
t.status =
|
|
195
|
+
const e = t.code, o = e === 0 || e === 200 || Number(e) === 0 || Number(e) === 200;
|
|
196
|
+
t.status = o ? 200 : Number(e);
|
|
194
197
|
}
|
|
195
198
|
if (t.status !== void 0 && t.status !== 200) {
|
|
196
199
|
const e = t.message || "请求失败";
|
|
197
200
|
return console.error("[HTTP Error]", e), Promise.reject(new Error(e));
|
|
198
201
|
}
|
|
199
202
|
}
|
|
200
|
-
return
|
|
203
|
+
return l;
|
|
201
204
|
},
|
|
202
|
-
(
|
|
203
|
-
var e,
|
|
204
|
-
const t = ((
|
|
205
|
-
return console.error("[HTTP Error]", t), Promise.reject(
|
|
205
|
+
(l) => {
|
|
206
|
+
var e, o;
|
|
207
|
+
const t = ((o = (e = l.response) == null ? void 0 : e.data) == null ? void 0 : o.message) || l.message || "请求失败";
|
|
208
|
+
return console.error("[HTTP Error]", t), Promise.reject(l);
|
|
206
209
|
}
|
|
207
210
|
);
|
|
208
|
-
const
|
|
209
|
-
get(
|
|
210
|
-
return
|
|
211
|
+
const A = {
|
|
212
|
+
get(l, t) {
|
|
213
|
+
return Q.get(l, t).then((e) => e.data);
|
|
211
214
|
},
|
|
212
|
-
post(
|
|
213
|
-
return
|
|
215
|
+
post(l, t, e) {
|
|
216
|
+
return Q.post(l, t, e).then((o) => o.data);
|
|
214
217
|
},
|
|
215
218
|
// 原始 axios 实例,用于特殊需求
|
|
216
|
-
instance:
|
|
217
|
-
},
|
|
218
|
-
formCfgApi(
|
|
219
|
-
return `/api/form?file-id=${
|
|
219
|
+
instance: Q
|
|
220
|
+
}, N = {
|
|
221
|
+
formCfgApi(l) {
|
|
222
|
+
return `/api/form?file-id=${l}`;
|
|
220
223
|
},
|
|
221
224
|
// 获取字典数据(单一/级联共用接口,返回树形结构)
|
|
222
|
-
dictApi(
|
|
223
|
-
return `/api/dict/tree-list?dict_type=${
|
|
225
|
+
dictApi(l) {
|
|
226
|
+
return `/api/dict/tree-list?dict_type=${l}&children=true`;
|
|
224
227
|
},
|
|
225
228
|
// 获取级联数据(与单一字典共用接口)
|
|
226
|
-
cascaderApi(
|
|
227
|
-
return `/api/dict/tree-list?dict_type=${
|
|
229
|
+
cascaderApi(l) {
|
|
230
|
+
return `/api/dict/tree-list?dict_type=${l}&children=true`;
|
|
228
231
|
}
|
|
229
|
-
},
|
|
230
|
-
function
|
|
231
|
-
const { children: t, ...e } =
|
|
232
|
+
}, te = {}, X = {};
|
|
233
|
+
function Ce(l) {
|
|
234
|
+
const { children: t, ...e } = l;
|
|
232
235
|
return {
|
|
233
|
-
label:
|
|
234
|
-
value:
|
|
236
|
+
label: l.label ?? l.dict_value ?? String(l.value ?? ""),
|
|
237
|
+
value: l.value ?? l.dict_code,
|
|
235
238
|
...e
|
|
236
239
|
};
|
|
237
240
|
}
|
|
238
|
-
function
|
|
239
|
-
return Array.isArray(
|
|
241
|
+
function se(l) {
|
|
242
|
+
return Array.isArray(l) ? l.map((t) => {
|
|
240
243
|
if (!t || typeof t != "object") return t;
|
|
241
|
-
const e =
|
|
242
|
-
return Array.isArray(
|
|
244
|
+
const e = Ce(t), o = t.children;
|
|
245
|
+
return Array.isArray(o) && o.length > 0 && (e.children = se(o)), e;
|
|
243
246
|
}) : [];
|
|
244
247
|
}
|
|
245
|
-
function
|
|
246
|
-
if (!Array.isArray(
|
|
247
|
-
const t = [], e = (
|
|
248
|
-
for (const
|
|
249
|
-
if (!
|
|
250
|
-
const
|
|
251
|
-
t.push(
|
|
248
|
+
function re(l) {
|
|
249
|
+
if (!Array.isArray(l)) return [];
|
|
250
|
+
const t = [], e = (o) => {
|
|
251
|
+
for (const c of o) {
|
|
252
|
+
if (!c || typeof c != "object") continue;
|
|
253
|
+
const r = c.children;
|
|
254
|
+
t.push(Ce(c)), Array.isArray(r) && r.length > 0 && e(r);
|
|
252
255
|
}
|
|
253
256
|
};
|
|
254
|
-
return e(
|
|
257
|
+
return e(l), t;
|
|
255
258
|
}
|
|
256
|
-
async function
|
|
257
|
-
if (!
|
|
259
|
+
async function ae(l) {
|
|
260
|
+
if (!l)
|
|
258
261
|
return [];
|
|
259
|
-
if (
|
|
260
|
-
return
|
|
261
|
-
if (
|
|
262
|
-
return await
|
|
262
|
+
if (te[l])
|
|
263
|
+
return te[l];
|
|
264
|
+
if (l in X)
|
|
265
|
+
return await X[l];
|
|
263
266
|
const t = (async () => {
|
|
264
267
|
try {
|
|
265
|
-
const e = await
|
|
268
|
+
const e = await A.get(N.dictApi(l));
|
|
266
269
|
if (e.status === 200) {
|
|
267
|
-
const
|
|
268
|
-
return
|
|
270
|
+
const o = re(e.data);
|
|
271
|
+
return te[l] = o, o;
|
|
269
272
|
}
|
|
270
273
|
return [];
|
|
271
274
|
} catch (e) {
|
|
272
|
-
return console.error(`[dict] 加载字典 ${
|
|
275
|
+
return console.error(`[dict] 加载字典 ${l} 失败:`, e), [];
|
|
273
276
|
} finally {
|
|
274
|
-
delete
|
|
277
|
+
delete X[l];
|
|
275
278
|
}
|
|
276
279
|
})();
|
|
277
|
-
return
|
|
280
|
+
return X[l] = t, t;
|
|
278
281
|
}
|
|
279
|
-
async function
|
|
282
|
+
async function He(l, t, e = "") {
|
|
280
283
|
if (t == null || t === "")
|
|
281
284
|
return e;
|
|
282
|
-
const
|
|
283
|
-
if (
|
|
284
|
-
return
|
|
285
|
-
const
|
|
286
|
-
return
|
|
285
|
+
const o = te[l];
|
|
286
|
+
if (o && o.length > 0)
|
|
287
|
+
return he(o, t);
|
|
288
|
+
const c = await ae(l);
|
|
289
|
+
return c && c.length > 0 ? he(c, t) : e || String(t);
|
|
287
290
|
}
|
|
288
|
-
function
|
|
289
|
-
const e =
|
|
290
|
-
(
|
|
291
|
+
function he(l, t) {
|
|
292
|
+
const e = l.find(
|
|
293
|
+
(o) => o.value === t || String(o.value) === String(t)
|
|
291
294
|
);
|
|
292
295
|
return e ? e.label : String(t);
|
|
293
296
|
}
|
|
294
|
-
const
|
|
297
|
+
const Ke = { class: "u-dict-field" }, Je = /* @__PURE__ */ V({
|
|
295
298
|
__name: "UDict",
|
|
296
299
|
props: {
|
|
297
300
|
fieldLabel: {},
|
|
@@ -315,67 +318,67 @@ const Qe = { class: "u-dict-field" }, Ge = /* @__PURE__ */ S({
|
|
|
315
318
|
dictType: {}
|
|
316
319
|
},
|
|
317
320
|
emits: ["update:modelValue"],
|
|
318
|
-
setup(
|
|
319
|
-
const e =
|
|
321
|
+
setup(l, { emit: t }) {
|
|
322
|
+
const e = l, o = t, c = z({
|
|
320
323
|
excluded: ["fieldLabel", "labelPosition", "labelWidth", "labelAlign", "required", "modelValue", "dictType"],
|
|
321
324
|
options: [],
|
|
322
325
|
loading: !1
|
|
323
|
-
}),
|
|
326
|
+
}), r = async () => {
|
|
324
327
|
if (e.dictType) {
|
|
325
|
-
|
|
328
|
+
c.loading = !0;
|
|
326
329
|
try {
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
} catch (
|
|
330
|
-
console.error("[UDict] 加载字典失败:",
|
|
330
|
+
const i = await A.get(N.dictApi(e.dictType));
|
|
331
|
+
i.status === 200 ? c.options = re(i.data) : (console.error("[UDict] 请求失败:", i.message), c.options = []);
|
|
332
|
+
} catch (i) {
|
|
333
|
+
console.error("[UDict] 加载字典失败:", i), c.options = [];
|
|
331
334
|
} finally {
|
|
332
|
-
|
|
335
|
+
c.loading = !1;
|
|
333
336
|
}
|
|
334
337
|
}
|
|
335
338
|
};
|
|
336
|
-
|
|
337
|
-
|
|
339
|
+
F(() => e.dictType, () => {
|
|
340
|
+
r();
|
|
338
341
|
}, { immediate: !0 });
|
|
339
|
-
const
|
|
340
|
-
const
|
|
341
|
-
return e.labelPosition === "left" && e.labelWidth && (
|
|
342
|
-
}),
|
|
342
|
+
const s = y(() => {
|
|
343
|
+
const i = {};
|
|
344
|
+
return e.labelPosition === "left" && e.labelWidth && (i.width = typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth), e.labelAlign && (i.textAlign = e.labelAlign), i;
|
|
345
|
+
}), d = y(() => ({
|
|
343
346
|
"u-dict-label-left": e.labelPosition === "left",
|
|
344
347
|
"u-dict-label-top": e.labelPosition === "top"
|
|
345
|
-
})),
|
|
346
|
-
onUpdate(
|
|
347
|
-
|
|
348
|
+
})), a = {
|
|
349
|
+
onUpdate(i) {
|
|
350
|
+
o("update:modelValue", i);
|
|
348
351
|
}
|
|
349
352
|
};
|
|
350
|
-
return (
|
|
351
|
-
const u =
|
|
352
|
-
return f(),
|
|
353
|
-
class:
|
|
353
|
+
return (i, n) => {
|
|
354
|
+
const u = ie, m = ne;
|
|
355
|
+
return f(), h("div", {
|
|
356
|
+
class: $(["u-dict", d.value])
|
|
354
357
|
}, [
|
|
355
|
-
|
|
358
|
+
l.fieldLabel ? (f(), h("div", {
|
|
356
359
|
key: 0,
|
|
357
360
|
class: "u-dict-label",
|
|
358
|
-
style:
|
|
361
|
+
style: U(s.value)
|
|
359
362
|
}, [
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
class:
|
|
363
|
+
B(T(l.fieldLabel) + " ", 1),
|
|
364
|
+
x("span", {
|
|
365
|
+
class: $(["required-star", { "required-star--visible": l.required }])
|
|
363
366
|
}, "*", 2)
|
|
364
|
-
], 4)) :
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
"model-value":
|
|
368
|
-
placeholder:
|
|
369
|
-
loading:
|
|
370
|
-
disabled:
|
|
367
|
+
], 4)) : D("", !0),
|
|
368
|
+
x("div", Ke, [
|
|
369
|
+
S(m, {
|
|
370
|
+
"model-value": l.modelValue,
|
|
371
|
+
placeholder: l.placeholder || "请选择",
|
|
372
|
+
loading: c.loading,
|
|
373
|
+
disabled: l.disable,
|
|
371
374
|
style: { width: "100%" },
|
|
372
|
-
onChange:
|
|
375
|
+
onChange: a.onUpdate
|
|
373
376
|
}, {
|
|
374
|
-
default:
|
|
375
|
-
(f(!0),
|
|
376
|
-
key:
|
|
377
|
-
label:
|
|
378
|
-
value:
|
|
377
|
+
default: w(() => [
|
|
378
|
+
(f(!0), h(I, null, M(c.options, (g) => (f(), k(u, {
|
|
379
|
+
key: g.value,
|
|
380
|
+
label: g.label,
|
|
381
|
+
value: g.value
|
|
379
382
|
}, null, 8, ["label", "value"]))), 128))
|
|
380
383
|
]),
|
|
381
384
|
_: 1
|
|
@@ -384,7 +387,7 @@ const Qe = { class: "u-dict-field" }, Ge = /* @__PURE__ */ S({
|
|
|
384
387
|
], 2);
|
|
385
388
|
};
|
|
386
389
|
}
|
|
387
|
-
}),
|
|
390
|
+
}), G = /* @__PURE__ */ P(Je, [["__scopeId", "data-v-239bb25f"]]), Xe = { class: "u-toggle-field" }, Ze = /* @__PURE__ */ V({
|
|
388
391
|
__name: "UToggle",
|
|
389
392
|
props: {
|
|
390
393
|
fieldLabel: {},
|
|
@@ -407,53 +410,53 @@ const Qe = { class: "u-dict-field" }, Ge = /* @__PURE__ */ S({
|
|
|
407
410
|
inactiveColor: {}
|
|
408
411
|
},
|
|
409
412
|
emits: ["update:modelValue"],
|
|
410
|
-
setup(
|
|
411
|
-
const e =
|
|
413
|
+
setup(l, { emit: t }) {
|
|
414
|
+
const e = l, o = t, c = z({
|
|
412
415
|
excluded: ["fieldLabel", "labelPosition", "labelWidth", "labelAlign", "required", "modelValue", "trueValue", "falseValue", "activeText", "inactiveText", "activeColor", "inactiveColor"]
|
|
413
|
-
}),
|
|
414
|
-
const
|
|
415
|
-
return e.labelPosition === "left" && e.labelWidth && (
|
|
416
|
-
},
|
|
416
|
+
}), r = () => {
|
|
417
|
+
const a = {};
|
|
418
|
+
return e.labelPosition === "left" && e.labelWidth && (a.width = typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth), e.labelAlign && (a.textAlign = e.labelAlign), a;
|
|
419
|
+
}, s = y({
|
|
417
420
|
get: () => e.modelValue === e.trueValue,
|
|
418
|
-
set: (
|
|
419
|
-
|
|
421
|
+
set: (a) => {
|
|
422
|
+
o("update:modelValue", a ? e.trueValue : e.falseValue);
|
|
420
423
|
}
|
|
421
|
-
}),
|
|
422
|
-
const
|
|
423
|
-
for (const
|
|
424
|
-
!
|
|
425
|
-
return
|
|
424
|
+
}), d = y(() => {
|
|
425
|
+
const a = {};
|
|
426
|
+
for (const i in e)
|
|
427
|
+
!c.excluded.includes(i) && i !== "modelValue" && (a[i] = e[i]);
|
|
428
|
+
return a;
|
|
426
429
|
});
|
|
427
|
-
return (
|
|
428
|
-
const
|
|
429
|
-
return f(),
|
|
430
|
-
class:
|
|
430
|
+
return (a, i) => {
|
|
431
|
+
const n = Ee;
|
|
432
|
+
return f(), h("div", {
|
|
433
|
+
class: $(["u-toggle", { "u-toggle-label-left": l.labelPosition === "left" }])
|
|
431
434
|
}, [
|
|
432
|
-
|
|
435
|
+
l.fieldLabel ? (f(), h("div", {
|
|
433
436
|
key: 0,
|
|
434
437
|
class: "u-toggle-label",
|
|
435
|
-
style:
|
|
438
|
+
style: U(r())
|
|
436
439
|
}, [
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
class:
|
|
440
|
+
B(T(l.fieldLabel) + " ", 1),
|
|
441
|
+
x("span", {
|
|
442
|
+
class: $(["required-star", { "required-star--visible": l.required }])
|
|
440
443
|
}, "*", 2)
|
|
441
|
-
], 4)) :
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
modelValue:
|
|
445
|
-
"onUpdate:modelValue":
|
|
446
|
-
},
|
|
447
|
-
"active-text":
|
|
448
|
-
"inactive-text":
|
|
449
|
-
"active-color":
|
|
450
|
-
"inactive-color":
|
|
444
|
+
], 4)) : D("", !0),
|
|
445
|
+
x("div", Xe, [
|
|
446
|
+
S(n, be({
|
|
447
|
+
modelValue: s.value,
|
|
448
|
+
"onUpdate:modelValue": i[0] || (i[0] = (u) => s.value = u)
|
|
449
|
+
}, d.value, {
|
|
450
|
+
"active-text": l.activeText,
|
|
451
|
+
"inactive-text": l.inactiveText,
|
|
452
|
+
"active-color": l.activeColor,
|
|
453
|
+
"inactive-color": l.inactiveColor
|
|
451
454
|
}), null, 16, ["modelValue", "active-text", "inactive-text", "active-color", "inactive-color"])
|
|
452
455
|
])
|
|
453
456
|
], 2);
|
|
454
457
|
};
|
|
455
458
|
}
|
|
456
|
-
}),
|
|
459
|
+
}), _e = /* @__PURE__ */ P(Ze, [["__scopeId", "data-v-94c1fd38"]]), et = { class: "u-cascader-levels" }, tt = /* @__PURE__ */ V({
|
|
457
460
|
__name: "UCascader",
|
|
458
461
|
props: {
|
|
459
462
|
fieldLabel: {},
|
|
@@ -466,64 +469,64 @@ const Qe = { class: "u-dict-field" }, Ge = /* @__PURE__ */ S({
|
|
|
466
469
|
depth: { default: 1 }
|
|
467
470
|
},
|
|
468
471
|
emits: ["update:modelValue"],
|
|
469
|
-
setup(
|
|
470
|
-
const e =
|
|
471
|
-
const
|
|
472
|
-
return e.labelPosition === "left" && e.labelWidth && (
|
|
473
|
-
},
|
|
474
|
-
const
|
|
475
|
-
let
|
|
476
|
-
for (let
|
|
477
|
-
if (
|
|
478
|
-
const u =
|
|
479
|
-
u && u.children ?
|
|
472
|
+
setup(l, { emit: t }) {
|
|
473
|
+
const e = l, o = t, c = () => {
|
|
474
|
+
const a = {};
|
|
475
|
+
return e.labelPosition === "left" && e.labelWidth && (a.width = typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth), e.labelAlign && (a.textAlign = e.labelAlign), a;
|
|
476
|
+
}, r = q([]), s = y(() => {
|
|
477
|
+
const a = [];
|
|
478
|
+
let i = e.options || [];
|
|
479
|
+
for (let n = 0; n < e.depth; n++)
|
|
480
|
+
if (a.push(i), r.value[n] !== void 0) {
|
|
481
|
+
const u = i.find((m) => m.value === r.value[n]);
|
|
482
|
+
u && u.children ? i = u.children : i = [];
|
|
480
483
|
} else
|
|
481
|
-
|
|
482
|
-
return
|
|
484
|
+
i = [];
|
|
485
|
+
return a;
|
|
483
486
|
});
|
|
484
|
-
|
|
485
|
-
|
|
487
|
+
F(() => e.modelValue, (a) => {
|
|
488
|
+
a != null ? r.value = Array.isArray(a) ? a : [a] : r.value = [];
|
|
486
489
|
}, { immediate: !0 });
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
for (let u =
|
|
490
|
-
|
|
491
|
-
const
|
|
492
|
-
|
|
490
|
+
const d = (a, i) => {
|
|
491
|
+
r.value[a] = i;
|
|
492
|
+
for (let u = a + 1; u < e.depth; u++)
|
|
493
|
+
r.value[u] = void 0;
|
|
494
|
+
const n = r.value.filter((u) => u !== void 0);
|
|
495
|
+
o("update:modelValue", n);
|
|
493
496
|
};
|
|
494
|
-
return (
|
|
495
|
-
const
|
|
496
|
-
return f(),
|
|
497
|
-
class:
|
|
497
|
+
return (a, i) => {
|
|
498
|
+
const n = ie, u = ne;
|
|
499
|
+
return f(), h("div", {
|
|
500
|
+
class: $(["u-cascader", { "u-cascader-label-left": l.labelPosition === "left" }])
|
|
498
501
|
}, [
|
|
499
|
-
|
|
502
|
+
l.fieldLabel ? (f(), h("div", {
|
|
500
503
|
key: 0,
|
|
501
504
|
class: "u-cascader-label",
|
|
502
|
-
style:
|
|
505
|
+
style: U(c())
|
|
503
506
|
}, [
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
class:
|
|
507
|
+
B(T(l.fieldLabel) + " ", 1),
|
|
508
|
+
x("span", {
|
|
509
|
+
class: $(["required-star", { "required-star--visible": l.required }])
|
|
507
510
|
}, "*", 2)
|
|
508
|
-
], 4)) :
|
|
509
|
-
|
|
510
|
-
(f(!0),
|
|
511
|
+
], 4)) : D("", !0),
|
|
512
|
+
x("div", et, [
|
|
513
|
+
(f(!0), h(I, null, M(l.depth, (m) => (f(), h("div", {
|
|
511
514
|
key: m - 1,
|
|
512
515
|
class: "u-cascader-level"
|
|
513
516
|
}, [
|
|
514
|
-
|
|
515
|
-
"model-value":
|
|
516
|
-
options:
|
|
517
|
-
disabled: m > 1 &&
|
|
517
|
+
S(u, {
|
|
518
|
+
"model-value": r.value[m - 1],
|
|
519
|
+
options: s.value[m - 1] || [],
|
|
520
|
+
disabled: m > 1 && r.value[m - 2] === void 0,
|
|
518
521
|
placeholder: `请选择${m}级`,
|
|
519
522
|
style: { width: "100%" },
|
|
520
|
-
onChange: (
|
|
523
|
+
onChange: (g) => d(m - 1, g)
|
|
521
524
|
}, {
|
|
522
|
-
default:
|
|
523
|
-
(f(!0),
|
|
524
|
-
key:
|
|
525
|
-
label:
|
|
526
|
-
value:
|
|
525
|
+
default: w(() => [
|
|
526
|
+
(f(!0), h(I, null, M(s.value[m - 1] || [], (g) => (f(), k(n, {
|
|
527
|
+
key: g.value,
|
|
528
|
+
label: g.label,
|
|
529
|
+
value: g.value
|
|
527
530
|
}, null, 8, ["label", "value"]))), 128))
|
|
528
531
|
]),
|
|
529
532
|
_: 2
|
|
@@ -533,7 +536,7 @@ const Qe = { class: "u-dict-field" }, Ge = /* @__PURE__ */ S({
|
|
|
533
536
|
], 2);
|
|
534
537
|
};
|
|
535
538
|
}
|
|
536
|
-
}),
|
|
539
|
+
}), Se = /* @__PURE__ */ P(tt, [["__scopeId", "data-v-d66c339c"]]), at = { class: "u-date-field" }, ot = /* @__PURE__ */ V({
|
|
537
540
|
__name: "UDate",
|
|
538
541
|
props: {
|
|
539
542
|
fieldLabel: {},
|
|
@@ -549,62 +552,445 @@ const Qe = { class: "u-dict-field" }, Ge = /* @__PURE__ */ S({
|
|
|
549
552
|
max: {}
|
|
550
553
|
},
|
|
551
554
|
emits: ["update:modelValue"],
|
|
552
|
-
setup(
|
|
553
|
-
const e =
|
|
554
|
-
const
|
|
555
|
-
return e.labelPosition === "left" && e.labelWidth && (
|
|
556
|
-
},
|
|
557
|
-
|
|
558
|
-
e.mode === "single" ?
|
|
555
|
+
setup(l, { emit: t }) {
|
|
556
|
+
const e = l, o = t, c = () => {
|
|
557
|
+
const a = {};
|
|
558
|
+
return e.labelPosition === "left" && e.labelWidth && (a.width = typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth), e.labelAlign && (a.textAlign = e.labelAlign), a;
|
|
559
|
+
}, r = q("");
|
|
560
|
+
F(() => e.modelValue, (a) => {
|
|
561
|
+
e.mode === "single" ? r.value = a || "" : e.mode === "multiple" ? r.value = Array.isArray(a) ? a : a ? [a] : [] : e.mode === "range" && (a && typeof a == "object" && a.from && a.to ? r.value = [a.from, a.to] : r.value = []);
|
|
559
562
|
}, { immediate: !0 });
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
},
|
|
563
|
-
return (
|
|
564
|
-
const
|
|
565
|
-
return f(),
|
|
566
|
-
class:
|
|
563
|
+
const s = (a) => {
|
|
564
|
+
a && (e.mode === "single" || e.mode === "multiple" ? o("update:modelValue", a) : e.mode === "range" && a && a.length === 2 && o("update:modelValue", { from: a[0], to: a[1] }));
|
|
565
|
+
}, d = y(() => e.mode === "range" ? "daterange" : e.mode === "multiple" ? "dates" : "date");
|
|
566
|
+
return (a, i) => {
|
|
567
|
+
const n = Ae;
|
|
568
|
+
return f(), h("div", {
|
|
569
|
+
class: $(["u-date", { "u-date-label-left": l.labelPosition === "left" }])
|
|
567
570
|
}, [
|
|
568
|
-
|
|
571
|
+
l.fieldLabel ? (f(), h("div", {
|
|
569
572
|
key: 0,
|
|
570
573
|
class: "u-date-label",
|
|
571
|
-
style:
|
|
574
|
+
style: U(c())
|
|
572
575
|
}, [
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
class:
|
|
576
|
+
B(T(l.fieldLabel) + " ", 1),
|
|
577
|
+
x("span", {
|
|
578
|
+
class: $(["required-star", { "required-star--visible": l.required }])
|
|
576
579
|
}, "*", 2)
|
|
577
|
-
], 4)) :
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
modelValue:
|
|
581
|
-
"onUpdate:modelValue":
|
|
582
|
-
type:
|
|
583
|
-
placeholder:
|
|
584
|
-
"range-separator":
|
|
585
|
-
"start-placeholder":
|
|
586
|
-
"end-placeholder":
|
|
587
|
-
format:
|
|
588
|
-
"value-format":
|
|
589
|
-
onChange:
|
|
580
|
+
], 4)) : D("", !0),
|
|
581
|
+
x("div", at, [
|
|
582
|
+
S(n, {
|
|
583
|
+
modelValue: r.value,
|
|
584
|
+
"onUpdate:modelValue": i[0] || (i[0] = (u) => r.value = u),
|
|
585
|
+
type: d.value,
|
|
586
|
+
placeholder: l.locale === "en-US" ? "Select date" : "选择日期",
|
|
587
|
+
"range-separator": l.locale === "en-US" ? "to" : "至",
|
|
588
|
+
"start-placeholder": l.locale === "en-US" ? "Start date" : "开始日期",
|
|
589
|
+
"end-placeholder": l.locale === "en-US" ? "End date" : "结束日期",
|
|
590
|
+
format: l.mask.replace("YYYY", "YYYY").replace("MM", "MM").replace("DD", "DD"),
|
|
591
|
+
"value-format": l.mask.replace("YYYY", "YYYY").replace("MM", "MM").replace("DD", "DD"),
|
|
592
|
+
onChange: s
|
|
590
593
|
}, null, 8, ["modelValue", "type", "placeholder", "range-separator", "start-placeholder", "end-placeholder", "format", "value-format"])
|
|
591
594
|
])
|
|
592
595
|
], 2);
|
|
593
596
|
};
|
|
594
597
|
}
|
|
595
|
-
}),
|
|
598
|
+
}), oe = /* @__PURE__ */ P(ot, [["__scopeId", "data-v-9cd05064"]]);
|
|
599
|
+
function J(l, t = "info") {
|
|
600
|
+
ge({
|
|
601
|
+
message: l,
|
|
602
|
+
type: t,
|
|
603
|
+
duration: 1e3,
|
|
604
|
+
showClose: !1
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
function E(l) {
|
|
608
|
+
ge({
|
|
609
|
+
message: l,
|
|
610
|
+
type: "error",
|
|
611
|
+
duration: 2e3,
|
|
612
|
+
showClose: !1
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
function lt(l) {
|
|
616
|
+
J(l, "success");
|
|
617
|
+
}
|
|
618
|
+
function nt(l) {
|
|
619
|
+
J(l, "error");
|
|
620
|
+
}
|
|
621
|
+
function it(l) {
|
|
622
|
+
J(l, "warning");
|
|
623
|
+
}
|
|
624
|
+
function st(l) {
|
|
625
|
+
J(l, "info");
|
|
626
|
+
}
|
|
627
|
+
const j = {
|
|
628
|
+
notify: J,
|
|
629
|
+
success: lt,
|
|
630
|
+
error: nt,
|
|
631
|
+
warning: it,
|
|
632
|
+
info: st,
|
|
633
|
+
alertError: E
|
|
634
|
+
}, rt = {
|
|
635
|
+
key: 0,
|
|
636
|
+
class: "u-menu-brand"
|
|
637
|
+
}, dt = ["src"], ct = { class: "u-menu-brand-text" }, ut = {
|
|
638
|
+
key: 1,
|
|
639
|
+
class: "u-menu-logout"
|
|
640
|
+
}, ft = /* @__PURE__ */ V({
|
|
641
|
+
__name: "UMenu",
|
|
642
|
+
props: {
|
|
643
|
+
menuId: { default: "menu" },
|
|
644
|
+
config: {},
|
|
645
|
+
mode: {},
|
|
646
|
+
projectName: {},
|
|
647
|
+
activePath: {},
|
|
648
|
+
width: {}
|
|
649
|
+
},
|
|
650
|
+
emits: ["menu-click", "logout"],
|
|
651
|
+
setup(l, { expose: t, emit: e }) {
|
|
652
|
+
const o = l, c = e, r = z({
|
|
653
|
+
// 菜单配置
|
|
654
|
+
config: null,
|
|
655
|
+
// 实际渲染的菜单列表(静态配置或字典菜单)
|
|
656
|
+
menus: [],
|
|
657
|
+
// 当前激活的跳转目标
|
|
658
|
+
activePath: "",
|
|
659
|
+
// 图标映射(@element-plus/icons-vue 的具名导出)
|
|
660
|
+
iconMap: {},
|
|
661
|
+
// 图标是否已加载
|
|
662
|
+
iconsLoaded: !1
|
|
663
|
+
}), s = y(() => {
|
|
664
|
+
var a, i, n, u, m, g, b, p;
|
|
665
|
+
return {
|
|
666
|
+
// 项目名称:为空则不显示
|
|
667
|
+
projectName: o.projectName ?? ((a = r.config) == null ? void 0 : a.projectName) ?? "",
|
|
668
|
+
// 项目 logo
|
|
669
|
+
logo: ((i = r.config) == null ? void 0 : i.logo) || "",
|
|
670
|
+
// 菜单模式
|
|
671
|
+
mode: o.mode ?? ((n = r.config) == null ? void 0 : n.mode) ?? "sidebar",
|
|
672
|
+
// 是否水平模式
|
|
673
|
+
isHorizontal: (o.mode ?? ((u = r.config) == null ? void 0 : u.mode) ?? "sidebar") === "horizontal",
|
|
674
|
+
// el-menu 的 mode
|
|
675
|
+
elMode: (o.mode ?? ((m = r.config) == null ? void 0 : m.mode) ?? "sidebar") === "horizontal" ? "horizontal" : "vertical",
|
|
676
|
+
// 菜单宽度(仅 sidebar 生效)
|
|
677
|
+
width: o.width ?? ((g = r.config) == null ? void 0 : g.width) ?? 220,
|
|
678
|
+
// 菜单列表
|
|
679
|
+
menus: r.menus,
|
|
680
|
+
// 当前激活项的 el-menu index
|
|
681
|
+
activeIndex: d.getIndexByPath(r.activePath),
|
|
682
|
+
// 是否显示退出登录区域
|
|
683
|
+
showLogout: ((b = r.config) == null ? void 0 : b.showLogout) !== !1,
|
|
684
|
+
// 退出登录按钮文本
|
|
685
|
+
logoutText: ((p = r.config) == null ? void 0 : p.logoutText) || "退出登录",
|
|
686
|
+
// 图标映射
|
|
687
|
+
iconMap: r.iconMap
|
|
688
|
+
};
|
|
689
|
+
}), d = {
|
|
690
|
+
// 初始化
|
|
691
|
+
async init() {
|
|
692
|
+
await d.ensureIcons(), o.config ? (r.config = o.config, r.menus = d.normalizeMenus(o.config.menus)) : await d.loadConfig(o.menuId), r.activePath = o.activePath || r.activePath;
|
|
693
|
+
},
|
|
694
|
+
// 加载菜单配置(与 UDict 一致:http + status === 200 判断)
|
|
695
|
+
async loadConfig(a) {
|
|
696
|
+
if (a)
|
|
697
|
+
try {
|
|
698
|
+
const i = await A.get(N.formCfgApi(a));
|
|
699
|
+
if (i.status !== 200) {
|
|
700
|
+
E(i.message || "获取菜单配置失败");
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
703
|
+
const n = i.data || {};
|
|
704
|
+
r.config = n, n.dictType ? await d.loadDictMenus(n.dictType) : r.menus = d.normalizeMenus(n.menus);
|
|
705
|
+
} catch (i) {
|
|
706
|
+
E((i == null ? void 0 : i.message) || "获取菜单配置失败"), r.menus = [];
|
|
707
|
+
}
|
|
708
|
+
},
|
|
709
|
+
// 加载字典菜单(参考 UDict 的字典数据来源,字典树对应菜单的 1、2 级)
|
|
710
|
+
async loadDictMenus(a) {
|
|
711
|
+
try {
|
|
712
|
+
const i = await A.get(N.dictApi(a));
|
|
713
|
+
if (i.status !== 200) {
|
|
714
|
+
E(i.message || "获取菜单字典失败");
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
r.menus = d.normalizeMenus(se(i.data));
|
|
718
|
+
} catch (i) {
|
|
719
|
+
E((i == null ? void 0 : i.message) || "获取菜单字典失败"), r.menus = [];
|
|
720
|
+
}
|
|
721
|
+
},
|
|
722
|
+
// 规范化菜单列表(最多 2 级,第二级的 children 不再展开)
|
|
723
|
+
normalizeMenus(a) {
|
|
724
|
+
return Array.isArray(a) ? a.map((i) => d.normalizeMenuNode(i)).filter(Boolean) : [];
|
|
725
|
+
},
|
|
726
|
+
// 规范化单个菜单节点(兼容静态配置与字典节点两种结构)
|
|
727
|
+
normalizeMenuNode(a) {
|
|
728
|
+
if (!a || typeof a != "object") return null;
|
|
729
|
+
const i = d.parseInfo(a.info), n = a.label ?? a.dict_value ?? a.name;
|
|
730
|
+
if (!n) return null;
|
|
731
|
+
const u = i.path ?? a.path ?? a.dict_code ?? a.value ?? "", m = i.type ?? a.type ?? "route", g = {
|
|
732
|
+
...a,
|
|
733
|
+
label: String(n),
|
|
734
|
+
type: m,
|
|
735
|
+
path: String(u ?? ""),
|
|
736
|
+
icon: i.icon ?? a.icon ?? ""
|
|
737
|
+
};
|
|
738
|
+
delete g.children;
|
|
739
|
+
const b = a.children;
|
|
740
|
+
return Array.isArray(b) && b.length > 0 && (g.children = b.map((p) => d.normalizeMenuNode(p)).filter(Boolean)), g;
|
|
741
|
+
},
|
|
742
|
+
// 解析字典节点的 info(可能是 JSON 字符串,也可能是对象)
|
|
743
|
+
parseInfo(a) {
|
|
744
|
+
if (!a) return {};
|
|
745
|
+
if (typeof a == "object") return a;
|
|
746
|
+
if (typeof a == "string")
|
|
747
|
+
try {
|
|
748
|
+
const i = JSON.parse(a);
|
|
749
|
+
return i && typeof i == "object" ? i : {};
|
|
750
|
+
} catch {
|
|
751
|
+
return { path: a };
|
|
752
|
+
}
|
|
753
|
+
return {};
|
|
754
|
+
},
|
|
755
|
+
// 生成 el-menu 的 index(一级)
|
|
756
|
+
itemIndex(a, i) {
|
|
757
|
+
return a.path || `menu-${i}`;
|
|
758
|
+
},
|
|
759
|
+
// 生成 el-menu 的 index(二级)
|
|
760
|
+
childIndex(a, i, n, u) {
|
|
761
|
+
return n.path ? n.path : `${d.itemIndex(a, i)}-${u}`;
|
|
762
|
+
},
|
|
763
|
+
// 是否有二级菜单(最多支持 2 级)
|
|
764
|
+
hasChildren(a) {
|
|
765
|
+
return Array.isArray(a.children) && a.children.length > 0;
|
|
766
|
+
},
|
|
767
|
+
// 根据跳转目标找到 el-menu index(用于 default-active)
|
|
768
|
+
getIndexByPath(a) {
|
|
769
|
+
if (!a) return "";
|
|
770
|
+
for (let i = 0; i < r.menus.length; i++) {
|
|
771
|
+
const n = r.menus[i];
|
|
772
|
+
if (n.path === a) return d.itemIndex(n, i);
|
|
773
|
+
const u = n.children || [];
|
|
774
|
+
for (let m = 0; m < u.length; m++)
|
|
775
|
+
if (u[m].path === a) return d.childIndex(n, i, u[m], m);
|
|
776
|
+
}
|
|
777
|
+
return "";
|
|
778
|
+
},
|
|
779
|
+
// 根据 el-menu index 找到菜单项
|
|
780
|
+
findItemByIndex(a, i) {
|
|
781
|
+
for (let n = 0; n < r.menus.length; n++) {
|
|
782
|
+
const u = r.menus[n], m = d.itemIndex(u, n);
|
|
783
|
+
if (m === a)
|
|
784
|
+
return { item: u, level: 1, indexPath: i || [m], index: a };
|
|
785
|
+
const g = u.children || [];
|
|
786
|
+
for (let b = 0; b < g.length; b++) {
|
|
787
|
+
const p = g[b], C = d.childIndex(u, n, p, b);
|
|
788
|
+
if (C === a)
|
|
789
|
+
return { item: p, level: 2, indexPath: i || [m, C], index: a };
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
return null;
|
|
793
|
+
},
|
|
794
|
+
// 解析跳转目标:外部可直接通过 type 判断跳转类型
|
|
795
|
+
resolveTarget(a) {
|
|
796
|
+
const i = a.type || "route", n = a.path || "";
|
|
797
|
+
return i === "url" ? { type: i, path: n, url: n } : i === "yaml" ? { type: i, path: n, fileId: a.fileId || n } : { type: "route", path: n, route: n };
|
|
798
|
+
},
|
|
799
|
+
// 菜单点击
|
|
800
|
+
handleSelect(a, i) {
|
|
801
|
+
const n = d.findItemByIndex(a, i);
|
|
802
|
+
if (!n || d.hasChildren(n.item)) return;
|
|
803
|
+
const u = d.resolveTarget(n.item);
|
|
804
|
+
r.activePath = n.item.path || a;
|
|
805
|
+
const m = {
|
|
806
|
+
...u,
|
|
807
|
+
item: n.item,
|
|
808
|
+
level: n.level,
|
|
809
|
+
indexPath: n.indexPath,
|
|
810
|
+
index: a
|
|
811
|
+
};
|
|
812
|
+
c("menu-click", m);
|
|
813
|
+
},
|
|
814
|
+
// 退出登录
|
|
815
|
+
handleLogout() {
|
|
816
|
+
c("logout");
|
|
817
|
+
},
|
|
818
|
+
// 设置激活项
|
|
819
|
+
setActivePath(a) {
|
|
820
|
+
r.activePath = a;
|
|
821
|
+
},
|
|
822
|
+
// 加载图标(按需 import,避免无图标时把整包图标打进产物)
|
|
823
|
+
async ensureIcons() {
|
|
824
|
+
if (!r.iconsLoaded) {
|
|
825
|
+
r.iconsLoaded = !0;
|
|
826
|
+
try {
|
|
827
|
+
const a = await import("@element-plus/icons-vue"), i = a != null && a.default ? { ...a.default, ...a } : { ...a }, n = {};
|
|
828
|
+
for (const [u, m] of Object.entries(i))
|
|
829
|
+
n[u] = ve(m);
|
|
830
|
+
r.iconMap = n;
|
|
831
|
+
} catch (a) {
|
|
832
|
+
console.warn("[UMenu] @element-plus/icons-vue 不可用,菜单图标将被忽略", a);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
},
|
|
836
|
+
// 取图标组件
|
|
837
|
+
getIcon(a) {
|
|
838
|
+
return a && r.iconMap[a] || null;
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
return F(() => o.menuId, (a) => {
|
|
842
|
+
o.config || d.loadConfig(a);
|
|
843
|
+
}), F(() => o.activePath, (a) => {
|
|
844
|
+
r.activePath = a || "";
|
|
845
|
+
}), F(() => o.config, (a) => {
|
|
846
|
+
a && (r.config = a, r.menus = d.normalizeMenus(a.menus));
|
|
847
|
+
}), H(() => {
|
|
848
|
+
d.init();
|
|
849
|
+
}), t({
|
|
850
|
+
loadConfig: d.loadConfig,
|
|
851
|
+
setActivePath: d.setActivePath
|
|
852
|
+
}), (a, i) => {
|
|
853
|
+
const n = ye, u = Ue, m = Re, g = Be, b = Y;
|
|
854
|
+
return f(), h("div", {
|
|
855
|
+
class: $(["u-menu", [`u-menu--${s.value.mode}`, { "u-menu--no-brand": !s.value.projectName }]]),
|
|
856
|
+
style: U(s.value.isHorizontal ? {} : { width: s.value.width + "px" })
|
|
857
|
+
}, [
|
|
858
|
+
s.value.projectName ? (f(), h("div", rt, [
|
|
859
|
+
L(a.$slots, "brand", {
|
|
860
|
+
projectName: s.value.projectName,
|
|
861
|
+
mode: s.value.mode
|
|
862
|
+
}, () => [
|
|
863
|
+
s.value.logo ? (f(), h("img", {
|
|
864
|
+
key: 0,
|
|
865
|
+
class: "u-menu-logo",
|
|
866
|
+
src: s.value.logo,
|
|
867
|
+
alt: "logo"
|
|
868
|
+
}, null, 8, dt)) : D("", !0),
|
|
869
|
+
x("span", ct, T(s.value.projectName), 1)
|
|
870
|
+
], !0)
|
|
871
|
+
])) : D("", !0),
|
|
872
|
+
S(g, {
|
|
873
|
+
class: "u-menu-list",
|
|
874
|
+
mode: s.value.elMode,
|
|
875
|
+
"default-active": s.value.activeIndex,
|
|
876
|
+
"unique-opened": !s.value.isHorizontal,
|
|
877
|
+
onSelect: d.handleSelect
|
|
878
|
+
}, {
|
|
879
|
+
default: w(() => [
|
|
880
|
+
(f(!0), h(I, null, M(s.value.menus, (p, C) => (f(), h(I, {
|
|
881
|
+
key: d.itemIndex(p, C)
|
|
882
|
+
}, [
|
|
883
|
+
d.hasChildren(p) ? (f(), k(m, {
|
|
884
|
+
key: 0,
|
|
885
|
+
index: d.itemIndex(p, C)
|
|
886
|
+
}, {
|
|
887
|
+
title: w(() => [
|
|
888
|
+
L(a.$slots, "menu-title", {
|
|
889
|
+
item: p,
|
|
890
|
+
level: 1,
|
|
891
|
+
index: C
|
|
892
|
+
}, () => [
|
|
893
|
+
d.getIcon(p.icon) ? (f(), k(n, {
|
|
894
|
+
key: 0,
|
|
895
|
+
class: "u-menu-icon"
|
|
896
|
+
}, {
|
|
897
|
+
default: w(() => [
|
|
898
|
+
(f(), k(O(d.getIcon(p.icon))))
|
|
899
|
+
]),
|
|
900
|
+
_: 2
|
|
901
|
+
}, 1024)) : D("", !0),
|
|
902
|
+
x("span", null, T(p.label), 1)
|
|
903
|
+
], !0)
|
|
904
|
+
]),
|
|
905
|
+
default: w(() => [
|
|
906
|
+
(f(!0), h(I, null, M(p.children, (v, W) => (f(), k(u, {
|
|
907
|
+
key: d.childIndex(p, C, v, W),
|
|
908
|
+
index: d.childIndex(p, C, v, W)
|
|
909
|
+
}, {
|
|
910
|
+
default: w(() => [
|
|
911
|
+
L(a.$slots, "menu-item", {
|
|
912
|
+
item: v,
|
|
913
|
+
level: 2,
|
|
914
|
+
index: W,
|
|
915
|
+
parent: p
|
|
916
|
+
}, () => [
|
|
917
|
+
d.getIcon(v.icon) ? (f(), k(n, {
|
|
918
|
+
key: 0,
|
|
919
|
+
class: "u-menu-icon"
|
|
920
|
+
}, {
|
|
921
|
+
default: w(() => [
|
|
922
|
+
(f(), k(O(d.getIcon(v.icon))))
|
|
923
|
+
]),
|
|
924
|
+
_: 2
|
|
925
|
+
}, 1024)) : D("", !0),
|
|
926
|
+
x("span", null, T(v.label), 1)
|
|
927
|
+
], !0)
|
|
928
|
+
]),
|
|
929
|
+
_: 2
|
|
930
|
+
}, 1032, ["index"]))), 128))
|
|
931
|
+
]),
|
|
932
|
+
_: 2
|
|
933
|
+
}, 1032, ["index"])) : (f(), k(u, {
|
|
934
|
+
key: 1,
|
|
935
|
+
index: d.itemIndex(p, C)
|
|
936
|
+
}, {
|
|
937
|
+
default: w(() => [
|
|
938
|
+
L(a.$slots, "menu-item", {
|
|
939
|
+
item: p,
|
|
940
|
+
level: 1,
|
|
941
|
+
index: C,
|
|
942
|
+
parent: null
|
|
943
|
+
}, () => [
|
|
944
|
+
d.getIcon(p.icon) ? (f(), k(n, {
|
|
945
|
+
key: 0,
|
|
946
|
+
class: "u-menu-icon"
|
|
947
|
+
}, {
|
|
948
|
+
default: w(() => [
|
|
949
|
+
(f(), k(O(d.getIcon(p.icon))))
|
|
950
|
+
]),
|
|
951
|
+
_: 2
|
|
952
|
+
}, 1024)) : D("", !0),
|
|
953
|
+
x("span", null, T(p.label), 1)
|
|
954
|
+
], !0)
|
|
955
|
+
]),
|
|
956
|
+
_: 2
|
|
957
|
+
}, 1032, ["index"]))
|
|
958
|
+
], 64))), 128))
|
|
959
|
+
]),
|
|
960
|
+
_: 3
|
|
961
|
+
}, 8, ["mode", "default-active", "unique-opened", "onSelect"]),
|
|
962
|
+
s.value.showLogout ? (f(), h("div", ut, [
|
|
963
|
+
L(a.$slots, "logout", {
|
|
964
|
+
mode: s.value.mode
|
|
965
|
+
}, () => [
|
|
966
|
+
S(b, {
|
|
967
|
+
class: "u-menu-logout-btn",
|
|
968
|
+
text: "",
|
|
969
|
+
onClick: d.handleLogout
|
|
970
|
+
}, {
|
|
971
|
+
default: w(() => [
|
|
972
|
+
B(T(s.value.logoutText), 1)
|
|
973
|
+
]),
|
|
974
|
+
_: 1
|
|
975
|
+
}, 8, ["onClick"])
|
|
976
|
+
], !0)
|
|
977
|
+
])) : D("", !0)
|
|
978
|
+
], 6);
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
}), mt = /* @__PURE__ */ P(ft, [["__scopeId", "data-v-48e7e044"]]), pt = {
|
|
596
982
|
key: 0,
|
|
597
983
|
class: "form-content"
|
|
598
|
-
},
|
|
984
|
+
}, ht = {
|
|
599
985
|
key: 1,
|
|
600
986
|
class: "form-layout"
|
|
601
|
-
},
|
|
987
|
+
}, gt = {
|
|
602
988
|
key: 0,
|
|
603
989
|
class: "form-header"
|
|
604
|
-
},
|
|
990
|
+
}, yt = { class: "title" }, bt = { class: "form-body" }, vt = {
|
|
605
991
|
key: 1,
|
|
606
992
|
class: "form-footer"
|
|
607
|
-
},
|
|
993
|
+
}, wt = /* @__PURE__ */ V({
|
|
608
994
|
__name: "FormContainer",
|
|
609
995
|
props: {
|
|
610
996
|
visible: { type: Boolean },
|
|
@@ -613,95 +999,95 @@ const Qe = { class: "u-dict-field" }, Ge = /* @__PURE__ */ S({
|
|
|
613
999
|
loading: { type: Boolean, default: !1 }
|
|
614
1000
|
},
|
|
615
1001
|
emits: ["update:visible", "close"],
|
|
616
|
-
setup(
|
|
617
|
-
const e =
|
|
1002
|
+
setup(l, { emit: t }) {
|
|
1003
|
+
const e = l, o = t, { visible: c } = We(e), r = y(() => e.layout.open === "normal"), s = y(() => e.layout.width || 400), d = {
|
|
618
1004
|
handleClose() {
|
|
619
|
-
|
|
1005
|
+
o("update:visible", !1), o("close");
|
|
620
1006
|
},
|
|
621
|
-
updateVisible(
|
|
622
|
-
|
|
1007
|
+
updateVisible(a) {
|
|
1008
|
+
o("update:visible", a);
|
|
623
1009
|
}
|
|
624
1010
|
};
|
|
625
|
-
return (
|
|
626
|
-
const
|
|
627
|
-
return
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
])) :
|
|
631
|
-
|
|
632
|
-
|
|
1011
|
+
return (a, i) => {
|
|
1012
|
+
const n = ye, u = Me;
|
|
1013
|
+
return r.value ? R(c) ? (f(), h("div", ht, [
|
|
1014
|
+
l.title ? (f(), h("div", gt, [
|
|
1015
|
+
x("div", yt, T(l.title), 1)
|
|
1016
|
+
])) : D("", !0),
|
|
1017
|
+
x("div", bt, [
|
|
1018
|
+
l.loading ? (f(), k(n, {
|
|
633
1019
|
key: 0,
|
|
634
1020
|
class: "is-loading",
|
|
635
1021
|
size: 40
|
|
636
1022
|
}, {
|
|
637
|
-
default:
|
|
638
|
-
|
|
1023
|
+
default: w(() => [
|
|
1024
|
+
S(R(pe))
|
|
639
1025
|
]),
|
|
640
1026
|
_: 1
|
|
641
|
-
})) :
|
|
1027
|
+
})) : L(a.$slots, "default", {}, void 0, !0, 1)
|
|
642
1028
|
]),
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
])) :
|
|
646
|
-
])) :
|
|
1029
|
+
a.$slots.actions ? (f(), h("div", vt, [
|
|
1030
|
+
L(a.$slots, "actions", {}, void 0, !0)
|
|
1031
|
+
])) : D("", !0)
|
|
1032
|
+
])) : D("", !0) : (f(), k(u, {
|
|
647
1033
|
key: 0,
|
|
648
|
-
"model-value":
|
|
649
|
-
title:
|
|
650
|
-
width:
|
|
1034
|
+
"model-value": R(c),
|
|
1035
|
+
title: l.title,
|
|
1036
|
+
width: s.value,
|
|
651
1037
|
"close-on-click-modal": !1,
|
|
652
|
-
"onUpdate:modelValue":
|
|
653
|
-
onClose:
|
|
1038
|
+
"onUpdate:modelValue": d.updateVisible,
|
|
1039
|
+
onClose: d.handleClose
|
|
654
1040
|
}, {
|
|
655
|
-
footer:
|
|
656
|
-
|
|
1041
|
+
footer: w(() => [
|
|
1042
|
+
L(a.$slots, "actions", {}, void 0, !0)
|
|
657
1043
|
]),
|
|
658
|
-
default:
|
|
659
|
-
|
|
660
|
-
|
|
1044
|
+
default: w(() => [
|
|
1045
|
+
R(c) ? (f(), h("div", pt, [
|
|
1046
|
+
l.loading ? (f(), k(n, {
|
|
661
1047
|
key: 0,
|
|
662
1048
|
class: "is-loading",
|
|
663
1049
|
size: 40
|
|
664
1050
|
}, {
|
|
665
|
-
default:
|
|
666
|
-
|
|
1051
|
+
default: w(() => [
|
|
1052
|
+
S(R(pe))
|
|
667
1053
|
]),
|
|
668
1054
|
_: 1
|
|
669
|
-
})) :
|
|
670
|
-
])) :
|
|
1055
|
+
})) : L(a.$slots, "default", {}, void 0, !0, 1)
|
|
1056
|
+
])) : D("", !0)
|
|
671
1057
|
]),
|
|
672
1058
|
_: 3
|
|
673
1059
|
}, 8, ["model-value", "title", "width", "onUpdate:modelValue", "onClose"]));
|
|
674
1060
|
};
|
|
675
1061
|
}
|
|
676
|
-
}),
|
|
1062
|
+
}), xt = /* @__PURE__ */ P(wt, [["__scopeId", "data-v-7e522999"]]), Ct = /* @__PURE__ */ V({
|
|
677
1063
|
__name: "FormGrid",
|
|
678
1064
|
props: {
|
|
679
1065
|
fields: {},
|
|
680
1066
|
layout: {}
|
|
681
1067
|
},
|
|
682
|
-
setup(
|
|
683
|
-
const t =
|
|
684
|
-
columns:
|
|
685
|
-
}),
|
|
686
|
-
getColSpan(
|
|
687
|
-
const
|
|
688
|
-
return Math.min(
|
|
1068
|
+
setup(l) {
|
|
1069
|
+
const t = l, e = z({
|
|
1070
|
+
columns: y(() => t.layout.columns || 1)
|
|
1071
|
+
}), o = {
|
|
1072
|
+
getColSpan(c) {
|
|
1073
|
+
const r = c.colSpan || 1;
|
|
1074
|
+
return Math.min(r, e.columns);
|
|
689
1075
|
}
|
|
690
1076
|
};
|
|
691
|
-
return (
|
|
1077
|
+
return (c, r) => (f(), h("div", {
|
|
692
1078
|
class: "form-grid",
|
|
693
|
-
style:
|
|
1079
|
+
style: U({ "--grid-columns": e.columns })
|
|
694
1080
|
}, [
|
|
695
|
-
(f(!0),
|
|
696
|
-
key:
|
|
1081
|
+
(f(!0), h(I, null, M(l.fields, (s) => (f(), h("div", {
|
|
1082
|
+
key: s.field,
|
|
697
1083
|
class: "form-grid-item",
|
|
698
|
-
style:
|
|
1084
|
+
style: U({ gridColumn: `span ${o.getColSpan(s)}` })
|
|
699
1085
|
}, [
|
|
700
|
-
|
|
1086
|
+
L(c.$slots, "default", { field: s }, void 0, !0)
|
|
701
1087
|
], 4))), 128))
|
|
702
1088
|
], 4));
|
|
703
1089
|
}
|
|
704
|
-
}),
|
|
1090
|
+
}), _t = /* @__PURE__ */ P(Ct, [["__scopeId", "data-v-90ed35a4"]]), St = { class: "form-field" }, kt = /* @__PURE__ */ V({
|
|
705
1091
|
__name: "FormField",
|
|
706
1092
|
props: {
|
|
707
1093
|
field: {},
|
|
@@ -711,113 +1097,113 @@ const Qe = { class: "u-dict-field" }, Ge = /* @__PURE__ */ S({
|
|
|
711
1097
|
error: {}
|
|
712
1098
|
},
|
|
713
1099
|
emits: ["update:modelValue"],
|
|
714
|
-
setup(
|
|
715
|
-
const e =
|
|
716
|
-
componentMap:
|
|
717
|
-
input:
|
|
718
|
-
"input-number":
|
|
719
|
-
dict:
|
|
720
|
-
switch:
|
|
721
|
-
cascader:
|
|
722
|
-
date:
|
|
1100
|
+
setup(l, { emit: t }) {
|
|
1101
|
+
const e = l, o = t, c = z({
|
|
1102
|
+
componentMap: ve({
|
|
1103
|
+
input: K,
|
|
1104
|
+
"input-number": xe,
|
|
1105
|
+
dict: G,
|
|
1106
|
+
switch: _e,
|
|
1107
|
+
cascader: Se,
|
|
1108
|
+
date: oe
|
|
723
1109
|
}),
|
|
724
1110
|
cascaderOptions: []
|
|
725
1111
|
});
|
|
726
|
-
|
|
727
|
-
e.field.cascaderKey &&
|
|
728
|
-
|
|
1112
|
+
F(() => e.field.cascaderKey, () => {
|
|
1113
|
+
e.field.cascaderKey && A.get(N.cascaderApi(e.field.cascaderKey)).then((n) => {
|
|
1114
|
+
n.status === 200 && (c.cascaderOptions = se(n.data));
|
|
729
1115
|
});
|
|
730
1116
|
}, { immediate: !0 });
|
|
731
|
-
const
|
|
1117
|
+
const s = y(() => c.componentMap[e.field.type] || K), d = y(() => {
|
|
732
1118
|
if ((e.layout.labelPosition || "top") === "left") {
|
|
733
1119
|
const u = e.layout.labelWidth || 0, m = typeof u == "number" ? u + 4 : u;
|
|
734
1120
|
return { marginLeft: typeof m == "number" ? `${m}px` : m };
|
|
735
1121
|
}
|
|
736
1122
|
return {};
|
|
737
|
-
}),
|
|
738
|
-
const { field:
|
|
739
|
-
let
|
|
740
|
-
|
|
741
|
-
const
|
|
742
|
-
fieldLabel:
|
|
743
|
-
modelValue:
|
|
1123
|
+
}), a = y(() => {
|
|
1124
|
+
const { field: n, modelValue: u, layout: m, disabled: g } = e;
|
|
1125
|
+
let b = u;
|
|
1126
|
+
n.type === "switch" && u == null && (b = !1);
|
|
1127
|
+
const p = {
|
|
1128
|
+
fieldLabel: n.label,
|
|
1129
|
+
modelValue: b,
|
|
744
1130
|
labelPosition: m.labelPosition || "top",
|
|
745
|
-
disable:
|
|
746
|
-
name:
|
|
747
|
-
required:
|
|
1131
|
+
disable: g,
|
|
1132
|
+
name: n.field,
|
|
1133
|
+
required: n.required
|
|
748
1134
|
};
|
|
749
|
-
if (m.labelWidth && (
|
|
750
|
-
|
|
751
|
-
const
|
|
752
|
-
|
|
1135
|
+
if (m.labelWidth && (p.labelWidth = m.labelWidth), m.labelAlign && (p.labelAlign = m.labelAlign), n.maxlength && (p.maxlength = n.maxlength), n.placeholder && (p.placeholder = n.placeholder), n.readonly && (p.readonly = n.readonly), n.lineCount && n.lineCount >= 2 ? (p.type = "textarea", p.rows = n.lineCount) : n.inputType && (p.type = n.inputType), n.type === "switch" && (n.activeText && (p.activeText = n.activeText), n.inactiveText && (p.inactiveText = n.inactiveText), n.activeColor && (p.activeColor = n.activeColor), n.inactiveColor && (p.inactiveColor = n.inactiveColor), n.trueValue !== void 0 && (p.trueValue = n.trueValue), n.falseValue !== void 0 && (p.falseValue = n.falseValue)), n.dictType && (p.dictType = n.dictType), n.cascaderKey && (p.options = c.cascaderOptions, p.depth = n.cascaderDepth || 2), n.type === "date") {
|
|
1136
|
+
n.mode && (p.mode = n.mode), n.locale && (p.locale = n.locale), n.format ? p.mask = n.format : n.mask && (p.mask = n.mask);
|
|
1137
|
+
const C = n.dateMin ?? n.min, v = n.dateMax ?? n.max;
|
|
1138
|
+
C != null && (p.min = C), v != null && (p.max = v);
|
|
753
1139
|
}
|
|
754
|
-
return
|
|
755
|
-
}),
|
|
756
|
-
handleUpdate(
|
|
757
|
-
|
|
1140
|
+
return n.type === "input-number" && (n.min !== void 0 && (p.min = n.min), n.max !== void 0 && (p.max = n.max), n.step && (p.step = n.step), n.precision !== void 0 && (p.precision = n.precision)), p;
|
|
1141
|
+
}), i = {
|
|
1142
|
+
handleUpdate(n) {
|
|
1143
|
+
o("update:modelValue", n);
|
|
758
1144
|
}
|
|
759
1145
|
};
|
|
760
|
-
return (
|
|
761
|
-
(f(),
|
|
762
|
-
"onUpdate:modelValue":
|
|
1146
|
+
return (n, u) => (f(), h("div", St, [
|
|
1147
|
+
(f(), k(O(s.value), be(a.value, {
|
|
1148
|
+
"onUpdate:modelValue": i.handleUpdate
|
|
763
1149
|
}), null, 16, ["onUpdate:modelValue"])),
|
|
764
|
-
|
|
765
|
-
class:
|
|
766
|
-
style:
|
|
767
|
-
},
|
|
1150
|
+
x("div", {
|
|
1151
|
+
class: $(["field-error", { "field-error--visible": l.error }]),
|
|
1152
|
+
style: U(d.value)
|
|
1153
|
+
}, T(l.error || ""), 7)
|
|
768
1154
|
]));
|
|
769
1155
|
}
|
|
770
|
-
}),
|
|
771
|
-
class
|
|
1156
|
+
}), Dt = /* @__PURE__ */ P(kt, [["__scopeId", "data-v-10299c8d"]]);
|
|
1157
|
+
class Tt {
|
|
772
1158
|
constructor() {
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
1159
|
+
_(this, "formConfig", null);
|
|
1160
|
+
_(this, "formData", {});
|
|
1161
|
+
_(this, "loading", !1);
|
|
1162
|
+
_(this, "submitting", !1);
|
|
1163
|
+
_(this, "visible", !1);
|
|
1164
|
+
_(this, "isEditMode", !1);
|
|
1165
|
+
_(this, "errors", []);
|
|
1166
|
+
_(this, "currentQuery", {});
|
|
781
1167
|
}
|
|
782
1168
|
}
|
|
783
|
-
let
|
|
1169
|
+
let Vt = class {
|
|
784
1170
|
constructor() {
|
|
785
1171
|
// 响应式数据
|
|
786
|
-
|
|
1172
|
+
_(this, "data", z(new Tt()));
|
|
787
1173
|
}
|
|
788
1174
|
// 解析 query 字符串
|
|
789
1175
|
parseQuery(t) {
|
|
790
1176
|
if (!t) return {};
|
|
791
|
-
const e = {},
|
|
792
|
-
for (const
|
|
793
|
-
const [
|
|
794
|
-
|
|
1177
|
+
const e = {}, o = t.split("&");
|
|
1178
|
+
for (const c of o) {
|
|
1179
|
+
const [r, s] = c.split("=");
|
|
1180
|
+
r && (e[r] = s || "");
|
|
795
1181
|
}
|
|
796
1182
|
return e;
|
|
797
1183
|
}
|
|
798
1184
|
// 获取表单配置
|
|
799
1185
|
async fetchFormConfig(t) {
|
|
800
|
-
const e = await
|
|
1186
|
+
const e = await A.get(N.formCfgApi(t));
|
|
801
1187
|
if (e.status !== 200)
|
|
802
1188
|
throw new Error(e.message || "获取表单配置失败");
|
|
803
1189
|
return e.data;
|
|
804
1190
|
}
|
|
805
1191
|
// 获取表单数据
|
|
806
1192
|
async fetchFormData(t, e) {
|
|
807
|
-
const
|
|
808
|
-
if (
|
|
809
|
-
throw new Error(
|
|
810
|
-
return
|
|
1193
|
+
const o = e ? `${t}?${e}` : t, c = await A.get(o);
|
|
1194
|
+
if (c.status !== 200)
|
|
1195
|
+
throw new Error(c.message || "获取表单数据失败");
|
|
1196
|
+
return c.data;
|
|
811
1197
|
}
|
|
812
1198
|
// 提交表单
|
|
813
1199
|
async submitForm(t, e) {
|
|
814
|
-
return await
|
|
1200
|
+
return await A.post(t, e);
|
|
815
1201
|
}
|
|
816
1202
|
// 构建字段初始值
|
|
817
1203
|
buildInitialData(t) {
|
|
818
1204
|
const e = {};
|
|
819
|
-
for (const
|
|
820
|
-
|
|
1205
|
+
for (const o of t)
|
|
1206
|
+
o.default !== void 0 ? e[o.field] = o.default : e[o.field] = null;
|
|
821
1207
|
return e;
|
|
822
1208
|
}
|
|
823
1209
|
// 判断编辑模式
|
|
@@ -829,21 +1215,21 @@ let ht = class {
|
|
|
829
1215
|
var e;
|
|
830
1216
|
this.data.errors = [];
|
|
831
1217
|
const t = ((e = this.data.formConfig) == null ? void 0 : e.fields) || [];
|
|
832
|
-
for (const
|
|
833
|
-
const
|
|
834
|
-
if (
|
|
1218
|
+
for (const o of t) {
|
|
1219
|
+
const c = this.data.formData[o.field];
|
|
1220
|
+
if (o.required && (c == null || c === "")) {
|
|
835
1221
|
this.data.errors.push({
|
|
836
|
-
field:
|
|
837
|
-
message: `${
|
|
1222
|
+
field: o.field,
|
|
1223
|
+
message: `${o.label}为必填项`
|
|
838
1224
|
});
|
|
839
1225
|
continue;
|
|
840
1226
|
}
|
|
841
|
-
if (
|
|
842
|
-
for (const
|
|
843
|
-
if (
|
|
1227
|
+
if (o.rules && o.rules.length > 0 && c) {
|
|
1228
|
+
for (const r of o.rules)
|
|
1229
|
+
if (r.pattern && !new RegExp(r.pattern).test(c)) {
|
|
844
1230
|
this.data.errors.push({
|
|
845
|
-
field:
|
|
846
|
-
message:
|
|
1231
|
+
field: o.field,
|
|
1232
|
+
message: r.message || `${o.label}格式不正确`
|
|
847
1233
|
});
|
|
848
1234
|
break;
|
|
849
1235
|
}
|
|
@@ -853,7 +1239,7 @@ let ht = class {
|
|
|
853
1239
|
}
|
|
854
1240
|
// 获取字段错误信息
|
|
855
1241
|
getFieldError(t) {
|
|
856
|
-
const e = this.data.errors.find((
|
|
1242
|
+
const e = this.data.errors.find((o) => o.field === t);
|
|
857
1243
|
return e ? e.message : null;
|
|
858
1244
|
}
|
|
859
1245
|
// 清除错误
|
|
@@ -864,13 +1250,13 @@ let ht = class {
|
|
|
864
1250
|
async openForm(t, e) {
|
|
865
1251
|
this.data.loading = !0, this.data.visible = !0, this.clearErrors(), this.data.currentQuery = this.parseQuery(e || "");
|
|
866
1252
|
try {
|
|
867
|
-
const
|
|
868
|
-
if (this.data.formConfig =
|
|
869
|
-
const
|
|
870
|
-
this.data.formData = { ...this.data.formData, ...
|
|
1253
|
+
const o = await this.fetchFormConfig(t);
|
|
1254
|
+
if (this.data.formConfig = o, this.data.isEditMode = this.checkIsEditMode(e || ""), this.data.formData = this.buildInitialData(o.fields), this.data.isEditMode && o.api.get && e) {
|
|
1255
|
+
const c = await this.fetchFormData(o.api.get, e), r = this.nestedToFlat(c);
|
|
1256
|
+
this.data.formData = { ...this.data.formData, ...r };
|
|
871
1257
|
}
|
|
872
|
-
} catch (
|
|
873
|
-
throw console.error("[FormRender] 打开表单失败:",
|
|
1258
|
+
} catch (o) {
|
|
1259
|
+
throw console.error("[FormRender] 打开表单失败:", o), this.data.visible = !1, o;
|
|
874
1260
|
} finally {
|
|
875
1261
|
this.data.loading = !1;
|
|
876
1262
|
}
|
|
@@ -884,13 +1270,13 @@ let ht = class {
|
|
|
884
1270
|
let e = this.data.isEditMode ? t.edit : t.add;
|
|
885
1271
|
if (!e)
|
|
886
1272
|
throw new Error("提交地址未配置");
|
|
887
|
-
let
|
|
888
|
-
|
|
1273
|
+
let o = { ...this.data.formData };
|
|
1274
|
+
o = this.flattenToNested(o), this.data.isEditMode && this.data.currentQuery.id && (o.id = Number(this.data.currentQuery.id)), this.data.submitting = !0;
|
|
889
1275
|
try {
|
|
890
|
-
const
|
|
891
|
-
if (
|
|
892
|
-
return
|
|
893
|
-
throw new Error(
|
|
1276
|
+
const c = await this.submitForm(e, o);
|
|
1277
|
+
if (c.status === 200)
|
|
1278
|
+
return c.data;
|
|
1279
|
+
throw new Error(c.message || "提交失败");
|
|
894
1280
|
} finally {
|
|
895
1281
|
this.data.submitting = !1;
|
|
896
1282
|
}
|
|
@@ -902,81 +1288,46 @@ let ht = class {
|
|
|
902
1288
|
// 扁平字段转嵌套对象(如 info.address -> { info: { address: xxx } })
|
|
903
1289
|
flattenToNested(t) {
|
|
904
1290
|
const e = {};
|
|
905
|
-
for (const
|
|
906
|
-
const
|
|
907
|
-
if (
|
|
908
|
-
const
|
|
909
|
-
let
|
|
910
|
-
for (let
|
|
911
|
-
const
|
|
912
|
-
|
|
1291
|
+
for (const o in t) {
|
|
1292
|
+
const c = t[o];
|
|
1293
|
+
if (o.includes(".")) {
|
|
1294
|
+
const r = o.split(".");
|
|
1295
|
+
let s = e;
|
|
1296
|
+
for (let d = 0; d < r.length - 1; d++) {
|
|
1297
|
+
const a = r[d];
|
|
1298
|
+
s[a] || (s[a] = {}), s = s[a];
|
|
913
1299
|
}
|
|
914
|
-
|
|
1300
|
+
s[r[r.length - 1]] = c;
|
|
915
1301
|
} else
|
|
916
|
-
e[
|
|
1302
|
+
e[o] = c;
|
|
917
1303
|
}
|
|
918
1304
|
return e;
|
|
919
1305
|
}
|
|
920
1306
|
// 嵌套对象展平为扁平字段(如 { info: { address: "xxx" } } -> { "info.address": "xxx" })
|
|
921
1307
|
// 注意:只展平 YAML 中配置的点号分隔字段(如 info.address),不展平已经是对象的字段(如 dateRange: { from, to })
|
|
922
1308
|
nestedToFlat(t, e = "") {
|
|
923
|
-
const
|
|
924
|
-
for (const
|
|
925
|
-
const
|
|
926
|
-
|
|
1309
|
+
const o = {};
|
|
1310
|
+
for (const c in t) {
|
|
1311
|
+
const r = t[c], s = e ? `${e}.${c}` : c;
|
|
1312
|
+
r && typeof r == "object" && !Array.isArray(r) ? Object.keys(r).length === 2 && "from" in r && "to" in r ? o[s] = r : Object.assign(o, this.nestedToFlat(r, s)) : o[s] = r;
|
|
927
1313
|
}
|
|
928
|
-
return
|
|
1314
|
+
return o;
|
|
929
1315
|
}
|
|
930
1316
|
};
|
|
931
|
-
|
|
932
|
-
he({
|
|
933
|
-
message: a,
|
|
934
|
-
type: t,
|
|
935
|
-
duration: 1e3,
|
|
936
|
-
showClose: !1
|
|
937
|
-
});
|
|
938
|
-
}
|
|
939
|
-
function B(a) {
|
|
940
|
-
he({
|
|
941
|
-
message: a,
|
|
942
|
-
type: "error",
|
|
943
|
-
duration: 2e3,
|
|
944
|
-
showClose: !1
|
|
945
|
-
});
|
|
946
|
-
}
|
|
947
|
-
function gt(a) {
|
|
948
|
-
G(a, "success");
|
|
949
|
-
}
|
|
950
|
-
function yt(a) {
|
|
951
|
-
G(a, "error");
|
|
952
|
-
}
|
|
953
|
-
function bt(a) {
|
|
954
|
-
G(a, "warning");
|
|
955
|
-
}
|
|
956
|
-
function vt(a) {
|
|
957
|
-
G(a, "info");
|
|
958
|
-
}
|
|
959
|
-
const W = {
|
|
960
|
-
notify: G,
|
|
961
|
-
success: gt,
|
|
962
|
-
error: yt,
|
|
963
|
-
warning: bt,
|
|
964
|
-
info: vt,
|
|
965
|
-
alertError: B
|
|
966
|
-
}, wt = /* @__PURE__ */ S({
|
|
1317
|
+
const Pt = /* @__PURE__ */ V({
|
|
967
1318
|
__name: "FormRender",
|
|
968
|
-
setup(
|
|
969
|
-
const e = new
|
|
1319
|
+
setup(l, { expose: t }) {
|
|
1320
|
+
const e = new Vt(), o = q(null), c = z({
|
|
970
1321
|
currentQuery: {},
|
|
971
1322
|
submitResolve: null
|
|
972
|
-
}),
|
|
973
|
-
var
|
|
1323
|
+
}), r = y(() => {
|
|
1324
|
+
var g;
|
|
974
1325
|
const m = {};
|
|
975
|
-
if (!e.data.isEditMode || !
|
|
976
|
-
for (const
|
|
977
|
-
|
|
1326
|
+
if (!e.data.isEditMode || !c.currentQuery) return m;
|
|
1327
|
+
for (const b of ((g = e.data.formConfig) == null ? void 0 : g.fields) || [])
|
|
1328
|
+
c.currentQuery[b.field] !== void 0 && (m[b.field] = !0);
|
|
978
1329
|
return m;
|
|
979
|
-
}),
|
|
1330
|
+
}), s = y(() => {
|
|
980
1331
|
var m;
|
|
981
1332
|
return ((m = e.data.formConfig) == null ? void 0 : m.layout) || {
|
|
982
1333
|
open: "dialog",
|
|
@@ -984,35 +1335,35 @@ const W = {
|
|
|
984
1335
|
labelPosition: "top",
|
|
985
1336
|
buttonAlign: "right"
|
|
986
1337
|
};
|
|
987
|
-
}),
|
|
1338
|
+
}), d = y(() => {
|
|
988
1339
|
var m;
|
|
989
1340
|
return ((m = e.data.formConfig) == null ? void 0 : m.fields) || [];
|
|
990
|
-
}),
|
|
991
|
-
var m,
|
|
992
|
-
return ((
|
|
993
|
-
}),
|
|
994
|
-
async showForm(m,
|
|
995
|
-
|
|
1341
|
+
}), a = y(() => {
|
|
1342
|
+
var m, g;
|
|
1343
|
+
return ((g = (m = e.data.formConfig) == null ? void 0 : m.meta) == null ? void 0 : g.title) || "表单";
|
|
1344
|
+
}), i = y(() => s.value.buttonAlign || "right"), n = y(() => s.value.open === "normal"), u = {
|
|
1345
|
+
async showForm(m, g) {
|
|
1346
|
+
c.currentQuery = e.parseQuery(g || "");
|
|
996
1347
|
try {
|
|
997
|
-
await e.openForm(m,
|
|
998
|
-
} catch (
|
|
999
|
-
return
|
|
1348
|
+
await e.openForm(m, g);
|
|
1349
|
+
} catch (b) {
|
|
1350
|
+
return E((b == null ? void 0 : b.message) || "打开表单失败"), null;
|
|
1000
1351
|
}
|
|
1001
|
-
return new Promise((
|
|
1002
|
-
|
|
1352
|
+
return new Promise((b) => {
|
|
1353
|
+
c.submitResolve = b;
|
|
1003
1354
|
});
|
|
1004
1355
|
},
|
|
1005
1356
|
async handleSubmit() {
|
|
1006
|
-
var m,
|
|
1357
|
+
var m, g;
|
|
1007
1358
|
try {
|
|
1008
|
-
const
|
|
1009
|
-
return
|
|
1010
|
-
} catch (
|
|
1011
|
-
return
|
|
1359
|
+
const b = await e.doSubmit(), p = ((g = (m = e.data.formConfig) == null ? void 0 : m.meta) == null ? void 0 : g.title) + "保存成功";
|
|
1360
|
+
return j.success(p), c.submitResolve && (c.submitResolve(b), c.submitResolve = null), n.value || e.closeForm(), b;
|
|
1361
|
+
} catch (b) {
|
|
1362
|
+
return c.submitResolve && (c.submitResolve(null), c.submitResolve = null), b != null && b.message && b.message !== "请完善表单信息" && E(b.message), null;
|
|
1012
1363
|
}
|
|
1013
1364
|
},
|
|
1014
1365
|
handleCancel() {
|
|
1015
|
-
|
|
1366
|
+
n.value || e.closeForm();
|
|
1016
1367
|
},
|
|
1017
1368
|
// 获取字段错误信息
|
|
1018
1369
|
getFieldError(m) {
|
|
@@ -1024,60 +1375,60 @@ const W = {
|
|
|
1024
1375
|
};
|
|
1025
1376
|
return t({
|
|
1026
1377
|
showForm: u.showForm
|
|
1027
|
-
}), (m,
|
|
1028
|
-
const
|
|
1029
|
-
return f(),
|
|
1030
|
-
visible:
|
|
1031
|
-
"onUpdate:visible":
|
|
1032
|
-
layout:
|
|
1033
|
-
title:
|
|
1034
|
-
loading:
|
|
1378
|
+
}), (m, g) => {
|
|
1379
|
+
const b = Le, p = Y;
|
|
1380
|
+
return f(), k(xt, {
|
|
1381
|
+
visible: R(e).data.visible,
|
|
1382
|
+
"onUpdate:visible": g[0] || (g[0] = (C) => R(e).data.visible = C),
|
|
1383
|
+
layout: s.value,
|
|
1384
|
+
title: a.value,
|
|
1385
|
+
loading: R(e).data.loading,
|
|
1035
1386
|
onClose: u.handleClose
|
|
1036
1387
|
}, {
|
|
1037
|
-
actions:
|
|
1038
|
-
|
|
1039
|
-
class:
|
|
1388
|
+
actions: w(() => [
|
|
1389
|
+
x("div", {
|
|
1390
|
+
class: $(["form-actions", i.value === "right" ? "justify-end" : "justify-start"])
|
|
1040
1391
|
}, [
|
|
1041
|
-
|
|
1392
|
+
S(p, {
|
|
1042
1393
|
onClick: u.handleCancel
|
|
1043
1394
|
}, {
|
|
1044
|
-
default:
|
|
1045
|
-
|
|
1395
|
+
default: w(() => [...g[1] || (g[1] = [
|
|
1396
|
+
B("取消", -1)
|
|
1046
1397
|
])]),
|
|
1047
1398
|
_: 1
|
|
1048
1399
|
}, 8, ["onClick"]),
|
|
1049
|
-
|
|
1400
|
+
S(p, {
|
|
1050
1401
|
type: "primary",
|
|
1051
|
-
loading:
|
|
1402
|
+
loading: R(e).data.submitting,
|
|
1052
1403
|
onClick: u.handleSubmit
|
|
1053
1404
|
}, {
|
|
1054
|
-
default:
|
|
1055
|
-
|
|
1405
|
+
default: w(() => [...g[2] || (g[2] = [
|
|
1406
|
+
B("提交", -1)
|
|
1056
1407
|
])]),
|
|
1057
1408
|
_: 1
|
|
1058
1409
|
}, 8, ["loading", "onClick"])
|
|
1059
1410
|
], 2)
|
|
1060
1411
|
]),
|
|
1061
|
-
default:
|
|
1062
|
-
|
|
1412
|
+
default: w(() => [
|
|
1413
|
+
S(b, {
|
|
1063
1414
|
ref_key: "formRef",
|
|
1064
|
-
ref:
|
|
1415
|
+
ref: o,
|
|
1065
1416
|
class: "form-render",
|
|
1066
1417
|
"label-position": "top"
|
|
1067
1418
|
}, {
|
|
1068
|
-
default:
|
|
1069
|
-
|
|
1070
|
-
fields:
|
|
1071
|
-
layout:
|
|
1419
|
+
default: w(() => [
|
|
1420
|
+
S(_t, {
|
|
1421
|
+
fields: d.value,
|
|
1422
|
+
layout: s.value
|
|
1072
1423
|
}, {
|
|
1073
|
-
default:
|
|
1074
|
-
|
|
1075
|
-
modelValue:
|
|
1076
|
-
"onUpdate:modelValue": (
|
|
1077
|
-
field:
|
|
1078
|
-
layout:
|
|
1079
|
-
disabled:
|
|
1080
|
-
error: u.getFieldError(
|
|
1424
|
+
default: w(({ field: C }) => [
|
|
1425
|
+
S(Dt, {
|
|
1426
|
+
modelValue: R(e).data.formData[C.field],
|
|
1427
|
+
"onUpdate:modelValue": (v) => R(e).data.formData[C.field] = v,
|
|
1428
|
+
field: C,
|
|
1429
|
+
layout: s.value,
|
|
1430
|
+
disabled: r.value[C.field],
|
|
1431
|
+
error: u.getFieldError(C.field)
|
|
1081
1432
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "field", "layout", "disabled", "error"])
|
|
1082
1433
|
]),
|
|
1083
1434
|
_: 1
|
|
@@ -1090,8 +1441,8 @@ const W = {
|
|
|
1090
1441
|
}, 8, ["visible", "layout", "title", "loading", "onClose"]);
|
|
1091
1442
|
};
|
|
1092
1443
|
}
|
|
1093
|
-
}),
|
|
1094
|
-
class
|
|
1444
|
+
}), ke = /* @__PURE__ */ P(Pt, [["__scopeId", "data-v-378d04bd"]]);
|
|
1445
|
+
class $t {
|
|
1095
1446
|
constructor(t) {
|
|
1096
1447
|
this.config = t;
|
|
1097
1448
|
}
|
|
@@ -1099,24 +1450,24 @@ class Ct {
|
|
|
1099
1450
|
* 获取列表数据
|
|
1100
1451
|
*/
|
|
1101
1452
|
async fetchList(t, e) {
|
|
1102
|
-
const
|
|
1453
|
+
const o = {
|
|
1103
1454
|
page: e.page,
|
|
1104
1455
|
pageSize: e.pageSize,
|
|
1105
1456
|
...t
|
|
1106
|
-
},
|
|
1107
|
-
for (const
|
|
1108
|
-
const
|
|
1109
|
-
|
|
1457
|
+
}, c = {};
|
|
1458
|
+
for (const a in o) {
|
|
1459
|
+
const i = o[a];
|
|
1460
|
+
i !== "" && i !== null && i !== void 0 && (c[a] = i);
|
|
1110
1461
|
}
|
|
1111
|
-
const
|
|
1112
|
-
for (const
|
|
1113
|
-
|
|
1114
|
-
const
|
|
1115
|
-
if (
|
|
1116
|
-
const
|
|
1117
|
-
return Array.isArray(
|
|
1462
|
+
const r = new URLSearchParams();
|
|
1463
|
+
for (const a in c)
|
|
1464
|
+
r.append(a, String(c[a]));
|
|
1465
|
+
const s = `${this.config.api.list}${r.toString() ? "?" + r.toString() : ""}`, d = await A.get(s);
|
|
1466
|
+
if (d.status === 200) {
|
|
1467
|
+
const a = d.data;
|
|
1468
|
+
return Array.isArray(a) ? { rows: a, total: a.length } : a || { rows: [], total: 0 };
|
|
1118
1469
|
}
|
|
1119
|
-
throw new Error(
|
|
1470
|
+
throw new Error(d.message || "获取列表数据失败");
|
|
1120
1471
|
}
|
|
1121
1472
|
/**
|
|
1122
1473
|
* 删除单行
|
|
@@ -1124,9 +1475,9 @@ class Ct {
|
|
|
1124
1475
|
async deleteRow(t) {
|
|
1125
1476
|
if (!this.config.api.delete)
|
|
1126
1477
|
throw new Error("未配置删除API");
|
|
1127
|
-
const e = this.config.key || "id",
|
|
1128
|
-
if (
|
|
1129
|
-
throw new Error(
|
|
1478
|
+
const e = this.config.key || "id", o = t[e], c = `${this.config.api.delete}?id=${o}`, r = await A.post(c);
|
|
1479
|
+
if (r.status !== 200)
|
|
1480
|
+
throw new Error(r.message || "删除失败");
|
|
1130
1481
|
}
|
|
1131
1482
|
/**
|
|
1132
1483
|
* 批量删除
|
|
@@ -1134,7 +1485,7 @@ class Ct {
|
|
|
1134
1485
|
async batchDelete(t) {
|
|
1135
1486
|
if (!this.config.api.delete)
|
|
1136
1487
|
throw new Error("未配置删除API");
|
|
1137
|
-
const e = await
|
|
1488
|
+
const e = await A.post(this.config.api.delete, t);
|
|
1138
1489
|
if (e.status !== 200)
|
|
1139
1490
|
throw new Error(e.message || "批量删除失败");
|
|
1140
1491
|
}
|
|
@@ -1144,10 +1495,10 @@ class Ct {
|
|
|
1144
1495
|
async exportData(t) {
|
|
1145
1496
|
if (!this.config.api.export)
|
|
1146
1497
|
throw new Error("未配置导出API");
|
|
1147
|
-
const
|
|
1498
|
+
const o = (await A.post(this.config.api.export, t, {
|
|
1148
1499
|
responseType: "blob"
|
|
1149
|
-
})).data,
|
|
1150
|
-
|
|
1500
|
+
})).data, c = window.URL.createObjectURL(o), r = document.createElement("a");
|
|
1501
|
+
r.href = c, r.download = `export_${Date.now()}.xlsx`, r.click(), window.URL.revokeObjectURL(c);
|
|
1151
1502
|
}
|
|
1152
1503
|
/**
|
|
1153
1504
|
* 下载导入模板
|
|
@@ -1155,10 +1506,10 @@ class Ct {
|
|
|
1155
1506
|
async downloadTemplate() {
|
|
1156
1507
|
if (!this.config.api.import)
|
|
1157
1508
|
throw new Error("未配置导入API");
|
|
1158
|
-
const e = (await
|
|
1509
|
+
const e = (await A.get(`${this.config.api.import}/template`, {
|
|
1159
1510
|
responseType: "blob"
|
|
1160
|
-
})).data,
|
|
1161
|
-
|
|
1511
|
+
})).data, o = window.URL.createObjectURL(e), c = document.createElement("a");
|
|
1512
|
+
c.href = o, c.download = `template_${Date.now()}.xlsx`, c.click(), window.URL.revokeObjectURL(o);
|
|
1162
1513
|
}
|
|
1163
1514
|
/**
|
|
1164
1515
|
* 导入数据
|
|
@@ -1168,61 +1519,61 @@ class Ct {
|
|
|
1168
1519
|
throw new Error("未配置导入API");
|
|
1169
1520
|
const e = new FormData();
|
|
1170
1521
|
e.append("file", t);
|
|
1171
|
-
const
|
|
1522
|
+
const o = await A.post(this.config.api.import, e, {
|
|
1172
1523
|
headers: {
|
|
1173
1524
|
"Content-Type": "multipart/form-data"
|
|
1174
1525
|
}
|
|
1175
1526
|
});
|
|
1176
|
-
if (
|
|
1177
|
-
throw new Error(
|
|
1178
|
-
return
|
|
1527
|
+
if (o.status !== 200)
|
|
1528
|
+
throw new Error(o.message || "导入失败");
|
|
1529
|
+
return o.data;
|
|
1179
1530
|
}
|
|
1180
1531
|
}
|
|
1181
|
-
class
|
|
1532
|
+
class It {
|
|
1182
1533
|
constructor() {
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1534
|
+
_(this, "tableConfig", null);
|
|
1535
|
+
_(this, "rows", []);
|
|
1536
|
+
_(this, "total", 0);
|
|
1537
|
+
_(this, "loading", !1);
|
|
1538
|
+
_(this, "searchParams", {});
|
|
1539
|
+
_(this, "pagination", { page: 1, pageSize: 20 });
|
|
1540
|
+
_(this, "selectedRows", []);
|
|
1541
|
+
_(this, "detailVisible", !1);
|
|
1542
|
+
_(this, "detailData", null);
|
|
1543
|
+
_(this, "detailLoading", !1);
|
|
1193
1544
|
}
|
|
1194
1545
|
}
|
|
1195
|
-
let
|
|
1546
|
+
let Et = class {
|
|
1196
1547
|
constructor() {
|
|
1197
1548
|
// 响应式数据
|
|
1198
|
-
|
|
1549
|
+
_(this, "data", z(new It()));
|
|
1199
1550
|
// 数据服务
|
|
1200
|
-
|
|
1551
|
+
_(this, "dataService", null);
|
|
1201
1552
|
}
|
|
1202
1553
|
/**
|
|
1203
1554
|
* 加载表格配置
|
|
1204
1555
|
*/
|
|
1205
1556
|
async loadConfig(t) {
|
|
1206
|
-
var
|
|
1207
|
-
const e =
|
|
1557
|
+
var c;
|
|
1558
|
+
const e = N.formCfgApi(t);
|
|
1208
1559
|
console.log("load config url =", e);
|
|
1209
|
-
const
|
|
1210
|
-
if (console.log("---"),
|
|
1211
|
-
throw new Error(
|
|
1212
|
-
this.data.tableConfig =
|
|
1560
|
+
const o = await A.get(e);
|
|
1561
|
+
if (console.log("---"), o.status !== 200)
|
|
1562
|
+
throw new Error(o.message || "获取表格配置失败");
|
|
1563
|
+
this.data.tableConfig = o.data, this.dataService = new $t(o.data), typeof console < "u" && console.log("[TableRender] loadConfig:", {
|
|
1213
1564
|
tableId: t,
|
|
1214
1565
|
hasDetail: this.hasDetail(),
|
|
1215
|
-
detail: (
|
|
1566
|
+
detail: (c = this.data.tableConfig) == null ? void 0 : c.detail
|
|
1216
1567
|
}), this.initSearchParams();
|
|
1217
1568
|
}
|
|
1218
1569
|
/**
|
|
1219
1570
|
* 初始化搜索参数
|
|
1220
1571
|
*/
|
|
1221
1572
|
initSearchParams() {
|
|
1222
|
-
var
|
|
1223
|
-
const t = {}, e = ((
|
|
1224
|
-
for (const
|
|
1225
|
-
t[
|
|
1573
|
+
var o;
|
|
1574
|
+
const t = {}, e = ((o = this.data.tableConfig) == null ? void 0 : o.search) || [];
|
|
1575
|
+
for (const c of e)
|
|
1576
|
+
t[c.field] = "";
|
|
1226
1577
|
this.data.searchParams = t;
|
|
1227
1578
|
}
|
|
1228
1579
|
/**
|
|
@@ -1370,7 +1721,7 @@ let _t = class {
|
|
|
1370
1721
|
var e;
|
|
1371
1722
|
const t = (e = this.data.tableConfig) == null ? void 0 : e.toolbar;
|
|
1372
1723
|
return t ? t.some(
|
|
1373
|
-
(
|
|
1724
|
+
(o) => o.type === "edit" || o.type === "delete"
|
|
1374
1725
|
) : !1;
|
|
1375
1726
|
}
|
|
1376
1727
|
/**
|
|
@@ -1409,78 +1760,78 @@ let _t = class {
|
|
|
1409
1760
|
return ((t = this.data.tableConfig) == null ? void 0 : t.pagination) || "page";
|
|
1410
1761
|
}
|
|
1411
1762
|
};
|
|
1412
|
-
const
|
|
1763
|
+
const At = { class: "table-search" }, Bt = { class: "search-fields" }, Rt = { class: "search-actions" }, Ut = /* @__PURE__ */ V({
|
|
1413
1764
|
__name: "TableSearch",
|
|
1414
1765
|
props: {
|
|
1415
1766
|
fields: {},
|
|
1416
1767
|
modelValue: {}
|
|
1417
1768
|
},
|
|
1418
1769
|
emits: ["update:modelValue", "search", "reset"],
|
|
1419
|
-
setup(
|
|
1420
|
-
const e =
|
|
1421
|
-
input:
|
|
1422
|
-
dict:
|
|
1423
|
-
dept:
|
|
1424
|
-
role:
|
|
1425
|
-
date:
|
|
1426
|
-
daterange:
|
|
1427
|
-
},
|
|
1770
|
+
setup(l, { emit: t }) {
|
|
1771
|
+
const e = l, o = t, c = {
|
|
1772
|
+
input: K,
|
|
1773
|
+
dict: G,
|
|
1774
|
+
dept: G,
|
|
1775
|
+
role: G,
|
|
1776
|
+
date: oe,
|
|
1777
|
+
daterange: oe
|
|
1778
|
+
}, r = {
|
|
1428
1779
|
// 组件映射
|
|
1429
|
-
getComponent(
|
|
1430
|
-
return s
|
|
1780
|
+
getComponent(s) {
|
|
1781
|
+
return c[s] || K;
|
|
1431
1782
|
},
|
|
1432
1783
|
// 更新搜索值
|
|
1433
|
-
updateValue(
|
|
1434
|
-
const
|
|
1435
|
-
|
|
1784
|
+
updateValue(s, d) {
|
|
1785
|
+
const a = { ...e.modelValue, [s]: d };
|
|
1786
|
+
o("update:modelValue", a);
|
|
1436
1787
|
},
|
|
1437
1788
|
// 搜索(查询字段值自动去除首尾空格)
|
|
1438
1789
|
handleSearch() {
|
|
1439
|
-
const
|
|
1440
|
-
for (const
|
|
1441
|
-
const
|
|
1442
|
-
|
|
1790
|
+
const s = {};
|
|
1791
|
+
for (const d in e.modelValue) {
|
|
1792
|
+
const a = e.modelValue[d];
|
|
1793
|
+
s[d] = typeof a == "string" ? a.trim() : a;
|
|
1443
1794
|
}
|
|
1444
|
-
|
|
1795
|
+
o("update:modelValue", s), o("search");
|
|
1445
1796
|
},
|
|
1446
1797
|
// 重置
|
|
1447
1798
|
handleReset() {
|
|
1448
|
-
|
|
1799
|
+
o("reset");
|
|
1449
1800
|
}
|
|
1450
1801
|
};
|
|
1451
|
-
return (
|
|
1452
|
-
const
|
|
1453
|
-
return f(),
|
|
1454
|
-
|
|
1455
|
-
(f(!0),
|
|
1456
|
-
key:
|
|
1802
|
+
return (s, d) => {
|
|
1803
|
+
const a = Y;
|
|
1804
|
+
return f(), h("div", At, [
|
|
1805
|
+
x("div", Bt, [
|
|
1806
|
+
(f(!0), h(I, null, M(e.fields, (i) => (f(), h("div", {
|
|
1807
|
+
key: i.field,
|
|
1457
1808
|
class: "search-field"
|
|
1458
1809
|
}, [
|
|
1459
|
-
(f(),
|
|
1460
|
-
"model-value": e.modelValue[
|
|
1461
|
-
"field-label":
|
|
1462
|
-
"dict-type":
|
|
1463
|
-
mode:
|
|
1810
|
+
(f(), k(O(r.getComponent(i.type)), {
|
|
1811
|
+
"model-value": e.modelValue[i.field],
|
|
1812
|
+
"field-label": i.label,
|
|
1813
|
+
"dict-type": i.dictType,
|
|
1814
|
+
mode: i.type === "daterange" ? "range" : void 0,
|
|
1464
1815
|
"label-position": "left",
|
|
1465
|
-
"onUpdate:modelValue": (
|
|
1816
|
+
"onUpdate:modelValue": (n) => r.updateValue(i.field, n)
|
|
1466
1817
|
}, null, 8, ["model-value", "field-label", "dict-type", "mode", "onUpdate:modelValue"]))
|
|
1467
1818
|
]))), 128))
|
|
1468
1819
|
]),
|
|
1469
|
-
|
|
1470
|
-
|
|
1820
|
+
x("div", Rt, [
|
|
1821
|
+
S(a, {
|
|
1471
1822
|
type: "primary",
|
|
1472
|
-
onClick:
|
|
1823
|
+
onClick: r.handleSearch
|
|
1473
1824
|
}, {
|
|
1474
|
-
default:
|
|
1475
|
-
|
|
1825
|
+
default: w(() => [...d[0] || (d[0] = [
|
|
1826
|
+
B("查询", -1)
|
|
1476
1827
|
])]),
|
|
1477
1828
|
_: 1
|
|
1478
1829
|
}, 8, ["onClick"]),
|
|
1479
|
-
|
|
1480
|
-
onClick:
|
|
1830
|
+
S(a, {
|
|
1831
|
+
onClick: r.handleReset
|
|
1481
1832
|
}, {
|
|
1482
|
-
default:
|
|
1483
|
-
|
|
1833
|
+
default: w(() => [...d[1] || (d[1] = [
|
|
1834
|
+
B("重置", -1)
|
|
1484
1835
|
])]),
|
|
1485
1836
|
_: 1
|
|
1486
1837
|
}, 8, ["onClick"])
|
|
@@ -1488,7 +1839,7 @@ const St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { cl
|
|
|
1488
1839
|
]);
|
|
1489
1840
|
};
|
|
1490
1841
|
}
|
|
1491
|
-
}),
|
|
1842
|
+
}), Mt = /* @__PURE__ */ P(Ut, [["__scopeId", "data-v-68dd4c13"]]), Lt = { class: "table-toolbar" }, Ft = { class: "toolbar-left" }, zt = /* @__PURE__ */ V({
|
|
1492
1843
|
__name: "TableToolbar",
|
|
1493
1844
|
props: {
|
|
1494
1845
|
toolbar: {},
|
|
@@ -1498,58 +1849,58 @@ const St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { cl
|
|
|
1498
1849
|
selectedCount: {}
|
|
1499
1850
|
},
|
|
1500
1851
|
emits: ["create", "import", "export", "batchEdit", "batchDelete", "custom"],
|
|
1501
|
-
setup(
|
|
1502
|
-
const e =
|
|
1852
|
+
setup(l, { emit: t }) {
|
|
1853
|
+
const e = l, o = t, c = y(() => ({
|
|
1503
1854
|
// 显示编辑按钮
|
|
1504
1855
|
showEdit: !!e.formId && (!e.actions || e.actions.edit !== !1),
|
|
1505
1856
|
// 显示删除按钮
|
|
1506
1857
|
showDelete: !!e.apiDelete && (!e.actions || e.actions.delete !== !1)
|
|
1507
|
-
})),
|
|
1858
|
+
})), r = {
|
|
1508
1859
|
// 判断是否为内置按钮
|
|
1509
|
-
isBuiltin(
|
|
1510
|
-
return typeof
|
|
1860
|
+
isBuiltin(s) {
|
|
1861
|
+
return typeof s == "string" || s.type !== void 0;
|
|
1511
1862
|
},
|
|
1512
1863
|
// 获取按钮属性
|
|
1513
|
-
getButtonProps(
|
|
1514
|
-
return typeof
|
|
1864
|
+
getButtonProps(s) {
|
|
1865
|
+
return typeof s == "string" ? { type: s } : s;
|
|
1515
1866
|
},
|
|
1516
1867
|
// 按钮是否可用
|
|
1517
|
-
isDisabled(
|
|
1518
|
-
const
|
|
1519
|
-
return
|
|
1868
|
+
isDisabled(s) {
|
|
1869
|
+
const d = r.getButtonProps(s);
|
|
1870
|
+
return d.type === "edit" || d.type === "delete" ? e.selectedCount === 0 : !1;
|
|
1520
1871
|
},
|
|
1521
1872
|
// 是否显示按钮
|
|
1522
|
-
shouldShow(
|
|
1523
|
-
const
|
|
1524
|
-
return
|
|
1873
|
+
shouldShow(s) {
|
|
1874
|
+
const d = r.getButtonProps(s);
|
|
1875
|
+
return d.type === "create" && e.formId || d.type === "edit" && c.value.showEdit || d.type === "delete" && c.value.showDelete ? !0 : d.type === "import" || d.type === "export" ? !1 : !r.isBuiltin(s);
|
|
1525
1876
|
},
|
|
1526
1877
|
// 处理按钮点击
|
|
1527
|
-
handleClick(
|
|
1528
|
-
switch (
|
|
1878
|
+
handleClick(s) {
|
|
1879
|
+
switch (r.getButtonProps(s).type) {
|
|
1529
1880
|
case "create":
|
|
1530
|
-
|
|
1881
|
+
o("create");
|
|
1531
1882
|
break;
|
|
1532
1883
|
case "import":
|
|
1533
|
-
|
|
1884
|
+
o("import");
|
|
1534
1885
|
break;
|
|
1535
1886
|
case "export":
|
|
1536
|
-
|
|
1887
|
+
o("export");
|
|
1537
1888
|
break;
|
|
1538
1889
|
case "edit":
|
|
1539
|
-
|
|
1890
|
+
o("batchEdit");
|
|
1540
1891
|
break;
|
|
1541
1892
|
case "delete":
|
|
1542
|
-
|
|
1893
|
+
o("batchDelete");
|
|
1543
1894
|
break;
|
|
1544
1895
|
default:
|
|
1545
|
-
|
|
1896
|
+
o("custom", s);
|
|
1546
1897
|
}
|
|
1547
1898
|
},
|
|
1548
1899
|
// 获取按钮文字
|
|
1549
|
-
getButtonText(
|
|
1550
|
-
const
|
|
1551
|
-
if (
|
|
1552
|
-
switch (
|
|
1900
|
+
getButtonText(s) {
|
|
1901
|
+
const d = r.getButtonProps(s);
|
|
1902
|
+
if (d.text) return d.text;
|
|
1903
|
+
switch (d.type) {
|
|
1553
1904
|
case "create":
|
|
1554
1905
|
return "新增";
|
|
1555
1906
|
case "import":
|
|
@@ -1565,65 +1916,65 @@ const St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { cl
|
|
|
1565
1916
|
}
|
|
1566
1917
|
},
|
|
1567
1918
|
// 获取按钮图标
|
|
1568
|
-
getButtonIcon(
|
|
1569
|
-
return
|
|
1919
|
+
getButtonIcon(s) {
|
|
1920
|
+
return r.getButtonProps(s).icon;
|
|
1570
1921
|
},
|
|
1571
1922
|
// 是否为主按钮
|
|
1572
|
-
isPrimary(
|
|
1573
|
-
return
|
|
1923
|
+
isPrimary(s) {
|
|
1924
|
+
return r.getButtonProps(s).primary === !0;
|
|
1574
1925
|
}
|
|
1575
1926
|
};
|
|
1576
|
-
return (
|
|
1577
|
-
const
|
|
1578
|
-
return f(),
|
|
1579
|
-
|
|
1580
|
-
(f(!0),
|
|
1581
|
-
|
|
1927
|
+
return (s, d) => {
|
|
1928
|
+
const a = Y;
|
|
1929
|
+
return f(), h("div", Lt, [
|
|
1930
|
+
x("div", Ft, [
|
|
1931
|
+
(f(!0), h(I, null, M(e.toolbar, (i, n) => (f(), h(I, { key: n }, [
|
|
1932
|
+
r.shouldShow(i) ? (f(), k(a, {
|
|
1582
1933
|
key: 0,
|
|
1583
|
-
type:
|
|
1584
|
-
disabled:
|
|
1585
|
-
onClick: (u) =>
|
|
1934
|
+
type: r.isPrimary(i) ? "primary" : "default",
|
|
1935
|
+
disabled: r.isDisabled(i),
|
|
1936
|
+
onClick: (u) => r.handleClick(i)
|
|
1586
1937
|
}, {
|
|
1587
|
-
default:
|
|
1588
|
-
|
|
1938
|
+
default: w(() => [
|
|
1939
|
+
B(T(r.getButtonText(i)), 1)
|
|
1589
1940
|
]),
|
|
1590
1941
|
_: 2
|
|
1591
|
-
}, 1032, ["type", "disabled", "onClick"])) :
|
|
1942
|
+
}, 1032, ["type", "disabled", "onClick"])) : D("", !0)
|
|
1592
1943
|
], 64))), 128))
|
|
1593
1944
|
])
|
|
1594
1945
|
]);
|
|
1595
1946
|
};
|
|
1596
1947
|
}
|
|
1597
|
-
}),
|
|
1948
|
+
}), qt = /* @__PURE__ */ P(zt, [["__scopeId", "data-v-a7c06f8c"]]), Nt = /* @__PURE__ */ V({
|
|
1598
1949
|
__name: "UInputShow",
|
|
1599
1950
|
props: {
|
|
1600
1951
|
modelValue: {},
|
|
1601
1952
|
multiline: { type: Boolean, default: !1 },
|
|
1602
1953
|
maxLines: { default: 0 }
|
|
1603
1954
|
},
|
|
1604
|
-
setup(
|
|
1605
|
-
const t =
|
|
1606
|
-
`)),
|
|
1955
|
+
setup(l) {
|
|
1956
|
+
const t = l, e = y(() => t.modelValue === null || t.modelValue === void 0 ? "" : String(t.modelValue)), o = y(() => t.multiline || e.value.includes(`
|
|
1957
|
+
`)), c = y(() => t.maxLines > 0 && o.value ? {
|
|
1607
1958
|
display: "-webkit-box",
|
|
1608
1959
|
WebkitLineClamp: t.maxLines,
|
|
1609
1960
|
WebkitBoxOrient: "vertical",
|
|
1610
1961
|
overflow: "hidden",
|
|
1611
1962
|
textOverflow: "ellipsis"
|
|
1612
1963
|
} : {});
|
|
1613
|
-
return (
|
|
1614
|
-
class:
|
|
1615
|
-
style:
|
|
1616
|
-
},
|
|
1964
|
+
return (r, s) => (f(), h("div", {
|
|
1965
|
+
class: $(["u-input-show", { "u-input-multiline": o.value }]),
|
|
1966
|
+
style: U(c.value)
|
|
1967
|
+
}, T(e.value), 7));
|
|
1617
1968
|
}
|
|
1618
|
-
}),
|
|
1969
|
+
}), Wt = /* @__PURE__ */ P(Nt, [["__scopeId", "data-v-c78b151e"]]), jt = /* @__PURE__ */ V({
|
|
1619
1970
|
__name: "UDictShow",
|
|
1620
1971
|
props: {
|
|
1621
1972
|
modelValue: {},
|
|
1622
1973
|
dictType: {},
|
|
1623
1974
|
defaultText: { default: "" }
|
|
1624
1975
|
},
|
|
1625
|
-
setup(
|
|
1626
|
-
const t =
|
|
1976
|
+
setup(l) {
|
|
1977
|
+
const t = l, e = q(""), o = q(!1), c = async () => {
|
|
1627
1978
|
if (t.modelValue === null || t.modelValue === void 0 || t.modelValue === "") {
|
|
1628
1979
|
e.value = t.defaultText;
|
|
1629
1980
|
return;
|
|
@@ -1632,25 +1983,25 @@ const St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { cl
|
|
|
1632
1983
|
e.value = String(t.modelValue);
|
|
1633
1984
|
return;
|
|
1634
1985
|
}
|
|
1635
|
-
|
|
1986
|
+
o.value = !0;
|
|
1636
1987
|
try {
|
|
1637
|
-
const
|
|
1638
|
-
e.value =
|
|
1639
|
-
} catch (
|
|
1640
|
-
console.error("[UDictShow] 翻译失败:",
|
|
1988
|
+
const r = await He(t.dictType, t.modelValue, t.defaultText);
|
|
1989
|
+
e.value = r;
|
|
1990
|
+
} catch (r) {
|
|
1991
|
+
console.error("[UDictShow] 翻译失败:", r), e.value = String(t.modelValue);
|
|
1641
1992
|
} finally {
|
|
1642
|
-
|
|
1993
|
+
o.value = !1;
|
|
1643
1994
|
}
|
|
1644
1995
|
};
|
|
1645
|
-
return
|
|
1646
|
-
t.dictType &&
|
|
1647
|
-
}),
|
|
1648
|
-
t.dictType ?
|
|
1649
|
-
}), (
|
|
1650
|
-
class:
|
|
1651
|
-
},
|
|
1652
|
-
}
|
|
1653
|
-
}),
|
|
1996
|
+
return F(() => t.modelValue, c, { immediate: !0 }), F(() => t.dictType, () => {
|
|
1997
|
+
t.dictType && ae(t.dictType).then(() => c());
|
|
1998
|
+
}), H(() => {
|
|
1999
|
+
t.dictType ? ae(t.dictType).then(() => c()) : c();
|
|
2000
|
+
}), (r, s) => (f(), h("div", {
|
|
2001
|
+
class: $(["u-dict-show", { "u-dict-loading": o.value }])
|
|
2002
|
+
}, T(e.value), 3));
|
|
2003
|
+
}
|
|
2004
|
+
}), Ot = /* @__PURE__ */ P(jt, [["__scopeId", "data-v-908045c4"]]), Yt = /* @__PURE__ */ V({
|
|
1654
2005
|
__name: "UToggleShow",
|
|
1655
2006
|
props: {
|
|
1656
2007
|
modelValue: {},
|
|
@@ -1658,13 +2009,13 @@ const St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { cl
|
|
|
1658
2009
|
falseText: { default: "关闭" },
|
|
1659
2010
|
useYesNo: { type: Boolean, default: !1 }
|
|
1660
2011
|
},
|
|
1661
|
-
setup(
|
|
1662
|
-
const t =
|
|
1663
|
-
return (
|
|
1664
|
-
class:
|
|
1665
|
-
},
|
|
2012
|
+
setup(l) {
|
|
2013
|
+
const t = l, e = y(() => t.useYesNo ? "是" : t.trueText), o = y(() => t.useYesNo ? "否" : t.falseText), c = y(() => t.modelValue === !0 || t.modelValue === "true" ? e.value : t.modelValue === !1 || t.modelValue === "false" ? o.value : String(t.modelValue ?? "")), r = y(() => t.modelValue === !0 || t.modelValue === "true" ? "toggle-true" : t.modelValue === !1 || t.modelValue === "false" ? "toggle-false" : "toggle-default");
|
|
2014
|
+
return (s, d) => (f(), h("div", {
|
|
2015
|
+
class: $(["u-toggle-show", r.value])
|
|
2016
|
+
}, T(c.value), 3));
|
|
1666
2017
|
}
|
|
1667
|
-
}),
|
|
2018
|
+
}), Qt = /* @__PURE__ */ P(Yt, [["__scopeId", "data-v-bac05efc"]]), Gt = /* @__PURE__ */ V({
|
|
1668
2019
|
__name: "UCascaderShow",
|
|
1669
2020
|
props: {
|
|
1670
2021
|
modelValue: {},
|
|
@@ -1672,36 +2023,36 @@ const St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { cl
|
|
|
1672
2023
|
separator: { default: " / " },
|
|
1673
2024
|
showRawValue: { type: Boolean, default: !0 }
|
|
1674
2025
|
},
|
|
1675
|
-
setup(
|
|
1676
|
-
const t =
|
|
2026
|
+
setup(l) {
|
|
2027
|
+
const t = l, e = q(""), o = q(!1), c = async () => {
|
|
1677
2028
|
if (!t.modelValue || !Array.isArray(t.modelValue)) {
|
|
1678
2029
|
e.value = "";
|
|
1679
2030
|
return;
|
|
1680
2031
|
}
|
|
1681
|
-
const
|
|
2032
|
+
const r = t.modelValue;
|
|
1682
2033
|
if (t.cascaderKey) {
|
|
1683
|
-
|
|
2034
|
+
o.value = !0;
|
|
1684
2035
|
try {
|
|
1685
|
-
const
|
|
1686
|
-
const
|
|
1687
|
-
return
|
|
1688
|
-
}).filter((
|
|
1689
|
-
e.value =
|
|
1690
|
-
} catch (
|
|
1691
|
-
console.error("[UCascaderShow] 翻译失败:",
|
|
2036
|
+
const s = await ae(t.cascaderKey), a = r.map((i) => {
|
|
2037
|
+
const n = s.find((u) => u.value === i || String(u.value) === String(i));
|
|
2038
|
+
return n ? n.label : t.showRawValue ? String(i) : "";
|
|
2039
|
+
}).filter((i) => i !== "");
|
|
2040
|
+
e.value = a.join(t.separator);
|
|
2041
|
+
} catch (s) {
|
|
2042
|
+
console.error("[UCascaderShow] 翻译失败:", s), e.value = t.showRawValue ? r.join(t.separator) : "";
|
|
1692
2043
|
} finally {
|
|
1693
|
-
|
|
2044
|
+
o.value = !1;
|
|
1694
2045
|
}
|
|
1695
2046
|
} else
|
|
1696
|
-
e.value =
|
|
2047
|
+
e.value = r.join(t.separator);
|
|
1697
2048
|
};
|
|
1698
|
-
return
|
|
1699
|
-
|
|
1700
|
-
}), (
|
|
1701
|
-
class:
|
|
1702
|
-
},
|
|
2049
|
+
return F(() => t.modelValue, c, { immediate: !0 }), H(() => {
|
|
2050
|
+
c();
|
|
2051
|
+
}), (r, s) => (f(), h("div", {
|
|
2052
|
+
class: $(["u-cascader-show", { "u-cascader-loading": o.value }])
|
|
2053
|
+
}, T(e.value), 3));
|
|
1703
2054
|
}
|
|
1704
|
-
}),
|
|
2055
|
+
}), Ht = /* @__PURE__ */ P(Gt, [["__scopeId", "data-v-5d84df67"]]), Kt = /* @__PURE__ */ V({
|
|
1705
2056
|
__name: "UDateShow",
|
|
1706
2057
|
props: {
|
|
1707
2058
|
modelValue: {},
|
|
@@ -1711,20 +2062,20 @@ const St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { cl
|
|
|
1711
2062
|
separator: { default: ", " },
|
|
1712
2063
|
rangeSeparator: { default: " ~ " }
|
|
1713
2064
|
},
|
|
1714
|
-
setup(
|
|
1715
|
-
const t =
|
|
1716
|
-
const
|
|
1717
|
-
return t.mode === "single" ?
|
|
2065
|
+
setup(l) {
|
|
2066
|
+
const t = l, e = y(() => t.locale === "en-US" ? t.mode === "range" ? " - " : ", " : t.mode === "range" ? t.rangeSeparator : t.separator), o = y(() => {
|
|
2067
|
+
const s = t.modelValue;
|
|
2068
|
+
return t.mode === "single" ? s ? c(s, t.format) : "" : t.mode === "multiple" ? s ? Array.isArray(s) ? s.map((d) => c(d, t.format)).join(e.value) : String(s) : "" : t.mode === "range" ? s ? typeof s == "object" && s.from && s.to ? `${c(s.from, t.format)}${e.value}${c(s.to, t.format)}` : Array.isArray(s) && s.length >= 2 ? `${c(s[0], t.format)}${e.value}${c(s[1], t.format)}` : String(s) : "" : String(s ?? "");
|
|
1718
2069
|
});
|
|
1719
|
-
function s
|
|
1720
|
-
return
|
|
2070
|
+
function c(s, d) {
|
|
2071
|
+
return s || "";
|
|
1721
2072
|
}
|
|
1722
|
-
const
|
|
1723
|
-
return (
|
|
1724
|
-
class:
|
|
1725
|
-
},
|
|
2073
|
+
const r = y(() => !o.value);
|
|
2074
|
+
return (s, d) => (f(), h("div", {
|
|
2075
|
+
class: $(["u-date-show", { "u-date-empty": r.value }])
|
|
2076
|
+
}, T(o.value || (l.locale === "en-US" ? "Empty" : "暂无")), 3));
|
|
1726
2077
|
}
|
|
1727
|
-
}),
|
|
2078
|
+
}), Jt = /* @__PURE__ */ P(Kt, [["__scopeId", "data-v-930657df"]]), Xt = /* @__PURE__ */ V({
|
|
1728
2079
|
__name: "UFieldView",
|
|
1729
2080
|
props: {
|
|
1730
2081
|
type: { default: "text" },
|
|
@@ -1741,21 +2092,21 @@ const St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { cl
|
|
|
1741
2092
|
multiline: { type: Boolean },
|
|
1742
2093
|
defaultText: { default: "" }
|
|
1743
2094
|
},
|
|
1744
|
-
setup(
|
|
1745
|
-
const t =
|
|
2095
|
+
setup(l) {
|
|
2096
|
+
const t = l, e = y(() => {
|
|
1746
2097
|
if (!t.text) return null;
|
|
1747
|
-
const
|
|
1748
|
-
return
|
|
1749
|
-
trueText:
|
|
1750
|
-
falseText:
|
|
2098
|
+
const s = t.text.split("/");
|
|
2099
|
+
return s.length >= 2 ? {
|
|
2100
|
+
trueText: s[0].trim(),
|
|
2101
|
+
falseText: s[1].trim()
|
|
1751
2102
|
} : null;
|
|
1752
|
-
}),
|
|
1753
|
-
var
|
|
1754
|
-
return t.trueText || ((
|
|
1755
|
-
}),
|
|
1756
|
-
var
|
|
1757
|
-
return t.falseText || ((
|
|
1758
|
-
}),
|
|
2103
|
+
}), o = y(() => {
|
|
2104
|
+
var s;
|
|
2105
|
+
return t.trueText || ((s = e.value) == null ? void 0 : s.trueText) || "开启";
|
|
2106
|
+
}), c = y(() => {
|
|
2107
|
+
var s;
|
|
2108
|
+
return t.falseText || ((s = e.value) == null ? void 0 : s.falseText) || "关闭";
|
|
2109
|
+
}), r = y(() => {
|
|
1759
2110
|
switch (t.type) {
|
|
1760
2111
|
case "dict":
|
|
1761
2112
|
return "UDictShow";
|
|
@@ -1771,21 +2122,21 @@ const St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { cl
|
|
|
1771
2122
|
return "UInputShow";
|
|
1772
2123
|
}
|
|
1773
2124
|
});
|
|
1774
|
-
return (
|
|
1775
|
-
"model-value":
|
|
1776
|
-
"dict-type":
|
|
1777
|
-
"cascader-key":
|
|
1778
|
-
mode:
|
|
1779
|
-
locale:
|
|
1780
|
-
format:
|
|
1781
|
-
"true-text":
|
|
1782
|
-
"false-text":
|
|
1783
|
-
"use-yes-no":
|
|
1784
|
-
multiline:
|
|
1785
|
-
"default-text":
|
|
2125
|
+
return (s, d) => (f(), k(O(r.value === "UDictShow" ? Ot : r.value === "UToggleShow" ? Qt : r.value === "UCascaderShow" ? Ht : r.value === "UDateShow" ? Jt : Wt), {
|
|
2126
|
+
"model-value": l.modelValue,
|
|
2127
|
+
"dict-type": l.type === "dict" ? l.dictType : void 0,
|
|
2128
|
+
"cascader-key": l.type === "cascader" ? l.cascaderKey : void 0,
|
|
2129
|
+
mode: l.type === "date" ? l.mode : void 0,
|
|
2130
|
+
locale: l.type === "date" ? l.locale : void 0,
|
|
2131
|
+
format: l.type === "date" ? l.format : void 0,
|
|
2132
|
+
"true-text": l.type === "switch" ? o.value : void 0,
|
|
2133
|
+
"false-text": l.type === "switch" ? c.value : void 0,
|
|
2134
|
+
"use-yes-no": l.type === "switch" ? l.useYesNo : void 0,
|
|
2135
|
+
multiline: l.type === "input" || l.type === "text" ? l.multiline : void 0,
|
|
2136
|
+
"default-text": l.type === "dict" ? l.defaultText : void 0
|
|
1786
2137
|
}, null, 8, ["model-value", "dict-type", "cascader-key", "mode", "locale", "format", "true-text", "false-text", "use-yes-no", "multiline", "default-text"]));
|
|
1787
2138
|
}
|
|
1788
|
-
}),
|
|
2139
|
+
}), de = /* @__PURE__ */ P(Xt, [["__scopeId", "data-v-fedb54d7"]]), Zt = { class: "table-grid" }, ea = /* @__PURE__ */ V({
|
|
1789
2140
|
__name: "TableGrid",
|
|
1790
2141
|
props: {
|
|
1791
2142
|
rows: {},
|
|
@@ -1799,172 +2150,172 @@ const St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { cl
|
|
|
1799
2150
|
dictData: {}
|
|
1800
2151
|
},
|
|
1801
2152
|
emits: ["selectionChange", "rowEdit", "rowDelete", "rowClick"],
|
|
1802
|
-
setup(
|
|
1803
|
-
const e =
|
|
1804
|
-
var
|
|
1805
|
-
return ((
|
|
1806
|
-
}),
|
|
1807
|
-
var
|
|
1808
|
-
return ((
|
|
1809
|
-
}),
|
|
1810
|
-
const
|
|
2153
|
+
setup(l, { emit: t }) {
|
|
2154
|
+
const e = l, o = t, c = y(() => e.formId && (!e.actions || e.actions.edit !== !1)), r = y(() => e.apiDelete && (!e.actions || e.actions.delete !== !1)), s = y(() => {
|
|
2155
|
+
var n;
|
|
2156
|
+
return ((n = e.actions) == null ? void 0 : n.edit) || "编辑";
|
|
2157
|
+
}), d = y(() => {
|
|
2158
|
+
var n;
|
|
2159
|
+
return ((n = e.actions) == null ? void 0 : n.delete) || "删除";
|
|
2160
|
+
}), a = y(() => {
|
|
2161
|
+
const n = e.columns.map((u) => {
|
|
1811
2162
|
const m = {
|
|
1812
2163
|
prop: u.field,
|
|
1813
2164
|
label: u.label
|
|
1814
2165
|
};
|
|
1815
2166
|
return typeof u.width == "number" && (m.width = u.width), m;
|
|
1816
2167
|
});
|
|
1817
|
-
return (
|
|
2168
|
+
return (c.value || r.value) && n.push({
|
|
1818
2169
|
prop: "actions",
|
|
1819
2170
|
label: "操作",
|
|
1820
2171
|
width: 120,
|
|
1821
2172
|
fixed: "right"
|
|
1822
|
-
}),
|
|
1823
|
-
}),
|
|
2173
|
+
}), n;
|
|
2174
|
+
}), i = {
|
|
1824
2175
|
// 手机号脱敏
|
|
1825
|
-
maskPhone(
|
|
1826
|
-
return !
|
|
2176
|
+
maskPhone(n) {
|
|
2177
|
+
return !n || n.length < 7 ? n : n.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
|
|
1827
2178
|
},
|
|
1828
2179
|
// 身份证脱敏
|
|
1829
|
-
maskIdCard(
|
|
1830
|
-
return !
|
|
2180
|
+
maskIdCard(n) {
|
|
2181
|
+
return !n || n.length < 8 ? n : n.replace(/(\d{3})\d{11}(\d{4})/, "$1***********$2");
|
|
1831
2182
|
},
|
|
1832
2183
|
// 金额格式化
|
|
1833
|
-
formatMoney(
|
|
1834
|
-
const u = Number(
|
|
1835
|
-
return isNaN(u) ? String(
|
|
2184
|
+
formatMoney(n) {
|
|
2185
|
+
const u = Number(n);
|
|
2186
|
+
return isNaN(u) ? String(n) : u.toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
1836
2187
|
},
|
|
1837
2188
|
// 根据 format 类型格式化
|
|
1838
|
-
formatByType(
|
|
1839
|
-
if (!
|
|
2189
|
+
formatByType(n, u) {
|
|
2190
|
+
if (!n)
|
|
1840
2191
|
return "";
|
|
1841
2192
|
switch (u) {
|
|
1842
2193
|
case "phone":
|
|
1843
|
-
return
|
|
2194
|
+
return i.maskPhone(n);
|
|
1844
2195
|
case "idcard":
|
|
1845
|
-
return
|
|
2196
|
+
return i.maskIdCard(n);
|
|
1846
2197
|
case "money":
|
|
1847
|
-
return
|
|
2198
|
+
return i.formatMoney(n);
|
|
1848
2199
|
case "percent":
|
|
1849
|
-
return String(
|
|
2200
|
+
return String(n * 100) + "%";
|
|
1850
2201
|
default:
|
|
1851
|
-
return u && u.includes("{}") ? u.replace("{}", String(
|
|
2202
|
+
return u && u.includes("{}") ? u.replace("{}", String(n)) : String(n);
|
|
1852
2203
|
}
|
|
1853
2204
|
},
|
|
1854
2205
|
// 获取嵌套字段值
|
|
1855
|
-
getNestedValue(
|
|
2206
|
+
getNestedValue(n, u) {
|
|
1856
2207
|
if (!u.includes("."))
|
|
1857
|
-
return
|
|
2208
|
+
return n[u];
|
|
1858
2209
|
const m = u.split(".");
|
|
1859
|
-
let
|
|
1860
|
-
for (const
|
|
1861
|
-
if (
|
|
1862
|
-
|
|
2210
|
+
let g = n;
|
|
2211
|
+
for (const b of m)
|
|
2212
|
+
if (g && typeof g == "object" && b in g)
|
|
2213
|
+
g = g[b];
|
|
1863
2214
|
else
|
|
1864
2215
|
return;
|
|
1865
|
-
return
|
|
2216
|
+
return g;
|
|
1866
2217
|
},
|
|
1867
2218
|
// 判断是否需要使用 UFieldView 组件
|
|
1868
|
-
useFieldView(
|
|
1869
|
-
return
|
|
2219
|
+
useFieldView(n) {
|
|
2220
|
+
return n.type ? ["dict", "switch", "cascader", "date", "input", "text"].includes(n.type) : !1;
|
|
1870
2221
|
},
|
|
1871
2222
|
// 选择变化
|
|
1872
|
-
onSelectionChange(
|
|
1873
|
-
|
|
2223
|
+
onSelectionChange(n) {
|
|
2224
|
+
o("selectionChange", n);
|
|
1874
2225
|
},
|
|
1875
2226
|
// 行点击
|
|
1876
|
-
onRowClick(
|
|
1877
|
-
|
|
2227
|
+
onRowClick(n) {
|
|
2228
|
+
o("rowClick", n);
|
|
1878
2229
|
},
|
|
1879
2230
|
// 编辑
|
|
1880
|
-
onRowEdit(
|
|
1881
|
-
|
|
2231
|
+
onRowEdit(n) {
|
|
2232
|
+
o("rowEdit", n);
|
|
1882
2233
|
},
|
|
1883
2234
|
// 删除
|
|
1884
|
-
onRowDelete(
|
|
1885
|
-
|
|
2235
|
+
onRowDelete(n) {
|
|
2236
|
+
o("rowDelete", n);
|
|
1886
2237
|
}
|
|
1887
2238
|
};
|
|
1888
|
-
return (
|
|
1889
|
-
const m =
|
|
1890
|
-
return f(),
|
|
1891
|
-
|
|
2239
|
+
return (n, u) => {
|
|
2240
|
+
const m = ze, g = Y, b = Fe;
|
|
2241
|
+
return f(), h("div", Zt, [
|
|
2242
|
+
S(b, {
|
|
1892
2243
|
data: e.rows.length ? e.rows : [{}],
|
|
1893
2244
|
loading: e.loading,
|
|
1894
2245
|
"row-key": e.keyField || "id",
|
|
1895
|
-
onSelectionChange:
|
|
1896
|
-
onRowClick: u[0] || (u[0] = (
|
|
2246
|
+
onSelectionChange: i.onSelectionChange,
|
|
2247
|
+
onRowClick: u[0] || (u[0] = (p) => i.onRowClick(p)),
|
|
1897
2248
|
stripe: "",
|
|
1898
2249
|
border: ""
|
|
1899
2250
|
}, {
|
|
1900
|
-
empty:
|
|
1901
|
-
|
|
2251
|
+
empty: w(() => [...u[1] || (u[1] = [
|
|
2252
|
+
x("div", { class: "no-data" }, "暂无数据", -1)
|
|
1902
2253
|
])]),
|
|
1903
|
-
default:
|
|
1904
|
-
e.selection ? (f(),
|
|
2254
|
+
default: w(() => [
|
|
2255
|
+
e.selection ? (f(), k(m, {
|
|
1905
2256
|
key: 0,
|
|
1906
2257
|
type: "selection",
|
|
1907
2258
|
width: "55"
|
|
1908
|
-
})) :
|
|
1909
|
-
(f(!0),
|
|
1910
|
-
key:
|
|
1911
|
-
prop:
|
|
1912
|
-
label:
|
|
1913
|
-
width:
|
|
1914
|
-
fixed:
|
|
2259
|
+
})) : D("", !0),
|
|
2260
|
+
(f(!0), h(I, null, M(a.value, (p) => (f(), k(m, {
|
|
2261
|
+
key: p.prop,
|
|
2262
|
+
prop: p.prop,
|
|
2263
|
+
label: p.label,
|
|
2264
|
+
width: p.width,
|
|
2265
|
+
fixed: p.fixed
|
|
1915
2266
|
}, {
|
|
1916
|
-
default:
|
|
1917
|
-
|
|
1918
|
-
Object.keys(
|
|
1919
|
-
|
|
2267
|
+
default: w(({ row: C }) => [
|
|
2268
|
+
p.prop === "actions" ? (f(), h(I, { key: 0 }, [
|
|
2269
|
+
Object.keys(C).length > 0 ? (f(), h(I, { key: 0 }, [
|
|
2270
|
+
c.value ? (f(), k(g, {
|
|
1920
2271
|
key: 0,
|
|
1921
2272
|
link: "",
|
|
1922
2273
|
type: "primary",
|
|
1923
2274
|
size: "small",
|
|
1924
|
-
onClick:
|
|
2275
|
+
onClick: me((v) => i.onRowEdit(C), ["stop"])
|
|
1925
2276
|
}, {
|
|
1926
|
-
default:
|
|
1927
|
-
|
|
2277
|
+
default: w(() => [
|
|
2278
|
+
B(T(s.value), 1)
|
|
1928
2279
|
]),
|
|
1929
2280
|
_: 1
|
|
1930
|
-
}, 8, ["onClick"])) :
|
|
1931
|
-
|
|
2281
|
+
}, 8, ["onClick"])) : D("", !0),
|
|
2282
|
+
r.value ? (f(), k(g, {
|
|
1932
2283
|
key: 1,
|
|
1933
2284
|
link: "",
|
|
1934
2285
|
type: "danger",
|
|
1935
2286
|
size: "small",
|
|
1936
|
-
onClick:
|
|
2287
|
+
onClick: me((v) => i.onRowDelete(C), ["stop"])
|
|
1937
2288
|
}, {
|
|
1938
|
-
default:
|
|
1939
|
-
|
|
2289
|
+
default: w(() => [
|
|
2290
|
+
B(T(d.value), 1)
|
|
1940
2291
|
]),
|
|
1941
2292
|
_: 1
|
|
1942
|
-
}, 8, ["onClick"])) :
|
|
1943
|
-
], 64)) :
|
|
1944
|
-
], 64)) : (f(),
|
|
1945
|
-
Object.keys(
|
|
1946
|
-
key:
|
|
2293
|
+
}, 8, ["onClick"])) : D("", !0)
|
|
2294
|
+
], 64)) : D("", !0)
|
|
2295
|
+
], 64)) : (f(), h(I, { key: 1 }, [
|
|
2296
|
+
Object.keys(C).length > 0 ? (f(!0), h(I, { key: 0 }, M(e.columns, (v) => (f(), h(I, {
|
|
2297
|
+
key: v.field
|
|
1947
2298
|
}, [
|
|
1948
|
-
|
|
2299
|
+
v.field === p.prop && i.useFieldView(v) ? (f(), k(de, {
|
|
1949
2300
|
key: 0,
|
|
1950
|
-
type:
|
|
1951
|
-
"model-value":
|
|
1952
|
-
"dict-type":
|
|
1953
|
-
mode:
|
|
1954
|
-
locale:
|
|
1955
|
-
format:
|
|
1956
|
-
text:
|
|
1957
|
-
"true-text":
|
|
1958
|
-
"false-text":
|
|
1959
|
-
"use-yes-no":
|
|
1960
|
-
"cascader-key":
|
|
1961
|
-
multiline:
|
|
1962
|
-
"default-text":
|
|
1963
|
-
}, null, 8, ["type", "model-value", "dict-type", "mode", "locale", "format", "text", "true-text", "false-text", "use-yes-no", "cascader-key", "multiline", "default-text"])) :
|
|
2301
|
+
type: v.type,
|
|
2302
|
+
"model-value": i.getNestedValue(C, v.field),
|
|
2303
|
+
"dict-type": v.dictType,
|
|
2304
|
+
mode: v.mode,
|
|
2305
|
+
locale: v.locale,
|
|
2306
|
+
format: v.format,
|
|
2307
|
+
text: v.text,
|
|
2308
|
+
"true-text": v.trueText,
|
|
2309
|
+
"false-text": v.falseText,
|
|
2310
|
+
"use-yes-no": v.useYesNo,
|
|
2311
|
+
"cascader-key": v.cascaderKey,
|
|
2312
|
+
multiline: v.multiline,
|
|
2313
|
+
"default-text": v.defaultText
|
|
2314
|
+
}, null, 8, ["type", "model-value", "dict-type", "mode", "locale", "format", "text", "true-text", "false-text", "use-yes-no", "cascader-key", "multiline", "default-text"])) : v.field === p.prop ? (f(), h("span", {
|
|
1964
2315
|
key: 1,
|
|
1965
|
-
class:
|
|
1966
|
-
},
|
|
1967
|
-
], 64))), 128)) :
|
|
2316
|
+
class: $({ "table-grid-format": v.format })
|
|
2317
|
+
}, T(i.formatByType(i.getNestedValue(C, v.field), v.format || "")), 3)) : D("", !0)
|
|
2318
|
+
], 64))), 128)) : D("", !0)
|
|
1968
2319
|
], 64))
|
|
1969
2320
|
]),
|
|
1970
2321
|
_: 2
|
|
@@ -1975,13 +2326,13 @@ const St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { cl
|
|
|
1975
2326
|
]);
|
|
1976
2327
|
};
|
|
1977
2328
|
}
|
|
1978
|
-
}),
|
|
2329
|
+
}), ta = /* @__PURE__ */ P(ea, [["__scopeId", "data-v-60cb7136"]]), aa = { class: "table-pagination" }, oa = { class: "page-size-select" }, la = { class: "total-text" }, na = {
|
|
1979
2330
|
key: 1,
|
|
1980
2331
|
class: "load-more"
|
|
1981
|
-
},
|
|
2332
|
+
}, ia = {
|
|
1982
2333
|
key: 2,
|
|
1983
2334
|
class: "total-text"
|
|
1984
|
-
},
|
|
2335
|
+
}, sa = /* @__PURE__ */ V({
|
|
1985
2336
|
__name: "TablePagination",
|
|
1986
2337
|
props: {
|
|
1987
2338
|
page: {},
|
|
@@ -1990,86 +2341,86 @@ const St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { cl
|
|
|
1990
2341
|
type: {}
|
|
1991
2342
|
},
|
|
1992
2343
|
emits: ["update:page", "update:pageSize"],
|
|
1993
|
-
setup(
|
|
1994
|
-
const e =
|
|
2344
|
+
setup(l, { emit: t }) {
|
|
2345
|
+
const e = l, o = t, c = y(() => ({
|
|
1995
2346
|
// 总页数
|
|
1996
2347
|
totalPages: Math.ceil(e.total / e.pageSize),
|
|
1997
2348
|
// 是否显示分页
|
|
1998
2349
|
showPagination: e.type === "page" && e.total > 0
|
|
1999
|
-
})),
|
|
2350
|
+
})), r = {
|
|
2000
2351
|
// 页码变化
|
|
2001
|
-
onPageChange: (
|
|
2002
|
-
|
|
2352
|
+
onPageChange: (s) => {
|
|
2353
|
+
o("update:page", s);
|
|
2003
2354
|
},
|
|
2004
2355
|
// 每页条数变化
|
|
2005
|
-
onPageSizeChange: (
|
|
2006
|
-
|
|
2356
|
+
onPageSizeChange: (s) => {
|
|
2357
|
+
o("update:pageSize", s);
|
|
2007
2358
|
}
|
|
2008
2359
|
};
|
|
2009
|
-
return (
|
|
2010
|
-
const
|
|
2011
|
-
return f(),
|
|
2012
|
-
|
|
2013
|
-
|
|
2360
|
+
return (s, d) => {
|
|
2361
|
+
const a = qe, i = ie, n = ne, u = Y;
|
|
2362
|
+
return f(), h("div", aa, [
|
|
2363
|
+
c.value.showPagination ? (f(), h(I, { key: 0 }, [
|
|
2364
|
+
S(a, {
|
|
2014
2365
|
"current-page": e.page,
|
|
2015
|
-
"page-count":
|
|
2366
|
+
"page-count": c.value.totalPages,
|
|
2016
2367
|
"page-sizes": [10, 20, 50, 100],
|
|
2017
2368
|
"page-size": e.pageSize,
|
|
2018
2369
|
layout: "total, prev, pager, next, jumper",
|
|
2019
|
-
onCurrentChange:
|
|
2020
|
-
onSizeChange:
|
|
2370
|
+
onCurrentChange: r.onPageChange,
|
|
2371
|
+
onSizeChange: r.onPageSizeChange
|
|
2021
2372
|
}, null, 8, ["current-page", "page-count", "page-size", "onCurrentChange", "onSizeChange"]),
|
|
2022
|
-
|
|
2023
|
-
|
|
2373
|
+
x("div", oa, [
|
|
2374
|
+
S(n, {
|
|
2024
2375
|
"model-value": e.pageSize,
|
|
2025
2376
|
style: { width: "100px" },
|
|
2026
|
-
onChange:
|
|
2377
|
+
onChange: r.onPageSizeChange
|
|
2027
2378
|
}, {
|
|
2028
|
-
default:
|
|
2029
|
-
|
|
2379
|
+
default: w(() => [
|
|
2380
|
+
S(i, {
|
|
2030
2381
|
value: 10,
|
|
2031
2382
|
label: "10条/页"
|
|
2032
2383
|
}),
|
|
2033
|
-
|
|
2384
|
+
S(i, {
|
|
2034
2385
|
value: 20,
|
|
2035
2386
|
label: "20条/页"
|
|
2036
2387
|
}),
|
|
2037
|
-
|
|
2388
|
+
S(i, {
|
|
2038
2389
|
value: 50,
|
|
2039
2390
|
label: "50条/页"
|
|
2040
2391
|
}),
|
|
2041
|
-
|
|
2392
|
+
S(i, {
|
|
2042
2393
|
value: 100,
|
|
2043
2394
|
label: "100条/页"
|
|
2044
2395
|
})
|
|
2045
2396
|
]),
|
|
2046
2397
|
_: 1
|
|
2047
2398
|
}, 8, ["model-value", "onChange"]),
|
|
2048
|
-
|
|
2399
|
+
x("span", la, "共 " + T(e.total) + " 条", 1)
|
|
2049
2400
|
])
|
|
2050
|
-
], 64)) : e.type === "auto" ? (f(),
|
|
2051
|
-
|
|
2401
|
+
], 64)) : e.type === "auto" ? (f(), h("div", na, [
|
|
2402
|
+
S(u, {
|
|
2052
2403
|
disabled: e.page * e.pageSize >= e.total
|
|
2053
2404
|
}, {
|
|
2054
|
-
default:
|
|
2055
|
-
|
|
2405
|
+
default: w(() => [...d[0] || (d[0] = [
|
|
2406
|
+
B("加载更多", -1)
|
|
2056
2407
|
])]),
|
|
2057
2408
|
_: 1
|
|
2058
2409
|
}, 8, ["disabled"])
|
|
2059
|
-
])) : e.type === "all" ? (f(),
|
|
2410
|
+
])) : e.type === "all" ? (f(), h("div", ia, "共 " + T(e.total) + " 条", 1)) : D("", !0)
|
|
2060
2411
|
]);
|
|
2061
2412
|
};
|
|
2062
2413
|
}
|
|
2063
|
-
}),
|
|
2414
|
+
}), ra = /* @__PURE__ */ P(sa, [["__scopeId", "data-v-53e593aa"]]), da = { class: "detail-header" }, ca = { class: "detail-title" }, ua = { class: "table-detail" }, fa = {
|
|
2064
2415
|
key: 0,
|
|
2065
2416
|
class: "loading"
|
|
2066
|
-
},
|
|
2417
|
+
}, ma = {
|
|
2067
2418
|
key: 1,
|
|
2068
2419
|
class: "detail-content"
|
|
2069
|
-
},
|
|
2420
|
+
}, pa = { class: "detail-label" }, ha = { class: "detail-value" }, ga = {
|
|
2070
2421
|
key: 2,
|
|
2071
2422
|
class: "no-data"
|
|
2072
|
-
},
|
|
2423
|
+
}, ya = /* @__PURE__ */ V({
|
|
2073
2424
|
__name: "TableDetail",
|
|
2074
2425
|
props: {
|
|
2075
2426
|
visible: { type: Boolean },
|
|
@@ -2080,82 +2431,82 @@ const St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { cl
|
|
|
2080
2431
|
columns: {}
|
|
2081
2432
|
},
|
|
2082
2433
|
emits: ["close"],
|
|
2083
|
-
setup(
|
|
2084
|
-
const e =
|
|
2434
|
+
setup(l, { emit: t }) {
|
|
2435
|
+
const e = l, o = t, c = y(() => ({
|
|
2085
2436
|
// el-drawer 位置
|
|
2086
2437
|
direction: {
|
|
2087
2438
|
left: "ltr",
|
|
2088
2439
|
right: "rtl",
|
|
2089
2440
|
top: "ttb"
|
|
2090
2441
|
}[e.position || "right"] || "rtl"
|
|
2091
|
-
})),
|
|
2092
|
-
if (!
|
|
2093
|
-
if (!
|
|
2094
|
-
return
|
|
2095
|
-
const
|
|
2096
|
-
let
|
|
2097
|
-
for (const
|
|
2098
|
-
if (
|
|
2099
|
-
|
|
2442
|
+
})), r = (s, d) => {
|
|
2443
|
+
if (!s || !d) return "";
|
|
2444
|
+
if (!d.includes("."))
|
|
2445
|
+
return s[d];
|
|
2446
|
+
const a = d.split(".");
|
|
2447
|
+
let i = s;
|
|
2448
|
+
for (const n of a)
|
|
2449
|
+
if (i && typeof i == "object" && n in i)
|
|
2450
|
+
i = i[n];
|
|
2100
2451
|
else
|
|
2101
2452
|
return "";
|
|
2102
|
-
return
|
|
2453
|
+
return i;
|
|
2103
2454
|
};
|
|
2104
|
-
return (
|
|
2105
|
-
const
|
|
2106
|
-
return f(),
|
|
2455
|
+
return (s, d) => {
|
|
2456
|
+
const a = Ne;
|
|
2457
|
+
return f(), k(a, {
|
|
2107
2458
|
"model-value": e.visible,
|
|
2108
|
-
direction:
|
|
2459
|
+
direction: c.value.direction,
|
|
2109
2460
|
size: 400,
|
|
2110
2461
|
"with-header": !0,
|
|
2111
2462
|
"show-close": !0,
|
|
2112
|
-
onClose:
|
|
2463
|
+
onClose: d[0] || (d[0] = (i) => o("close"))
|
|
2113
2464
|
}, {
|
|
2114
|
-
header:
|
|
2115
|
-
|
|
2116
|
-
|
|
2465
|
+
header: w(() => [
|
|
2466
|
+
x("div", da, [
|
|
2467
|
+
x("div", ca, T(e.title || "详情"), 1)
|
|
2117
2468
|
])
|
|
2118
2469
|
]),
|
|
2119
|
-
default:
|
|
2120
|
-
|
|
2121
|
-
e.loading ? (f(),
|
|
2122
|
-
(f(!0),
|
|
2123
|
-
key:
|
|
2470
|
+
default: w(() => [
|
|
2471
|
+
x("div", ua, [
|
|
2472
|
+
e.loading ? (f(), h("div", fa, "加载中...")) : e.rowData ? (f(), h("div", ma, [
|
|
2473
|
+
(f(!0), h(I, null, M(e.columns, (i) => (f(), h("div", {
|
|
2474
|
+
key: i.field,
|
|
2124
2475
|
class: "detail-item"
|
|
2125
2476
|
}, [
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
type:
|
|
2130
|
-
"model-value":
|
|
2131
|
-
"dict-type":
|
|
2132
|
-
mode:
|
|
2133
|
-
locale:
|
|
2134
|
-
format:
|
|
2135
|
-
text:
|
|
2136
|
-
"true-text":
|
|
2137
|
-
"false-text":
|
|
2138
|
-
"use-yes-no":
|
|
2139
|
-
"cascader-key":
|
|
2140
|
-
multiline:
|
|
2141
|
-
"default-text":
|
|
2477
|
+
x("div", pa, T(i.label), 1),
|
|
2478
|
+
x("div", ha, [
|
|
2479
|
+
S(de, {
|
|
2480
|
+
type: i.type,
|
|
2481
|
+
"model-value": r(e.rowData, i.field),
|
|
2482
|
+
"dict-type": i.dictType,
|
|
2483
|
+
mode: i.mode,
|
|
2484
|
+
locale: i.locale,
|
|
2485
|
+
format: i.format,
|
|
2486
|
+
text: i.text,
|
|
2487
|
+
"true-text": i.trueText,
|
|
2488
|
+
"false-text": i.falseText,
|
|
2489
|
+
"use-yes-no": i.useYesNo,
|
|
2490
|
+
"cascader-key": i.cascaderKey,
|
|
2491
|
+
multiline: i.multiline,
|
|
2492
|
+
"default-text": i.defaultText
|
|
2142
2493
|
}, null, 8, ["type", "model-value", "dict-type", "mode", "locale", "format", "text", "true-text", "false-text", "use-yes-no", "cascader-key", "multiline", "default-text"])
|
|
2143
2494
|
])
|
|
2144
2495
|
]))), 128))
|
|
2145
|
-
])) : (f(),
|
|
2496
|
+
])) : (f(), h("div", ga, "暂无数据"))
|
|
2146
2497
|
])
|
|
2147
2498
|
]),
|
|
2148
2499
|
_: 1
|
|
2149
2500
|
}, 8, ["model-value", "direction"]);
|
|
2150
2501
|
};
|
|
2151
2502
|
}
|
|
2152
|
-
}),
|
|
2503
|
+
}), ba = /* @__PURE__ */ P(ya, [["__scopeId", "data-v-ee569603"]]), va = { class: "table-render" }, wa = { class: "table-body" }, xa = { class: "table-container" }, Ca = /* @__PURE__ */ V({
|
|
2153
2504
|
__name: "TableRender",
|
|
2154
2505
|
props: {
|
|
2155
2506
|
formId: {}
|
|
2156
2507
|
},
|
|
2157
|
-
setup(
|
|
2158
|
-
const e =
|
|
2508
|
+
setup(l, { expose: t }) {
|
|
2509
|
+
const e = l, o = new Et(), c = q(null), r = z({
|
|
2159
2510
|
// 内部搜索参数
|
|
2160
2511
|
searchParams: {},
|
|
2161
2512
|
// 选中行
|
|
@@ -2165,129 +2516,129 @@ const St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { cl
|
|
|
2165
2516
|
// 字典数据缓存
|
|
2166
2517
|
dictData: {}
|
|
2167
2518
|
});
|
|
2168
|
-
|
|
2169
|
-
e.formId && await
|
|
2519
|
+
H(async () => {
|
|
2520
|
+
e.formId && await d.loadConfig(e.formId);
|
|
2170
2521
|
});
|
|
2171
|
-
const
|
|
2522
|
+
const s = y(() => ({
|
|
2172
2523
|
// 表格配置
|
|
2173
|
-
tableConfig:
|
|
2524
|
+
tableConfig: o.data.tableConfig,
|
|
2174
2525
|
// 表格数据
|
|
2175
|
-
rows:
|
|
2526
|
+
rows: o.data.rows,
|
|
2176
2527
|
// 总数
|
|
2177
|
-
total:
|
|
2528
|
+
total: o.data.total,
|
|
2178
2529
|
// 加载状态
|
|
2179
|
-
loading:
|
|
2530
|
+
loading: o.data.loading,
|
|
2180
2531
|
// 分页信息
|
|
2181
|
-
pagination:
|
|
2532
|
+
pagination: o.data.pagination,
|
|
2182
2533
|
// 选中行
|
|
2183
|
-
selectedRows:
|
|
2534
|
+
selectedRows: o.data.selectedRows,
|
|
2184
2535
|
// 搜索字段
|
|
2185
|
-
searchFields:
|
|
2536
|
+
searchFields: o.getSearchFields(),
|
|
2186
2537
|
// 列定义
|
|
2187
|
-
columns:
|
|
2538
|
+
columns: o.getColumns(),
|
|
2188
2539
|
// 工具栏
|
|
2189
|
-
toolbar:
|
|
2540
|
+
toolbar: o.getToolbar(),
|
|
2190
2541
|
// 行操作
|
|
2191
|
-
actions:
|
|
2542
|
+
actions: o.getActions(),
|
|
2192
2543
|
// 是否显示详情
|
|
2193
|
-
showDetail:
|
|
2544
|
+
showDetail: o.hasDetail(),
|
|
2194
2545
|
// 详情可见
|
|
2195
|
-
detailVisible:
|
|
2546
|
+
detailVisible: o.data.detailVisible,
|
|
2196
2547
|
// 详情数据
|
|
2197
|
-
detailData:
|
|
2548
|
+
detailData: o.data.detailData,
|
|
2198
2549
|
// 详情加载状态
|
|
2199
|
-
detailLoading:
|
|
2550
|
+
detailLoading: o.data.detailLoading,
|
|
2200
2551
|
// 选择模式
|
|
2201
|
-
selectionMode:
|
|
2552
|
+
selectionMode: o.showSelection() ? "multiple" : void 0,
|
|
2202
2553
|
// 字典数据
|
|
2203
|
-
dictData:
|
|
2204
|
-
})),
|
|
2554
|
+
dictData: r.dictData
|
|
2555
|
+
})), d = {
|
|
2205
2556
|
// 加载配置
|
|
2206
|
-
async loadConfig(
|
|
2207
|
-
console.log("loadConfig",
|
|
2557
|
+
async loadConfig(a) {
|
|
2558
|
+
console.log("loadConfig", a);
|
|
2208
2559
|
try {
|
|
2209
|
-
await
|
|
2210
|
-
} catch (
|
|
2211
|
-
|
|
2560
|
+
await o.loadConfig(a);
|
|
2561
|
+
} catch (i) {
|
|
2562
|
+
E((i == null ? void 0 : i.message) || "获取表格配置失败");
|
|
2212
2563
|
return;
|
|
2213
2564
|
}
|
|
2214
|
-
|
|
2565
|
+
r.searchParams = { ...o.data.searchParams }, r.loaded = !0, await d.loadDictData(), await d.handleLoadData();
|
|
2215
2566
|
},
|
|
2216
2567
|
// 加载表格数据(报错时提示框展示 message)
|
|
2217
2568
|
async handleLoadData() {
|
|
2218
2569
|
try {
|
|
2219
|
-
await
|
|
2220
|
-
} catch (
|
|
2221
|
-
|
|
2570
|
+
await o.loadData();
|
|
2571
|
+
} catch (a) {
|
|
2572
|
+
E((a == null ? void 0 : a.message) || "加载数据失败");
|
|
2222
2573
|
}
|
|
2223
2574
|
},
|
|
2224
2575
|
// 加载字典数据
|
|
2225
2576
|
async loadDictData() {
|
|
2226
|
-
const
|
|
2227
|
-
for (const
|
|
2228
|
-
|
|
2229
|
-
for (const
|
|
2577
|
+
const a = o.getColumns(), i = /* @__PURE__ */ new Set();
|
|
2578
|
+
for (const n of a)
|
|
2579
|
+
n.type === "dict" && n.dictType && i.add(n.dictType);
|
|
2580
|
+
for (const n of i)
|
|
2230
2581
|
try {
|
|
2231
|
-
const u = await
|
|
2232
|
-
u.status === 200 && (
|
|
2582
|
+
const u = await A.get(N.dictApi(n));
|
|
2583
|
+
u.status === 200 && (r.dictData[n] = re(u.data));
|
|
2233
2584
|
} catch (u) {
|
|
2234
|
-
console.error(`[TableRender] 加载字典 ${
|
|
2585
|
+
console.error(`[TableRender] 加载字典 ${n} 失败:`, u);
|
|
2235
2586
|
}
|
|
2236
2587
|
},
|
|
2237
2588
|
// 搜索
|
|
2238
2589
|
async handleSearch() {
|
|
2239
|
-
|
|
2590
|
+
o.data.searchParams = { ...r.searchParams };
|
|
2240
2591
|
try {
|
|
2241
|
-
await
|
|
2242
|
-
} catch (
|
|
2243
|
-
|
|
2592
|
+
await o.search();
|
|
2593
|
+
} catch (a) {
|
|
2594
|
+
E((a == null ? void 0 : a.message) || "查询失败");
|
|
2244
2595
|
}
|
|
2245
2596
|
},
|
|
2246
2597
|
// 重置
|
|
2247
2598
|
async handleReset() {
|
|
2248
|
-
|
|
2599
|
+
r.searchParams = {};
|
|
2249
2600
|
try {
|
|
2250
|
-
await
|
|
2251
|
-
} catch (
|
|
2252
|
-
|
|
2601
|
+
await o.reset();
|
|
2602
|
+
} catch (a) {
|
|
2603
|
+
E((a == null ? void 0 : a.message) || "重置失败");
|
|
2253
2604
|
}
|
|
2254
2605
|
},
|
|
2255
2606
|
// 更新搜索参数
|
|
2256
|
-
updateSearchParam(
|
|
2257
|
-
|
|
2607
|
+
updateSearchParam(a, i) {
|
|
2608
|
+
r.searchParams[a] = i;
|
|
2258
2609
|
},
|
|
2259
2610
|
// 选择变化
|
|
2260
|
-
handleSelectionChange(
|
|
2261
|
-
|
|
2611
|
+
handleSelectionChange(a) {
|
|
2612
|
+
o.updateSelection(a);
|
|
2262
2613
|
},
|
|
2263
2614
|
// 新增
|
|
2264
2615
|
async handleCreate() {
|
|
2265
|
-
var
|
|
2266
|
-
const
|
|
2267
|
-
|
|
2616
|
+
var i;
|
|
2617
|
+
const a = o.getFormId();
|
|
2618
|
+
a && c.value && await ((i = c.value) == null ? void 0 : i.showForm(a)) != null && await d.handleLoadData();
|
|
2268
2619
|
},
|
|
2269
2620
|
// 编辑(批量)
|
|
2270
2621
|
async handleBatchEdit() {
|
|
2271
|
-
if (
|
|
2272
|
-
|
|
2622
|
+
if (s.value.selectedRows.length !== 1) {
|
|
2623
|
+
j.warning("请选择一行数据进行编辑");
|
|
2273
2624
|
return;
|
|
2274
2625
|
}
|
|
2275
|
-
await
|
|
2626
|
+
await d.handleRowEdit(s.value.selectedRows[0]);
|
|
2276
2627
|
},
|
|
2277
2628
|
// 编辑(行)
|
|
2278
|
-
async handleRowEdit(
|
|
2279
|
-
var
|
|
2280
|
-
const
|
|
2281
|
-
if (
|
|
2282
|
-
const m =
|
|
2283
|
-
await ((
|
|
2629
|
+
async handleRowEdit(a) {
|
|
2630
|
+
var n, u;
|
|
2631
|
+
const i = o.getFormId();
|
|
2632
|
+
if (i && c.value) {
|
|
2633
|
+
const m = o.getKeyField();
|
|
2634
|
+
await ((n = c.value) == null ? void 0 : n.showForm(i, `${m}=${a[m]}`)) != null && (await d.handleLoadData(), s.value.detailVisible && ((u = o.data.detailData) == null ? void 0 : u[m]) === a[m] && await o.openDetail(a));
|
|
2284
2635
|
}
|
|
2285
2636
|
},
|
|
2286
2637
|
// 删除(批量)
|
|
2287
2638
|
async handleBatchDelete() {
|
|
2288
2639
|
try {
|
|
2289
|
-
await
|
|
2290
|
-
`确定要删除选中的 ${
|
|
2640
|
+
await fe.confirm(
|
|
2641
|
+
`确定要删除选中的 ${s.value.selectedRows.length} 条数据吗?`,
|
|
2291
2642
|
"确认删除",
|
|
2292
2643
|
{
|
|
2293
2644
|
confirmButtonText: "确定",
|
|
@@ -2296,17 +2647,17 @@ const St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { cl
|
|
|
2296
2647
|
}
|
|
2297
2648
|
);
|
|
2298
2649
|
try {
|
|
2299
|
-
await
|
|
2300
|
-
} catch (
|
|
2301
|
-
|
|
2650
|
+
await o.batchDelete(), j.success("删除成功");
|
|
2651
|
+
} catch (a) {
|
|
2652
|
+
E((a == null ? void 0 : a.message) || "删除失败");
|
|
2302
2653
|
}
|
|
2303
2654
|
} catch {
|
|
2304
2655
|
}
|
|
2305
2656
|
},
|
|
2306
2657
|
// 删除(行)
|
|
2307
|
-
async handleRowDelete(
|
|
2658
|
+
async handleRowDelete(a) {
|
|
2308
2659
|
try {
|
|
2309
|
-
await
|
|
2660
|
+
await fe.confirm(
|
|
2310
2661
|
"确定要删除这条数据吗?",
|
|
2311
2662
|
"确认删除",
|
|
2312
2663
|
{
|
|
@@ -2316,9 +2667,9 @@ const St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { cl
|
|
|
2316
2667
|
}
|
|
2317
2668
|
);
|
|
2318
2669
|
try {
|
|
2319
|
-
await
|
|
2320
|
-
} catch (
|
|
2321
|
-
|
|
2670
|
+
await o.deleteRow(a), j.success("删除成功");
|
|
2671
|
+
} catch (i) {
|
|
2672
|
+
E((i == null ? void 0 : i.message) || "删除失败");
|
|
2322
2673
|
}
|
|
2323
2674
|
} catch {
|
|
2324
2675
|
}
|
|
@@ -2326,119 +2677,119 @@ const St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { cl
|
|
|
2326
2677
|
// 导出
|
|
2327
2678
|
async handleExport() {
|
|
2328
2679
|
try {
|
|
2329
|
-
await
|
|
2330
|
-
} catch (
|
|
2331
|
-
|
|
2680
|
+
await o.exportData(), j.success("导出成功");
|
|
2681
|
+
} catch (a) {
|
|
2682
|
+
E((a == null ? void 0 : a.message) || "导出失败");
|
|
2332
2683
|
}
|
|
2333
2684
|
},
|
|
2334
2685
|
// 导入
|
|
2335
2686
|
handleImport() {
|
|
2336
|
-
|
|
2687
|
+
j.info("导入功能开发中");
|
|
2337
2688
|
},
|
|
2338
2689
|
// 分页变化
|
|
2339
|
-
async handlePageChange(
|
|
2690
|
+
async handlePageChange(a) {
|
|
2340
2691
|
try {
|
|
2341
|
-
await
|
|
2342
|
-
} catch (
|
|
2343
|
-
|
|
2692
|
+
await o.changePage(a);
|
|
2693
|
+
} catch (i) {
|
|
2694
|
+
E((i == null ? void 0 : i.message) || "加载数据失败");
|
|
2344
2695
|
}
|
|
2345
2696
|
},
|
|
2346
2697
|
// 每页条数变化
|
|
2347
|
-
async handlePageSizeChange(
|
|
2698
|
+
async handlePageSizeChange(a) {
|
|
2348
2699
|
try {
|
|
2349
|
-
await
|
|
2350
|
-
} catch (
|
|
2351
|
-
|
|
2700
|
+
await o.changePageSize(a);
|
|
2701
|
+
} catch (i) {
|
|
2702
|
+
E((i == null ? void 0 : i.message) || "加载数据失败");
|
|
2352
2703
|
}
|
|
2353
2704
|
},
|
|
2354
2705
|
// 行点击(显示详情)
|
|
2355
|
-
handleRowClick(
|
|
2356
|
-
|
|
2706
|
+
handleRowClick(a) {
|
|
2707
|
+
s.value.showDetail && o.openDetail(a);
|
|
2357
2708
|
},
|
|
2358
2709
|
// 关闭详情
|
|
2359
2710
|
handleDetailClose() {
|
|
2360
|
-
|
|
2711
|
+
o.closeDetail();
|
|
2361
2712
|
}
|
|
2362
2713
|
};
|
|
2363
|
-
return
|
|
2714
|
+
return H(() => {
|
|
2364
2715
|
}), t({
|
|
2365
|
-
loadConfig:
|
|
2366
|
-
}), (
|
|
2367
|
-
var
|
|
2368
|
-
return f(),
|
|
2369
|
-
|
|
2716
|
+
loadConfig: d.loadConfig
|
|
2717
|
+
}), (a, i) => {
|
|
2718
|
+
var n, u, m, g, b, p, C, v, W, ce, ue;
|
|
2719
|
+
return f(), h("div", va, [
|
|
2720
|
+
s.value.searchFields.length > 0 ? (f(), k(Mt, {
|
|
2370
2721
|
key: 0,
|
|
2371
|
-
fields:
|
|
2372
|
-
modelValue:
|
|
2373
|
-
"onUpdate:modelValue":
|
|
2374
|
-
onSearch:
|
|
2375
|
-
onReset:
|
|
2376
|
-
}, null, 8, ["fields", "modelValue", "onSearch", "onReset"])) :
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
rows:
|
|
2381
|
-
columns:
|
|
2382
|
-
loading:
|
|
2383
|
-
actions:
|
|
2384
|
-
"form-id": (
|
|
2385
|
-
"api-delete": (u =
|
|
2386
|
-
"key-field": (m =
|
|
2387
|
-
selection:
|
|
2388
|
-
"dict-data":
|
|
2389
|
-
onSelectionChange:
|
|
2390
|
-
onRowEdit:
|
|
2391
|
-
onRowDelete:
|
|
2392
|
-
onRowClick:
|
|
2722
|
+
fields: s.value.searchFields,
|
|
2723
|
+
modelValue: r.searchParams,
|
|
2724
|
+
"onUpdate:modelValue": i[0] || (i[0] = (De) => r.searchParams = De),
|
|
2725
|
+
onSearch: d.handleSearch,
|
|
2726
|
+
onReset: d.handleReset
|
|
2727
|
+
}, null, 8, ["fields", "modelValue", "onSearch", "onReset"])) : D("", !0),
|
|
2728
|
+
x("div", wa, [
|
|
2729
|
+
x("div", xa, [
|
|
2730
|
+
S(ta, {
|
|
2731
|
+
rows: s.value.rows,
|
|
2732
|
+
columns: s.value.columns,
|
|
2733
|
+
loading: s.value.loading,
|
|
2734
|
+
actions: s.value.actions,
|
|
2735
|
+
"form-id": (n = s.value.tableConfig) == null ? void 0 : n.form,
|
|
2736
|
+
"api-delete": (u = s.value.tableConfig) == null ? void 0 : u.api.delete,
|
|
2737
|
+
"key-field": (m = s.value.tableConfig) == null ? void 0 : m.key,
|
|
2738
|
+
selection: s.value.selectionMode,
|
|
2739
|
+
"dict-data": s.value.dictData,
|
|
2740
|
+
onSelectionChange: d.handleSelectionChange,
|
|
2741
|
+
onRowEdit: d.handleRowEdit,
|
|
2742
|
+
onRowDelete: d.handleRowDelete,
|
|
2743
|
+
onRowClick: d.handleRowClick
|
|
2393
2744
|
}, null, 8, ["rows", "columns", "loading", "actions", "form-id", "api-delete", "key-field", "selection", "dict-data", "onSelectionChange", "onRowEdit", "onRowDelete", "onRowClick"]),
|
|
2394
|
-
|
|
2745
|
+
S(ra, {
|
|
2395
2746
|
class: "table-pagination",
|
|
2396
|
-
page:
|
|
2397
|
-
"page-size":
|
|
2398
|
-
total:
|
|
2399
|
-
type: (
|
|
2400
|
-
"onUpdate:page":
|
|
2401
|
-
"onUpdate:pageSize":
|
|
2747
|
+
page: s.value.pagination.page,
|
|
2748
|
+
"page-size": s.value.pagination.pageSize,
|
|
2749
|
+
total: s.value.total,
|
|
2750
|
+
type: (g = s.value.tableConfig) == null ? void 0 : g.pagination,
|
|
2751
|
+
"onUpdate:page": d.handlePageChange,
|
|
2752
|
+
"onUpdate:pageSize": d.handlePageSizeChange
|
|
2402
2753
|
}, null, 8, ["page", "page-size", "total", "type", "onUpdate:page", "onUpdate:pageSize"])
|
|
2403
2754
|
]),
|
|
2404
|
-
|
|
2755
|
+
s.value.showDetail ? (f(), k(ba, {
|
|
2405
2756
|
key: 0,
|
|
2406
|
-
visible:
|
|
2407
|
-
loading:
|
|
2408
|
-
position: (
|
|
2409
|
-
title: (
|
|
2410
|
-
"row-data":
|
|
2411
|
-
columns:
|
|
2412
|
-
onClose:
|
|
2413
|
-
}, null, 8, ["visible", "loading", "position", "title", "row-data", "columns", "onClose"])) :
|
|
2757
|
+
visible: s.value.detailVisible,
|
|
2758
|
+
loading: s.value.detailLoading,
|
|
2759
|
+
position: (p = (b = s.value.tableConfig) == null ? void 0 : b.detail) == null ? void 0 : p.position,
|
|
2760
|
+
title: (v = (C = s.value.tableConfig) == null ? void 0 : C.meta) == null ? void 0 : v.title,
|
|
2761
|
+
"row-data": s.value.detailData,
|
|
2762
|
+
columns: s.value.columns,
|
|
2763
|
+
onClose: d.handleDetailClose
|
|
2764
|
+
}, null, 8, ["visible", "loading", "position", "title", "row-data", "columns", "onClose"])) : D("", !0)
|
|
2414
2765
|
]),
|
|
2415
|
-
|
|
2766
|
+
s.value.toolbar.length > 0 || (W = s.value.tableConfig) != null && W.form ? (f(), k(qt, {
|
|
2416
2767
|
key: 1,
|
|
2417
2768
|
class: "table-toolbar-bottom",
|
|
2418
|
-
toolbar:
|
|
2419
|
-
actions:
|
|
2420
|
-
"form-id": (
|
|
2421
|
-
"api-delete": (
|
|
2422
|
-
"selected-count":
|
|
2423
|
-
onCreate:
|
|
2424
|
-
onImport:
|
|
2425
|
-
onExport:
|
|
2426
|
-
onBatchEdit:
|
|
2427
|
-
onBatchDelete:
|
|
2428
|
-
}, null, 8, ["toolbar", "actions", "form-id", "api-delete", "selected-count", "onCreate", "onImport", "onExport", "onBatchEdit", "onBatchDelete"])) :
|
|
2429
|
-
|
|
2769
|
+
toolbar: s.value.toolbar,
|
|
2770
|
+
actions: s.value.actions,
|
|
2771
|
+
"form-id": (ce = s.value.tableConfig) == null ? void 0 : ce.form,
|
|
2772
|
+
"api-delete": (ue = s.value.tableConfig) == null ? void 0 : ue.api.delete,
|
|
2773
|
+
"selected-count": s.value.selectedRows.length,
|
|
2774
|
+
onCreate: d.handleCreate,
|
|
2775
|
+
onImport: d.handleImport,
|
|
2776
|
+
onExport: d.handleExport,
|
|
2777
|
+
onBatchEdit: d.handleBatchEdit,
|
|
2778
|
+
onBatchDelete: d.handleBatchDelete
|
|
2779
|
+
}, null, 8, ["toolbar", "actions", "form-id", "api-delete", "selected-count", "onCreate", "onImport", "onExport", "onBatchEdit", "onBatchDelete"])) : D("", !0),
|
|
2780
|
+
S(ke, {
|
|
2430
2781
|
ref_key: "formRef",
|
|
2431
|
-
ref:
|
|
2782
|
+
ref: c
|
|
2432
2783
|
}, null, 512)
|
|
2433
2784
|
]);
|
|
2434
2785
|
};
|
|
2435
2786
|
}
|
|
2436
|
-
}),
|
|
2437
|
-
class
|
|
2787
|
+
}), _a = /* @__PURE__ */ P(Ca, [["__scopeId", "data-v-91132dca"]]);
|
|
2788
|
+
class Sa {
|
|
2438
2789
|
constructor(t) {
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
this.axiosInstance =
|
|
2790
|
+
_(this, "axiosInstance");
|
|
2791
|
+
_(this, "baseUrl", "");
|
|
2792
|
+
this.axiosInstance = we.create({
|
|
2442
2793
|
timeout: 1e4,
|
|
2443
2794
|
baseURL: ""
|
|
2444
2795
|
}), this.axiosInstance.defaults.headers["Content-Type"] = "application/json;charset=utf-8", this.axiosInstance.interceptors.request.use(
|
|
@@ -2483,11 +2834,11 @@ class ha {
|
|
|
2483
2834
|
});
|
|
2484
2835
|
}
|
|
2485
2836
|
}
|
|
2486
|
-
class
|
|
2837
|
+
class ka {
|
|
2487
2838
|
//事件总线
|
|
2488
2839
|
constructor() {
|
|
2489
|
-
|
|
2490
|
-
this.emitter =
|
|
2840
|
+
_(this, "emitter");
|
|
2841
|
+
this.emitter = je();
|
|
2491
2842
|
}
|
|
2492
2843
|
On(t, e) {
|
|
2493
2844
|
this.emitter.on(t, e);
|
|
@@ -2499,10 +2850,10 @@ class ga {
|
|
|
2499
2850
|
this.emitter.off(t, e);
|
|
2500
2851
|
}
|
|
2501
2852
|
}
|
|
2502
|
-
class
|
|
2853
|
+
class Da {
|
|
2503
2854
|
constructor(t, e) {
|
|
2504
|
-
|
|
2505
|
-
|
|
2855
|
+
_(this, "mqttClient", null);
|
|
2856
|
+
_(this, "eventBus");
|
|
2506
2857
|
this.eventBus = t, this.connect(e).then();
|
|
2507
2858
|
}
|
|
2508
2859
|
async connect(t) {
|
|
@@ -2515,72 +2866,72 @@ class ya {
|
|
|
2515
2866
|
connectTimeout: 5e3,
|
|
2516
2867
|
reconnectPeriod: 5e3
|
|
2517
2868
|
};
|
|
2518
|
-
let
|
|
2519
|
-
if (console.log("connect to mqtt..."), this.mqttClient =
|
|
2869
|
+
let o = t.mqttUrl || "ws://127.0.0.1:5002/ws";
|
|
2870
|
+
if (console.log("connect to mqtt..."), this.mqttClient = Oe.connect(o, e), !this.mqttClient) {
|
|
2520
2871
|
console.log("connect mqtt failed");
|
|
2521
2872
|
return;
|
|
2522
2873
|
}
|
|
2523
2874
|
this.mqttClient.on("connect", () => {
|
|
2524
|
-
console.log("=====> mqtt connect success!"), this.mqttClient.subscribe(
|
|
2525
|
-
console.log(
|
|
2875
|
+
console.log("=====> mqtt connect success!"), this.mqttClient.subscribe(le, { qos: 0 }, (c) => {
|
|
2876
|
+
console.log(c ? `mqtt subscribe [${le}] failed` : `mqtt subscribe [${le}] success`);
|
|
2526
2877
|
});
|
|
2527
|
-
}), this.mqttClient.on("message", (
|
|
2528
|
-
const
|
|
2529
|
-
if (!
|
|
2530
|
-
console.error("Received empty message",
|
|
2878
|
+
}), this.mqttClient.on("message", (c, r) => {
|
|
2879
|
+
const s = r.toString();
|
|
2880
|
+
if (!s) {
|
|
2881
|
+
console.error("Received empty message", c);
|
|
2531
2882
|
return;
|
|
2532
2883
|
}
|
|
2533
|
-
let
|
|
2884
|
+
let d = null;
|
|
2534
2885
|
try {
|
|
2535
|
-
|
|
2536
|
-
} catch (
|
|
2537
|
-
console.error("Failed to parse message JSON",
|
|
2886
|
+
d = JSON.parse(s);
|
|
2887
|
+
} catch (a) {
|
|
2888
|
+
console.error("Failed to parse message JSON", c, s, a);
|
|
2538
2889
|
return;
|
|
2539
2890
|
}
|
|
2540
|
-
if (!
|
|
2541
|
-
console.log("parse notice failed!",
|
|
2891
|
+
if (!d || d.Content === void 0 || d.Content === null || !d.PType) {
|
|
2892
|
+
console.log("parse notice failed!", s);
|
|
2542
2893
|
return;
|
|
2543
2894
|
}
|
|
2544
|
-
|
|
2545
|
-
}), this.mqttClient.on(
|
|
2895
|
+
d.PType == Ta && this.eventBus.Emit(d.Route, d.Content);
|
|
2896
|
+
}), this.mqttClient.on(Z.OffLine, () => {
|
|
2546
2897
|
console.log("mqtt offline...");
|
|
2547
|
-
}), this.mqttClient.on(
|
|
2898
|
+
}), this.mqttClient.on(Z.Reconnect, () => {
|
|
2548
2899
|
console.log("mqtt reconnecting...");
|
|
2549
|
-
}), this.mqttClient.on(
|
|
2900
|
+
}), this.mqttClient.on(Z.Close, () => {
|
|
2550
2901
|
console.log("mqtt close");
|
|
2551
|
-
}), this.mqttClient.on(
|
|
2902
|
+
}), this.mqttClient.on(Z.Error, (c) => {
|
|
2552
2903
|
console.log("mqtt error");
|
|
2553
2904
|
});
|
|
2554
2905
|
}
|
|
2555
2906
|
// 生成随机字符串
|
|
2556
2907
|
randomStr(t) {
|
|
2557
2908
|
const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
2558
|
-
let
|
|
2559
|
-
for (let
|
|
2560
|
-
|
|
2561
|
-
return
|
|
2909
|
+
let o = "";
|
|
2910
|
+
for (let c = 0; c < t; c++)
|
|
2911
|
+
o += e.charAt(Math.floor(Math.random() * e.length));
|
|
2912
|
+
return o;
|
|
2562
2913
|
}
|
|
2563
2914
|
}
|
|
2564
|
-
const
|
|
2915
|
+
const le = "Notice", Ta = "NOTICE", Z = {
|
|
2565
2916
|
OffLine: "offline",
|
|
2566
2917
|
Close: "close",
|
|
2567
2918
|
Reconnect: "reconnect",
|
|
2568
2919
|
Error: "error"
|
|
2569
2920
|
};
|
|
2570
|
-
let
|
|
2571
|
-
const
|
|
2572
|
-
if (!
|
|
2921
|
+
let ee;
|
|
2922
|
+
const no = (l) => {
|
|
2923
|
+
if (!l)
|
|
2573
2924
|
throw new Error("QfOptions is undefined");
|
|
2574
|
-
if (!
|
|
2925
|
+
if (!ee && l && (ee = new Va(l)), !ee)
|
|
2575
2926
|
throw new Error("Qf not initialized, please call GetQf(options) first");
|
|
2576
|
-
return
|
|
2927
|
+
return ee;
|
|
2577
2928
|
};
|
|
2578
|
-
class
|
|
2929
|
+
class Va {
|
|
2579
2930
|
constructor(t) {
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2931
|
+
_(this, "EventBus");
|
|
2932
|
+
_(this, "WebApi");
|
|
2933
|
+
_(this, "Mqtt");
|
|
2934
|
+
_(this, "options");
|
|
2584
2935
|
this.initQf(t);
|
|
2585
2936
|
}
|
|
2586
2937
|
/**
|
|
@@ -2589,7 +2940,7 @@ class va {
|
|
|
2589
2940
|
initQf(t) {
|
|
2590
2941
|
if (!t)
|
|
2591
2942
|
throw new Error(`StartQf failed! options is ${t}`);
|
|
2592
|
-
this.options = t, console.log("StartQf(), qfOptions=", t), this.EventBus = new
|
|
2943
|
+
this.options = t, console.log("StartQf(), qfOptions=", t), this.EventBus = new ka(), this.WebApi = new Sa(t), this.options.useMqtt && (this.Mqtt = new Da(this.EventBus, t));
|
|
2593
2944
|
}
|
|
2594
2945
|
// ==================== EventBus 相关 ====================
|
|
2595
2946
|
On(t, e) {
|
|
@@ -2622,35 +2973,37 @@ class va {
|
|
|
2622
2973
|
this.EventBus.On(t, e);
|
|
2623
2974
|
}
|
|
2624
2975
|
}
|
|
2625
|
-
const
|
|
2626
|
-
UInput:
|
|
2627
|
-
UInputNumber:
|
|
2628
|
-
UDict:
|
|
2629
|
-
UToggle:
|
|
2630
|
-
UCascader:
|
|
2631
|
-
UDate:
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2976
|
+
const Pa = {
|
|
2977
|
+
UInput: K,
|
|
2978
|
+
UInputNumber: xe,
|
|
2979
|
+
UDict: G,
|
|
2980
|
+
UToggle: _e,
|
|
2981
|
+
UCascader: Se,
|
|
2982
|
+
UDate: oe,
|
|
2983
|
+
UMenu: mt,
|
|
2984
|
+
FormRender: ke,
|
|
2985
|
+
TableRender: _a,
|
|
2986
|
+
UFieldView: de
|
|
2987
|
+
}, io = {
|
|
2988
|
+
install(l) {
|
|
2989
|
+
l.use(Pe);
|
|
2990
|
+
for (const [t, e] of Object.entries(Pa))
|
|
2991
|
+
l.component(t, e);
|
|
2640
2992
|
}
|
|
2641
2993
|
};
|
|
2642
2994
|
export {
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2995
|
+
ke as FormRender,
|
|
2996
|
+
no as GetQf,
|
|
2997
|
+
_a as TableRender,
|
|
2998
|
+
Se as UCascader,
|
|
2999
|
+
oe as UDate,
|
|
3000
|
+
G as UDict,
|
|
3001
|
+
de as UFieldView,
|
|
3002
|
+
K as UInput,
|
|
3003
|
+
xe as UInputNumber,
|
|
3004
|
+
mt as UMenu,
|
|
3005
|
+
_e as UToggle,
|
|
3006
|
+
io as default,
|
|
3007
|
+
j as notify,
|
|
3008
|
+
J as notifyUtil
|
|
2656
3009
|
};
|