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