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