urit-qf-ui 0.2.4 → 0.2.5
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 +41 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1137 -1035
- 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/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/TableRender.vue.d.ts +8 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var x = (
|
|
4
|
-
import
|
|
1
|
+
var Me = Object.defineProperty;
|
|
2
|
+
var Ee = (o, t, e) => t in o ? Me(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var x = (o, t, e) => Ee(o, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import Ue, { ElMessage as Te, ElMessageBox as De } from "element-plus";
|
|
5
5
|
import "element-plus/dist/index.css";
|
|
6
|
-
import { ElInput as Be, ElInputNumber as Fe, ElSelect as
|
|
6
|
+
import { ElInput as Be, ElInputNumber as Fe, ElSelect as pe, ElOption as he, ElSwitch as Le, ElDatePicker as ze, ElMenu as Ne, ElSubMenu as We, ElMenuItem as qe, ElIcon as ge, ElButton as J, ElDialog as je, ElForm as Oe, ElTable as Ye, ElTableColumn as Qe, ElPagination as Ke, ElDrawer as He } from "element-plus/es";
|
|
7
7
|
import "element-plus/es/components/base/style/css";
|
|
8
8
|
import "element-plus/es/components/input/style/css";
|
|
9
|
-
import { defineComponent as P, computed as v, openBlock as h, createElementBlock as y, normalizeClass as V, normalizeStyle as B, createTextVNode as F, toDisplayString as
|
|
9
|
+
import { defineComponent as P, computed as v, openBlock as h, createElementBlock as y, normalizeClass as V, normalizeStyle as B, createTextVNode as F, toDisplayString as k, createElementVNode as C, createCommentVNode as D, createVNode as _, reactive as W, watch as L, withCtx as w, Fragment as I, renderList as E, createBlock as S, mergeProps as ce, ref as Q, markRaw as re, onMounted as oe, renderSlot as T, resolveDynamicComponent as H, toRefs as Ge, unref as N, useSlots as ye, createSlots as X, withModifiers as Je, normalizeProps as q, guardReactiveProps as j, useAttrs as Xe } from "vue";
|
|
10
10
|
import "element-plus/es/components/input-number/style/css";
|
|
11
11
|
import "element-plus/es/components/select/style/css";
|
|
12
12
|
import "element-plus/es/components/option/style/css";
|
|
@@ -20,7 +20,7 @@ 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 ke } 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";
|
|
@@ -54,55 +54,55 @@ const tt = /* @__PURE__ */ P({
|
|
|
54
54
|
maxlength: {}
|
|
55
55
|
},
|
|
56
56
|
emits: ["update:modelValue"],
|
|
57
|
-
setup(
|
|
58
|
-
const e =
|
|
57
|
+
setup(o, { emit: t }) {
|
|
58
|
+
const e = o, l = t, d = v(() => {
|
|
59
59
|
const s = {};
|
|
60
60
|
return e.labelPosition === "left" && e.labelWidth && (s.width = typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth), e.labelAlign && (s.textAlign = e.labelAlign), s;
|
|
61
61
|
}), r = v(() => ({
|
|
62
62
|
"u-input-label-left": e.labelPosition === "left",
|
|
63
63
|
"u-input-label-top": e.labelPosition === "top"
|
|
64
|
-
})),
|
|
64
|
+
})), c = {
|
|
65
65
|
onInput(s) {
|
|
66
|
-
|
|
66
|
+
l("update:modelValue", s);
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
return (s, a) => {
|
|
70
|
-
const
|
|
70
|
+
const i = Be;
|
|
71
71
|
return h(), y("div", {
|
|
72
72
|
class: V(["u-input", r.value])
|
|
73
73
|
}, [
|
|
74
|
-
|
|
74
|
+
o.fieldLabel ? (h(), y("div", {
|
|
75
75
|
key: 0,
|
|
76
76
|
class: "u-input-label",
|
|
77
|
-
style: B(
|
|
77
|
+
style: B(d.value)
|
|
78
78
|
}, [
|
|
79
|
-
F(
|
|
79
|
+
F(k(o.fieldLabel) + " ", 1),
|
|
80
80
|
C("span", {
|
|
81
|
-
class: V(["required-star", { "required-star--visible":
|
|
81
|
+
class: V(["required-star", { "required-star--visible": o.required }])
|
|
82
82
|
}, "*", 2)
|
|
83
|
-
], 4)) :
|
|
83
|
+
], 4)) : D("", !0),
|
|
84
84
|
C("div", {
|
|
85
|
-
class: V(["u-input-field", { "u-input-field--top":
|
|
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
|
+
_(i, {
|
|
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": c.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 [l, d] of t)
|
|
103
|
+
e[l] = d;
|
|
104
104
|
return e;
|
|
105
|
-
},
|
|
105
|
+
}, te = /* @__PURE__ */ $(tt, [["__scopeId", "data-v-ecf5177c"]]), at = { class: "u-input-number-field" }, ot = /* @__PURE__ */ P({
|
|
106
106
|
__name: "UInputNumber",
|
|
107
107
|
props: {
|
|
108
108
|
fieldLabel: {},
|
|
@@ -129,203 +129,203 @@ const tt = /* @__PURE__ */ P({
|
|
|
129
129
|
precision: {}
|
|
130
130
|
},
|
|
131
131
|
emits: ["update:modelValue"],
|
|
132
|
-
setup(
|
|
133
|
-
const e =
|
|
132
|
+
setup(o, { emit: t }) {
|
|
133
|
+
const e = o, l = t, d = v(() => {
|
|
134
134
|
const s = {};
|
|
135
135
|
return e.labelPosition === "left" && e.labelWidth && (s.width = typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth), e.labelAlign && (s.textAlign = e.labelAlign), s;
|
|
136
136
|
}), r = v(() => ({
|
|
137
137
|
"u-input-number-label-left": e.labelPosition === "left",
|
|
138
138
|
"u-input-number-label-top": e.labelPosition === "top"
|
|
139
|
-
})),
|
|
139
|
+
})), c = {
|
|
140
140
|
onUpdate(s) {
|
|
141
|
-
|
|
141
|
+
l("update:modelValue", s === void 0 ? 0 : s);
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
144
|
return (s, a) => {
|
|
145
|
-
const
|
|
145
|
+
const i = Fe;
|
|
146
146
|
return h(), y("div", {
|
|
147
147
|
class: V(["u-input-number", r.value])
|
|
148
148
|
}, [
|
|
149
|
-
|
|
149
|
+
o.fieldLabel ? (h(), y("div", {
|
|
150
150
|
key: 0,
|
|
151
151
|
class: "u-input-number-label",
|
|
152
|
-
style: B(
|
|
152
|
+
style: B(d.value)
|
|
153
153
|
}, [
|
|
154
|
-
F(
|
|
154
|
+
F(k(o.fieldLabel) + " ", 1),
|
|
155
155
|
C("span", {
|
|
156
|
-
class: V(["required-star", { "required-star--visible":
|
|
156
|
+
class: V(["required-star", { "required-star--visible": o.required }])
|
|
157
157
|
}, "*", 2)
|
|
158
|
-
], 4)) :
|
|
158
|
+
], 4)) : D("", !0),
|
|
159
159
|
C("div", at, [
|
|
160
|
-
_(
|
|
161
|
-
"model-value":
|
|
162
|
-
placeholder:
|
|
163
|
-
disabled:
|
|
164
|
-
min:
|
|
165
|
-
max:
|
|
166
|
-
step:
|
|
167
|
-
precision:
|
|
160
|
+
_(i, {
|
|
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: c.onUpdate
|
|
172
172
|
}, null, 8, ["model-value", "placeholder", "disabled", "min", "max", "step", "precision", "onChange"])
|
|
173
173
|
])
|
|
174
174
|
], 2);
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
-
}), Pe = /* @__PURE__ */ $(
|
|
177
|
+
}), Pe = /* @__PURE__ */ $(ot, [["__scopeId", "data-v-cb70bd5b"]]), Z = Ve.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, l = e === 0 || e === 200 || Number(e) === 0 || Number(e) === 200;
|
|
196
|
+
t.status = l ? 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, l;
|
|
207
|
+
const t = ((l = (e = o.response) == null ? void 0 : e.data) == null ? void 0 : l.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 M = {
|
|
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((l) => l.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
|
-
},
|
|
246
|
-
function
|
|
247
|
-
const { children: t, ...e } =
|
|
245
|
+
}, O = {}, ne = {};
|
|
246
|
+
function be(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 ve(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 = be(t), l = t.children;
|
|
258
|
+
return Array.isArray(l) && l.length > 0 && (e.children = ve(l)), e;
|
|
259
259
|
}) : [];
|
|
260
260
|
}
|
|
261
|
-
function
|
|
262
|
-
return Array.isArray(
|
|
261
|
+
function we(o) {
|
|
262
|
+
return Array.isArray(o) ? o.filter((t) => t && typeof t == "object").map((t) => be(t)) : [];
|
|
263
263
|
}
|
|
264
|
-
function
|
|
265
|
-
if (!Array.isArray(
|
|
266
|
-
const t = [], e = (
|
|
267
|
-
for (const
|
|
268
|
-
if (!
|
|
269
|
-
const r =
|
|
270
|
-
t.push(
|
|
264
|
+
function po(o) {
|
|
265
|
+
if (!Array.isArray(o)) return [];
|
|
266
|
+
const t = [], e = (l) => {
|
|
267
|
+
for (const d of l) {
|
|
268
|
+
if (!d || typeof d != "object") continue;
|
|
269
|
+
const r = d.children;
|
|
270
|
+
t.push(be(d)), Array.isArray(r) && r.length > 0 && e(r);
|
|
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 (
|
|
279
|
-
return
|
|
280
|
-
if (
|
|
281
|
-
return await
|
|
278
|
+
if (O[o])
|
|
279
|
+
return O[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 M.get(K.dictApi(o));
|
|
285
285
|
if (e.status === 200) {
|
|
286
|
-
const
|
|
287
|
-
return
|
|
286
|
+
const l = we(e.data);
|
|
287
|
+
return O[o] = l, l;
|
|
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 lt(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 l = O[o];
|
|
302
|
+
if (l && l.length > 0)
|
|
303
|
+
return me(l, t);
|
|
304
|
+
const d = await ae(o);
|
|
305
|
+
return d && d.length > 0 ? me(d, t) : e || String(t);
|
|
306
306
|
}
|
|
307
|
-
function
|
|
308
|
-
const e =
|
|
309
|
-
(
|
|
307
|
+
function me(o, t) {
|
|
308
|
+
const e = o.find(
|
|
309
|
+
(l) => l.value === t || String(l.value) === String(t)
|
|
310
310
|
);
|
|
311
311
|
return e ? e.label : String(t);
|
|
312
312
|
}
|
|
313
|
-
function
|
|
313
|
+
function ho(o, t, e = "") {
|
|
314
314
|
if (t == null || t === "")
|
|
315
315
|
return e;
|
|
316
|
-
const
|
|
317
|
-
return
|
|
316
|
+
const l = O[o];
|
|
317
|
+
return l && l.length > 0 ? me(l, t) : e || String(t);
|
|
318
318
|
}
|
|
319
|
-
async function
|
|
320
|
-
await Promise.all(
|
|
319
|
+
async function go(o) {
|
|
320
|
+
await Promise.all(o.map((t) => ae(t)));
|
|
321
321
|
}
|
|
322
|
-
function
|
|
323
|
-
|
|
324
|
-
delete
|
|
322
|
+
function yo(o) {
|
|
323
|
+
o ? delete O[o] : Object.keys(O).forEach((t) => {
|
|
324
|
+
delete O[t];
|
|
325
325
|
});
|
|
326
326
|
}
|
|
327
|
-
function
|
|
328
|
-
|
|
327
|
+
function bo(o, t) {
|
|
328
|
+
O[o] = t;
|
|
329
329
|
}
|
|
330
330
|
const nt = { class: "u-dict-field" }, it = /* @__PURE__ */ P({
|
|
331
331
|
__name: "UDict",
|
|
@@ -351,64 +351,64 @@ 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, l = t, d = W({
|
|
356
356
|
excluded: ["fieldLabel", "labelPosition", "labelWidth", "labelAlign", "required", "modelValue", "dictType"],
|
|
357
357
|
options: [],
|
|
358
358
|
loading: !1
|
|
359
359
|
}), r = async () => {
|
|
360
360
|
if (e.dictType) {
|
|
361
|
-
|
|
361
|
+
d.loading = !0;
|
|
362
362
|
try {
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
} catch (
|
|
366
|
-
console.error("[UDict] 加载字典失败:",
|
|
363
|
+
const i = await M.get(K.dictApi(e.dictType));
|
|
364
|
+
i.status === 200 ? d.options = we(i.data) : (console.error("[UDict] 请求失败:", i.message), d.options = []);
|
|
365
|
+
} catch (i) {
|
|
366
|
+
console.error("[UDict] 加载字典失败:", i), d.options = [];
|
|
367
367
|
} finally {
|
|
368
|
-
|
|
368
|
+
d.loading = !1;
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
371
|
};
|
|
372
|
-
|
|
372
|
+
L(() => e.dictType, () => {
|
|
373
373
|
r();
|
|
374
374
|
}, { immediate: !0 });
|
|
375
|
-
const
|
|
376
|
-
const
|
|
377
|
-
return e.labelPosition === "left" && e.labelWidth && (
|
|
375
|
+
const c = v(() => {
|
|
376
|
+
const i = {};
|
|
377
|
+
return e.labelPosition === "left" && e.labelWidth && (i.width = typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth), e.labelAlign && (i.textAlign = e.labelAlign), i;
|
|
378
378
|
}), s = 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(i) {
|
|
383
|
+
l("update:modelValue", i);
|
|
384
384
|
}
|
|
385
385
|
};
|
|
386
|
-
return (
|
|
387
|
-
const f =
|
|
386
|
+
return (i, n) => {
|
|
387
|
+
const f = he, m = pe;
|
|
388
388
|
return h(), y("div", {
|
|
389
389
|
class: V(["u-dict", s.value])
|
|
390
390
|
}, [
|
|
391
|
-
|
|
391
|
+
o.fieldLabel ? (h(), y("div", {
|
|
392
392
|
key: 0,
|
|
393
393
|
class: "u-dict-label",
|
|
394
|
-
style: B(
|
|
394
|
+
style: B(c.value)
|
|
395
395
|
}, [
|
|
396
|
-
F(
|
|
396
|
+
F(k(o.fieldLabel) + " ", 1),
|
|
397
397
|
C("span", {
|
|
398
|
-
class: V(["required-star", { "required-star--visible":
|
|
398
|
+
class: V(["required-star", { "required-star--visible": o.required }])
|
|
399
399
|
}, "*", 2)
|
|
400
|
-
], 4)) :
|
|
400
|
+
], 4)) : D("", !0),
|
|
401
401
|
C("div", nt, [
|
|
402
|
-
_(
|
|
403
|
-
"model-value":
|
|
404
|
-
placeholder:
|
|
405
|
-
loading:
|
|
406
|
-
disabled:
|
|
402
|
+
_(m, {
|
|
403
|
+
"model-value": o.modelValue,
|
|
404
|
+
placeholder: o.placeholder || "请选择",
|
|
405
|
+
loading: d.loading,
|
|
406
|
+
disabled: o.disable,
|
|
407
407
|
style: { width: "100%" },
|
|
408
408
|
onChange: a.onUpdate
|
|
409
409
|
}, {
|
|
410
410
|
default: w(() => [
|
|
411
|
-
(h(!0), y(
|
|
411
|
+
(h(!0), y(I, null, E(d.options, (u) => (h(), S(f, {
|
|
412
412
|
key: u.value,
|
|
413
413
|
label: u.label,
|
|
414
414
|
value: u.value
|
|
@@ -420,7 +420,7 @@ const nt = { class: "u-dict-field" }, it = /* @__PURE__ */ P({
|
|
|
420
420
|
], 2);
|
|
421
421
|
};
|
|
422
422
|
}
|
|
423
|
-
}),
|
|
423
|
+
}), ee = /* @__PURE__ */ $(it, [["__scopeId", "data-v-8bfd4dcf"]]), st = { class: "u-toggle-field" }, rt = /* @__PURE__ */ P({
|
|
424
424
|
__name: "UToggle",
|
|
425
425
|
props: {
|
|
426
426
|
fieldLabel: {},
|
|
@@ -443,47 +443,47 @@ 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, l = t, d = W({
|
|
448
448
|
excluded: ["fieldLabel", "labelPosition", "labelWidth", "labelAlign", "required", "modelValue", "trueValue", "falseValue", "activeText", "inactiveText", "activeColor", "inactiveColor"]
|
|
449
449
|
}), r = () => {
|
|
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
|
+
}, c = v({
|
|
453
453
|
get: () => e.modelValue === e.trueValue,
|
|
454
454
|
set: (a) => {
|
|
455
|
-
|
|
455
|
+
l("update:modelValue", a ? e.trueValue : e.falseValue);
|
|
456
456
|
}
|
|
457
457
|
}), s = v(() => {
|
|
458
458
|
const a = {};
|
|
459
|
-
for (const
|
|
460
|
-
!
|
|
459
|
+
for (const i in e)
|
|
460
|
+
!d.excluded.includes(i) && i !== "modelValue" && (a[i] = e[i]);
|
|
461
461
|
return a;
|
|
462
462
|
});
|
|
463
|
-
return (a,
|
|
464
|
-
const
|
|
463
|
+
return (a, i) => {
|
|
464
|
+
const n = Le;
|
|
465
465
|
return h(), y("div", {
|
|
466
|
-
class: V(["u-toggle", { "u-toggle-label-left":
|
|
466
|
+
class: V(["u-toggle", { "u-toggle-label-left": o.labelPosition === "left" }])
|
|
467
467
|
}, [
|
|
468
|
-
|
|
468
|
+
o.fieldLabel ? (h(), y("div", {
|
|
469
469
|
key: 0,
|
|
470
470
|
class: "u-toggle-label",
|
|
471
471
|
style: B(r())
|
|
472
472
|
}, [
|
|
473
|
-
F(
|
|
473
|
+
F(k(o.fieldLabel) + " ", 1),
|
|
474
474
|
C("span", {
|
|
475
|
-
class: V(["required-star", { "required-star--visible":
|
|
475
|
+
class: V(["required-star", { "required-star--visible": o.required }])
|
|
476
476
|
}, "*", 2)
|
|
477
|
-
], 4)) :
|
|
477
|
+
], 4)) : D("", !0),
|
|
478
478
|
C("div", st, [
|
|
479
|
-
_(
|
|
480
|
-
modelValue:
|
|
481
|
-
"onUpdate:modelValue":
|
|
479
|
+
_(n, ce({
|
|
480
|
+
modelValue: c.value,
|
|
481
|
+
"onUpdate:modelValue": i[0] || (i[0] = (f) => c.value = f)
|
|
482
482
|
}, s.value, {
|
|
483
|
-
"active-text":
|
|
484
|
-
"inactive-text":
|
|
485
|
-
"active-color":
|
|
486
|
-
"inactive-color":
|
|
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);
|
|
@@ -502,61 +502,61 @@ 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, l = t, d = () => {
|
|
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
|
-
}, r =
|
|
509
|
+
}, r = Q([]), c = v(() => {
|
|
510
510
|
const a = [];
|
|
511
|
-
let
|
|
512
|
-
for (let
|
|
513
|
-
if (a.push(
|
|
514
|
-
const f =
|
|
515
|
-
f && f.children ?
|
|
511
|
+
let i = e.options || [];
|
|
512
|
+
for (let n = 0; n < e.depth; n++)
|
|
513
|
+
if (a.push(i), r.value[n] !== void 0) {
|
|
514
|
+
const f = i.find((m) => m.value === r.value[n]);
|
|
515
|
+
f && f.children ? i = f.children : i = [];
|
|
516
516
|
} else
|
|
517
|
-
|
|
517
|
+
i = [];
|
|
518
518
|
return a;
|
|
519
519
|
});
|
|
520
|
-
|
|
520
|
+
L(() => e.modelValue, (a) => {
|
|
521
521
|
a != null ? r.value = Array.isArray(a) ? a : [a] : r.value = [];
|
|
522
522
|
}, { immediate: !0 });
|
|
523
|
-
const s = (a,
|
|
524
|
-
r.value[a] =
|
|
523
|
+
const s = (a, i) => {
|
|
524
|
+
r.value[a] = i;
|
|
525
525
|
for (let f = a + 1; f < e.depth; f++)
|
|
526
526
|
r.value[f] = void 0;
|
|
527
|
-
const
|
|
528
|
-
|
|
527
|
+
const n = r.value.filter((f) => f !== void 0);
|
|
528
|
+
l("update:modelValue", n);
|
|
529
529
|
};
|
|
530
|
-
return (a,
|
|
531
|
-
const
|
|
530
|
+
return (a, i) => {
|
|
531
|
+
const n = he, f = pe;
|
|
532
532
|
return h(), y("div", {
|
|
533
|
-
class: V(["u-cascader", { "u-cascader-label-left":
|
|
533
|
+
class: V(["u-cascader", { "u-cascader-label-left": o.labelPosition === "left" }])
|
|
534
534
|
}, [
|
|
535
|
-
|
|
535
|
+
o.fieldLabel ? (h(), y("div", {
|
|
536
536
|
key: 0,
|
|
537
537
|
class: "u-cascader-label",
|
|
538
|
-
style: B(
|
|
538
|
+
style: B(d())
|
|
539
539
|
}, [
|
|
540
|
-
F(
|
|
540
|
+
F(k(o.fieldLabel) + " ", 1),
|
|
541
541
|
C("span", {
|
|
542
|
-
class: V(["required-star", { "required-star--visible":
|
|
542
|
+
class: V(["required-star", { "required-star--visible": o.required }])
|
|
543
543
|
}, "*", 2)
|
|
544
|
-
], 4)) :
|
|
544
|
+
], 4)) : D("", !0),
|
|
545
545
|
C("div", dt, [
|
|
546
|
-
(h(!0), y(
|
|
547
|
-
key:
|
|
546
|
+
(h(!0), y(I, null, E(o.depth, (m) => (h(), y("div", {
|
|
547
|
+
key: m - 1,
|
|
548
548
|
class: "u-cascader-level"
|
|
549
549
|
}, [
|
|
550
550
|
_(f, {
|
|
551
|
-
"model-value": r.value[
|
|
552
|
-
options:
|
|
553
|
-
disabled:
|
|
554
|
-
placeholder: `请选择${
|
|
551
|
+
"model-value": r.value[m - 1],
|
|
552
|
+
options: c.value[m - 1] || [],
|
|
553
|
+
disabled: m > 1 && r.value[m - 2] === void 0,
|
|
554
|
+
placeholder: `请选择${m}级`,
|
|
555
555
|
style: { width: "100%" },
|
|
556
|
-
onChange: (u) => s(
|
|
556
|
+
onChange: (u) => s(m - 1, u)
|
|
557
557
|
}, {
|
|
558
558
|
default: w(() => [
|
|
559
|
-
(h(!0), y(
|
|
559
|
+
(h(!0), y(I, null, E(c.value[m - 1] || [], (u) => (h(), S(n, {
|
|
560
560
|
key: u.value,
|
|
561
561
|
label: u.label,
|
|
562
562
|
value: u.value
|
|
@@ -569,7 +569,7 @@ const nt = { class: "u-dict-field" }, it = /* @__PURE__ */ P({
|
|
|
569
569
|
], 2);
|
|
570
570
|
};
|
|
571
571
|
}
|
|
572
|
-
}),
|
|
572
|
+
}), Re = /* @__PURE__ */ $(ct, [["__scopeId", "data-v-d66c339c"]]), ut = { class: "u-date-field" }, ft = /* @__PURE__ */ P({
|
|
573
573
|
__name: "UDate",
|
|
574
574
|
props: {
|
|
575
575
|
fieldLabel: {},
|
|
@@ -585,80 +585,80 @@ 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, l = t, d = () => {
|
|
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
|
-
}, r =
|
|
593
|
-
|
|
592
|
+
}, r = Q("");
|
|
593
|
+
L(() => e.modelValue, (a) => {
|
|
594
594
|
e.mode === "single" ? r.value = a || "" : e.mode === "multiple" ? r.value = Array.isArray(a) ? a : a ? [a] : [] : e.mode === "range" && (a && typeof a == "object" && a.from && a.to ? r.value = [a.from, a.to] : r.value = []);
|
|
595
595
|
}, { immediate: !0 });
|
|
596
|
-
const
|
|
597
|
-
a && (e.mode === "single" || e.mode === "multiple" ?
|
|
596
|
+
const c = (a) => {
|
|
597
|
+
a && (e.mode === "single" || e.mode === "multiple" ? l("update:modelValue", a) : e.mode === "range" && a && a.length === 2 && l("update:modelValue", { from: a[0], to: a[1] }));
|
|
598
598
|
}, s = v(() => e.mode === "range" ? "daterange" : e.mode === "multiple" ? "dates" : "date");
|
|
599
|
-
return (a,
|
|
600
|
-
const
|
|
599
|
+
return (a, i) => {
|
|
600
|
+
const n = ze;
|
|
601
601
|
return h(), y("div", {
|
|
602
|
-
class: V(["u-date", { "u-date-label-left":
|
|
602
|
+
class: V(["u-date", { "u-date-label-left": o.labelPosition === "left" }])
|
|
603
603
|
}, [
|
|
604
|
-
|
|
604
|
+
o.fieldLabel ? (h(), y("div", {
|
|
605
605
|
key: 0,
|
|
606
606
|
class: "u-date-label",
|
|
607
|
-
style: B(
|
|
607
|
+
style: B(d())
|
|
608
608
|
}, [
|
|
609
|
-
F(
|
|
609
|
+
F(k(o.fieldLabel) + " ", 1),
|
|
610
610
|
C("span", {
|
|
611
|
-
class: V(["required-star", { "required-star--visible":
|
|
611
|
+
class: V(["required-star", { "required-star--visible": o.required }])
|
|
612
612
|
}, "*", 2)
|
|
613
|
-
], 4)) :
|
|
613
|
+
], 4)) : D("", !0),
|
|
614
614
|
C("div", ut, [
|
|
615
|
-
_(
|
|
615
|
+
_(n, {
|
|
616
616
|
modelValue: r.value,
|
|
617
|
-
"onUpdate:modelValue":
|
|
617
|
+
"onUpdate:modelValue": i[0] || (i[0] = (f) => r.value = f),
|
|
618
618
|
type: s.value,
|
|
619
|
-
placeholder:
|
|
620
|
-
"range-separator":
|
|
621
|
-
"start-placeholder":
|
|
622
|
-
"end-placeholder":
|
|
623
|
-
format:
|
|
624
|
-
"value-format":
|
|
625
|
-
onChange:
|
|
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: c
|
|
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__ */ $(ft, [["__scopeId", "data-v-9cd05064"]]);
|
|
632
|
+
function le(o, t = "info") {
|
|
633
|
+
Te({
|
|
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
|
+
Te({
|
|
642
|
+
message: o,
|
|
643
643
|
type: "error",
|
|
644
644
|
duration: 2e3,
|
|
645
645
|
showClose: !1
|
|
646
646
|
});
|
|
647
647
|
}
|
|
648
|
-
function mt(
|
|
649
|
-
|
|
648
|
+
function mt(o) {
|
|
649
|
+
le(o, "success");
|
|
650
650
|
}
|
|
651
|
-
function pt(
|
|
652
|
-
|
|
651
|
+
function pt(o) {
|
|
652
|
+
le(o, "error");
|
|
653
653
|
}
|
|
654
|
-
function ht(
|
|
655
|
-
|
|
654
|
+
function ht(o) {
|
|
655
|
+
le(o, "warning");
|
|
656
656
|
}
|
|
657
|
-
function gt(
|
|
658
|
-
|
|
657
|
+
function gt(o) {
|
|
658
|
+
le(o, "info");
|
|
659
659
|
}
|
|
660
|
-
const
|
|
661
|
-
notify:
|
|
660
|
+
const z = {
|
|
661
|
+
notify: le,
|
|
662
662
|
success: mt,
|
|
663
663
|
error: pt,
|
|
664
664
|
warning: ht,
|
|
@@ -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 l = o, d = e, r = W({
|
|
686
686
|
// 菜单配置
|
|
687
687
|
config: null,
|
|
688
688
|
// 实际渲染的菜单列表(静态配置或字典菜单)
|
|
@@ -693,21 +693,21 @@ const N = {
|
|
|
693
693
|
iconMap: {},
|
|
694
694
|
// 图标是否已加载
|
|
695
695
|
iconsLoaded: !1
|
|
696
|
-
}),
|
|
697
|
-
var a,
|
|
696
|
+
}), c = v(() => {
|
|
697
|
+
var a, i, n, f, m, u, g, p;
|
|
698
698
|
return {
|
|
699
699
|
// 项目名称:为空则不显示
|
|
700
|
-
projectName:
|
|
700
|
+
projectName: l.projectName ?? ((a = r.config) == null ? void 0 : a.projectName) ?? "",
|
|
701
701
|
// 项目 logo
|
|
702
|
-
logo: ((
|
|
702
|
+
logo: ((i = r.config) == null ? void 0 : i.logo) || "",
|
|
703
703
|
// 菜单模式
|
|
704
|
-
mode:
|
|
704
|
+
mode: l.mode ?? ((n = r.config) == null ? void 0 : n.mode) ?? "sidebar",
|
|
705
705
|
// 是否水平模式
|
|
706
|
-
isHorizontal: (
|
|
706
|
+
isHorizontal: (l.mode ?? ((f = r.config) == null ? void 0 : f.mode) ?? "sidebar") === "horizontal",
|
|
707
707
|
// el-menu 的 mode
|
|
708
|
-
elMode: (
|
|
708
|
+
elMode: (l.mode ?? ((m = r.config) == null ? void 0 : m.mode) ?? "sidebar") === "horizontal" ? "horizontal" : "vertical",
|
|
709
709
|
// 菜单宽度(仅 sidebar 生效)
|
|
710
|
-
width:
|
|
710
|
+
width: l.width ?? ((u = r.config) == null ? void 0 : u.width) ?? 220,
|
|
711
711
|
// 菜单列表
|
|
712
712
|
menus: r.menus,
|
|
713
713
|
// 当前激活项的 el-menu index
|
|
@@ -715,64 +715,64 @@ const N = {
|
|
|
715
715
|
// 是否显示退出登录区域
|
|
716
716
|
showLogout: ((g = r.config) == null ? void 0 : g.showLogout) !== !1,
|
|
717
717
|
// 退出登录按钮文本
|
|
718
|
-
logoutText: ((
|
|
718
|
+
logoutText: ((p = r.config) == null ? void 0 : p.logoutText) || "退出登录",
|
|
719
719
|
// 图标映射
|
|
720
720
|
iconMap: r.iconMap
|
|
721
721
|
};
|
|
722
722
|
}), s = {
|
|
723
723
|
// 初始化
|
|
724
724
|
async init() {
|
|
725
|
-
await s.ensureIcons(),
|
|
725
|
+
await s.ensureIcons(), l.config ? (r.config = l.config, r.menus = s.normalizeMenus(l.config.menus)) : await s.loadConfig(l.menuId), r.activePath = l.activePath || r.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 i = await M.get(K.formCfgApi(a, "menus"));
|
|
732
|
+
if (i.status !== 200) {
|
|
733
|
+
U(i.message || "获取菜单配置失败");
|
|
734
734
|
return;
|
|
735
735
|
}
|
|
736
|
-
const
|
|
737
|
-
r.config =
|
|
738
|
-
} catch (
|
|
739
|
-
U((
|
|
736
|
+
const n = i.data || {};
|
|
737
|
+
r.config = n, n.dictType ? await s.loadDictMenus(n.dictType) : r.menus = s.normalizeMenus(n.menus);
|
|
738
|
+
} catch (i) {
|
|
739
|
+
U((i == null ? void 0 : i.message) || "获取菜单配置失败"), r.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 i = await M.get(K.cascaderApi(a));
|
|
746
|
+
if (i.status !== 200) {
|
|
747
|
+
U(i.message || "获取菜单字典失败");
|
|
748
748
|
return;
|
|
749
749
|
}
|
|
750
|
-
r.menus = s.normalizeMenus(
|
|
751
|
-
} catch (
|
|
752
|
-
U((
|
|
750
|
+
r.menus = s.normalizeMenus(ve(i.data));
|
|
751
|
+
} catch (i) {
|
|
752
|
+
U((i == null ? void 0 : i.message) || "获取菜单字典失败"), r.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((i) => s.normalizeMenuNode(i)).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 f =
|
|
762
|
+
const i = s.parseInfo(a.info), n = a.label ?? a.dict_value ?? a.name;
|
|
763
|
+
if (!n) return null;
|
|
764
|
+
const f = i.path ?? a.path ?? a.dict_code ?? a.value ?? "", m = i.type ?? a.type ?? "route", u = {
|
|
765
765
|
...a,
|
|
766
|
-
label: String(
|
|
767
|
-
type:
|
|
766
|
+
label: String(n),
|
|
767
|
+
type: m,
|
|
768
768
|
path: String(f ?? ""),
|
|
769
|
-
icon:
|
|
770
|
-
}, g =
|
|
769
|
+
icon: i.icon ?? a.icon ?? ""
|
|
770
|
+
}, g = i.id ?? a.id;
|
|
771
771
|
g != null && g !== "" && (u.id = String(g));
|
|
772
|
-
const
|
|
773
|
-
(
|
|
772
|
+
const p = i.open ?? a.open;
|
|
773
|
+
(p === "new" || p === "self") && (u.open = p), delete u.children;
|
|
774
774
|
const b = a.children;
|
|
775
|
-
return Array.isArray(b) && b.length > 0 && (u.children = b.map((
|
|
775
|
+
return Array.isArray(b) && b.length > 0 && (u.children = b.map((R) => s.normalizeMenuNode(R)).filter(Boolean)), u;
|
|
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 i = JSON.parse(a);
|
|
784
|
+
return i && typeof i == "object" ? i : {};
|
|
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, i) {
|
|
792
|
+
return a.path || `menu-${i}`;
|
|
793
793
|
},
|
|
794
794
|
// 生成 el-menu 的 index(二级)
|
|
795
|
-
childIndex(a,
|
|
796
|
-
return
|
|
795
|
+
childIndex(a, i, n, f) {
|
|
796
|
+
return n.path ? n.path : `${s.itemIndex(a, i)}-${f}`;
|
|
797
797
|
},
|
|
798
798
|
// 是否有二级菜单(最多支持 2 级)
|
|
799
799
|
hasChildren(a) {
|
|
@@ -802,53 +802,53 @@ 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 f =
|
|
809
|
-
for (let
|
|
810
|
-
if (f[
|
|
805
|
+
for (let i = 0; i < r.menus.length; i++) {
|
|
806
|
+
const n = r.menus[i];
|
|
807
|
+
if (n.path === a) return s.itemIndex(n, i);
|
|
808
|
+
const f = n.children || [];
|
|
809
|
+
for (let m = 0; m < f.length; m++)
|
|
810
|
+
if (f[m].path === a) return s.childIndex(n, i, f[m], m);
|
|
811
811
|
}
|
|
812
812
|
return "";
|
|
813
813
|
},
|
|
814
814
|
// 根据 el-menu index 找到菜单项
|
|
815
|
-
findItemByIndex(a,
|
|
816
|
-
for (let
|
|
817
|
-
const f = r.menus[
|
|
818
|
-
if (
|
|
819
|
-
return { item: f, level: 1, indexPath:
|
|
815
|
+
findItemByIndex(a, i) {
|
|
816
|
+
for (let n = 0; n < r.menus.length; n++) {
|
|
817
|
+
const f = r.menus[n], m = s.itemIndex(f, n);
|
|
818
|
+
if (m === a)
|
|
819
|
+
return { item: f, level: 1, indexPath: i || [m], index: a };
|
|
820
820
|
const u = f.children || [];
|
|
821
821
|
for (let g = 0; g < u.length; g++) {
|
|
822
|
-
const
|
|
822
|
+
const p = u[g], b = s.childIndex(f, n, p, g);
|
|
823
823
|
if (b === a)
|
|
824
|
-
return { item:
|
|
824
|
+
return { item: p, level: 2, indexPath: i || [m, b], 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 i = a.type || "route", n = a.path || "";
|
|
832
|
+
return i === "url" ? { type: i, path: n, url: n, open: a.open || "new" } : i === "form" || i === "table" || i === "menu" ? { type: i, 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 f = s.resolveTarget(
|
|
839
|
-
r.activePath =
|
|
840
|
-
const
|
|
835
|
+
handleSelect(a, i) {
|
|
836
|
+
const n = s.findItemByIndex(a, i);
|
|
837
|
+
if (!n || s.hasChildren(n.item)) return;
|
|
838
|
+
const f = s.resolveTarget(n.item);
|
|
839
|
+
r.activePath = n.item.path || a;
|
|
840
|
+
const m = {
|
|
841
841
|
...f,
|
|
842
|
-
item:
|
|
843
|
-
level:
|
|
844
|
-
indexPath:
|
|
842
|
+
item: n.item,
|
|
843
|
+
level: n.level,
|
|
844
|
+
indexPath: n.indexPath,
|
|
845
845
|
index: a
|
|
846
846
|
};
|
|
847
|
-
|
|
847
|
+
d("menu-click", m);
|
|
848
848
|
},
|
|
849
849
|
// 退出登录
|
|
850
850
|
handleLogout() {
|
|
851
|
-
|
|
851
|
+
d("logout");
|
|
852
852
|
},
|
|
853
853
|
// 设置激活项
|
|
854
854
|
setActivePath(a) {
|
|
@@ -859,10 +859,10 @@ const N = {
|
|
|
859
859
|
if (!r.iconsLoaded) {
|
|
860
860
|
r.iconsLoaded = !0;
|
|
861
861
|
try {
|
|
862
|
-
const a = await import("@element-plus/icons-vue"),
|
|
863
|
-
for (const [f,
|
|
864
|
-
|
|
865
|
-
r.iconMap =
|
|
862
|
+
const a = await import("@element-plus/icons-vue"), i = a != null && a.default ? { ...a.default, ...a } : { ...a }, n = {};
|
|
863
|
+
for (const [f, m] of Object.entries(i))
|
|
864
|
+
n[f] = re(m);
|
|
865
|
+
r.iconMap = n;
|
|
866
866
|
} catch (a) {
|
|
867
867
|
console.warn("[UMenu] @element-plus/icons-vue 不可用,菜单图标将被忽略", a);
|
|
868
868
|
}
|
|
@@ -873,92 +873,92 @@ const N = {
|
|
|
873
873
|
return a && r.iconMap[a] || null;
|
|
874
874
|
}
|
|
875
875
|
};
|
|
876
|
-
return
|
|
877
|
-
|
|
878
|
-
}),
|
|
876
|
+
return L(() => l.menuId, (a) => {
|
|
877
|
+
l.config || s.loadConfig(a);
|
|
878
|
+
}), L(() => l.activePath, (a) => {
|
|
879
879
|
r.activePath = a || "";
|
|
880
|
-
}),
|
|
880
|
+
}), L(() => l.config, (a) => {
|
|
881
881
|
a && (r.config = a, r.menus = s.normalizeMenus(a.menus));
|
|
882
|
-
}),
|
|
882
|
+
}), oe(() => {
|
|
883
883
|
s.init();
|
|
884
884
|
}), t({
|
|
885
885
|
loadConfig: s.loadConfig,
|
|
886
886
|
setActivePath: s.setActivePath
|
|
887
|
-
}), (a,
|
|
888
|
-
const
|
|
887
|
+
}), (a, i) => {
|
|
888
|
+
const n = ge, f = qe, m = We, u = Ne, g = J;
|
|
889
889
|
return h(), y("div", {
|
|
890
|
-
class: V(["u-menu", [`u-menu--${
|
|
891
|
-
style: B(
|
|
890
|
+
class: V(["u-menu", [`u-menu--${c.value.mode}`, { "u-menu--no-brand": !c.value.projectName }]]),
|
|
891
|
+
style: B(c.value.isHorizontal ? {} : { width: c.value.width + "px" })
|
|
892
892
|
}, [
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
projectName:
|
|
896
|
-
mode:
|
|
893
|
+
c.value.projectName ? (h(), y("div", yt, [
|
|
894
|
+
T(a.$slots, "brand", {
|
|
895
|
+
projectName: c.value.projectName,
|
|
896
|
+
mode: c.value.mode
|
|
897
897
|
}, () => [
|
|
898
|
-
|
|
898
|
+
c.value.logo ? (h(), y("img", {
|
|
899
899
|
key: 0,
|
|
900
900
|
class: "u-menu-logo",
|
|
901
|
-
src:
|
|
901
|
+
src: c.value.logo,
|
|
902
902
|
alt: "logo"
|
|
903
|
-
}, null, 8, bt)) :
|
|
904
|
-
C("span", vt,
|
|
903
|
+
}, null, 8, bt)) : D("", !0),
|
|
904
|
+
C("span", vt, k(c.value.projectName), 1)
|
|
905
905
|
], !0)
|
|
906
|
-
])) :
|
|
906
|
+
])) : D("", !0),
|
|
907
907
|
_(u, {
|
|
908
908
|
class: "u-menu-list",
|
|
909
|
-
mode:
|
|
910
|
-
"default-active":
|
|
911
|
-
"unique-opened": !
|
|
909
|
+
mode: c.value.elMode,
|
|
910
|
+
"default-active": c.value.activeIndex,
|
|
911
|
+
"unique-opened": !c.value.isHorizontal,
|
|
912
912
|
onSelect: s.handleSelect
|
|
913
913
|
}, {
|
|
914
914
|
default: w(() => [
|
|
915
|
-
(h(!0), y(
|
|
916
|
-
key: s.itemIndex(
|
|
915
|
+
(h(!0), y(I, null, E(c.value.menus, (p, b) => (h(), y(I, {
|
|
916
|
+
key: s.itemIndex(p, b)
|
|
917
917
|
}, [
|
|
918
|
-
s.hasChildren(
|
|
918
|
+
s.hasChildren(p) ? (h(), S(m, {
|
|
919
919
|
key: 0,
|
|
920
|
-
index: s.itemIndex(
|
|
920
|
+
index: s.itemIndex(p, b)
|
|
921
921
|
}, {
|
|
922
922
|
title: w(() => [
|
|
923
|
-
|
|
924
|
-
item:
|
|
923
|
+
T(a.$slots, "menu-title", {
|
|
924
|
+
item: p,
|
|
925
925
|
level: 1,
|
|
926
926
|
index: b
|
|
927
927
|
}, () => [
|
|
928
|
-
s.getIcon(
|
|
928
|
+
s.getIcon(p.icon) ? (h(), S(n, {
|
|
929
929
|
key: 0,
|
|
930
930
|
class: "u-menu-icon"
|
|
931
931
|
}, {
|
|
932
932
|
default: w(() => [
|
|
933
|
-
(h(), S(
|
|
933
|
+
(h(), S(H(s.getIcon(p.icon))))
|
|
934
934
|
]),
|
|
935
935
|
_: 2
|
|
936
|
-
}, 1024)) :
|
|
937
|
-
C("span", null,
|
|
936
|
+
}, 1024)) : D("", !0),
|
|
937
|
+
C("span", null, k(p.label), 1)
|
|
938
938
|
], !0)
|
|
939
939
|
]),
|
|
940
940
|
default: w(() => [
|
|
941
|
-
(h(!0), y(
|
|
942
|
-
key: s.childIndex(
|
|
943
|
-
index: s.childIndex(
|
|
941
|
+
(h(!0), y(I, null, E(p.children, (R, G) => (h(), S(f, {
|
|
942
|
+
key: s.childIndex(p, b, R, G),
|
|
943
|
+
index: s.childIndex(p, b, R, G)
|
|
944
944
|
}, {
|
|
945
945
|
default: w(() => [
|
|
946
|
-
|
|
947
|
-
item:
|
|
946
|
+
T(a.$slots, "menu-item", {
|
|
947
|
+
item: R,
|
|
948
948
|
level: 2,
|
|
949
|
-
index:
|
|
950
|
-
parent:
|
|
949
|
+
index: G,
|
|
950
|
+
parent: p
|
|
951
951
|
}, () => [
|
|
952
|
-
s.getIcon(
|
|
952
|
+
s.getIcon(R.icon) ? (h(), S(n, {
|
|
953
953
|
key: 0,
|
|
954
954
|
class: "u-menu-icon"
|
|
955
955
|
}, {
|
|
956
956
|
default: w(() => [
|
|
957
|
-
(h(), S(
|
|
957
|
+
(h(), S(H(s.getIcon(R.icon))))
|
|
958
958
|
]),
|
|
959
959
|
_: 2
|
|
960
|
-
}, 1024)) :
|
|
961
|
-
C("span", null,
|
|
960
|
+
}, 1024)) : D("", !0),
|
|
961
|
+
C("span", null, k(R.label), 1)
|
|
962
962
|
], !0)
|
|
963
963
|
]),
|
|
964
964
|
_: 2
|
|
@@ -967,25 +967,25 @@ const N = {
|
|
|
967
967
|
_: 2
|
|
968
968
|
}, 1032, ["index"])) : (h(), S(f, {
|
|
969
969
|
key: 1,
|
|
970
|
-
index: s.itemIndex(
|
|
970
|
+
index: s.itemIndex(p, b)
|
|
971
971
|
}, {
|
|
972
972
|
default: w(() => [
|
|
973
|
-
|
|
974
|
-
item:
|
|
973
|
+
T(a.$slots, "menu-item", {
|
|
974
|
+
item: p,
|
|
975
975
|
level: 1,
|
|
976
976
|
index: b,
|
|
977
977
|
parent: null
|
|
978
978
|
}, () => [
|
|
979
|
-
s.getIcon(
|
|
979
|
+
s.getIcon(p.icon) ? (h(), S(n, {
|
|
980
980
|
key: 0,
|
|
981
981
|
class: "u-menu-icon"
|
|
982
982
|
}, {
|
|
983
983
|
default: w(() => [
|
|
984
|
-
(h(), S(
|
|
984
|
+
(h(), S(H(s.getIcon(p.icon))))
|
|
985
985
|
]),
|
|
986
986
|
_: 2
|
|
987
|
-
}, 1024)) :
|
|
988
|
-
C("span", null,
|
|
987
|
+
}, 1024)) : D("", !0),
|
|
988
|
+
C("span", null, k(p.label), 1)
|
|
989
989
|
], !0)
|
|
990
990
|
]),
|
|
991
991
|
_: 2
|
|
@@ -994,9 +994,9 @@ const N = {
|
|
|
994
994
|
]),
|
|
995
995
|
_: 3
|
|
996
996
|
}, 8, ["mode", "default-active", "unique-opened", "onSelect"]),
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
mode:
|
|
997
|
+
c.value.showLogout ? (h(), y("div", wt, [
|
|
998
|
+
T(a.$slots, "logout", {
|
|
999
|
+
mode: c.value.mode
|
|
1000
1000
|
}, () => [
|
|
1001
1001
|
_(g, {
|
|
1002
1002
|
class: "u-menu-logout-btn",
|
|
@@ -1004,25 +1004,22 @@ const N = {
|
|
|
1004
1004
|
onClick: s.handleLogout
|
|
1005
1005
|
}, {
|
|
1006
1006
|
default: w(() => [
|
|
1007
|
-
F(
|
|
1007
|
+
F(k(c.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
|
-
}), Ct = /* @__PURE__ */ $(xt, [["__scopeId", "data-v-fe63251c"]]), _t = {
|
|
1017
|
-
key: 0,
|
|
1018
|
-
class: "form-content"
|
|
1019
|
-
}, St = {
|
|
1016
|
+
}), Ct = /* @__PURE__ */ $(xt, [["__scopeId", "data-v-fe63251c"]]), _t = { class: "form-content" }, St = {
|
|
1020
1017
|
key: 1,
|
|
1021
1018
|
class: "form-layout"
|
|
1022
|
-
},
|
|
1019
|
+
}, Dt = {
|
|
1023
1020
|
key: 0,
|
|
1024
1021
|
class: "form-header"
|
|
1025
|
-
},
|
|
1022
|
+
}, kt = { class: "title" }, Tt = { class: "form-body" }, Vt = {
|
|
1026
1023
|
key: 1,
|
|
1027
1024
|
class: "form-footer"
|
|
1028
1025
|
}, Pt = /* @__PURE__ */ P({
|
|
@@ -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, l = t, { visible: d } = Ge(e), r = v(() => e.layout.open === "normal"), c = v(() => e.layout.width || 400), s = {
|
|
1039
1036
|
handleClose() {
|
|
1040
|
-
|
|
1037
|
+
l("update:visible", !1), l("close");
|
|
1038
|
+
},
|
|
1039
|
+
handleClosed() {
|
|
1040
|
+
l("closed");
|
|
1041
1041
|
},
|
|
1042
1042
|
updateVisible(a) {
|
|
1043
|
-
|
|
1043
|
+
l("update:visible", a);
|
|
1044
1044
|
}
|
|
1045
1045
|
};
|
|
1046
|
-
return (a,
|
|
1047
|
-
const
|
|
1048
|
-
return r.value ?
|
|
1049
|
-
|
|
1050
|
-
C("div",
|
|
1051
|
-
])) :
|
|
1052
|
-
C("div",
|
|
1053
|
-
|
|
1046
|
+
return (a, i) => {
|
|
1047
|
+
const n = ge, f = je;
|
|
1048
|
+
return r.value ? N(d) ? (h(), y("div", St, [
|
|
1049
|
+
o.title ? (h(), y("div", Dt, [
|
|
1050
|
+
C("div", kt, k(o.title), 1)
|
|
1051
|
+
])) : D("", !0),
|
|
1052
|
+
C("div", Tt, [
|
|
1053
|
+
o.loading ? (h(), S(n, {
|
|
1054
1054
|
key: 0,
|
|
1055
1055
|
class: "is-loading",
|
|
1056
1056
|
size: 40
|
|
1057
1057
|
}, {
|
|
1058
1058
|
default: w(() => [
|
|
1059
|
-
_(
|
|
1059
|
+
_(N(ke))
|
|
1060
1060
|
]),
|
|
1061
1061
|
_: 1
|
|
1062
|
-
})) :
|
|
1062
|
+
})) : T(a.$slots, "default", {}, void 0, !0, 1)
|
|
1063
1063
|
]),
|
|
1064
1064
|
a.$slots.actions ? (h(), y("div", Vt, [
|
|
1065
|
-
|
|
1066
|
-
])) :
|
|
1067
|
-
])) :
|
|
1065
|
+
T(a.$slots, "actions", {}, void 0, !0)
|
|
1066
|
+
])) : D("", !0)
|
|
1067
|
+
])) : D("", !0) : (h(), S(f, {
|
|
1068
1068
|
key: 0,
|
|
1069
|
-
"model-value":
|
|
1070
|
-
title:
|
|
1071
|
-
width:
|
|
1069
|
+
"model-value": N(d),
|
|
1070
|
+
title: o.title,
|
|
1071
|
+
width: c.value,
|
|
1072
1072
|
"close-on-click-modal": !1,
|
|
1073
1073
|
"onUpdate:modelValue": s.updateVisible,
|
|
1074
|
-
onClose: s.handleClose
|
|
1074
|
+
onClose: s.handleClose,
|
|
1075
|
+
onClosed: s.handleClosed
|
|
1075
1076
|
}, {
|
|
1076
1077
|
footer: w(() => [
|
|
1077
|
-
|
|
1078
|
+
T(a.$slots, "actions", {}, void 0, !0)
|
|
1078
1079
|
]),
|
|
1079
1080
|
default: w(() => [
|
|
1080
|
-
|
|
1081
|
-
|
|
1081
|
+
C("div", _t, [
|
|
1082
|
+
o.loading ? (h(), S(n, {
|
|
1082
1083
|
key: 0,
|
|
1083
1084
|
class: "is-loading",
|
|
1084
1085
|
size: 40
|
|
1085
1086
|
}, {
|
|
1086
1087
|
default: w(() => [
|
|
1087
|
-
_(
|
|
1088
|
+
_(N(ke))
|
|
1088
1089
|
]),
|
|
1089
1090
|
_: 1
|
|
1090
|
-
})) :
|
|
1091
|
-
])
|
|
1091
|
+
})) : T(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
|
-
}), $t = /* @__PURE__ */ $(Pt, [["__scopeId", "data-v-
|
|
1098
|
+
}), $t = /* @__PURE__ */ $(Pt, [["__scopeId", "data-v-83362259"]]), Rt = /* @__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 = W({
|
|
1105
1106
|
columns: v(() => t.layout.columns || 1)
|
|
1106
|
-
}),
|
|
1107
|
-
getColSpan(
|
|
1108
|
-
const r =
|
|
1107
|
+
}), l = {
|
|
1108
|
+
getColSpan(d) {
|
|
1109
|
+
const r = d.colSpan || 1;
|
|
1109
1110
|
return Math.min(r, e.columns);
|
|
1110
1111
|
}
|
|
1111
1112
|
};
|
|
1112
|
-
return (
|
|
1113
|
+
return (d, r) => (h(), y("div", {
|
|
1113
1114
|
class: "form-grid",
|
|
1114
1115
|
style: B({ "--grid-columns": e.columns })
|
|
1115
1116
|
}, [
|
|
1116
|
-
(h(!0), y(
|
|
1117
|
-
key:
|
|
1117
|
+
(h(!0), y(I, null, E(o.fields, (c) => (h(), y("div", {
|
|
1118
|
+
key: c.field,
|
|
1118
1119
|
class: "form-grid-item",
|
|
1119
|
-
style: B({ gridColumn: `span ${
|
|
1120
|
+
style: B({ gridColumn: `span ${l.getColSpan(c)}` })
|
|
1120
1121
|
}, [
|
|
1121
|
-
|
|
1122
|
+
T(d.$slots, "default", { field: c }, void 0, !0)
|
|
1122
1123
|
], 4))), 128))
|
|
1123
1124
|
], 4));
|
|
1124
1125
|
}
|
|
1125
|
-
}),
|
|
1126
|
+
}), At = /* @__PURE__ */ $(Rt, [["__scopeId", "data-v-90ed35a4"]]), It = { class: "form-field" }, Mt = /* @__PURE__ */ P({
|
|
1126
1127
|
__name: "FormField",
|
|
1127
1128
|
props: {
|
|
1128
1129
|
field: {},
|
|
@@ -1132,64 +1133,64 @@ const N = {
|
|
|
1132
1133
|
error: {}
|
|
1133
1134
|
},
|
|
1134
1135
|
emits: ["update:modelValue"],
|
|
1135
|
-
setup(
|
|
1136
|
-
const e =
|
|
1137
|
-
componentMap:
|
|
1138
|
-
input:
|
|
1136
|
+
setup(o, { emit: t }) {
|
|
1137
|
+
const e = o, l = t, d = W({
|
|
1138
|
+
componentMap: re({
|
|
1139
|
+
input: te,
|
|
1139
1140
|
"input-number": Pe,
|
|
1140
|
-
dict:
|
|
1141
|
+
dict: ee,
|
|
1141
1142
|
switch: $e,
|
|
1142
|
-
cascader:
|
|
1143
|
-
date:
|
|
1143
|
+
cascader: Re,
|
|
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 && M.get(K.cascaderApi(e.field.cascaderKey)).then((n) => {
|
|
1150
|
+
n.status === 200 && (d.cascaderOptions = ve(n.data));
|
|
1150
1151
|
});
|
|
1151
1152
|
}, { immediate: !0 });
|
|
1152
|
-
const
|
|
1153
|
+
const c = v(() => d.componentMap[e.field.type] || te), s = v(() => {
|
|
1153
1154
|
if ((e.layout.labelPosition || "top") === "left") {
|
|
1154
|
-
const f = e.layout.labelWidth || 0,
|
|
1155
|
-
return { marginLeft: typeof
|
|
1155
|
+
const f = e.layout.labelWidth || 0, m = typeof f == "number" ? f + 4 : f;
|
|
1156
|
+
return { marginLeft: typeof m == "number" ? `${m}px` : m };
|
|
1156
1157
|
}
|
|
1157
1158
|
return {};
|
|
1158
1159
|
}), a = v(() => {
|
|
1159
|
-
const { field:
|
|
1160
|
+
const { field: n, modelValue: f, layout: m, disabled: u } = e;
|
|
1160
1161
|
let g = f;
|
|
1161
|
-
|
|
1162
|
-
const
|
|
1163
|
-
fieldLabel:
|
|
1162
|
+
n.type === "switch" && f == null && (g = !1);
|
|
1163
|
+
const p = {
|
|
1164
|
+
fieldLabel: n.label,
|
|
1164
1165
|
modelValue: g,
|
|
1165
|
-
labelPosition:
|
|
1166
|
+
labelPosition: m.labelPosition || "top",
|
|
1166
1167
|
disable: u,
|
|
1167
|
-
name:
|
|
1168
|
-
required:
|
|
1168
|
+
name: n.field,
|
|
1169
|
+
required: n.required
|
|
1169
1170
|
};
|
|
1170
|
-
if (
|
|
1171
|
-
|
|
1172
|
-
const b =
|
|
1173
|
-
b != null && (
|
|
1171
|
+
if (m.labelWidth && (p.labelWidth = m.labelWidth), m.labelAlign && (p.labelAlign = m.labelAlign), n.maxlength && (p.maxlength = n.maxlength), n.placeholder && (p.placeholder = n.placeholder), n.readonly && (p.readonly = n.readonly), n.lineCount && n.lineCount >= 2 ? (p.type = "textarea", p.rows = n.lineCount) : n.inputType && (p.type = n.inputType), n.type === "switch" && (n.activeText && (p.activeText = n.activeText), n.inactiveText && (p.inactiveText = n.inactiveText), n.activeColor && (p.activeColor = n.activeColor), n.inactiveColor && (p.inactiveColor = n.inactiveColor), n.trueValue !== void 0 && (p.trueValue = n.trueValue), n.falseValue !== void 0 && (p.falseValue = n.falseValue)), n.dictType && (p.dictType = n.dictType), n.cascaderKey && (p.options = d.cascaderOptions, p.depth = n.cascaderDepth || 2), n.type === "date") {
|
|
1172
|
+
n.mode && (p.mode = n.mode), n.locale && (p.locale = n.locale), n.format ? p.mask = n.format : n.mask && (p.mask = n.mask);
|
|
1173
|
+
const b = n.dateMin ?? n.min, R = n.dateMax ?? n.max;
|
|
1174
|
+
b != null && (p.min = b), R != null && (p.max = R);
|
|
1174
1175
|
}
|
|
1175
|
-
return
|
|
1176
|
-
}),
|
|
1177
|
-
handleUpdate(
|
|
1178
|
-
|
|
1176
|
+
return n.type === "input-number" && (n.min !== void 0 && (p.min = n.min), n.max !== void 0 && (p.max = n.max), n.step && (p.step = n.step), n.precision !== void 0 && (p.precision = n.precision)), p;
|
|
1177
|
+
}), i = {
|
|
1178
|
+
handleUpdate(n) {
|
|
1179
|
+
l("update:modelValue", n);
|
|
1179
1180
|
}
|
|
1180
1181
|
};
|
|
1181
|
-
return (
|
|
1182
|
-
(h(), S(
|
|
1183
|
-
"onUpdate:modelValue":
|
|
1182
|
+
return (n, f) => (h(), y("div", It, [
|
|
1183
|
+
(h(), S(H(c.value), ce(a.value, {
|
|
1184
|
+
"onUpdate:modelValue": i.handleUpdate
|
|
1184
1185
|
}), null, 16, ["onUpdate:modelValue"])),
|
|
1185
1186
|
C("div", {
|
|
1186
|
-
class: V(["field-error", { "field-error--visible":
|
|
1187
|
+
class: V(["field-error", { "field-error--visible": o.error }]),
|
|
1187
1188
|
style: B(s.value)
|
|
1188
|
-
},
|
|
1189
|
+
}, k(o.error || ""), 7)
|
|
1189
1190
|
]));
|
|
1190
1191
|
}
|
|
1191
|
-
}),
|
|
1192
|
-
class
|
|
1192
|
+
}), Et = /* @__PURE__ */ $(Mt, [["__scopeId", "data-v-10299c8d"]]);
|
|
1193
|
+
class Ut {
|
|
1193
1194
|
constructor() {
|
|
1194
1195
|
x(this, "formConfig", null);
|
|
1195
1196
|
x(this, "formData", {});
|
|
@@ -1204,41 +1205,41 @@ class Mt {
|
|
|
1204
1205
|
let Bt = class {
|
|
1205
1206
|
constructor() {
|
|
1206
1207
|
// 响应式数据
|
|
1207
|
-
x(this, "data", W(new
|
|
1208
|
+
x(this, "data", W(new Ut()));
|
|
1208
1209
|
}
|
|
1209
1210
|
// 解析 query 字符串
|
|
1210
1211
|
parseQuery(t) {
|
|
1211
1212
|
if (!t) return {};
|
|
1212
|
-
const e = {},
|
|
1213
|
-
for (const
|
|
1214
|
-
const [r,
|
|
1215
|
-
r && (e[r] =
|
|
1213
|
+
const e = {}, l = t.split("&");
|
|
1214
|
+
for (const d of l) {
|
|
1215
|
+
const [r, c] = d.split("=");
|
|
1216
|
+
r && (e[r] = c || "");
|
|
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 M.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 l = e ? `${t}?${e}` : t, d = await M.get(l);
|
|
1230
|
+
if (d.status !== 200)
|
|
1231
|
+
throw new Error(d.message || "获取表单数据失败");
|
|
1232
|
+
return d.data;
|
|
1232
1233
|
}
|
|
1233
1234
|
// 提交表单
|
|
1234
1235
|
async submitForm(t, e) {
|
|
1235
|
-
return await
|
|
1236
|
+
return await M.post(t, e);
|
|
1236
1237
|
}
|
|
1237
1238
|
// 构建字段初始值
|
|
1238
1239
|
buildInitialData(t) {
|
|
1239
1240
|
const e = {};
|
|
1240
|
-
for (const
|
|
1241
|
-
|
|
1241
|
+
for (const l of t)
|
|
1242
|
+
l.default !== void 0 ? e[l.field] = l.default : e[l.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 l of t) {
|
|
1255
|
+
const d = this.data.formData[l.field];
|
|
1256
|
+
if (l.required && (d == null || d === "")) {
|
|
1256
1257
|
this.data.errors.push({
|
|
1257
|
-
field:
|
|
1258
|
-
message: `${
|
|
1258
|
+
field: l.field,
|
|
1259
|
+
message: `${l.label}为必填项`
|
|
1259
1260
|
});
|
|
1260
1261
|
continue;
|
|
1261
1262
|
}
|
|
1262
|
-
if (
|
|
1263
|
-
for (const r of
|
|
1264
|
-
if (r.pattern && !new RegExp(r.pattern).test(
|
|
1263
|
+
if (l.rules && l.rules.length > 0 && d) {
|
|
1264
|
+
for (const r of l.rules)
|
|
1265
|
+
if (r.pattern && !new RegExp(r.pattern).test(d)) {
|
|
1265
1266
|
this.data.errors.push({
|
|
1266
|
-
field:
|
|
1267
|
-
message: r.message || `${
|
|
1267
|
+
field: l.field,
|
|
1268
|
+
message: r.message || `${l.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((l) => l.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
|
|
1289
|
+
const l = await this.fetchFormConfig(t);
|
|
1290
|
+
if (this.data.formConfig = l, this.data.isEditMode = this.checkIsEditMode(e || ""), this.data.formData = this.buildInitialData(l.fields), this.data.isEditMode && l.api.get && e) {
|
|
1291
|
+
const d = await this.fetchFormData(l.api.get, e), r = this.nestedToFlat(d);
|
|
1291
1292
|
this.data.formData = { ...this.data.formData, ...r };
|
|
1292
1293
|
}
|
|
1293
|
-
} catch (
|
|
1294
|
-
throw console.error("[FormRender] 打开表单失败:",
|
|
1294
|
+
} catch (l) {
|
|
1295
|
+
throw console.error("[FormRender] 打开表单失败:", l), this.data.visible = !1, l;
|
|
1295
1296
|
} finally {
|
|
1296
1297
|
this.data.loading = !1;
|
|
1297
1298
|
}
|
|
@@ -1305,131 +1306,147 @@ 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 l = { ...this.data.formData };
|
|
1310
|
+
l = this.flattenToNested(l), this.data.isEditMode && this.data.currentQuery.id && (l.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 d = await this.submitForm(e, l);
|
|
1313
|
+
if (d.status === 200)
|
|
1314
|
+
return d.data;
|
|
1315
|
+
throw new Error(d.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 r =
|
|
1330
|
-
let
|
|
1338
|
+
for (const l in t) {
|
|
1339
|
+
const d = t[l];
|
|
1340
|
+
if (l.includes(".")) {
|
|
1341
|
+
const r = l.split(".");
|
|
1342
|
+
let c = e;
|
|
1331
1343
|
for (let s = 0; s < r.length - 1; s++) {
|
|
1332
1344
|
const a = r[s];
|
|
1333
|
-
|
|
1345
|
+
c[a] || (c[a] = {}), c = c[a];
|
|
1334
1346
|
}
|
|
1335
|
-
|
|
1347
|
+
c[r[r.length - 1]] = d;
|
|
1336
1348
|
} else
|
|
1337
|
-
e[
|
|
1349
|
+
e[l] = d;
|
|
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 r = t[
|
|
1347
|
-
r && typeof r == "object" && !Array.isArray(r) ? Object.keys(r).length === 2 && "from" in r && "to" in r ?
|
|
1356
|
+
const l = {};
|
|
1357
|
+
for (const d in t) {
|
|
1358
|
+
const r = t[d], c = e ? `${e}.${d}` : d;
|
|
1359
|
+
r && typeof r == "object" && !Array.isArray(r) ? Object.keys(r).length === 2 && "from" in r && "to" in r ? l[c] = r : Object.assign(l, this.nestedToFlat(r, c)) : l[c] = r;
|
|
1348
1360
|
}
|
|
1349
|
-
return
|
|
1361
|
+
return l;
|
|
1350
1362
|
}
|
|
1351
1363
|
};
|
|
1352
1364
|
const Ft = /* @__PURE__ */ P({
|
|
1353
1365
|
__name: "FormRender",
|
|
1354
|
-
setup(
|
|
1355
|
-
const e = new Bt(),
|
|
1366
|
+
setup(o, { expose: t }) {
|
|
1367
|
+
const e = new Bt(), l = Q(null), d = W({
|
|
1356
1368
|
currentQuery: {},
|
|
1357
1369
|
submitResolve: null
|
|
1358
1370
|
}), r = v(() => {
|
|
1359
1371
|
var u;
|
|
1360
|
-
const
|
|
1361
|
-
if (!e.data.isEditMode || !
|
|
1372
|
+
const m = {};
|
|
1373
|
+
if (!e.data.isEditMode || !d.currentQuery) return m;
|
|
1362
1374
|
for (const g of ((u = e.data.formConfig) == null ? void 0 : u.fields) || [])
|
|
1363
|
-
|
|
1364
|
-
return
|
|
1365
|
-
}),
|
|
1366
|
-
var
|
|
1367
|
-
return ((
|
|
1375
|
+
d.currentQuery[g.field] !== void 0 && (m[g.field] = !0);
|
|
1376
|
+
return m;
|
|
1377
|
+
}), c = 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
1385
|
}), s = v(() => {
|
|
1374
|
-
var
|
|
1375
|
-
return ((
|
|
1386
|
+
var m;
|
|
1387
|
+
return ((m = e.data.formConfig) == null ? void 0 : m.fields) || [];
|
|
1376
1388
|
}), a = v(() => {
|
|
1377
|
-
var
|
|
1378
|
-
return ((u = (
|
|
1379
|
-
}),
|
|
1380
|
-
async showForm(
|
|
1381
|
-
|
|
1389
|
+
var m, u;
|
|
1390
|
+
return ((u = (m = e.data.formConfig) == null ? void 0 : m.meta) == null ? void 0 : u.title) || "表单";
|
|
1391
|
+
}), i = v(() => c.value.buttonAlign || "right"), n = v(() => c.value.open === "normal"), f = {
|
|
1392
|
+
async showForm(m, u) {
|
|
1393
|
+
d.currentQuery = e.parseQuery(u || "");
|
|
1382
1394
|
try {
|
|
1383
|
-
await e.openForm(
|
|
1395
|
+
await e.openForm(m, u);
|
|
1384
1396
|
} catch (g) {
|
|
1385
1397
|
return U((g == null ? void 0 : g.message) || "打开表单失败"), null;
|
|
1386
1398
|
}
|
|
1387
1399
|
return new Promise((g) => {
|
|
1388
|
-
|
|
1400
|
+
d.submitResolve = g;
|
|
1389
1401
|
});
|
|
1390
1402
|
},
|
|
1391
1403
|
async handleSubmit() {
|
|
1392
|
-
var
|
|
1404
|
+
var m, u;
|
|
1393
1405
|
try {
|
|
1394
|
-
const g = await e.doSubmit(),
|
|
1395
|
-
return
|
|
1406
|
+
const g = await e.doSubmit(), p = ((u = (m = e.data.formConfig) == null ? void 0 : m.meta) == null ? void 0 : u.title) + "保存成功";
|
|
1407
|
+
return z.success(p), d.submitResolve && (d.submitResolve(g), d.submitResolve = null), n.value || e.closeForm(), g;
|
|
1396
1408
|
} catch (g) {
|
|
1397
|
-
return
|
|
1409
|
+
return d.submitResolve && (d.submitResolve(null), d.submitResolve = null), g != null && g.message && g.message !== "请完善表单信息" && U(g.message), null;
|
|
1398
1410
|
}
|
|
1399
1411
|
},
|
|
1400
1412
|
// 结束等待:把 submitResolve 以 null 收尾(取消/关闭时调用,避免 Promise 永远悬挂)
|
|
1401
1413
|
resolvePending() {
|
|
1402
|
-
|
|
1414
|
+
d.submitResolve && (d.submitResolve(null), d.submitResolve = null);
|
|
1403
1415
|
},
|
|
1404
1416
|
handleCancel() {
|
|
1405
|
-
|
|
1417
|
+
n.value || (f.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
|
f.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
1433
|
showForm: f.showForm
|
|
1418
|
-
}), (
|
|
1419
|
-
const g =
|
|
1434
|
+
}), (m, u) => {
|
|
1435
|
+
const g = Oe, p = J;
|
|
1420
1436
|
return h(), S($t, {
|
|
1421
|
-
visible:
|
|
1422
|
-
"onUpdate:visible": u[0] || (u[0] = (b) =>
|
|
1423
|
-
layout:
|
|
1437
|
+
visible: N(e).data.visible,
|
|
1438
|
+
"onUpdate:visible": u[0] || (u[0] = (b) => N(e).data.visible = b),
|
|
1439
|
+
layout: c.value,
|
|
1424
1440
|
title: a.value,
|
|
1425
|
-
loading:
|
|
1426
|
-
onClose: f.handleClose
|
|
1441
|
+
loading: N(e).data.loading,
|
|
1442
|
+
onClose: f.handleClose,
|
|
1443
|
+
onClosed: f.handleClosed
|
|
1427
1444
|
}, {
|
|
1428
1445
|
actions: w(() => [
|
|
1429
1446
|
C("div", {
|
|
1430
|
-
class: V(["form-actions",
|
|
1447
|
+
class: V(["form-actions", i.value === "right" ? "justify-end" : "justify-start"])
|
|
1431
1448
|
}, [
|
|
1432
|
-
_(
|
|
1449
|
+
_(p, {
|
|
1433
1450
|
onClick: f.handleCancel
|
|
1434
1451
|
}, {
|
|
1435
1452
|
default: w(() => [...u[1] || (u[1] = [
|
|
@@ -1437,9 +1454,9 @@ const Ft = /* @__PURE__ */ P({
|
|
|
1437
1454
|
])]),
|
|
1438
1455
|
_: 1
|
|
1439
1456
|
}, 8, ["onClick"]),
|
|
1440
|
-
_(
|
|
1457
|
+
_(p, {
|
|
1441
1458
|
type: "primary",
|
|
1442
|
-
loading:
|
|
1459
|
+
loading: N(e).data.submitting,
|
|
1443
1460
|
onClick: f.handleSubmit
|
|
1444
1461
|
}, {
|
|
1445
1462
|
default: w(() => [...u[2] || (u[2] = [
|
|
@@ -1452,21 +1469,21 @@ const Ft = /* @__PURE__ */ P({
|
|
|
1452
1469
|
default: w(() => [
|
|
1453
1470
|
_(g, {
|
|
1454
1471
|
ref_key: "formRef",
|
|
1455
|
-
ref:
|
|
1472
|
+
ref: l,
|
|
1456
1473
|
class: "form-render",
|
|
1457
1474
|
"label-position": "top"
|
|
1458
1475
|
}, {
|
|
1459
1476
|
default: w(() => [
|
|
1460
|
-
_(
|
|
1477
|
+
_(At, {
|
|
1461
1478
|
fields: s.value,
|
|
1462
|
-
layout:
|
|
1479
|
+
layout: c.value
|
|
1463
1480
|
}, {
|
|
1464
1481
|
default: w(({ field: b }) => [
|
|
1465
|
-
_(
|
|
1466
|
-
modelValue:
|
|
1467
|
-
"onUpdate:modelValue": (
|
|
1482
|
+
_(Et, {
|
|
1483
|
+
modelValue: N(e).data.formData[b.field],
|
|
1484
|
+
"onUpdate:modelValue": (R) => N(e).data.formData[b.field] = R,
|
|
1468
1485
|
field: b,
|
|
1469
|
-
layout:
|
|
1486
|
+
layout: c.value,
|
|
1470
1487
|
disabled: r.value[b.field],
|
|
1471
1488
|
error: f.getFieldError(b.field)
|
|
1472
1489
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "field", "layout", "disabled", "error"])
|
|
@@ -1478,10 +1495,10 @@ 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
|
-
}),
|
|
1501
|
+
}), Ae = /* @__PURE__ */ $(Ft, [["__scopeId", "data-v-b3267c00"]]);
|
|
1485
1502
|
class Lt {
|
|
1486
1503
|
constructor(t) {
|
|
1487
1504
|
this.config = t;
|
|
@@ -1490,19 +1507,19 @@ class Lt {
|
|
|
1490
1507
|
* 获取列表数据
|
|
1491
1508
|
*/
|
|
1492
1509
|
async fetchList(t, e) {
|
|
1493
|
-
const
|
|
1510
|
+
const l = {
|
|
1494
1511
|
page: e.page,
|
|
1495
1512
|
pageSize: e.pageSize,
|
|
1496
1513
|
...t
|
|
1497
|
-
},
|
|
1498
|
-
for (const a in
|
|
1499
|
-
const
|
|
1500
|
-
|
|
1514
|
+
}, d = {};
|
|
1515
|
+
for (const a in l) {
|
|
1516
|
+
const i = l[a];
|
|
1517
|
+
i !== "" && i !== null && i !== void 0 && (d[a] = i);
|
|
1501
1518
|
}
|
|
1502
1519
|
const r = new URLSearchParams();
|
|
1503
|
-
for (const a in
|
|
1504
|
-
r.append(a, String(
|
|
1505
|
-
const
|
|
1520
|
+
for (const a in d)
|
|
1521
|
+
r.append(a, String(d[a]));
|
|
1522
|
+
const c = `${this.config.api.list}${r.toString() ? "?" + r.toString() : ""}`, s = await M.get(c);
|
|
1506
1523
|
if (s.status === 200) {
|
|
1507
1524
|
const a = s.data;
|
|
1508
1525
|
return Array.isArray(a) ? { rows: a, total: a.length } : a || { rows: [], total: 0 };
|
|
@@ -1515,7 +1532,7 @@ 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",
|
|
1535
|
+
const e = this.config.key || "id", l = t[e], d = `${this.config.api.delete}?${encodeURIComponent(e)}=${encodeURIComponent(String(l ?? ""))}`, r = await M.post(d);
|
|
1519
1536
|
if (r.status !== 200)
|
|
1520
1537
|
throw new Error(r.message || "删除失败");
|
|
1521
1538
|
}
|
|
@@ -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 M.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 l = (await M.post(this.config.api.export, t, {
|
|
1539
1556
|
responseType: "blob"
|
|
1540
|
-
})).data,
|
|
1541
|
-
r.href =
|
|
1557
|
+
})).data, d = window.URL.createObjectURL(l), r = document.createElement("a");
|
|
1558
|
+
r.href = d, r.download = `export_${Date.now()}.xlsx`, r.click(), window.URL.revokeObjectURL(d);
|
|
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 M.get(`${this.config.api.import}/template`, {
|
|
1550
1567
|
responseType: "blob"
|
|
1551
|
-
})).data,
|
|
1552
|
-
|
|
1568
|
+
})).data, l = window.URL.createObjectURL(e), d = document.createElement("a");
|
|
1569
|
+
d.href = l, d.download = `template_${Date.now()}.xlsx`, d.click(), window.URL.revokeObjectURL(l);
|
|
1553
1570
|
}
|
|
1554
1571
|
/**
|
|
1555
1572
|
* 导入数据
|
|
@@ -1559,14 +1576,14 @@ class Lt {
|
|
|
1559
1576
|
throw new Error("未配置导入API");
|
|
1560
1577
|
const e = new FormData();
|
|
1561
1578
|
e.append("file", t);
|
|
1562
|
-
const
|
|
1579
|
+
const l = await M.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 (l.status !== 200)
|
|
1585
|
+
throw new Error(l.message || "导入失败");
|
|
1586
|
+
return l.data;
|
|
1570
1587
|
}
|
|
1571
1588
|
}
|
|
1572
1589
|
class zt {
|
|
@@ -1583,7 +1600,12 @@ class zt {
|
|
|
1583
1600
|
x(this, "detailData", null);
|
|
1584
1601
|
x(this, "detailLoading", !1);
|
|
1585
1602
|
// 预览抽屉(action: preview 触发,独立于 detail 配置)
|
|
1603
|
+
// previewVisible —— 显隐(交给 el-drawer 的 :model-value)
|
|
1604
|
+
// previewMounted —— 是否挂载。打开时置 true;退场动画播完(@closed)才置 false。
|
|
1605
|
+
// 为什么要两个:抽屉**只在打开时挂载**(省 DOM),但挂载开关不能跟着显隐一起变,
|
|
1606
|
+
// 否则关闭瞬间组件就被卸载,el-drawer 的退场动画没机会播(见 closePreview 注释)。
|
|
1586
1607
|
x(this, "previewVisible", !1);
|
|
1608
|
+
x(this, "previewMounted", !1);
|
|
1587
1609
|
x(this, "previewRow", null);
|
|
1588
1610
|
}
|
|
1589
1611
|
}
|
|
@@ -1598,26 +1620,26 @@ let Nt = class {
|
|
|
1598
1620
|
* 加载表格配置
|
|
1599
1621
|
*/
|
|
1600
1622
|
async loadConfig(t) {
|
|
1601
|
-
var
|
|
1602
|
-
const e =
|
|
1623
|
+
var d;
|
|
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 l = await M.get(e);
|
|
1627
|
+
if (console.log("---"), l.status !== 200)
|
|
1628
|
+
throw new Error(l.message || "获取表格配置失败");
|
|
1629
|
+
this.data.tableConfig = l.data, this.dataService = new Lt(l.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: (d = this.data.tableConfig) == null ? void 0 : d.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 l;
|
|
1640
|
+
const t = {}, e = ((l = this.data.tableConfig) == null ? void 0 : l.search) || [];
|
|
1641
|
+
for (const d of e)
|
|
1642
|
+
t[d.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 l = this.getKeyField(), d = (r) => r && this.data.rows.find((c) => c[l] === r[l]) || null;
|
|
1670
|
+
this.data.currentRow = d(t), this.data.detailData && (this.data.detailData = d(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, l;
|
|
1821
|
+
const t = (l = (e = this.data.tableConfig) == null ? void 0 : e.detail) == null ? void 0 : l.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,68 +1949,68 @@ let Nt = class {
|
|
|
1903
1949
|
return ((t = this.data.tableConfig) == null ? void 0 : t.pagination) || "page";
|
|
1904
1950
|
}
|
|
1905
1951
|
};
|
|
1906
|
-
const Wt = { class: "table-search" }, qt = { class: "search-fields" },
|
|
1952
|
+
const Wt = { class: "table-search" }, qt = { class: "search-fields" }, jt = { class: "search-actions" }, Ot = /* @__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:
|
|
1959
|
+
setup(o, { emit: t }) {
|
|
1960
|
+
const e = o, l = t, d = {
|
|
1961
|
+
input: te,
|
|
1962
|
+
dict: ee,
|
|
1963
|
+
dept: ee,
|
|
1964
|
+
role: ee,
|
|
1965
|
+
date: de,
|
|
1966
|
+
daterange: de
|
|
1921
1967
|
}, r = {
|
|
1922
1968
|
// 组件映射
|
|
1923
|
-
getComponent(
|
|
1924
|
-
return c
|
|
1969
|
+
getComponent(c) {
|
|
1970
|
+
return d[c] || te;
|
|
1925
1971
|
},
|
|
1926
1972
|
// 更新搜索值
|
|
1927
|
-
updateValue(
|
|
1928
|
-
const a = { ...e.modelValue, [
|
|
1929
|
-
|
|
1973
|
+
updateValue(c, s) {
|
|
1974
|
+
const a = { ...e.modelValue, [c]: s };
|
|
1975
|
+
l("update:modelValue", a);
|
|
1930
1976
|
},
|
|
1931
1977
|
// 搜索(查询字段值自动去除首尾空格)
|
|
1932
1978
|
handleSearch() {
|
|
1933
|
-
const
|
|
1979
|
+
const c = {};
|
|
1934
1980
|
for (const s in e.modelValue) {
|
|
1935
1981
|
const a = e.modelValue[s];
|
|
1936
|
-
|
|
1982
|
+
c[s] = typeof a == "string" ? a.trim() : a;
|
|
1937
1983
|
}
|
|
1938
|
-
|
|
1984
|
+
l("update:modelValue", c), l("search");
|
|
1939
1985
|
},
|
|
1940
1986
|
// 重置
|
|
1941
1987
|
handleReset() {
|
|
1942
|
-
|
|
1988
|
+
l("reset");
|
|
1943
1989
|
}
|
|
1944
1990
|
};
|
|
1945
|
-
return (
|
|
1946
|
-
const a =
|
|
1991
|
+
return (c, s) => {
|
|
1992
|
+
const a = J;
|
|
1947
1993
|
return h(), y("div", Wt, [
|
|
1948
1994
|
C("div", qt, [
|
|
1949
|
-
(h(!0), y(
|
|
1950
|
-
key:
|
|
1995
|
+
(h(!0), y(I, null, E(e.fields, (i) => (h(), y("div", {
|
|
1996
|
+
key: i.field,
|
|
1951
1997
|
class: "search-field"
|
|
1952
1998
|
}, [
|
|
1953
|
-
(h(), S(
|
|
1954
|
-
"model-value": e.modelValue[
|
|
1955
|
-
"field-label":
|
|
1956
|
-
"dict-type":
|
|
1957
|
-
mode:
|
|
1999
|
+
(h(), S(H(r.getComponent(i.type)), {
|
|
2000
|
+
"model-value": e.modelValue[i.field],
|
|
2001
|
+
"field-label": i.label,
|
|
2002
|
+
"dict-type": i.dictType,
|
|
2003
|
+
mode: i.type === "daterange" ? "range" : void 0,
|
|
1958
2004
|
"label-position": "left",
|
|
1959
|
-
"onUpdate:modelValue": (
|
|
2005
|
+
"onUpdate:modelValue": (n) => r.updateValue(i.field, n)
|
|
1960
2006
|
}, null, 8, ["model-value", "field-label", "dict-type", "mode", "onUpdate:modelValue"]))
|
|
1961
2007
|
]))), 128)),
|
|
1962
|
-
|
|
2008
|
+
T(c.$slots, "search-extra", {
|
|
1963
2009
|
params: e.modelValue,
|
|
1964
2010
|
update: r.updateValue
|
|
1965
2011
|
}, void 0, !0)
|
|
1966
2012
|
]),
|
|
1967
|
-
C("div",
|
|
2013
|
+
C("div", jt, [
|
|
1968
2014
|
_(a, {
|
|
1969
2015
|
type: "primary",
|
|
1970
2016
|
onClick: r.handleSearch
|
|
@@ -1982,7 +2028,7 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
1982
2028
|
])]),
|
|
1983
2029
|
_: 1
|
|
1984
2030
|
}, 8, ["onClick"]),
|
|
1985
|
-
|
|
2031
|
+
T(c.$slots, "search-actions", {
|
|
1986
2032
|
params: e.modelValue,
|
|
1987
2033
|
search: r.handleSearch,
|
|
1988
2034
|
reset: r.handleReset
|
|
@@ -1991,21 +2037,21 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
1991
2037
|
]);
|
|
1992
2038
|
};
|
|
1993
2039
|
}
|
|
1994
|
-
}), Yt = /* @__PURE__ */ $(
|
|
2040
|
+
}), Yt = /* @__PURE__ */ $(Ot, [["__scopeId", "data-v-09e61a77"]]), Qt = { class: "table-toolbar" }, Kt = { class: "toolbar-items" }, Ht = { key: 1 }, Gt = /* @__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, l = t, d = W({
|
|
2003
2049
|
// 图标组件缓存(@element-plus/icons-vue 按需加载)
|
|
2004
2050
|
iconMap: {}
|
|
2005
2051
|
}), r = v(() => ({
|
|
2006
2052
|
// 是否有当前行
|
|
2007
2053
|
hasCurrentRow: !!e.currentRow
|
|
2008
|
-
})),
|
|
2054
|
+
})), c = {
|
|
2009
2055
|
// 需要目标行的动作
|
|
2010
2056
|
needRow(s) {
|
|
2011
2057
|
return s === "edit" || s === "delete" || s === "preview";
|
|
@@ -2032,15 +2078,15 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2032
2078
|
},
|
|
2033
2079
|
// 是否禁用
|
|
2034
2080
|
isDisabled(s) {
|
|
2035
|
-
return s.disabled ? !0 :
|
|
2081
|
+
return s.disabled ? !0 : c.needRow(s.action) && !r.value.hasCurrentRow;
|
|
2036
2082
|
},
|
|
2037
2083
|
// 图标组件
|
|
2038
2084
|
getIcon(s) {
|
|
2039
|
-
return s.icon ?
|
|
2085
|
+
return s.icon ? d.iconMap[s.icon] : null;
|
|
2040
2086
|
},
|
|
2041
2087
|
// 点击按钮:把 action 抛给父组件
|
|
2042
2088
|
handleClick(s) {
|
|
2043
|
-
|
|
2089
|
+
l("action", {
|
|
2044
2090
|
action: s.action,
|
|
2045
2091
|
item: s,
|
|
2046
2092
|
row: e.currentRow
|
|
@@ -2048,44 +2094,44 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2048
2094
|
},
|
|
2049
2095
|
// 按需加载图标(避免整包图标进产物)
|
|
2050
2096
|
async ensureIcons() {
|
|
2051
|
-
const s = [...new Set(e.items.map((
|
|
2097
|
+
const s = [...new Set(e.items.map((n) => n.icon).filter(Boolean))];
|
|
2052
2098
|
if (s.length === 0) return;
|
|
2053
|
-
const a = await import("@element-plus/icons-vue"),
|
|
2054
|
-
for (const
|
|
2055
|
-
a[
|
|
2056
|
-
|
|
2099
|
+
const a = await import("@element-plus/icons-vue"), i = { ...d.iconMap };
|
|
2100
|
+
for (const n of s)
|
|
2101
|
+
a[n] && (i[n] = re(a[n]));
|
|
2102
|
+
d.iconMap = re(i);
|
|
2057
2103
|
}
|
|
2058
2104
|
};
|
|
2059
|
-
return
|
|
2060
|
-
|
|
2061
|
-
}),
|
|
2062
|
-
|
|
2105
|
+
return oe(() => {
|
|
2106
|
+
c.ensureIcons();
|
|
2107
|
+
}), L(() => e.items, () => {
|
|
2108
|
+
c.ensureIcons();
|
|
2063
2109
|
}), (s, a) => {
|
|
2064
|
-
const
|
|
2110
|
+
const i = ge, n = J;
|
|
2065
2111
|
return h(), y("div", Qt, [
|
|
2066
|
-
|
|
2112
|
+
T(s.$slots, "toolbar-left", {
|
|
2067
2113
|
currentRow: e.currentRow
|
|
2068
2114
|
}, void 0, !0),
|
|
2069
2115
|
C("div", Kt, [
|
|
2070
|
-
(h(!0), y(
|
|
2071
|
-
key:
|
|
2072
|
-
type:
|
|
2073
|
-
disabled:
|
|
2074
|
-
onClick: (u) =>
|
|
2116
|
+
(h(!0), y(I, null, E(e.items, (f, m) => (h(), S(n, {
|
|
2117
|
+
key: m,
|
|
2118
|
+
type: c.getButtonType(f),
|
|
2119
|
+
disabled: c.isDisabled(f),
|
|
2120
|
+
onClick: (u) => c.handleClick(f)
|
|
2075
2121
|
}, {
|
|
2076
2122
|
default: w(() => [
|
|
2077
|
-
|
|
2123
|
+
c.getIcon(f) ? (h(), S(i, { key: 0 }, {
|
|
2078
2124
|
default: w(() => [
|
|
2079
|
-
(h(), S(
|
|
2125
|
+
(h(), S(H(c.getIcon(f))))
|
|
2080
2126
|
]),
|
|
2081
2127
|
_: 2
|
|
2082
|
-
}, 1024)) :
|
|
2083
|
-
|
|
2128
|
+
}, 1024)) : D("", !0),
|
|
2129
|
+
c.getText(f) ? (h(), y("span", Ht, k(c.getText(f)), 1)) : D("", !0)
|
|
2084
2130
|
]),
|
|
2085
2131
|
_: 2
|
|
2086
2132
|
}, 1032, ["type", "disabled", "onClick"]))), 128))
|
|
2087
2133
|
]),
|
|
2088
|
-
|
|
2134
|
+
T(s.$slots, "toolbar-extra", {
|
|
2089
2135
|
currentRow: e.currentRow
|
|
2090
2136
|
}, void 0, !0)
|
|
2091
2137
|
]);
|
|
@@ -2098,19 +2144,19 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
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)), l = v(() => t.multiline || e.value.includes(`
|
|
2149
|
+
`)), d = v(() => t.maxLines > 0 && l.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 (r,
|
|
2111
|
-
class: V(["u-input-show", { "u-input-multiline":
|
|
2112
|
-
style: B(
|
|
2113
|
-
},
|
|
2156
|
+
return (r, c) => (h(), y("div", {
|
|
2157
|
+
class: V(["u-input-show", { "u-input-multiline": l.value }]),
|
|
2158
|
+
style: B(d.value)
|
|
2159
|
+
}, k(e.value), 7));
|
|
2114
2160
|
}
|
|
2115
2161
|
}), Zt = /* @__PURE__ */ $(Xt, [["__scopeId", "data-v-c78b151e"]]), ea = /* @__PURE__ */ P({
|
|
2116
2162
|
__name: "UDictShow",
|
|
@@ -2119,8 +2165,8 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2119
2165
|
dictType: {},
|
|
2120
2166
|
defaultText: { default: "" }
|
|
2121
2167
|
},
|
|
2122
|
-
setup(
|
|
2123
|
-
const t =
|
|
2168
|
+
setup(o) {
|
|
2169
|
+
const t = o, e = Q(""), l = Q(!1), d = async () => {
|
|
2124
2170
|
if (t.modelValue === null || t.modelValue === void 0 || t.modelValue === "") {
|
|
2125
2171
|
e.value = t.defaultText;
|
|
2126
2172
|
return;
|
|
@@ -2129,23 +2175,23 @@ 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
|
+
l.value = !0;
|
|
2133
2179
|
try {
|
|
2134
|
-
const r = await
|
|
2180
|
+
const r = await lt(t.dictType, t.modelValue, t.defaultText);
|
|
2135
2181
|
e.value = r;
|
|
2136
2182
|
} catch (r) {
|
|
2137
2183
|
console.error("[UDictShow] 翻译失败:", r), e.value = String(t.modelValue);
|
|
2138
2184
|
} finally {
|
|
2139
|
-
|
|
2185
|
+
l.value = !1;
|
|
2140
2186
|
}
|
|
2141
2187
|
};
|
|
2142
|
-
return
|
|
2143
|
-
t.dictType &&
|
|
2144
|
-
}),
|
|
2145
|
-
t.dictType ?
|
|
2146
|
-
}), (r,
|
|
2147
|
-
class: V(["u-dict-show", { "u-dict-loading":
|
|
2148
|
-
},
|
|
2188
|
+
return L(() => t.modelValue, d, { immediate: !0 }), L(() => t.dictType, () => {
|
|
2189
|
+
t.dictType && ae(t.dictType).then(() => d());
|
|
2190
|
+
}), oe(() => {
|
|
2191
|
+
t.dictType ? ae(t.dictType).then(() => d()) : d();
|
|
2192
|
+
}), (r, c) => (h(), y("div", {
|
|
2193
|
+
class: V(["u-dict-show", { "u-dict-loading": l.value }])
|
|
2194
|
+
}, k(e.value), 3));
|
|
2149
2195
|
}
|
|
2150
2196
|
}), ta = /* @__PURE__ */ $(ea, [["__scopeId", "data-v-908045c4"]]), aa = /* @__PURE__ */ P({
|
|
2151
2197
|
__name: "UToggleShow",
|
|
@@ -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 (
|
|
2204
|
+
setup(o) {
|
|
2205
|
+
const t = o, e = v(() => t.useYesNo ? "是" : t.trueText), l = v(() => t.useYesNo ? "否" : t.falseText), d = v(() => t.modelValue === !0 || t.modelValue === "true" ? e.value : t.modelValue === !1 || t.modelValue === "false" ? l.value : String(t.modelValue ?? "")), r = v(() => t.modelValue === !0 || t.modelValue === "true" ? "toggle-true" : t.modelValue === !1 || t.modelValue === "false" ? "toggle-false" : "toggle-default");
|
|
2206
|
+
return (c, s) => (h(), y("div", {
|
|
2161
2207
|
class: V(["u-toggle-show", r.value])
|
|
2162
|
-
},
|
|
2208
|
+
}, k(d.value), 3));
|
|
2163
2209
|
}
|
|
2164
|
-
}),
|
|
2210
|
+
}), oa = /* @__PURE__ */ $(aa, [["__scopeId", "data-v-bac05efc"]]), la = /* @__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(""), l = Q(!1), d = async () => {
|
|
2174
2220
|
if (!t.modelValue || !Array.isArray(t.modelValue)) {
|
|
2175
2221
|
e.value = "";
|
|
2176
2222
|
return;
|
|
2177
2223
|
}
|
|
2178
2224
|
const r = t.modelValue;
|
|
2179
2225
|
if (t.cascaderKey) {
|
|
2180
|
-
|
|
2226
|
+
l.value = !0;
|
|
2181
2227
|
try {
|
|
2182
|
-
const
|
|
2183
|
-
const
|
|
2184
|
-
return
|
|
2185
|
-
}).filter((
|
|
2228
|
+
const c = await ae(t.cascaderKey), a = r.map((i) => {
|
|
2229
|
+
const n = c.find((f) => f.value === i || String(f.value) === String(i));
|
|
2230
|
+
return n ? n.label : t.showRawValue ? String(i) : "";
|
|
2231
|
+
}).filter((i) => i !== "");
|
|
2186
2232
|
e.value = a.join(t.separator);
|
|
2187
|
-
} catch (
|
|
2188
|
-
console.error("[UCascaderShow] 翻译失败:",
|
|
2233
|
+
} catch (c) {
|
|
2234
|
+
console.error("[UCascaderShow] 翻译失败:", c), e.value = t.showRawValue ? r.join(t.separator) : "";
|
|
2189
2235
|
} finally {
|
|
2190
|
-
|
|
2236
|
+
l.value = !1;
|
|
2191
2237
|
}
|
|
2192
2238
|
} else
|
|
2193
2239
|
e.value = r.join(t.separator);
|
|
2194
2240
|
};
|
|
2195
|
-
return
|
|
2196
|
-
|
|
2197
|
-
}), (r,
|
|
2198
|
-
class: V(["u-cascader-show", { "u-cascader-loading":
|
|
2199
|
-
},
|
|
2241
|
+
return L(() => t.modelValue, d, { immediate: !0 }), oe(() => {
|
|
2242
|
+
d();
|
|
2243
|
+
}), (r, c) => (h(), y("div", {
|
|
2244
|
+
class: V(["u-cascader-show", { "u-cascader-loading": l.value }])
|
|
2245
|
+
}, k(e.value), 3));
|
|
2200
2246
|
}
|
|
2201
|
-
}), na = /* @__PURE__ */ $(
|
|
2247
|
+
}), na = /* @__PURE__ */ $(la, [["__scopeId", "data-v-5d84df67"]]), ia = /* @__PURE__ */ P({
|
|
2202
2248
|
__name: "UDateShow",
|
|
2203
2249
|
props: {
|
|
2204
2250
|
modelValue: {},
|
|
@@ -2208,18 +2254,18 @@ 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), l = v(() => {
|
|
2259
|
+
const c = t.modelValue;
|
|
2260
|
+
return t.mode === "single" ? c ? d(c, t.format) : "" : t.mode === "multiple" ? c ? Array.isArray(c) ? c.map((s) => d(s, t.format)).join(e.value) : String(c) : "" : t.mode === "range" ? c ? typeof c == "object" && c.from && c.to ? `${d(c.from, t.format)}${e.value}${d(c.to, t.format)}` : Array.isArray(c) && c.length >= 2 ? `${d(c[0], t.format)}${e.value}${d(c[1], t.format)}` : String(c) : "" : String(c ?? "");
|
|
2215
2261
|
});
|
|
2216
|
-
function c
|
|
2217
|
-
return
|
|
2262
|
+
function d(c, s) {
|
|
2263
|
+
return c || "";
|
|
2218
2264
|
}
|
|
2219
|
-
const r = v(() => !
|
|
2220
|
-
return (
|
|
2265
|
+
const r = v(() => !l.value);
|
|
2266
|
+
return (c, s) => (h(), y("div", {
|
|
2221
2267
|
class: V(["u-date-show", { "u-date-empty": r.value }])
|
|
2222
|
-
},
|
|
2268
|
+
}, k(l.value || (o.locale === "en-US" ? "Empty" : "暂无")), 3));
|
|
2223
2269
|
}
|
|
2224
2270
|
}), sa = /* @__PURE__ */ $(ia, [["__scopeId", "data-v-930657df"]]), ra = /* @__PURE__ */ P({
|
|
2225
2271
|
__name: "UFieldView",
|
|
@@ -2238,20 +2284,20 @@ 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 c = t.text.split("/");
|
|
2291
|
+
return c.length >= 2 ? {
|
|
2292
|
+
trueText: c[0].trim(),
|
|
2293
|
+
falseText: c[1].trim()
|
|
2248
2294
|
} : null;
|
|
2249
|
-
}),
|
|
2250
|
-
var
|
|
2251
|
-
return t.trueText || ((
|
|
2252
|
-
}),
|
|
2253
|
-
var
|
|
2254
|
-
return t.falseText || ((
|
|
2295
|
+
}), l = v(() => {
|
|
2296
|
+
var c;
|
|
2297
|
+
return t.trueText || ((c = e.value) == null ? void 0 : c.trueText) || "开启";
|
|
2298
|
+
}), d = v(() => {
|
|
2299
|
+
var c;
|
|
2300
|
+
return t.falseText || ((c = e.value) == null ? void 0 : c.falseText) || "关闭";
|
|
2255
2301
|
}), r = v(() => {
|
|
2256
2302
|
switch (t.type) {
|
|
2257
2303
|
case "dict":
|
|
@@ -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 (c, s) => (h(), S(H(r.value === "UDictShow" ? ta : r.value === "UToggleShow" ? oa : r.value === "UCascaderShow" ? na : r.value === "UDateShow" ? sa : Zt), {
|
|
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" ? l.value : void 0,
|
|
2325
|
+
"false-text": o.type === "switch" ? d.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__ */ $(ra, [["__scopeId", "data-v-fedb54d7"]]), da = { class: "table-grid" }, ca = /* @__PURE__ */ P({
|
|
2286
2332
|
// 属性/事件手动透传给 el-table,不再自动落到根节点
|
|
2287
2333
|
inheritAttrs: !1,
|
|
2288
2334
|
__name: "TableGrid",
|
|
@@ -2297,23 +2343,23 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2297
2343
|
activeKey: {}
|
|
2298
2344
|
},
|
|
2299
2345
|
emits: ["rowAction", "rowClick", "selectionChange"],
|
|
2300
|
-
setup(
|
|
2301
|
-
const e =
|
|
2346
|
+
setup(o, { emit: t }) {
|
|
2347
|
+
const e = o, l = ye(), d = t, r = v(() => ({
|
|
2302
2348
|
// 行操作按钮
|
|
2303
2349
|
actionList: e.actions || [],
|
|
2304
2350
|
// 操作列宽度:按按钮文字估算
|
|
2305
2351
|
actionColumnWidth: s.getActionColumnWidth(),
|
|
2306
2352
|
// 用户自己提供了 empty 插槽就用用户的,否则用内置空状态
|
|
2307
|
-
hasUserEmpty: !!
|
|
2353
|
+
hasUserEmpty: !!l.empty,
|
|
2308
2354
|
// 透传给 el-table 的插槽(default 由 <slot name="default"/> 单独渲染)
|
|
2309
|
-
forwardSlots: Object.keys(
|
|
2310
|
-
})),
|
|
2311
|
-
const a = e.columns.map((
|
|
2312
|
-
const
|
|
2313
|
-
prop:
|
|
2314
|
-
label:
|
|
2355
|
+
forwardSlots: Object.keys(l).filter((a) => a !== "default")
|
|
2356
|
+
})), c = v(() => {
|
|
2357
|
+
const a = e.columns.map((i) => {
|
|
2358
|
+
const n = {
|
|
2359
|
+
prop: i.field,
|
|
2360
|
+
label: i.label
|
|
2315
2361
|
};
|
|
2316
|
-
return typeof
|
|
2362
|
+
return typeof i.width == "number" && (n.width = i.width), n;
|
|
2317
2363
|
});
|
|
2318
2364
|
return r.value.actionList.length > 0 && a.push({
|
|
2319
2365
|
prop: "actions",
|
|
@@ -2344,8 +2390,8 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2344
2390
|
},
|
|
2345
2391
|
// 操作列宽度:按各按钮文字长度估算
|
|
2346
2392
|
getActionColumnWidth() {
|
|
2347
|
-
const
|
|
2348
|
-
return Math.max(80, Math.ceil(
|
|
2393
|
+
const i = (e.actions || []).reduce((n, f) => n + Math.max(52, s.actionText(f).length * 16 + 12), 0);
|
|
2394
|
+
return Math.max(80, Math.ceil(i) + 16);
|
|
2349
2395
|
},
|
|
2350
2396
|
// 手机号脱敏
|
|
2351
2397
|
maskPhone(a) {
|
|
@@ -2357,14 +2403,14 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2357
2403
|
},
|
|
2358
2404
|
// 金额格式化
|
|
2359
2405
|
formatMoney(a) {
|
|
2360
|
-
const
|
|
2361
|
-
return isNaN(
|
|
2406
|
+
const i = Number(a);
|
|
2407
|
+
return isNaN(i) ? String(a) : i.toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
2362
2408
|
},
|
|
2363
2409
|
// 根据 format 类型格式化
|
|
2364
|
-
formatByType(a,
|
|
2410
|
+
formatByType(a, i) {
|
|
2365
2411
|
if (!a)
|
|
2366
2412
|
return "";
|
|
2367
|
-
switch (
|
|
2413
|
+
switch (i) {
|
|
2368
2414
|
case "phone":
|
|
2369
2415
|
return s.maskPhone(a);
|
|
2370
2416
|
case "idcard":
|
|
@@ -2374,18 +2420,18 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2374
2420
|
case "percent":
|
|
2375
2421
|
return String(a * 100) + "%";
|
|
2376
2422
|
default:
|
|
2377
|
-
return
|
|
2423
|
+
return i && i.includes("{}") ? i.replace("{}", String(a)) : String(a);
|
|
2378
2424
|
}
|
|
2379
2425
|
},
|
|
2380
2426
|
// 获取嵌套字段值
|
|
2381
|
-
getNestedValue(a,
|
|
2382
|
-
if (!
|
|
2383
|
-
return a[
|
|
2384
|
-
const
|
|
2427
|
+
getNestedValue(a, i) {
|
|
2428
|
+
if (!i.includes("."))
|
|
2429
|
+
return a[i];
|
|
2430
|
+
const n = i.split(".");
|
|
2385
2431
|
let f = a;
|
|
2386
|
-
for (const
|
|
2387
|
-
if (f && typeof f == "object" &&
|
|
2388
|
-
f = f[
|
|
2432
|
+
for (const m of n)
|
|
2433
|
+
if (f && typeof f == "object" && m in f)
|
|
2434
|
+
f = f[m];
|
|
2389
2435
|
else
|
|
2390
2436
|
return;
|
|
2391
2437
|
return f;
|
|
@@ -2397,44 +2443,44 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2397
2443
|
// 当前行高亮(与详情/预览对应)
|
|
2398
2444
|
rowClassName({ row: a }) {
|
|
2399
2445
|
if (!a || e.activeKey === void 0 || e.activeKey === null) return "";
|
|
2400
|
-
const
|
|
2401
|
-
return a[
|
|
2446
|
+
const i = e.keyField || "id";
|
|
2447
|
+
return a[i] === e.activeKey ? "table-grid-active-row" : "";
|
|
2402
2448
|
},
|
|
2403
2449
|
// 选择变化
|
|
2404
2450
|
onSelectionChange(a) {
|
|
2405
|
-
|
|
2451
|
+
d("selectionChange", a);
|
|
2406
2452
|
},
|
|
2407
2453
|
// 行点击
|
|
2408
2454
|
onRowClick(a) {
|
|
2409
|
-
|
|
2455
|
+
d("rowClick", a);
|
|
2410
2456
|
},
|
|
2411
2457
|
// 行操作按钮点击
|
|
2412
|
-
onRowAction(a,
|
|
2413
|
-
|
|
2458
|
+
onRowAction(a, i) {
|
|
2459
|
+
d("rowAction", {
|
|
2414
2460
|
action: a.action,
|
|
2415
2461
|
item: a,
|
|
2416
|
-
row:
|
|
2462
|
+
row: i
|
|
2417
2463
|
});
|
|
2418
2464
|
}
|
|
2419
2465
|
};
|
|
2420
|
-
return (a,
|
|
2421
|
-
const
|
|
2466
|
+
return (a, i) => {
|
|
2467
|
+
const n = Qe, f = J, m = Ye;
|
|
2422
2468
|
return h(), y("div", da, [
|
|
2423
|
-
_(
|
|
2469
|
+
_(m, ce({ stripe: !0, border: !0, ...a.$attrs }, {
|
|
2424
2470
|
data: e.rows.length ? e.rows : [{}],
|
|
2425
2471
|
loading: e.loading,
|
|
2426
2472
|
"row-key": e.keyField || "id",
|
|
2427
2473
|
"row-class-name": s.rowClassName,
|
|
2428
2474
|
onSelectionChange: s.onSelectionChange,
|
|
2429
|
-
onRowClick:
|
|
2430
|
-
}),
|
|
2475
|
+
onRowClick: i[0] || (i[0] = (u) => s.onRowClick(u))
|
|
2476
|
+
}), X({
|
|
2431
2477
|
default: w(() => [
|
|
2432
|
-
e.selection ? (h(), S(
|
|
2478
|
+
e.selection ? (h(), S(n, {
|
|
2433
2479
|
key: 0,
|
|
2434
2480
|
type: "selection",
|
|
2435
2481
|
width: "55"
|
|
2436
|
-
})) :
|
|
2437
|
-
(h(!0), y(
|
|
2482
|
+
})) : D("", !0),
|
|
2483
|
+
(h(!0), y(I, null, E(c.value, (u) => (h(), S(n, {
|
|
2438
2484
|
key: u.prop,
|
|
2439
2485
|
prop: u.prop,
|
|
2440
2486
|
label: u.label,
|
|
@@ -2442,62 +2488,62 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2442
2488
|
fixed: u.fixed
|
|
2443
2489
|
}, {
|
|
2444
2490
|
default: w(({ row: g }) => [
|
|
2445
|
-
u.prop === "actions" ? (h(), y(
|
|
2446
|
-
Object.keys(g).length > 0 ? (h(!0), y(
|
|
2491
|
+
u.prop === "actions" ? (h(), y(I, { key: 0 }, [
|
|
2492
|
+
Object.keys(g).length > 0 ? (h(!0), y(I, { key: 0 }, E(r.value.actionList, (p, b) => (h(), S(f, {
|
|
2447
2493
|
key: b,
|
|
2448
2494
|
link: "",
|
|
2449
|
-
type: s.actionType(
|
|
2450
|
-
disabled:
|
|
2495
|
+
type: s.actionType(p),
|
|
2496
|
+
disabled: p.disabled === !0,
|
|
2451
2497
|
size: "small",
|
|
2452
|
-
onClick: Je((
|
|
2498
|
+
onClick: Je((R) => s.onRowAction(p, g), ["stop"])
|
|
2453
2499
|
}, {
|
|
2454
2500
|
default: w(() => [
|
|
2455
|
-
F(
|
|
2501
|
+
F(k(s.actionText(p)), 1)
|
|
2456
2502
|
]),
|
|
2457
2503
|
_: 2
|
|
2458
|
-
}, 1032, ["type", "disabled", "onClick"]))), 128)) :
|
|
2459
|
-
], 64)) : (h(), y(
|
|
2460
|
-
Object.keys(g).length > 0 ? (h(!0), y(
|
|
2461
|
-
key:
|
|
2504
|
+
}, 1032, ["type", "disabled", "onClick"]))), 128)) : D("", !0)
|
|
2505
|
+
], 64)) : (h(), y(I, { key: 1 }, [
|
|
2506
|
+
Object.keys(g).length > 0 ? (h(!0), y(I, { key: 0 }, E(e.columns, (p) => (h(), y(I, {
|
|
2507
|
+
key: p.field
|
|
2462
2508
|
}, [
|
|
2463
|
-
|
|
2509
|
+
p.field === u.prop && s.useFieldView(p) ? (h(), S(xe, {
|
|
2464
2510
|
key: 0,
|
|
2465
|
-
type:
|
|
2466
|
-
"model-value": s.getNestedValue(g,
|
|
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"])) :
|
|
2511
|
+
type: p.type,
|
|
2512
|
+
"model-value": s.getNestedValue(g, p.field),
|
|
2513
|
+
"dict-type": p.dictType,
|
|
2514
|
+
mode: p.mode,
|
|
2515
|
+
locale: p.locale,
|
|
2516
|
+
format: p.format,
|
|
2517
|
+
text: p.text,
|
|
2518
|
+
"true-text": p.trueText,
|
|
2519
|
+
"false-text": p.falseText,
|
|
2520
|
+
"use-yes-no": p.useYesNo,
|
|
2521
|
+
"cascader-key": p.cascaderKey,
|
|
2522
|
+
multiline: p.multiline,
|
|
2523
|
+
"default-text": p.defaultText
|
|
2524
|
+
}, null, 8, ["type", "model-value", "dict-type", "mode", "locale", "format", "text", "true-text", "false-text", "use-yes-no", "cascader-key", "multiline", "default-text"])) : p.field === u.prop ? (h(), y("span", {
|
|
2479
2525
|
key: 1,
|
|
2480
|
-
class: V({ "table-grid-format":
|
|
2481
|
-
},
|
|
2482
|
-
], 64))), 128)) :
|
|
2526
|
+
class: V({ "table-grid-format": p.format })
|
|
2527
|
+
}, k(s.formatByType(s.getNestedValue(g, p.field), p.format || "")), 3)) : D("", !0)
|
|
2528
|
+
], 64))), 128)) : D("", !0)
|
|
2483
2529
|
], 64))
|
|
2484
2530
|
]),
|
|
2485
2531
|
_: 2
|
|
2486
2532
|
}, 1032, ["prop", "label", "width", "fixed"]))), 128)),
|
|
2487
|
-
|
|
2533
|
+
T(a.$slots, "default", {}, void 0, !0)
|
|
2488
2534
|
]),
|
|
2489
2535
|
_: 2
|
|
2490
2536
|
}, [
|
|
2491
|
-
|
|
2537
|
+
E(r.value.forwardSlots, (u) => ({
|
|
2492
2538
|
name: u,
|
|
2493
2539
|
fn: w((g) => [
|
|
2494
|
-
|
|
2540
|
+
T(a.$slots, u, q(j(g || {})), void 0, !0)
|
|
2495
2541
|
])
|
|
2496
2542
|
})),
|
|
2497
2543
|
r.value.hasUserEmpty ? void 0 : {
|
|
2498
2544
|
name: "empty",
|
|
2499
2545
|
fn: w(() => [
|
|
2500
|
-
|
|
2546
|
+
i[1] || (i[1] = C("div", { class: "no-data" }, "暂无数据", -1))
|
|
2501
2547
|
]),
|
|
2502
2548
|
key: "0"
|
|
2503
2549
|
}
|
|
@@ -2520,29 +2566,29 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2520
2566
|
type: {}
|
|
2521
2567
|
},
|
|
2522
2568
|
emits: ["update:page", "update:pageSize"],
|
|
2523
|
-
setup(
|
|
2524
|
-
const e =
|
|
2569
|
+
setup(o, { emit: t }) {
|
|
2570
|
+
const e = o, l = t, d = v(() => ({
|
|
2525
2571
|
// 总页数
|
|
2526
2572
|
totalPages: Math.ceil(e.total / e.pageSize),
|
|
2527
2573
|
// 是否显示分页
|
|
2528
2574
|
showPagination: e.type === "page" && e.total > 0
|
|
2529
2575
|
})), r = {
|
|
2530
2576
|
// 页码变化
|
|
2531
|
-
onPageChange: (
|
|
2532
|
-
|
|
2577
|
+
onPageChange: (c) => {
|
|
2578
|
+
l("update:page", c);
|
|
2533
2579
|
},
|
|
2534
2580
|
// 每页条数变化
|
|
2535
|
-
onPageSizeChange: (
|
|
2536
|
-
|
|
2581
|
+
onPageSizeChange: (c) => {
|
|
2582
|
+
l("update:pageSize", c);
|
|
2537
2583
|
}
|
|
2538
2584
|
};
|
|
2539
|
-
return (
|
|
2540
|
-
const a = Ke,
|
|
2585
|
+
return (c, s) => {
|
|
2586
|
+
const a = Ke, i = he, n = pe, f = J;
|
|
2541
2587
|
return h(), y("div", fa, [
|
|
2542
|
-
|
|
2588
|
+
d.value.showPagination ? (h(), y(I, { key: 0 }, [
|
|
2543
2589
|
_(a, {
|
|
2544
2590
|
"current-page": e.page,
|
|
2545
|
-
"page-count":
|
|
2591
|
+
"page-count": d.value.totalPages,
|
|
2546
2592
|
"page-sizes": [10, 20, 50, 100],
|
|
2547
2593
|
"page-size": e.pageSize,
|
|
2548
2594
|
layout: "total, prev, pager, next, jumper",
|
|
@@ -2550,32 +2596,32 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2550
2596
|
onSizeChange: r.onPageSizeChange
|
|
2551
2597
|
}, null, 8, ["current-page", "page-count", "page-size", "onCurrentChange", "onSizeChange"]),
|
|
2552
2598
|
C("div", ma, [
|
|
2553
|
-
_(
|
|
2599
|
+
_(n, {
|
|
2554
2600
|
"model-value": e.pageSize,
|
|
2555
2601
|
style: { width: "100px" },
|
|
2556
2602
|
onChange: r.onPageSizeChange
|
|
2557
2603
|
}, {
|
|
2558
2604
|
default: w(() => [
|
|
2559
|
-
_(
|
|
2605
|
+
_(i, {
|
|
2560
2606
|
value: 10,
|
|
2561
2607
|
label: "10条/页"
|
|
2562
2608
|
}),
|
|
2563
|
-
_(
|
|
2609
|
+
_(i, {
|
|
2564
2610
|
value: 20,
|
|
2565
2611
|
label: "20条/页"
|
|
2566
2612
|
}),
|
|
2567
|
-
_(
|
|
2613
|
+
_(i, {
|
|
2568
2614
|
value: 50,
|
|
2569
2615
|
label: "50条/页"
|
|
2570
2616
|
}),
|
|
2571
|
-
_(
|
|
2617
|
+
_(i, {
|
|
2572
2618
|
value: 100,
|
|
2573
2619
|
label: "100条/页"
|
|
2574
2620
|
})
|
|
2575
2621
|
]),
|
|
2576
2622
|
_: 1
|
|
2577
2623
|
}, 8, ["model-value", "onChange"]),
|
|
2578
|
-
C("span", pa, "共 " +
|
|
2624
|
+
C("span", pa, "共 " + k(e.total) + " 条", 1)
|
|
2579
2625
|
])
|
|
2580
2626
|
], 64)) : e.type === "auto" ? (h(), y("div", ha, [
|
|
2581
2627
|
_(f, {
|
|
@@ -2586,7 +2632,7 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2586
2632
|
])]),
|
|
2587
2633
|
_: 1
|
|
2588
2634
|
}, 8, ["disabled"])
|
|
2589
|
-
])) : e.type === "all" ? (h(), y("div", ga, "共 " +
|
|
2635
|
+
])) : e.type === "all" ? (h(), y("div", ga, "共 " + k(e.total) + " 条", 1)) : D("", !0)
|
|
2590
2636
|
]);
|
|
2591
2637
|
};
|
|
2592
2638
|
}
|
|
@@ -2599,7 +2645,7 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2599
2645
|
}, Sa = {
|
|
2600
2646
|
key: 1,
|
|
2601
2647
|
class: "detail-content"
|
|
2602
|
-
},
|
|
2648
|
+
}, Da = { class: "detail-label" }, ka = { class: "detail-value" }, Ta = {
|
|
2603
2649
|
key: 2,
|
|
2604
2650
|
class: "detail-status"
|
|
2605
2651
|
}, Va = /* @__PURE__ */ P({
|
|
@@ -2610,10 +2656,11 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2610
2656
|
loading: { type: Boolean },
|
|
2611
2657
|
rowData: {},
|
|
2612
2658
|
columns: {},
|
|
2613
|
-
emptyText: {}
|
|
2659
|
+
emptyText: {},
|
|
2660
|
+
extraMode: {}
|
|
2614
2661
|
},
|
|
2615
|
-
setup(
|
|
2616
|
-
const t =
|
|
2662
|
+
setup(o) {
|
|
2663
|
+
const t = o, e = ye(), l = v(() => !!e["detail-extra"]), d = v(() => l.value), r = v(() => !l.value || t.extraMode === "append"), c = v(() => ({
|
|
2617
2664
|
// 标题栏
|
|
2618
2665
|
showHeader: t.showHeader !== !1,
|
|
2619
2666
|
// 面板标题
|
|
@@ -2622,69 +2669,72 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2622
2669
|
emptyText: t.emptyText || "暂无数据",
|
|
2623
2670
|
// 是否有记录可展示
|
|
2624
2671
|
hasRow: !!t.rowData
|
|
2625
|
-
})),
|
|
2672
|
+
})), s = {
|
|
2626
2673
|
// 获取嵌套字段值
|
|
2627
|
-
getNestedValue(
|
|
2628
|
-
if (!
|
|
2629
|
-
if (!
|
|
2630
|
-
return
|
|
2631
|
-
const
|
|
2632
|
-
let
|
|
2633
|
-
for (const
|
|
2634
|
-
if (
|
|
2635
|
-
|
|
2674
|
+
getNestedValue(a, i) {
|
|
2675
|
+
if (!a || !i) return "";
|
|
2676
|
+
if (!i.includes("."))
|
|
2677
|
+
return a[i];
|
|
2678
|
+
const n = i.split(".");
|
|
2679
|
+
let f = a;
|
|
2680
|
+
for (const m of n)
|
|
2681
|
+
if (f && typeof f == "object" && m in f)
|
|
2682
|
+
f = f[m];
|
|
2636
2683
|
else
|
|
2637
2684
|
return "";
|
|
2638
|
-
return
|
|
2685
|
+
return f;
|
|
2639
2686
|
}
|
|
2640
2687
|
};
|
|
2641
|
-
return (
|
|
2642
|
-
|
|
2643
|
-
C("div", xa,
|
|
2644
|
-
])) :
|
|
2688
|
+
return (a, i) => (h(), y("div", va, [
|
|
2689
|
+
c.value.showHeader ? (h(), y("div", wa, [
|
|
2690
|
+
C("div", xa, k(c.value.title), 1)
|
|
2691
|
+
])) : D("", !0),
|
|
2645
2692
|
C("div", Ca, [
|
|
2646
|
-
|
|
2647
|
-
(h(
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2693
|
+
r.value ? (h(), y(I, { key: 0 }, [
|
|
2694
|
+
t.loading ? (h(), y("div", _a, "加载中...")) : c.value.hasRow ? (h(), y("div", Sa, [
|
|
2695
|
+
(h(!0), y(I, null, E(t.columns, (n) => (h(), y("div", {
|
|
2696
|
+
key: n.field,
|
|
2697
|
+
class: "detail-item"
|
|
2698
|
+
}, [
|
|
2699
|
+
C("div", Da, k(n.label), 1),
|
|
2700
|
+
C("div", ka, [
|
|
2701
|
+
_(xe, {
|
|
2702
|
+
type: n.type,
|
|
2703
|
+
"model-value": s.getNestedValue(t.rowData, n.field),
|
|
2704
|
+
"dict-type": n.dictType,
|
|
2705
|
+
mode: n.mode,
|
|
2706
|
+
locale: n.locale,
|
|
2707
|
+
format: n.format,
|
|
2708
|
+
text: n.text,
|
|
2709
|
+
"true-text": n.trueText,
|
|
2710
|
+
"false-text": n.falseText,
|
|
2711
|
+
"use-yes-no": n.useYesNo,
|
|
2712
|
+
"cascader-key": n.cascaderKey,
|
|
2713
|
+
multiline: n.multiline,
|
|
2714
|
+
"default-text": n.defaultText
|
|
2715
|
+
}, null, 8, ["type", "model-value", "dict-type", "mode", "locale", "format", "text", "true-text", "false-text", "use-yes-no", "cascader-key", "multiline", "default-text"])
|
|
2716
|
+
])
|
|
2717
|
+
]))), 128))
|
|
2718
|
+
])) : (h(), y("div", Ta, k(c.value.emptyText), 1))
|
|
2719
|
+
], 64)) : D("", !0),
|
|
2720
|
+
d.value ? T(a.$slots, "detail-extra", {
|
|
2672
2721
|
rowData: t.rowData,
|
|
2673
2722
|
columns: t.columns
|
|
2674
|
-
}, void 0, !0)
|
|
2723
|
+
}, void 0, !0, 1) : D("", !0)
|
|
2675
2724
|
])
|
|
2676
2725
|
]));
|
|
2677
2726
|
}
|
|
2678
|
-
}),
|
|
2727
|
+
}), ue = /* @__PURE__ */ $(Va, [["__scopeId", "data-v-3314a22f"]]), Pa = { class: "table-body" }, $a = { class: "table-container" }, Ra = /* @__PURE__ */ P({
|
|
2679
2728
|
// 属性/事件手动处理:class/style 留根节点,其余透传给 el-table
|
|
2680
2729
|
inheritAttrs: !1,
|
|
2681
2730
|
__name: "TableRender",
|
|
2682
2731
|
props: {
|
|
2683
|
-
formId: {}
|
|
2732
|
+
formId: {},
|
|
2733
|
+
detailExtraMode: {}
|
|
2684
2734
|
},
|
|
2685
2735
|
emits: ["back", "toolbar-action", "row-action"],
|
|
2686
|
-
setup(
|
|
2687
|
-
const
|
|
2736
|
+
setup(o, { expose: t, emit: e }) {
|
|
2737
|
+
const l = ["search-extra", "search-actions", "toolbar-left", "toolbar-extra", "detail-extra"], d = o, r = Xe(), c = ye(), s = e, a = new Nt(), i = Q(null), n = W({
|
|
2688
2738
|
// 内部搜索参数
|
|
2689
2739
|
searchParams: {},
|
|
2690
2740
|
// 是否已加载配置
|
|
@@ -2692,8 +2742,8 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2692
2742
|
// 字典数据缓存
|
|
2693
2743
|
dictData: {}
|
|
2694
2744
|
});
|
|
2695
|
-
|
|
2696
|
-
|
|
2745
|
+
oe(async () => {
|
|
2746
|
+
d.formId && await m.loadConfig(d.formId);
|
|
2697
2747
|
});
|
|
2698
2748
|
const f = v(() => ({
|
|
2699
2749
|
// 表格配置
|
|
@@ -2736,24 +2786,39 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2736
2786
|
// 详情加载状态
|
|
2737
2787
|
detailLoading: a.data.detailLoading,
|
|
2738
2788
|
// 预览抽屉(action: preview 触发)
|
|
2789
|
+
// previewMounted —— 是否挂载(懒挂载:打开时挂上,退场动画播完才卸下)
|
|
2790
|
+
// previewVisible —— 显隐(给 el-drawer 的 :model-value)
|
|
2791
|
+
previewMounted: a.data.previewMounted,
|
|
2739
2792
|
previewVisible: a.data.previewVisible,
|
|
2740
2793
|
previewRow: a.data.previewRow,
|
|
2741
2794
|
// 字典数据
|
|
2742
|
-
dictData:
|
|
2743
|
-
})),
|
|
2795
|
+
dictData: n.dictData
|
|
2796
|
+
})), m = {
|
|
2744
2797
|
// ============ 透传相关 ============
|
|
2745
2798
|
// 透传给 el-table 的属性/事件(class、style 留在本组件根节点)
|
|
2746
2799
|
getTableAttrs() {
|
|
2747
|
-
const { class: u, style: g, ...
|
|
2748
|
-
return
|
|
2800
|
+
const { class: u, style: g, ...p } = r;
|
|
2801
|
+
return p;
|
|
2749
2802
|
},
|
|
2750
2803
|
// 透传给 el-table 的插槽(本组件自己消费的插槽除外)
|
|
2751
2804
|
getTableSlots() {
|
|
2752
2805
|
const u = {};
|
|
2753
|
-
for (const g of Object.keys(
|
|
2754
|
-
|
|
2806
|
+
for (const g of Object.keys(c))
|
|
2807
|
+
l.includes(g) || (u[g] = !0);
|
|
2755
2808
|
return u;
|
|
2756
2809
|
},
|
|
2810
|
+
// 转发给 TableDetail 的插槽:**页面真的给了才转发**。
|
|
2811
|
+
// 为什么必须判断:TableDetail 用「有没有 detail-extra 插槽」决定要不要渲染默认的
|
|
2812
|
+
// 字段列表(见 detailExtraMode)。如果这里无条件挂一个转发模板,TableDetail 会永远
|
|
2813
|
+
// 认为「有插槽」→ replace 模式下详情区会变成空白。
|
|
2814
|
+
// (返回类型必须显式写:否则与 slots 互相推导会触发 TS7022/TS7023)
|
|
2815
|
+
getDetailSlots() {
|
|
2816
|
+
return c["detail-extra"] ? ["detail-extra"] : [];
|
|
2817
|
+
},
|
|
2818
|
+
// 传给 TableDetail 的插槽/默认内容关系(页面没给插槽时无所谓,给了才生效)
|
|
2819
|
+
getDetailExtraMode() {
|
|
2820
|
+
return d.detailExtraMode === "append" ? "append" : "replace";
|
|
2821
|
+
},
|
|
2757
2822
|
// ============ 配置与数据 ============
|
|
2758
2823
|
// 加载配置
|
|
2759
2824
|
async loadConfig(u) {
|
|
@@ -2763,7 +2828,7 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2763
2828
|
U((g == null ? void 0 : g.message) || "获取表格配置失败");
|
|
2764
2829
|
return;
|
|
2765
2830
|
}
|
|
2766
|
-
|
|
2831
|
+
n.searchParams = { ...a.data.searchParams }, n.loaded = !0, await m.loadDictData(), await m.handleLoadData();
|
|
2767
2832
|
},
|
|
2768
2833
|
// 加载表格数据(报错时提示框展示 message)
|
|
2769
2834
|
async handleLoadData() {
|
|
@@ -2776,19 +2841,19 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2776
2841
|
// 加载字典数据
|
|
2777
2842
|
async loadDictData() {
|
|
2778
2843
|
const u = a.getColumns(), g = /* @__PURE__ */ new Set();
|
|
2779
|
-
for (const
|
|
2780
|
-
|
|
2781
|
-
for (const
|
|
2844
|
+
for (const p of u)
|
|
2845
|
+
p.type === "dict" && p.dictType && g.add(p.dictType);
|
|
2846
|
+
for (const p of g)
|
|
2782
2847
|
try {
|
|
2783
|
-
const b = await
|
|
2784
|
-
b.status === 200 && (
|
|
2848
|
+
const b = await M.get(K.dictApi(p));
|
|
2849
|
+
b.status === 200 && (n.dictData[p] = we(b.data));
|
|
2785
2850
|
} catch (b) {
|
|
2786
|
-
console.error(`[TableRender] 加载字典 ${
|
|
2851
|
+
console.error(`[TableRender] 加载字典 ${p} 失败:`, b);
|
|
2787
2852
|
}
|
|
2788
2853
|
},
|
|
2789
2854
|
// 搜索
|
|
2790
2855
|
async handleSearch() {
|
|
2791
|
-
a.data.searchParams = { ...
|
|
2856
|
+
a.data.searchParams = { ...n.searchParams };
|
|
2792
2857
|
try {
|
|
2793
2858
|
await a.search();
|
|
2794
2859
|
} catch (u) {
|
|
@@ -2797,7 +2862,7 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2797
2862
|
},
|
|
2798
2863
|
// 重置
|
|
2799
2864
|
async handleReset() {
|
|
2800
|
-
|
|
2865
|
+
n.searchParams = {};
|
|
2801
2866
|
try {
|
|
2802
2867
|
await a.reset();
|
|
2803
2868
|
} catch (u) {
|
|
@@ -2806,7 +2871,7 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2806
2871
|
},
|
|
2807
2872
|
// 更新搜索参数
|
|
2808
2873
|
updateSearchParam(u, g) {
|
|
2809
|
-
|
|
2874
|
+
n.searchParams[u] = g;
|
|
2810
2875
|
},
|
|
2811
2876
|
// 分页变化
|
|
2812
2877
|
async handlePageChange(u) {
|
|
@@ -2833,14 +2898,22 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2833
2898
|
handleDetailClose() {
|
|
2834
2899
|
a.closeDetail();
|
|
2835
2900
|
},
|
|
2901
|
+
// 详情抽屉退场动画播完:此时才清内容
|
|
2902
|
+
handleDetailClosed() {
|
|
2903
|
+
a.resetDetail();
|
|
2904
|
+
},
|
|
2836
2905
|
// 关闭预览抽屉
|
|
2837
2906
|
handlePreviewClose() {
|
|
2838
2907
|
a.closePreview();
|
|
2839
2908
|
},
|
|
2909
|
+
// 预览抽屉退场动画播完:此时才清内容
|
|
2910
|
+
handlePreviewClosed() {
|
|
2911
|
+
a.resetPreview();
|
|
2912
|
+
},
|
|
2840
2913
|
// 预览一行(只读,用抽屉展示)
|
|
2841
2914
|
handlePreview(u) {
|
|
2842
2915
|
if (!u) {
|
|
2843
|
-
|
|
2916
|
+
z.warning("请先点击表格中的一行数据");
|
|
2844
2917
|
return;
|
|
2845
2918
|
}
|
|
2846
2919
|
a.openPreview(u);
|
|
@@ -2848,70 +2921,70 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2848
2921
|
// ============ 按钮动作分发 ============
|
|
2849
2922
|
// 工具栏按钮点击
|
|
2850
2923
|
handleToolbarAction(u) {
|
|
2851
|
-
s("toolbar-action", u),
|
|
2924
|
+
s("toolbar-action", u), m.dispatchAction(u);
|
|
2852
2925
|
},
|
|
2853
2926
|
// 行操作按钮点击
|
|
2854
2927
|
handleRowAction(u) {
|
|
2855
|
-
s("row-action", u),
|
|
2928
|
+
s("row-action", u), m.dispatchAction(u);
|
|
2856
2929
|
},
|
|
2857
2930
|
// 按 action 分发
|
|
2858
2931
|
async dispatchAction(u) {
|
|
2859
2932
|
switch (u.action) {
|
|
2860
2933
|
case "add":
|
|
2861
|
-
await
|
|
2934
|
+
await m.handleAdd(u.item);
|
|
2862
2935
|
break;
|
|
2863
2936
|
case "edit":
|
|
2864
|
-
await
|
|
2937
|
+
await m.handleEdit(u.row, u.item);
|
|
2865
2938
|
break;
|
|
2866
2939
|
case "delete":
|
|
2867
|
-
await
|
|
2940
|
+
await m.handleDelete(u.row, u.item);
|
|
2868
2941
|
break;
|
|
2869
2942
|
case "preview":
|
|
2870
|
-
|
|
2943
|
+
m.handlePreview(u.row);
|
|
2871
2944
|
break;
|
|
2872
2945
|
case "back":
|
|
2873
2946
|
s("back", u);
|
|
2874
2947
|
break;
|
|
2875
2948
|
case "export":
|
|
2876
|
-
await
|
|
2949
|
+
await m.handleExport();
|
|
2877
2950
|
break;
|
|
2878
2951
|
default:
|
|
2879
|
-
await
|
|
2952
|
+
await m.handleCustomAction(u);
|
|
2880
2953
|
}
|
|
2881
2954
|
},
|
|
2882
2955
|
// 新增:打开表单(表单 id 优先取按钮自己的 form)
|
|
2883
2956
|
async handleAdd(u) {
|
|
2884
2957
|
const g = u ? a.getButtonFormId(u) : a.getFormId();
|
|
2885
2958
|
if (!g) {
|
|
2886
|
-
|
|
2959
|
+
z.warning("未配置表单,无法新增");
|
|
2887
2960
|
return;
|
|
2888
2961
|
}
|
|
2889
|
-
if (!
|
|
2890
|
-
await
|
|
2962
|
+
if (!i.value) return;
|
|
2963
|
+
await i.value.showForm(g) != null && await m.handleLoadData();
|
|
2891
2964
|
},
|
|
2892
2965
|
// 编辑:打开表单并回显目标行
|
|
2893
2966
|
async handleEdit(u, g) {
|
|
2894
2967
|
if (!u) {
|
|
2895
|
-
|
|
2968
|
+
z.warning("请先点击表格中的一行数据");
|
|
2896
2969
|
return;
|
|
2897
2970
|
}
|
|
2898
|
-
const
|
|
2899
|
-
if (!
|
|
2900
|
-
|
|
2971
|
+
const p = g ? a.getButtonFormId(g) : a.getFormId();
|
|
2972
|
+
if (!p) {
|
|
2973
|
+
z.warning("未配置表单,无法编辑");
|
|
2901
2974
|
return;
|
|
2902
2975
|
}
|
|
2903
|
-
if (!
|
|
2976
|
+
if (!i.value) return;
|
|
2904
2977
|
const b = a.getKeyField();
|
|
2905
|
-
await
|
|
2978
|
+
await i.value.showForm(p, `${b}=${u[b]}`) != null && await m.handleLoadData();
|
|
2906
2979
|
},
|
|
2907
2980
|
// 删除:二次确认后删除目标行
|
|
2908
2981
|
async handleDelete(u, g) {
|
|
2909
2982
|
if (!u) {
|
|
2910
|
-
|
|
2983
|
+
z.warning("请先点击表格中的一行数据");
|
|
2911
2984
|
return;
|
|
2912
2985
|
}
|
|
2913
2986
|
try {
|
|
2914
|
-
await
|
|
2987
|
+
await De.confirm(
|
|
2915
2988
|
(g == null ? void 0 : g.confirm) || "确定要删除这条数据吗?",
|
|
2916
2989
|
"确认删除",
|
|
2917
2990
|
{
|
|
@@ -2924,28 +2997,28 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2924
2997
|
return;
|
|
2925
2998
|
}
|
|
2926
2999
|
try {
|
|
2927
|
-
await a.deleteRow(u),
|
|
2928
|
-
} catch (
|
|
2929
|
-
U((
|
|
3000
|
+
await a.deleteRow(u), z.success("删除成功");
|
|
3001
|
+
} catch (p) {
|
|
3002
|
+
U((p == null ? void 0 : p.message) || "删除失败");
|
|
2930
3003
|
}
|
|
2931
3004
|
},
|
|
2932
3005
|
// 导出(需要配置 api.export)
|
|
2933
3006
|
async handleExport() {
|
|
2934
3007
|
try {
|
|
2935
|
-
await a.exportData(),
|
|
3008
|
+
await a.exportData(), z.success("导出成功");
|
|
2936
3009
|
} catch (u) {
|
|
2937
3010
|
U((u == null ? void 0 : u.message) || "导出失败");
|
|
2938
3011
|
}
|
|
2939
3012
|
},
|
|
2940
3013
|
// 自定义动作:按钮配了 url 就 POST 该地址(body = 目标行)
|
|
2941
3014
|
async handleCustomAction(u) {
|
|
2942
|
-
const { item: g, row:
|
|
3015
|
+
const { item: g, row: p } = u;
|
|
2943
3016
|
if (!(g != null && g.url)) {
|
|
2944
|
-
|
|
3017
|
+
z.warning(`未识别的按钮动作:${u.action}`);
|
|
2945
3018
|
return;
|
|
2946
3019
|
}
|
|
2947
3020
|
try {
|
|
2948
|
-
await
|
|
3021
|
+
await De.confirm(g.confirm || "确定执行该操作吗?", "确认", {
|
|
2949
3022
|
confirmButtonText: "确定",
|
|
2950
3023
|
cancelButtonText: "取消",
|
|
2951
3024
|
type: "warning"
|
|
@@ -2954,20 +3027,20 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2954
3027
|
return;
|
|
2955
3028
|
}
|
|
2956
3029
|
try {
|
|
2957
|
-
const b = await
|
|
3030
|
+
const b = await M.post(g.url, p || {});
|
|
2958
3031
|
if (b.status !== 200)
|
|
2959
3032
|
throw new Error(b.message || "操作失败");
|
|
2960
|
-
|
|
3033
|
+
z.success(b.message || "操作成功"), await m.handleLoadData();
|
|
2961
3034
|
} catch (b) {
|
|
2962
3035
|
U((b == null ? void 0 : b.message) || "操作失败");
|
|
2963
3036
|
}
|
|
2964
3037
|
}
|
|
2965
3038
|
};
|
|
2966
3039
|
return t({
|
|
2967
|
-
loadConfig:
|
|
3040
|
+
loadConfig: m.loadConfig
|
|
2968
3041
|
}), (u, g) => {
|
|
2969
|
-
var b,
|
|
2970
|
-
const
|
|
3042
|
+
var b, R, G, Ce, _e, Se;
|
|
3043
|
+
const p = He;
|
|
2971
3044
|
return h(), y("div", {
|
|
2972
3045
|
class: V(["table-render", u.$attrs.class]),
|
|
2973
3046
|
style: B(u.$attrs.style)
|
|
@@ -2975,22 +3048,22 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2975
3048
|
f.value.hasSearch ? (h(), S(Yt, {
|
|
2976
3049
|
key: 0,
|
|
2977
3050
|
fields: f.value.searchFields,
|
|
2978
|
-
modelValue:
|
|
2979
|
-
"onUpdate:modelValue": g[0] || (g[0] = (
|
|
2980
|
-
onSearch:
|
|
2981
|
-
onReset:
|
|
3051
|
+
modelValue: n.searchParams,
|
|
3052
|
+
"onUpdate:modelValue": g[0] || (g[0] = (A) => n.searchParams = A),
|
|
3053
|
+
onSearch: m.handleSearch,
|
|
3054
|
+
onReset: m.handleReset
|
|
2982
3055
|
}, {
|
|
2983
|
-
"search-extra": w((
|
|
2984
|
-
|
|
3056
|
+
"search-extra": w((A) => [
|
|
3057
|
+
T(u.$slots, "search-extra", q(j(A || {})), void 0, !0)
|
|
2985
3058
|
]),
|
|
2986
|
-
"search-actions": w((
|
|
2987
|
-
|
|
3059
|
+
"search-actions": w((A) => [
|
|
3060
|
+
T(u.$slots, "search-actions", q(j(A || {})), void 0, !0)
|
|
2988
3061
|
]),
|
|
2989
3062
|
_: 3
|
|
2990
|
-
}, 8, ["fields", "modelValue", "onSearch", "onReset"])) :
|
|
3063
|
+
}, 8, ["fields", "modelValue", "onSearch", "onReset"])) : D("", !0),
|
|
2991
3064
|
C("div", Pa, [
|
|
2992
3065
|
C("div", $a, [
|
|
2993
|
-
_(ua,
|
|
3066
|
+
_(ua, ce(m.getTableAttrs(), {
|
|
2994
3067
|
rows: f.value.rows,
|
|
2995
3068
|
columns: f.value.columns,
|
|
2996
3069
|
loading: f.value.loading,
|
|
@@ -2998,13 +3071,13 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
2998
3071
|
"key-field": (b = f.value.tableConfig) == null ? void 0 : b.key,
|
|
2999
3072
|
"dict-data": f.value.dictData,
|
|
3000
3073
|
"active-key": f.value.currentKey,
|
|
3001
|
-
onRowAction:
|
|
3002
|
-
onRowClick:
|
|
3003
|
-
}),
|
|
3004
|
-
|
|
3005
|
-
name:
|
|
3074
|
+
onRowAction: m.handleRowAction,
|
|
3075
|
+
onRowClick: m.handleRowClick
|
|
3076
|
+
}), X({ _: 2 }, [
|
|
3077
|
+
E(m.getTableSlots(), (A, Y) => ({
|
|
3078
|
+
name: Y,
|
|
3006
3079
|
fn: w((Ie) => [
|
|
3007
|
-
|
|
3080
|
+
T(u.$slots, Y, q(j(Ie || {})), void 0, !0)
|
|
3008
3081
|
])
|
|
3009
3082
|
}))
|
|
3010
3083
|
]), 1040, ["rows", "columns", "loading", "actions", "key-field", "dict-data", "active-key", "onRowAction", "onRowClick"]),
|
|
@@ -3013,104 +3086,132 @@ const Wt = { class: "table-search" }, qt = { class: "search-fields" }, Ot = { cl
|
|
|
3013
3086
|
page: f.value.pagination.page,
|
|
3014
3087
|
"page-size": f.value.pagination.pageSize,
|
|
3015
3088
|
total: f.value.total,
|
|
3016
|
-
type: (
|
|
3017
|
-
"onUpdate:page":
|
|
3018
|
-
"onUpdate:pageSize":
|
|
3089
|
+
type: (R = f.value.tableConfig) == null ? void 0 : R.pagination,
|
|
3090
|
+
"onUpdate:page": m.handlePageChange,
|
|
3091
|
+
"onUpdate:pageSize": m.handlePageSizeChange
|
|
3019
3092
|
}, null, 8, ["page", "page-size", "total", "type", "onUpdate:page", "onUpdate:pageSize"])
|
|
3020
3093
|
]),
|
|
3021
|
-
f.value.showDetail && f.value.detailMode === "inline" ? (h(), S(
|
|
3094
|
+
f.value.showDetail && f.value.detailMode === "inline" ? (h(), S(ue, {
|
|
3022
3095
|
key: 0,
|
|
3023
3096
|
class: V(["table-detail-inline", `table-detail-inline-${f.value.detailSide}`]),
|
|
3024
3097
|
style: B({ width: f.value.detailWidth }),
|
|
3025
|
-
title: (
|
|
3098
|
+
title: (Ce = (G = f.value.tableConfig) == null ? void 0 : G.meta) == null ? void 0 : Ce.title,
|
|
3026
3099
|
loading: f.value.detailLoading,
|
|
3027
3100
|
"row-data": f.value.detailData,
|
|
3028
3101
|
columns: f.value.columns,
|
|
3029
|
-
"empty-text": f.value.detailSide === "left" ? "请点击右侧表格行查看详情" : "请点击左侧表格行查看详情"
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3102
|
+
"empty-text": f.value.detailSide === "left" ? "请点击右侧表格行查看详情" : "请点击左侧表格行查看详情",
|
|
3103
|
+
"extra-mode": m.getDetailExtraMode()
|
|
3104
|
+
}, X({ _: 2 }, [
|
|
3105
|
+
E(m.getDetailSlots(), (A) => ({
|
|
3106
|
+
name: A,
|
|
3107
|
+
fn: w((Y) => [
|
|
3108
|
+
T(u.$slots, A, q(j(Y || {})), void 0, !0)
|
|
3109
|
+
])
|
|
3110
|
+
}))
|
|
3111
|
+
]), 1032, ["class", "style", "title", "loading", "row-data", "columns", "empty-text", "extra-mode"])) : D("", !0)
|
|
3036
3112
|
]),
|
|
3037
|
-
f.value.showDetail && f.value.detailMode === "drawer" ? (h(), S(
|
|
3113
|
+
f.value.showDetail && f.value.detailMode === "drawer" ? (h(), S(p, {
|
|
3038
3114
|
key: 1,
|
|
3039
3115
|
"model-value": f.value.detailVisible,
|
|
3040
3116
|
direction: f.value.detailDirection,
|
|
3041
3117
|
size: f.value.detailWidth,
|
|
3042
|
-
title: ((
|
|
3043
|
-
onClose:
|
|
3118
|
+
title: ((Se = (_e = f.value.tableConfig) == null ? void 0 : _e.meta) == null ? void 0 : Se.title) || "详情",
|
|
3119
|
+
onClose: m.handleDetailClose,
|
|
3120
|
+
onClosed: m.handleDetailClosed
|
|
3044
3121
|
}, {
|
|
3045
3122
|
default: w(() => [
|
|
3046
|
-
_(
|
|
3123
|
+
_(ue, {
|
|
3047
3124
|
"show-header": !1,
|
|
3048
3125
|
loading: f.value.detailLoading,
|
|
3049
3126
|
"row-data": f.value.detailData,
|
|
3050
|
-
columns: f.value.columns
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3127
|
+
columns: f.value.columns,
|
|
3128
|
+
"extra-mode": m.getDetailExtraMode()
|
|
3129
|
+
}, X({ _: 2 }, [
|
|
3130
|
+
E(m.getDetailSlots(), (A) => ({
|
|
3131
|
+
name: A,
|
|
3132
|
+
fn: w((Y) => [
|
|
3133
|
+
T(u.$slots, A, q(j(Y || {})), void 0, !0)
|
|
3134
|
+
])
|
|
3135
|
+
}))
|
|
3136
|
+
]), 1032, ["loading", "row-data", "columns", "extra-mode"])
|
|
3057
3137
|
]),
|
|
3058
3138
|
_: 3
|
|
3059
|
-
}, 8, ["model-value", "direction", "size", "title", "onClose"])) :
|
|
3060
|
-
f.value.
|
|
3139
|
+
}, 8, ["model-value", "direction", "size", "title", "onClose", "onClosed"])) : D("", !0),
|
|
3140
|
+
f.value.previewMounted ? (h(), S(p, {
|
|
3061
3141
|
key: 2,
|
|
3062
|
-
"model-value":
|
|
3142
|
+
"model-value": f.value.previewVisible,
|
|
3063
3143
|
direction: f.value.detailDirection,
|
|
3064
3144
|
size: f.value.detailWidth,
|
|
3065
3145
|
title: "详情",
|
|
3066
|
-
onClose:
|
|
3146
|
+
onClose: m.handlePreviewClose,
|
|
3147
|
+
onClosed: m.handlePreviewClosed
|
|
3067
3148
|
}, {
|
|
3068
3149
|
default: w(() => [
|
|
3069
|
-
_(
|
|
3150
|
+
_(ue, {
|
|
3070
3151
|
"show-header": !1,
|
|
3071
3152
|
"row-data": f.value.previewRow,
|
|
3072
|
-
columns: f.value.columns
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3153
|
+
columns: f.value.columns,
|
|
3154
|
+
"extra-mode": m.getDetailExtraMode()
|
|
3155
|
+
}, X({ _: 2 }, [
|
|
3156
|
+
E(m.getDetailSlots(), (A) => ({
|
|
3157
|
+
name: A,
|
|
3158
|
+
fn: w((Y) => [
|
|
3159
|
+
T(u.$slots, A, q(j(Y || {})), void 0, !0)
|
|
3160
|
+
])
|
|
3161
|
+
}))
|
|
3162
|
+
]), 1032, ["row-data", "columns", "extra-mode"])
|
|
3079
3163
|
]),
|
|
3080
3164
|
_: 3
|
|
3081
|
-
}, 8, ["direction", "size", "onClose"])) :
|
|
3165
|
+
}, 8, ["model-value", "direction", "size", "onClose", "onClosed"])) : D("", !0),
|
|
3082
3166
|
f.value.hasToolbar ? (h(), S(Jt, {
|
|
3083
3167
|
key: 3,
|
|
3084
3168
|
class: "table-toolbar-bottom",
|
|
3085
3169
|
items: f.value.toolbar,
|
|
3086
3170
|
"current-row": f.value.currentRow,
|
|
3087
|
-
onAction:
|
|
3171
|
+
onAction: m.handleToolbarAction
|
|
3088
3172
|
}, {
|
|
3089
|
-
"toolbar-left": w((
|
|
3090
|
-
|
|
3173
|
+
"toolbar-left": w((A) => [
|
|
3174
|
+
T(u.$slots, "toolbar-left", q(j(A || {})), void 0, !0)
|
|
3091
3175
|
]),
|
|
3092
|
-
"toolbar-extra": w((
|
|
3093
|
-
|
|
3176
|
+
"toolbar-extra": w((A) => [
|
|
3177
|
+
T(u.$slots, "toolbar-extra", q(j(A || {})), void 0, !0)
|
|
3094
3178
|
]),
|
|
3095
3179
|
_: 3
|
|
3096
|
-
}, 8, ["items", "current-row", "onAction"])) :
|
|
3097
|
-
_(
|
|
3180
|
+
}, 8, ["items", "current-row", "onAction"])) : D("", !0),
|
|
3181
|
+
_(Ae, {
|
|
3098
3182
|
ref_key: "formRef",
|
|
3099
|
-
ref:
|
|
3183
|
+
ref: i
|
|
3100
3184
|
}, null, 512)
|
|
3101
3185
|
], 6);
|
|
3102
3186
|
};
|
|
3103
3187
|
}
|
|
3104
|
-
}),
|
|
3105
|
-
|
|
3188
|
+
}), Aa = /* @__PURE__ */ $(Ra, [["__scopeId", "data-v-00444d8c"]]);
|
|
3189
|
+
function Ia() {
|
|
3190
|
+
var o, t;
|
|
3191
|
+
try {
|
|
3192
|
+
if (typeof document < "u" && document.baseURI) {
|
|
3193
|
+
const e = new URL(document.baseURI).origin;
|
|
3194
|
+
if (e && e !== "null") return e;
|
|
3195
|
+
}
|
|
3196
|
+
} catch {
|
|
3197
|
+
}
|
|
3198
|
+
try {
|
|
3199
|
+
const e = (t = (o = window == null ? void 0 : window.$wujie) == null ? void 0 : o.location) == null ? void 0 : t.origin;
|
|
3200
|
+
if (typeof e == "string" && e) return e;
|
|
3201
|
+
} catch {
|
|
3202
|
+
}
|
|
3203
|
+
return typeof window < "u" ? window.location.origin : "";
|
|
3204
|
+
}
|
|
3205
|
+
class Ma {
|
|
3106
3206
|
constructor(t) {
|
|
3107
3207
|
x(this, "axiosInstance");
|
|
3208
|
+
// 免配基地址:只解析一次并缓存(一个页面生命周期内不会变)
|
|
3108
3209
|
x(this, "baseUrl", "");
|
|
3109
3210
|
this.axiosInstance = Ve.create({
|
|
3110
3211
|
timeout: 1e4,
|
|
3111
3212
|
baseURL: ""
|
|
3112
3213
|
}), 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 :
|
|
3214
|
+
(e) => (e.headers.token = localStorage.getItem("token"), t.baseUrl ? e.baseURL = t.baseUrl : (this.baseUrl || (this.baseUrl = Ia()), e.baseURL = this.baseUrl), e),
|
|
3114
3215
|
(e) => Promise.reject(e)
|
|
3115
3216
|
), this.axiosInstance.interceptors.response.use(
|
|
3116
3217
|
(e) => e.config.responseType === "blob" ? e : e.data,
|
|
@@ -3183,67 +3284,67 @@ class Ua {
|
|
|
3183
3284
|
connectTimeout: 5e3,
|
|
3184
3285
|
reconnectPeriod: 5e3
|
|
3185
3286
|
};
|
|
3186
|
-
let
|
|
3187
|
-
if (console.log("connect to mqtt..."), this.mqttClient = et.connect(
|
|
3287
|
+
let l = t.mqttUrl || "ws://127.0.0.1:5002/ws";
|
|
3288
|
+
if (console.log("connect to mqtt..."), this.mqttClient = et.connect(l, e), !this.mqttClient) {
|
|
3188
3289
|
console.log("connect mqtt failed");
|
|
3189
3290
|
return;
|
|
3190
3291
|
}
|
|
3191
3292
|
this.mqttClient.on("connect", () => {
|
|
3192
|
-
console.log("=====> mqtt connect success!"), this.mqttClient.subscribe(
|
|
3193
|
-
console.log(
|
|
3293
|
+
console.log("=====> mqtt connect success!"), this.mqttClient.subscribe(fe, { qos: 0 }, (d) => {
|
|
3294
|
+
console.log(d ? `mqtt subscribe [${fe}] failed` : `mqtt subscribe [${fe}] success`);
|
|
3194
3295
|
});
|
|
3195
|
-
}), this.mqttClient.on("message", (
|
|
3196
|
-
const
|
|
3197
|
-
if (!
|
|
3198
|
-
console.error("Received empty message",
|
|
3296
|
+
}), this.mqttClient.on("message", (d, r) => {
|
|
3297
|
+
const c = r.toString();
|
|
3298
|
+
if (!c) {
|
|
3299
|
+
console.error("Received empty message", d);
|
|
3199
3300
|
return;
|
|
3200
3301
|
}
|
|
3201
3302
|
let s = null;
|
|
3202
3303
|
try {
|
|
3203
|
-
s = JSON.parse(
|
|
3304
|
+
s = JSON.parse(c);
|
|
3204
3305
|
} catch (a) {
|
|
3205
|
-
console.error("Failed to parse message JSON",
|
|
3306
|
+
console.error("Failed to parse message JSON", d, c, a);
|
|
3206
3307
|
return;
|
|
3207
3308
|
}
|
|
3208
3309
|
if (!s || s.Content === void 0 || s.Content === null || !s.PType) {
|
|
3209
|
-
console.log("parse notice failed!",
|
|
3310
|
+
console.log("parse notice failed!", c);
|
|
3210
3311
|
return;
|
|
3211
3312
|
}
|
|
3212
|
-
s.PType ==
|
|
3213
|
-
}), this.mqttClient.on(
|
|
3313
|
+
s.PType == Ba && this.eventBus.Emit(s.Route, s.Content);
|
|
3314
|
+
}), this.mqttClient.on(ie.OffLine, () => {
|
|
3214
3315
|
console.log("mqtt offline...");
|
|
3215
|
-
}), this.mqttClient.on(
|
|
3316
|
+
}), this.mqttClient.on(ie.Reconnect, () => {
|
|
3216
3317
|
console.log("mqtt reconnecting...");
|
|
3217
|
-
}), this.mqttClient.on(
|
|
3318
|
+
}), this.mqttClient.on(ie.Close, () => {
|
|
3218
3319
|
console.log("mqtt close");
|
|
3219
|
-
}), this.mqttClient.on(
|
|
3320
|
+
}), this.mqttClient.on(ie.Error, (d) => {
|
|
3220
3321
|
console.log("mqtt error");
|
|
3221
3322
|
});
|
|
3222
3323
|
}
|
|
3223
3324
|
// 生成随机字符串
|
|
3224
3325
|
randomStr(t) {
|
|
3225
3326
|
const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
3226
|
-
let
|
|
3227
|
-
for (let
|
|
3228
|
-
|
|
3229
|
-
return
|
|
3327
|
+
let l = "";
|
|
3328
|
+
for (let d = 0; d < t; d++)
|
|
3329
|
+
l += e.charAt(Math.floor(Math.random() * e.length));
|
|
3330
|
+
return l;
|
|
3230
3331
|
}
|
|
3231
3332
|
}
|
|
3232
|
-
const
|
|
3333
|
+
const fe = "Notice", Ba = "NOTICE", ie = {
|
|
3233
3334
|
OffLine: "offline",
|
|
3234
3335
|
Close: "close",
|
|
3235
3336
|
Reconnect: "reconnect",
|
|
3236
3337
|
Error: "error"
|
|
3237
3338
|
};
|
|
3238
|
-
let
|
|
3239
|
-
const
|
|
3240
|
-
if (!
|
|
3339
|
+
let se;
|
|
3340
|
+
const xo = (o) => {
|
|
3341
|
+
if (!o)
|
|
3241
3342
|
throw new Error("QfOptions is undefined");
|
|
3242
|
-
if (!
|
|
3343
|
+
if (!se && o && (se = new Fa(o)), !se)
|
|
3243
3344
|
throw new Error("Qf not initialized, please call GetQf(options) first");
|
|
3244
|
-
return
|
|
3345
|
+
return se;
|
|
3245
3346
|
};
|
|
3246
|
-
class
|
|
3347
|
+
class Fa {
|
|
3247
3348
|
constructor(t) {
|
|
3248
3349
|
x(this, "EventBus");
|
|
3249
3350
|
x(this, "WebApi");
|
|
@@ -3257,7 +3358,7 @@ class Ba {
|
|
|
3257
3358
|
initQf(t) {
|
|
3258
3359
|
if (!t)
|
|
3259
3360
|
throw new Error(`StartQf failed! options is ${t}`);
|
|
3260
|
-
this.options = t, console.log("StartQf(), qfOptions=", t), this.EventBus = new Ea(), this.WebApi = new
|
|
3361
|
+
this.options = t, console.log("StartQf(), qfOptions=", t), this.EventBus = new Ea(), this.WebApi = new Ma(t), this.options.useMqtt && (this.Mqtt = new Ua(this.EventBus, t));
|
|
3261
3362
|
}
|
|
3262
3363
|
// ==================== EventBus 相关 ====================
|
|
3263
3364
|
On(t, e) {
|
|
@@ -3290,48 +3391,49 @@ class Ba {
|
|
|
3290
3391
|
this.EventBus.On(t, e);
|
|
3291
3392
|
}
|
|
3292
3393
|
}
|
|
3293
|
-
const
|
|
3294
|
-
UInput:
|
|
3394
|
+
const La = {
|
|
3395
|
+
UInput: te,
|
|
3295
3396
|
UInputNumber: Pe,
|
|
3296
|
-
UDict:
|
|
3397
|
+
UDict: ee,
|
|
3297
3398
|
UToggle: $e,
|
|
3298
|
-
UCascader:
|
|
3299
|
-
UDate:
|
|
3399
|
+
UCascader: Re,
|
|
3400
|
+
UDate: de,
|
|
3300
3401
|
UMenu: Ct,
|
|
3301
|
-
FormRender:
|
|
3302
|
-
TableRender:
|
|
3303
|
-
UFieldView:
|
|
3304
|
-
},
|
|
3305
|
-
install(
|
|
3306
|
-
|
|
3307
|
-
for (const [t, e] of Object.entries(
|
|
3308
|
-
|
|
3402
|
+
FormRender: Ae,
|
|
3403
|
+
TableRender: Aa,
|
|
3404
|
+
UFieldView: xe
|
|
3405
|
+
}, Co = {
|
|
3406
|
+
install(o) {
|
|
3407
|
+
o.use(Ue);
|
|
3408
|
+
for (const [t, e] of Object.entries(La))
|
|
3409
|
+
o.component(t, e);
|
|
3309
3410
|
}
|
|
3310
3411
|
};
|
|
3311
3412
|
export {
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3413
|
+
Ae as FormRender,
|
|
3414
|
+
xo as GetQf,
|
|
3415
|
+
Aa as TableRender,
|
|
3416
|
+
Re as UCascader,
|
|
3417
|
+
de as UDate,
|
|
3418
|
+
ee as UDict,
|
|
3419
|
+
xe as UFieldView,
|
|
3420
|
+
te as UInput,
|
|
3320
3421
|
Pe as UInputNumber,
|
|
3321
3422
|
Ct as UMenu,
|
|
3322
3423
|
$e as UToggle,
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3424
|
+
K as apis,
|
|
3425
|
+
yo as clearDictCache,
|
|
3426
|
+
Co as default,
|
|
3427
|
+
po as flattenDictTree,
|
|
3428
|
+
ae as getDict,
|
|
3429
|
+
ve as mapDictTree,
|
|
3430
|
+
be as normalizeDictNode,
|
|
3431
|
+
z as notify,
|
|
3432
|
+
le as notifyUtil,
|
|
3433
|
+
go as preloadDicts,
|
|
3434
|
+
Ia as resolveBaseUrl,
|
|
3435
|
+
bo as setDictCache,
|
|
3436
|
+
we as toDictOptions,
|
|
3437
|
+
lt as translateDict,
|
|
3438
|
+
ho as translateDictSync
|
|
3337
3439
|
};
|