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