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/index.js CHANGED
@@ -1,30 +1,33 @@
1
- var De = Object.defineProperty;
2
- var ke = (a, t, e) => t in a ? De(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
- var v = (a, t, e) => ke(a, typeof t != "symbol" ? t + "" : t, e);
4
- import Te, { ElMessage as he, ElMessageBox as ue } from "element-plus";
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 Ve, ElInputNumber as Pe, ElSelect as le, ElOption as oe, ElSwitch as Ee, ElDatePicker as $e, ElDialog as Re, ElIcon as Ue, ElForm as Be, ElButton as Q, ElTable as Ae, ElTableColumn as Ie, ElPagination as Fe, ElDrawer as Le } from "element-plus/es";
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 S, computed as g, openBlock as f, createElementBlock as p, normalizeClass as V, normalizeStyle as I, createTextVNode as U, toDisplayString as P, createElementVNode as C, createCommentVNode as T, createVNode as x, reactive as q, watch as M, withCtx as _, Fragment as $, renderList as F, createBlock as E, mergeProps as ge, ref as L, toRefs as qe, unref as A, renderSlot as N, markRaw as Me, resolveDynamicComponent as ie, onMounted as Z, withModifiers as fe } from "vue";
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 ye from "axios";
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/es/components/icon/style/css";
20
- import { Loading as me } from "@element-plus/icons-vue";
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 "element-plus/es/components/drawer/style/css";
25
- import We from "mitt";
26
- import ze from "mqtt";
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(a, { emit: t }) {
55
- const e = a, l = t, s = g(() => {
56
- const c = {};
57
- return e.labelPosition === "left" && e.labelWidth && (c.width = typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth), e.labelAlign && (c.textAlign = e.labelAlign), c;
58
- }), d = g(() => ({
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
- })), o = {
62
- onInput(c) {
63
- l("update:modelValue", c);
64
+ })), d = {
65
+ onInput(s) {
66
+ o("update:modelValue", s);
64
67
  }
65
68
  };
66
- return (c, n) => {
67
- const r = Ve;
68
- return f(), p("div", {
69
- class: V(["u-input", d.value])
69
+ return (s, a) => {
70
+ const n = Be;
71
+ return h(), y("div", {
72
+ class: V(["u-input", r.value])
70
73
  }, [
71
- a.fieldLabel ? (f(), p("div", {
74
+ l.fieldLabel ? (h(), y("div", {
72
75
  key: 0,
73
76
  class: "u-input-label",
74
- style: I(s.value)
77
+ style: B(c.value)
75
78
  }, [
76
- U(P(a.fieldLabel) + " ", 1),
79
+ F(T(l.fieldLabel) + " ", 1),
77
80
  C("span", {
78
- class: V(["required-star", { "required-star--visible": a.required }])
81
+ class: V(["required-star", { "required-star--visible": l.required }])
79
82
  }, "*", 2)
80
- ], 4)) : T("", !0),
83
+ ], 4)) : k("", !0),
81
84
  C("div", {
82
- class: V(["u-input-field", { "u-input-field--top": a.labelPosition === "top" }])
85
+ class: V(["u-input-field", { "u-input-field--top": l.labelPosition === "top" }])
83
86
  }, [
84
- x(r, {
85
- "model-value": a.modelValue,
86
- placeholder: a.placeholder,
87
- type: a.type,
88
- disabled: a.disable,
89
- readonly: a.readonly,
90
- maxlength: a.maxlength,
91
- "onUpdate:modelValue": o.onInput
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
- }), D = (a, t) => {
98
- const e = a.__vccOpts || a;
99
- for (const [l, s] of t)
100
- e[l] = s;
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
- }, Y = /* @__PURE__ */ D(Ne, [["__scopeId", "data-v-ecf5177c"]]), Oe = { class: "u-input-number-field" }, je = /* @__PURE__ */ S({
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(a, { emit: t }) {
130
- const e = a, l = t, s = g(() => {
131
- const c = {};
132
- return e.labelPosition === "left" && e.labelWidth && (c.width = typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth), e.labelAlign && (c.textAlign = e.labelAlign), c;
133
- }), d = g(() => ({
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
- })), o = {
137
- onUpdate(c) {
138
- l("update:modelValue", c === void 0 ? 0 : c);
139
+ })), d = {
140
+ onUpdate(s) {
141
+ o("update:modelValue", s === void 0 ? 0 : s);
139
142
  }
140
143
  };
141
- return (c, n) => {
142
- const r = Pe;
143
- return f(), p("div", {
144
- class: V(["u-input-number", d.value])
144
+ return (s, a) => {
145
+ const n = Fe;
146
+ return h(), y("div", {
147
+ class: V(["u-input-number", r.value])
145
148
  }, [
146
- a.fieldLabel ? (f(), p("div", {
149
+ l.fieldLabel ? (h(), y("div", {
147
150
  key: 0,
148
151
  class: "u-input-number-label",
149
- style: I(s.value)
152
+ style: B(c.value)
150
153
  }, [
151
- U(P(a.fieldLabel) + " ", 1),
154
+ F(T(l.fieldLabel) + " ", 1),
152
155
  C("span", {
153
- class: V(["required-star", { "required-star--visible": a.required }])
156
+ class: V(["required-star", { "required-star--visible": l.required }])
154
157
  }, "*", 2)
155
- ], 4)) : T("", !0),
156
- C("div", Oe, [
157
- x(r, {
158
- "model-value": a.modelValue,
159
- placeholder: a.placeholder || "请输入数值",
160
- disabled: a.disable,
161
- min: a.min,
162
- max: a.max,
163
- step: a.step,
164
- precision: a.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: o.onUpdate
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
- }), be = /* @__PURE__ */ D(je, [["__scopeId", "data-v-cb70bd5b"]]), O = ye.create({
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
- O.interceptors.request.use(
181
- (a) => {
183
+ J.interceptors.request.use(
184
+ (l) => {
182
185
  const t = localStorage.getItem("token");
183
- return t && (a.headers.Authorization = `Bearer ${t}`), a;
186
+ return t && (l.headers.Authorization = `Bearer ${t}`), l;
184
187
  },
185
- (a) => Promise.reject(a)
188
+ (l) => Promise.reject(l)
186
189
  );
187
- O.interceptors.response.use(
188
- (a) => {
189
- const t = a.data;
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, l = e === 0 || e === 200 || Number(e) === 0 || Number(e) === 200;
193
- t.status = l ? 200 : Number(e);
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 a;
203
+ return l;
201
204
  },
202
- (a) => {
203
- var e, l;
204
- const t = ((l = (e = a.response) == null ? void 0 : e.data) == null ? void 0 : l.message) || a.message || "请求失败";
205
- return console.error("[HTTP Error]", t), Promise.reject(a);
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 R = {
209
- get(a, t) {
210
- return O.get(a, t).then((e) => e.data);
211
+ const I = {
212
+ get(l, t) {
213
+ return J.get(l, t).then((e) => e.data);
211
214
  },
212
- post(a, t, e) {
213
- return O.post(a, t, e).then((l) => l.data);
215
+ post(l, t, e) {
216
+ return J.post(l, t, e).then((o) => o.data);
214
217
  },
215
218
  // 原始 axios 实例,用于特殊需求
216
- instance: O
217
- }, z = {
218
- formCfgApi(a) {
219
- return `/api/form?file-id=${a}`;
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
- dictApi(a) {
223
- return `/api/dict/tree-list?dict_type=${a}&children=true`;
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
- cascaderApi(a) {
227
- return `/api/dict/tree-list?dict_type=${a}&children=true`;
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
- }, X = {}, K = {};
230
- function ve(a) {
231
- const { children: t, ...e } = a;
245
+ }, j = {}, le = {};
246
+ function he(l) {
247
+ const { children: t, ...e } = l;
232
248
  return {
233
- label: a.label ?? a.dict_value ?? String(a.value ?? ""),
234
- value: a.value ?? a.dict_code,
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 we(a) {
239
- return Array.isArray(a) ? a.map((t) => {
254
+ function ge(l) {
255
+ return Array.isArray(l) ? l.map((t) => {
240
256
  if (!t || typeof t != "object") return t;
241
- const e = ve(t), l = t.children;
242
- return Array.isArray(l) && l.length > 0 && (e.children = we(l)), e;
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 ne(a) {
246
- if (!Array.isArray(a)) return [];
247
- const t = [], e = (l) => {
248
- for (const s of l) {
249
- if (!s || typeof s != "object") continue;
250
- const d = s.children;
251
- t.push(ve(s)), Array.isArray(d) && d.length > 0 && e(d);
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(a), t;
273
+ return e(l), t;
255
274
  }
256
- async function ee(a) {
257
- if (!a)
275
+ async function ee(l) {
276
+ if (!l)
258
277
  return [];
259
- if (X[a])
260
- return X[a];
261
- if (a in K)
262
- return await K[a];
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 R.get(z.dictApi(a));
284
+ const e = await I.get(Q.dictApi(l));
266
285
  if (e.status === 200) {
267
- const l = ne(e.data);
268
- return X[a] = l, l;
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] 加载字典 ${a} 失败:`, e), [];
291
+ return console.error(`[dict] 加载字典 ${l} 失败:`, e), [];
273
292
  } finally {
274
- delete K[a];
293
+ delete le[l];
275
294
  }
276
295
  })();
277
- return K[a] = t, t;
296
+ return le[l] = t, t;
278
297
  }
279
- async function Ye(a, t, e = "") {
298
+ async function ot(l, t, e = "") {
280
299
  if (t == null || t === "")
281
300
  return e;
282
- const l = X[a];
283
- if (l && l.length > 0)
284
- return pe(l, t);
285
- const s = await ee(a);
286
- return s && s.length > 0 ? pe(s, t) : e || String(t);
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 pe(a, t) {
289
- const e = a.find(
290
- (l) => l.value === t || String(l.value) === String(t)
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
- const Qe = { class: "u-dict-field" }, Ge = /* @__PURE__ */ S({
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(a, { emit: t }) {
319
- const e = a, l = t, s = q({
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
- }), d = async () => {
359
+ }), r = async () => {
324
360
  if (e.dictType) {
325
- s.loading = !0;
361
+ c.loading = !0;
326
362
  try {
327
- const r = await R.get(z.dictApi(e.dictType));
328
- r.status === 200 ? s.options = ne(r.data) : (console.error("[UDict] 请求失败:", r.message), s.options = []);
329
- } catch (r) {
330
- console.error("[UDict] 加载字典失败:", r), s.options = [];
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
- s.loading = !1;
368
+ c.loading = !1;
333
369
  }
334
370
  }
335
371
  };
336
- M(() => e.dictType, () => {
337
- d();
372
+ z(() => e.dictType, () => {
373
+ r();
338
374
  }, { immediate: !0 });
339
- const o = g(() => {
340
- const r = {};
341
- return e.labelPosition === "left" && e.labelWidth && (r.width = typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth), e.labelAlign && (r.textAlign = e.labelAlign), r;
342
- }), c = g(() => ({
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
- })), n = {
346
- onUpdate(r) {
347
- l("update:modelValue", r);
381
+ })), a = {
382
+ onUpdate(n) {
383
+ o("update:modelValue", n);
348
384
  }
349
385
  };
350
- return (r, i) => {
351
- const u = oe, m = le;
352
- return f(), p("div", {
353
- class: V(["u-dict", c.value])
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
- a.fieldLabel ? (f(), p("div", {
391
+ l.fieldLabel ? (h(), y("div", {
356
392
  key: 0,
357
393
  class: "u-dict-label",
358
- style: I(o.value)
394
+ style: B(d.value)
359
395
  }, [
360
- U(P(a.fieldLabel) + " ", 1),
396
+ F(T(l.fieldLabel) + " ", 1),
361
397
  C("span", {
362
- class: V(["required-star", { "required-star--visible": a.required }])
398
+ class: V(["required-star", { "required-star--visible": l.required }])
363
399
  }, "*", 2)
364
- ], 4)) : T("", !0),
365
- C("div", Qe, [
366
- x(m, {
367
- "model-value": a.modelValue,
368
- placeholder: a.placeholder || "请选择",
369
- loading: s.loading,
370
- disabled: a.disable,
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: n.onUpdate
408
+ onChange: a.onUpdate
373
409
  }, {
374
- default: _(() => [
375
- (f(!0), p($, null, F(s.options, (y) => (f(), E(u, {
376
- key: y.value,
377
- label: y.label,
378
- value: y.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
- }), j = /* @__PURE__ */ D(Ge, [["__scopeId", "data-v-239bb25f"]]), Ke = { class: "u-toggle-field" }, He = /* @__PURE__ */ S({
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(a, { emit: t }) {
411
- const e = a, l = t, s = q({
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
- }), d = () => {
414
- const n = {};
415
- return e.labelPosition === "left" && e.labelWidth && (n.width = typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth), e.labelAlign && (n.textAlign = e.labelAlign), n;
416
- }, o = g({
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: (n) => {
419
- l("update:modelValue", n ? e.trueValue : e.falseValue);
454
+ set: (a) => {
455
+ o("update:modelValue", a ? e.trueValue : e.falseValue);
420
456
  }
421
- }), c = g(() => {
422
- const n = {};
423
- for (const r in e)
424
- !s.excluded.includes(r) && r !== "modelValue" && (n[r] = e[r]);
425
- return n;
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 (n, r) => {
428
- const i = Ee;
429
- return f(), p("div", {
430
- class: V(["u-toggle", { "u-toggle-label-left": a.labelPosition === "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
- a.fieldLabel ? (f(), p("div", {
468
+ l.fieldLabel ? (h(), y("div", {
433
469
  key: 0,
434
470
  class: "u-toggle-label",
435
- style: I(d())
471
+ style: B(r())
436
472
  }, [
437
- U(P(a.fieldLabel) + " ", 1),
473
+ F(T(l.fieldLabel) + " ", 1),
438
474
  C("span", {
439
- class: V(["required-star", { "required-star--visible": a.required }])
475
+ class: V(["required-star", { "required-star--visible": l.required }])
440
476
  }, "*", 2)
441
- ], 4)) : T("", !0),
442
- C("div", Ke, [
443
- x(i, ge({
444
- modelValue: o.value,
445
- "onUpdate:modelValue": r[0] || (r[0] = (u) => o.value = u)
446
- }, c.value, {
447
- "active-text": a.activeText,
448
- "inactive-text": a.inactiveText,
449
- "active-color": a.activeColor,
450
- "inactive-color": a.inactiveColor
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
- }), Ce = /* @__PURE__ */ D(He, [["__scopeId", "data-v-94c1fd38"]]), Je = { class: "u-cascader-levels" }, Xe = /* @__PURE__ */ S({
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(a, { emit: t }) {
470
- const e = a, l = t, s = () => {
471
- const n = {};
472
- return e.labelPosition === "left" && e.labelWidth && (n.width = typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth), e.labelAlign && (n.textAlign = e.labelAlign), n;
473
- }, d = L([]), o = g(() => {
474
- const n = [];
475
- let r = e.options || [];
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 (n.push(r), d.value[i] !== void 0) {
478
- const u = r.find((m) => m.value === d.value[i]);
479
- u && u.children ? r = u.children : r = [];
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
- r = [];
482
- return n;
517
+ n = [];
518
+ return a;
483
519
  });
484
- M(() => e.modelValue, (n) => {
485
- n != null ? d.value = Array.isArray(n) ? n : [n] : d.value = [];
520
+ z(() => e.modelValue, (a) => {
521
+ a != null ? r.value = Array.isArray(a) ? a : [a] : r.value = [];
486
522
  }, { immediate: !0 });
487
- const c = (n, r) => {
488
- d.value[n] = r;
489
- for (let u = n + 1; u < e.depth; u++)
490
- d.value[u] = void 0;
491
- const i = d.value.filter((u) => u !== void 0);
492
- l("update:modelValue", i);
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 (n, r) => {
495
- const i = oe, u = le;
496
- return f(), p("div", {
497
- class: V(["u-cascader", { "u-cascader-label-left": a.labelPosition === "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
- a.fieldLabel ? (f(), p("div", {
535
+ l.fieldLabel ? (h(), y("div", {
500
536
  key: 0,
501
537
  class: "u-cascader-label",
502
- style: I(s())
538
+ style: B(c())
503
539
  }, [
504
- U(P(a.fieldLabel) + " ", 1),
540
+ F(T(l.fieldLabel) + " ", 1),
505
541
  C("span", {
506
- class: V(["required-star", { "required-star--visible": a.required }])
542
+ class: V(["required-star", { "required-star--visible": l.required }])
507
543
  }, "*", 2)
508
- ], 4)) : T("", !0),
509
- C("div", Je, [
510
- (f(!0), p($, null, F(a.depth, (m) => (f(), p("div", {
511
- key: m - 1,
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
- x(u, {
515
- "model-value": d.value[m - 1],
516
- options: o.value[m - 1] || [],
517
- disabled: m > 1 && d.value[m - 2] === void 0,
518
- placeholder: `请选择${m}级`,
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: (y) => c(m - 1, y)
556
+ onChange: (u) => s(p - 1, u)
521
557
  }, {
522
- default: _(() => [
523
- (f(!0), p($, null, F(o.value[m - 1] || [], (y) => (f(), E(i, {
524
- key: y.value,
525
- label: y.label,
526
- value: y.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
- }), xe = /* @__PURE__ */ D(Xe, [["__scopeId", "data-v-d66c339c"]]), Ze = { class: "u-date-field" }, et = /* @__PURE__ */ S({
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(a, { emit: t }) {
553
- const e = a, l = t, s = () => {
554
- const n = {};
555
- return e.labelPosition === "left" && e.labelWidth && (n.width = typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth), e.labelAlign && (n.textAlign = e.labelAlign), n;
556
- }, d = L("");
557
- M(() => e.modelValue, (n) => {
558
- e.mode === "single" ? d.value = n || "" : e.mode === "multiple" ? d.value = Array.isArray(n) ? n : n ? [n] : [] : e.mode === "range" && (n && typeof n == "object" && n.from && n.to ? d.value = [n.from, n.to] : d.value = []);
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 o = (n) => {
561
- n && (e.mode === "single" || e.mode === "multiple" ? l("update:modelValue", n) : e.mode === "range" && n && n.length === 2 && l("update:modelValue", { from: n[0], to: n[1] }));
562
- }, c = g(() => e.mode === "range" ? "daterange" : e.mode === "multiple" ? "dates" : "date");
563
- return (n, r) => {
564
- const i = $e;
565
- return f(), p("div", {
566
- class: V(["u-date", { "u-date-label-left": a.labelPosition === "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
- a.fieldLabel ? (f(), p("div", {
604
+ l.fieldLabel ? (h(), y("div", {
569
605
  key: 0,
570
606
  class: "u-date-label",
571
- style: I(s())
607
+ style: B(c())
572
608
  }, [
573
- U(P(a.fieldLabel) + " ", 1),
609
+ F(T(l.fieldLabel) + " ", 1),
574
610
  C("span", {
575
- class: V(["required-star", { "required-star--visible": a.required }])
611
+ class: V(["required-star", { "required-star--visible": l.required }])
576
612
  }, "*", 2)
577
- ], 4)) : T("", !0),
578
- C("div", Ze, [
579
- x(i, {
580
- modelValue: d.value,
581
- "onUpdate:modelValue": r[0] || (r[0] = (u) => d.value = u),
582
- type: c.value,
583
- placeholder: a.locale === "en-US" ? "Select date" : "选择日期",
584
- "range-separator": a.locale === "en-US" ? "to" : "至",
585
- "start-placeholder": a.locale === "en-US" ? "Start date" : "开始日期",
586
- "end-placeholder": a.locale === "en-US" ? "End date" : "结束日期",
587
- format: a.mask.replace("YYYY", "YYYY").replace("MM", "MM").replace("DD", "DD"),
588
- "value-format": a.mask.replace("YYYY", "YYYY").replace("MM", "MM").replace("DD", "DD"),
589
- onChange: o
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
- }), te = /* @__PURE__ */ D(et, [["__scopeId", "data-v-9cd05064"]]), tt = {
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
- }, at = {
1019
+ }, St = {
599
1020
  key: 1,
600
1021
  class: "form-layout"
601
- }, lt = {
1022
+ }, kt = {
602
1023
  key: 0,
603
1024
  class: "form-header"
604
- }, ot = { class: "title" }, it = { class: "form-body" }, nt = {
1025
+ }, Tt = { class: "title" }, Dt = { class: "form-body" }, Vt = {
605
1026
  key: 1,
606
1027
  class: "form-footer"
607
- }, st = /* @__PURE__ */ S({
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(a, { emit: t }) {
617
- const e = a, l = t, { visible: s } = qe(e), d = g(() => e.layout.open === "normal"), o = g(() => e.layout.width || 400), c = {
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
- l("update:visible", !1), l("close");
1040
+ o("update:visible", !1), o("close");
620
1041
  },
621
- updateVisible(n) {
622
- l("update:visible", n);
1042
+ updateVisible(a) {
1043
+ o("update:visible", a);
623
1044
  }
624
1045
  };
625
- return (n, r) => {
626
- const i = Ue, u = Re;
627
- return d.value ? A(s) ? (f(), p("div", at, [
628
- a.title ? (f(), p("div", lt, [
629
- C("div", ot, P(a.title), 1)
630
- ])) : T("", !0),
631
- C("div", it, [
632
- a.loading ? (f(), E(i, {
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
- x(A(me))
1058
+ default: w(() => [
1059
+ _(L(Se))
639
1060
  ]),
640
1061
  _: 1
641
- })) : N(n.$slots, "default", {}, void 0, !0, 1)
1062
+ })) : D(a.$slots, "default", {}, void 0, !0, 1)
642
1063
  ]),
643
- n.$slots.actions ? (f(), p("div", nt, [
644
- N(n.$slots, "actions", {}, void 0, !0)
645
- ])) : T("", !0)
646
- ])) : T("", !0) : (f(), E(u, {
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": A(s),
649
- title: a.title,
650
- width: o.value,
1069
+ "model-value": L(c),
1070
+ title: l.title,
1071
+ width: d.value,
651
1072
  "close-on-click-modal": !1,
652
- "onUpdate:modelValue": c.updateVisible,
653
- onClose: c.handleClose
1073
+ "onUpdate:modelValue": s.updateVisible,
1074
+ onClose: s.handleClose
654
1075
  }, {
655
- footer: _(() => [
656
- N(n.$slots, "actions", {}, void 0, !0)
1076
+ footer: w(() => [
1077
+ D(a.$slots, "actions", {}, void 0, !0)
657
1078
  ]),
658
- default: _(() => [
659
- A(s) ? (f(), p("div", tt, [
660
- a.loading ? (f(), E(i, {
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
- x(A(me))
1086
+ default: w(() => [
1087
+ _(L(Se))
667
1088
  ]),
668
1089
  _: 1
669
- })) : N(n.$slots, "default", {}, void 0, !0, 1)
670
- ])) : T("", !0)
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
- }), rt = /* @__PURE__ */ D(st, [["__scopeId", "data-v-7e522999"]]), dt = /* @__PURE__ */ S({
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(a) {
683
- const t = a, e = q({
684
- columns: g(() => t.layout.columns || 1)
685
- }), l = {
686
- getColSpan(s) {
687
- const d = s.colSpan || 1;
688
- return Math.min(d, e.columns);
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 (s, d) => (f(), p("div", {
1112
+ return (c, r) => (h(), y("div", {
692
1113
  class: "form-grid",
693
- style: I({ "--grid-columns": e.columns })
1114
+ style: B({ "--grid-columns": e.columns })
694
1115
  }, [
695
- (f(!0), p($, null, F(a.fields, (o) => (f(), p("div", {
696
- key: o.field,
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: I({ gridColumn: `span ${l.getColSpan(o)}` })
1119
+ style: B({ gridColumn: `span ${o.getColSpan(d)}` })
699
1120
  }, [
700
- N(s.$slots, "default", { field: o }, void 0, !0)
1121
+ D(c.$slots, "default", { field: d }, void 0, !0)
701
1122
  ], 4))), 128))
702
1123
  ], 4));
703
1124
  }
704
- }), ct = /* @__PURE__ */ D(dt, [["__scopeId", "data-v-90ed35a4"]]), ut = { class: "form-field" }, ft = /* @__PURE__ */ S({
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(a, { emit: t }) {
715
- const e = a, l = t, s = q({
716
- componentMap: Me({
717
- input: Y,
718
- "input-number": be,
719
- dict: j,
720
- switch: Ce,
721
- cascader: xe,
722
- date: te
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
- M(() => e.field.cascaderKey, () => {
727
- e.field.cascaderKey && R.get(z.cascaderApi(e.field.cascaderKey)).then((i) => {
728
- i.status === 200 && (s.cascaderOptions = we(i.data));
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 o = g(() => s.componentMap[e.field.type] || Y), c = g(() => {
1152
+ const d = v(() => c.componentMap[e.field.type] || Z), s = v(() => {
732
1153
  if ((e.layout.labelPosition || "top") === "left") {
733
- const u = e.layout.labelWidth || 0, m = typeof u == "number" ? u + 4 : u;
734
- return { marginLeft: typeof m == "number" ? `${m}px` : m };
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
- }), n = g(() => {
738
- const { field: i, modelValue: u, layout: m, disabled: y } = e;
739
- let w = u;
740
- i.type === "switch" && u == null && (w = !1);
741
- const h = {
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: w,
744
- labelPosition: m.labelPosition || "top",
745
- disable: y,
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 (m.labelWidth && (h.labelWidth = m.labelWidth), m.labelAlign && (h.labelAlign = m.labelAlign), i.maxlength && (h.maxlength = i.maxlength), i.placeholder && (h.placeholder = i.placeholder), i.readonly && (h.readonly = i.readonly), i.lineCount && i.lineCount >= 2 ? (h.type = "textarea", h.rows = i.lineCount) : i.inputType && (h.type = i.inputType), i.type === "switch" && (i.activeText && (h.activeText = i.activeText), i.inactiveText && (h.inactiveText = i.inactiveText), i.activeColor && (h.activeColor = i.activeColor), i.inactiveColor && (h.inactiveColor = i.inactiveColor), i.trueValue !== void 0 && (h.trueValue = i.trueValue), i.falseValue !== void 0 && (h.falseValue = i.falseValue)), i.dictType && (h.dictType = i.dictType), i.cascaderKey && (h.options = s.cascaderOptions, h.depth = i.cascaderDepth || 2), i.type === "date") {
750
- i.mode && (h.mode = i.mode), i.locale && (h.locale = i.locale), i.format ? h.mask = i.format : i.mask && (h.mask = i.mask);
751
- const k = i.dateMin ?? i.min, b = i.dateMax ?? i.max;
752
- k != null && (h.min = k), b != null && (h.max = b);
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 && (h.min = i.min), i.max !== void 0 && (h.max = i.max), i.step && (h.step = i.step), i.precision !== void 0 && (h.precision = i.precision)), h;
755
- }), r = {
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
- l("update:modelValue", i);
1178
+ o("update:modelValue", i);
758
1179
  }
759
1180
  };
760
- return (i, u) => (f(), p("div", ut, [
761
- (f(), E(ie(o.value), ge(n.value, {
762
- "onUpdate:modelValue": r.handleUpdate
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": a.error }]),
766
- style: I(c.value)
767
- }, P(a.error || ""), 7)
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
- }), mt = /* @__PURE__ */ D(ft, [["__scopeId", "data-v-10299c8d"]]);
771
- class pt {
1191
+ }), Ut = /* @__PURE__ */ $(Et, [["__scopeId", "data-v-10299c8d"]]);
1192
+ class Mt {
772
1193
  constructor() {
773
- v(this, "formConfig", null);
774
- v(this, "formData", {});
775
- v(this, "loading", !1);
776
- v(this, "submitting", !1);
777
- v(this, "visible", !1);
778
- v(this, "isEditMode", !1);
779
- v(this, "errors", []);
780
- v(this, "currentQuery", {});
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 ht = class {
1204
+ let Bt = class {
784
1205
  constructor() {
785
1206
  // 响应式数据
786
- v(this, "data", q(new pt()));
1207
+ x(this, "data", W(new Mt()));
787
1208
  }
788
1209
  // 解析 query 字符串
789
1210
  parseQuery(t) {
790
1211
  if (!t) return {};
791
- const e = {}, l = t.split("&");
792
- for (const s of l) {
793
- const [d, o] = s.split("=");
794
- d && (e[d] = o || "");
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 R.get(z.formCfgApi(t));
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 l = e ? `${t}?${e}` : t, s = await R.get(l);
808
- if (s.status !== 200)
809
- throw new Error(s.message || "获取表单数据失败");
810
- return s.data;
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 R.post(t, e);
1235
+ return await I.post(t, e);
815
1236
  }
816
1237
  // 构建字段初始值
817
1238
  buildInitialData(t) {
818
1239
  const e = {};
819
- for (const l of t)
820
- l.default !== void 0 ? e[l.field] = l.default : e[l.field] = null;
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 l of t) {
833
- const s = this.data.formData[l.field];
834
- if (l.required && (s == null || s === "")) {
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: l.field,
837
- message: `${l.label}为必填项`
1257
+ field: o.field,
1258
+ message: `${o.label}为必填项`
838
1259
  });
839
1260
  continue;
840
1261
  }
841
- if (l.rules && l.rules.length > 0 && s) {
842
- for (const d of l.rules)
843
- if (d.pattern && !new RegExp(d.pattern).test(s)) {
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: l.field,
846
- message: d.message || `${l.label}格式不正确`
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((l) => l.field === t);
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 l = await this.fetchFormConfig(t);
868
- if (this.data.formConfig = l, this.data.isEditMode = this.checkIsEditMode(e || ""), this.data.formData = this.buildInitialData(l.fields), this.data.isEditMode && l.api.get && e) {
869
- const s = await this.fetchFormData(l.api.get, e), d = this.nestedToFlat(s);
870
- this.data.formData = { ...this.data.formData, ...d };
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 (l) {
873
- throw console.error("[FormRender] 打开表单失败:", l), this.data.visible = !1, l;
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 l = { ...this.data.formData };
888
- l = this.flattenToNested(l), this.data.isEditMode && this.data.currentQuery.id && (l.id = Number(this.data.currentQuery.id)), this.data.submitting = !0;
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 s = await this.submitForm(e, l);
891
- if (s.status === 200)
892
- return s.data;
893
- throw new Error(s.message || "提交失败");
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 l in t) {
906
- const s = t[l];
907
- if (l.includes(".")) {
908
- const d = l.split(".");
909
- let o = e;
910
- for (let c = 0; c < d.length - 1; c++) {
911
- const n = d[c];
912
- o[n] || (o[n] = {}), o = o[n];
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
- o[d[d.length - 1]] = s;
1335
+ d[r[r.length - 1]] = c;
915
1336
  } else
916
- e[l] = s;
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 l = {};
924
- for (const s in t) {
925
- const d = t[s], o = e ? `${e}.${s}` : s;
926
- d && typeof d == "object" && !Array.isArray(d) ? Object.keys(d).length === 2 && "from" in d && "to" in d ? l[o] = d : Object.assign(l, this.nestedToFlat(d, o)) : l[o] = d;
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 l;
1349
+ return o;
929
1350
  }
930
1351
  };
931
- function G(a, t = "info") {
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(a, { expose: t }) {
969
- const e = new ht(), l = L(null), s = q({
1354
+ setup(l, { expose: t }) {
1355
+ const e = new Bt(), o = Y(null), c = W({
970
1356
  currentQuery: {},
971
1357
  submitResolve: null
972
- }), d = g(() => {
973
- var y;
974
- const m = {};
975
- if (!e.data.isEditMode || !s.currentQuery) return m;
976
- for (const w of ((y = e.data.formConfig) == null ? void 0 : y.fields) || [])
977
- s.currentQuery[w.field] !== void 0 && (m[w.field] = !0);
978
- return m;
979
- }), o = g(() => {
980
- var m;
981
- return ((m = e.data.formConfig) == null ? void 0 : m.layout) || {
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
- }), c = g(() => {
988
- var m;
989
- return ((m = e.data.formConfig) == null ? void 0 : m.fields) || [];
990
- }), n = g(() => {
991
- var m, y;
992
- return ((y = (m = e.data.formConfig) == null ? void 0 : m.meta) == null ? void 0 : y.title) || "表单";
993
- }), r = g(() => o.value.buttonAlign || "right"), i = g(() => o.value.open === "normal"), u = {
994
- async showForm(m, y) {
995
- s.currentQuery = e.parseQuery(y || "");
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(m, y);
998
- } catch (w) {
999
- return B((w == null ? void 0 : w.message) || "打开表单失败"), null;
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((w) => {
1002
- s.submitResolve = w;
1387
+ return new Promise((g) => {
1388
+ c.submitResolve = g;
1003
1389
  });
1004
1390
  },
1005
1391
  async handleSubmit() {
1006
- var m, y;
1392
+ var p, u;
1007
1393
  try {
1008
- const w = await e.doSubmit(), h = ((y = (m = e.data.formConfig) == null ? void 0 : m.meta) == null ? void 0 : y.title) + "保存成功";
1009
- return W.success(h), s.submitResolve && (s.submitResolve(w), s.submitResolve = null), i.value || e.closeForm(), w;
1010
- } catch (w) {
1011
- return s.submitResolve && (s.submitResolve(null), s.submitResolve = null), w != null && w.message && w.message !== "请完善表单信息" && B(w.message), null;
1394
+ const g = await e.doSubmit(), m = ((u = (p = e.data.formConfig) == null ? void 0 : p.meta) == null ? void 0 : u.title) + "保存成功";
1395
+ return N.success(m), c.submitResolve && (c.submitResolve(g), c.submitResolve = null), i.value || e.closeForm(), g;
1396
+ } catch (g) {
1397
+ return c.submitResolve && (c.submitResolve(null), c.submitResolve = null), g != null && g.message && g.message !== "请完善表单信息" && U(g.message), null;
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(m) {
1019
- return e.getFieldError(m);
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: u.showForm
1027
- }), (m, y) => {
1028
- const w = Be, h = Q;
1029
- return f(), E(rt, {
1030
- visible: A(e).data.visible,
1031
- "onUpdate:visible": y[0] || (y[0] = (k) => A(e).data.visible = k),
1032
- layout: o.value,
1033
- title: n.value,
1034
- loading: A(e).data.loading,
1035
- onClose: u.handleClose
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", r.value === "right" ? "justify-end" : "justify-start"])
1430
+ class: V(["form-actions", n.value === "right" ? "justify-end" : "justify-start"])
1040
1431
  }, [
1041
- x(h, {
1042
- onClick: u.handleCancel
1432
+ _(m, {
1433
+ onClick: f.handleCancel
1043
1434
  }, {
1044
- default: _(() => [...y[1] || (y[1] = [
1045
- U("取消", -1)
1435
+ default: w(() => [...u[1] || (u[1] = [
1436
+ F("取消", -1)
1046
1437
  ])]),
1047
1438
  _: 1
1048
1439
  }, 8, ["onClick"]),
1049
- x(h, {
1440
+ _(m, {
1050
1441
  type: "primary",
1051
- loading: A(e).data.submitting,
1052
- onClick: u.handleSubmit
1442
+ loading: L(e).data.submitting,
1443
+ onClick: f.handleSubmit
1053
1444
  }, {
1054
- default: _(() => [...y[2] || (y[2] = [
1055
- U("提交", -1)
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
- x(w, {
1452
+ default: w(() => [
1453
+ _(g, {
1063
1454
  ref_key: "formRef",
1064
- ref: l,
1455
+ ref: o,
1065
1456
  class: "form-render",
1066
1457
  "label-position": "top"
1067
1458
  }, {
1068
- default: _(() => [
1069
- x(ct, {
1070
- fields: c.value,
1071
- layout: o.value
1459
+ default: w(() => [
1460
+ _(Rt, {
1461
+ fields: s.value,
1462
+ layout: d.value
1072
1463
  }, {
1073
- default: _(({ field: k }) => [
1074
- x(mt, {
1075
- modelValue: A(e).data.formData[k.field],
1076
- "onUpdate:modelValue": (b) => A(e).data.formData[k.field] = b,
1077
- field: k,
1078
- layout: o.value,
1079
- disabled: d.value[k.field],
1080
- error: u.getFieldError(k.field)
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
- }), _e = /* @__PURE__ */ D(wt, [["__scopeId", "data-v-378d04bd"]]);
1094
- class Ct {
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 l = {
1493
+ const o = {
1103
1494
  page: e.page,
1104
1495
  pageSize: e.pageSize,
1105
1496
  ...t
1106
- }, s = {};
1107
- for (const n in l) {
1108
- const r = l[n];
1109
- r !== "" && r !== null && r !== void 0 && (s[n] = r);
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 d = new URLSearchParams();
1112
- for (const n in s)
1113
- d.append(n, String(s[n]));
1114
- const o = `${this.config.api.list}${d.toString() ? "?" + d.toString() : ""}`, c = await R.get(o);
1115
- if (c.status === 200) {
1116
- const n = c.data;
1117
- return Array.isArray(n) ? { rows: n, total: n.length } : n || { rows: [], total: 0 };
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(c.message || "获取列表数据失败");
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", l = t[e], s = `${this.config.api.delete}?id=${l}`, d = await R.post(s);
1128
- if (d.status !== 200)
1129
- throw new Error(d.message || "删除失败");
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 R.post(this.config.api.delete, t);
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 l = (await R.post(this.config.api.export, t, {
1538
+ const o = (await I.post(this.config.api.export, t, {
1148
1539
  responseType: "blob"
1149
- })).data, s = window.URL.createObjectURL(l), d = document.createElement("a");
1150
- d.href = s, d.download = `export_${Date.now()}.xlsx`, d.click(), window.URL.revokeObjectURL(s);
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 R.get(`${this.config.api.import}/template`, {
1549
+ const e = (await I.get(`${this.config.api.import}/template`, {
1159
1550
  responseType: "blob"
1160
- })).data, l = window.URL.createObjectURL(e), s = document.createElement("a");
1161
- s.href = l, s.download = `template_${Date.now()}.xlsx`, s.click(), window.URL.revokeObjectURL(l);
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 l = await R.post(this.config.api.import, e, {
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 (l.status !== 200)
1177
- throw new Error(l.message || "导入失败");
1178
- return l.data;
1567
+ if (o.status !== 200)
1568
+ throw new Error(o.message || "导入失败");
1569
+ return o.data;
1179
1570
  }
1180
1571
  }
1181
- class xt {
1572
+ class zt {
1182
1573
  constructor() {
1183
- v(this, "tableConfig", null);
1184
- v(this, "rows", []);
1185
- v(this, "total", 0);
1186
- v(this, "loading", !1);
1187
- v(this, "searchParams", {});
1188
- v(this, "pagination", { page: 1, pageSize: 20 });
1189
- v(this, "selectedRows", []);
1190
- v(this, "detailVisible", !1);
1191
- v(this, "detailData", null);
1192
- v(this, "detailLoading", !1);
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 _t = class {
1590
+ let Nt = class {
1196
1591
  constructor() {
1197
1592
  // 响应式数据
1198
- v(this, "data", q(new xt()));
1593
+ x(this, "data", W(new zt()));
1199
1594
  // 数据服务
1200
- v(this, "dataService", null);
1595
+ x(this, "dataService", null);
1201
1596
  }
1202
1597
  /**
1203
1598
  * 加载表格配置
1204
1599
  */
1205
1600
  async loadConfig(t) {
1206
- var s;
1207
- const e = z.formCfgApi(t);
1601
+ var c;
1602
+ const e = Q.formCfgApi(t, "tables");
1208
1603
  console.log("load config url =", e);
1209
- const l = await R.get(e);
1210
- if (console.log("---"), l.status !== 200)
1211
- throw new Error(l.message || "获取表格配置失败");
1212
- this.data.tableConfig = l.data, this.dataService = new Ct(l.data), typeof console < "u" && console.log("[TableRender] loadConfig:", {
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: (s = this.data.tableConfig) == null ? void 0 : s.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 l;
1223
- const t = {}, e = ((l = this.data.tableConfig) == null ? void 0 : l.search) || [];
1224
- for (const s of e)
1225
- t[s.field] = "";
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
- async batchDelete() {
1275
- if (!this.dataService)
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
- updateSelection(t) {
1297
- this.data.selectedRows = t;
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
- * detail 配置必须包含 formId 或 position 才视为有效,避免空对象误判
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 !!(t && typeof t == "object" && (t.formId || t.position));
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
- showSelection() {
1370
- var e;
1371
- const t = (e = this.data.tableConfig) == null ? void 0 : e.toolbar;
1372
- return t ? t.some(
1373
- (l) => l.type === "edit" || l.type === "delete"
1374
- ) : !1;
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 t;
1395
- return ((t = this.data.tableConfig) == null ? void 0 : t.toolbar) || [];
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 t;
1402
- return (t = this.data.tableConfig) == null ? void 0 : t.actions;
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 St = { class: "table-search" }, Dt = { class: "search-fields" }, kt = { class: "search-actions" }, Tt = /* @__PURE__ */ S({
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(a, { emit: t }) {
1420
- const e = a, l = t, s = {
1421
- input: Y,
1422
- dict: j,
1423
- dept: j,
1424
- role: j,
1425
- date: te,
1426
- daterange: te
1427
- }, d = {
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(o) {
1430
- return s[o] || Y;
1923
+ getComponent(d) {
1924
+ return c[d] || Z;
1431
1925
  },
1432
1926
  // 更新搜索值
1433
- updateValue(o, c) {
1434
- const n = { ...e.modelValue, [o]: c };
1435
- l("update:modelValue", n);
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 o = {};
1440
- for (const c in e.modelValue) {
1441
- const n = e.modelValue[c];
1442
- o[c] = typeof n == "string" ? n.trim() : n;
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
- l("update:modelValue", o), l("search");
1938
+ o("update:modelValue", d), o("search");
1445
1939
  },
1446
1940
  // 重置
1447
1941
  handleReset() {
1448
- l("reset");
1942
+ o("reset");
1449
1943
  }
1450
1944
  };
1451
- return (o, c) => {
1452
- const n = Q;
1453
- return f(), p("div", St, [
1454
- C("div", Dt, [
1455
- (f(!0), p($, null, F(e.fields, (r) => (f(), p("div", {
1456
- key: r.field,
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
- (f(), E(ie(d.getComponent(r.type)), {
1460
- "model-value": e.modelValue[r.field],
1461
- "field-label": r.label,
1462
- "dict-type": r.dictType,
1463
- mode: r.type === "daterange" ? "range" : void 0,
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) => d.updateValue(r.field, 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", kt, [
1470
- x(n, {
1967
+ C("div", Ot, [
1968
+ _(a, {
1471
1969
  type: "primary",
1472
- onClick: d.handleSearch
1970
+ onClick: r.handleSearch
1473
1971
  }, {
1474
- default: _(() => [...c[0] || (c[0] = [
1475
- U("查询", -1)
1972
+ default: w(() => [...s[0] || (s[0] = [
1973
+ F("查询", -1)
1476
1974
  ])]),
1477
1975
  _: 1
1478
1976
  }, 8, ["onClick"]),
1479
- x(n, {
1480
- onClick: d.handleReset
1977
+ _(a, {
1978
+ onClick: r.handleReset
1481
1979
  }, {
1482
- default: _(() => [...c[1] || (c[1] = [
1483
- U("重置", -1)
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
- }), Vt = /* @__PURE__ */ D(Tt, [["__scopeId", "data-v-68dd4c13"]]), Pt = { class: "table-toolbar" }, Et = { class: "toolbar-left" }, $t = /* @__PURE__ */ S({
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
- toolbar: {},
1495
- actions: {},
1496
- formId: {},
1497
- apiDelete: {},
1498
- selectedCount: {}
1997
+ items: {},
1998
+ currentRow: {}
1499
1999
  },
1500
- emits: ["create", "import", "export", "batchEdit", "batchDelete", "custom"],
1501
- setup(a, { emit: t }) {
1502
- const e = a, l = t, s = g(() => ({
1503
- // 显示编辑按钮
1504
- showEdit: !!e.formId && (!e.actions || e.actions.edit !== !1),
1505
- // 显示删除按钮
1506
- showDelete: !!e.apiDelete && (!e.actions || e.actions.delete !== !1)
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
- isBuiltin(o) {
1510
- return typeof o == "string" || o.type !== void 0;
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
- getButtonText(o) {
1550
- const c = d.getButtonProps(o);
1551
- if (c.text) return c.text;
1552
- switch (c.type) {
1553
- case "create":
1554
- return "新增";
1555
- case "import":
1556
- return "导入";
1557
- case "export":
1558
- return "导出";
1559
- case "edit":
1560
- return "编辑";
1561
- case "delete":
1562
- return "删除";
1563
- default:
1564
- return "";
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
- getButtonIcon(o) {
1569
- return d.getButtonProps(o).icon;
2041
+ // 点击按钮:把 action 抛给父组件
2042
+ handleClick(s) {
2043
+ o("action", {
2044
+ action: s.action,
2045
+ item: s,
2046
+ row: e.currentRow
2047
+ });
1570
2048
  },
1571
- // 是否为主按钮
1572
- isPrimary(o) {
1573
- return d.getButtonProps(o).primary === !0;
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 (o, c) => {
1577
- const n = Q;
1578
- return f(), p("div", Pt, [
1579
- C("div", Et, [
1580
- (f(!0), p($, null, F(e.toolbar, (r, i) => (f(), p($, { key: i }, [
1581
- d.shouldShow(r) ? (f(), E(n, {
1582
- key: 0,
1583
- type: d.isPrimary(r) ? "primary" : "default",
1584
- disabled: d.isDisabled(r),
1585
- onClick: (u) => d.handleClick(r)
1586
- }, {
1587
- default: _(() => [
1588
- U(P(d.getButtonText(r)), 1)
1589
- ]),
1590
- _: 2
1591
- }, 1032, ["type", "disabled", "onClick"])) : T("", !0)
1592
- ], 64))), 128))
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
- }), Rt = /* @__PURE__ */ D($t, [["__scopeId", "data-v-a7c06f8c"]]), Ut = /* @__PURE__ */ S({
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(a) {
1605
- const t = a, e = g(() => t.modelValue === null || t.modelValue === void 0 ? "" : String(t.modelValue)), l = g(() => t.multiline || e.value.includes(`
1606
- `)), s = g(() => t.maxLines > 0 && l.value ? {
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 (d, o) => (f(), p("div", {
1614
- class: V(["u-input-show", { "u-input-multiline": l.value }]),
1615
- style: I(s.value)
1616
- }, P(e.value), 7));
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
- }), Bt = /* @__PURE__ */ D(Ut, [["__scopeId", "data-v-c78b151e"]]), At = /* @__PURE__ */ S({
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(a) {
1626
- const t = a, e = L(""), l = L(!1), s = async () => {
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
- l.value = !0;
2132
+ o.value = !0;
1636
2133
  try {
1637
- const d = await Ye(t.dictType, t.modelValue, t.defaultText);
1638
- e.value = d;
1639
- } catch (d) {
1640
- console.error("[UDictShow] 翻译失败:", d), e.value = String(t.modelValue);
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
- l.value = !1;
2139
+ o.value = !1;
1643
2140
  }
1644
2141
  };
1645
- return M(() => t.modelValue, s, { immediate: !0 }), M(() => t.dictType, () => {
1646
- t.dictType && ee(t.dictType).then(() => s());
1647
- }), Z(() => {
1648
- t.dictType ? ee(t.dictType).then(() => s()) : s();
1649
- }), (d, o) => (f(), p("div", {
1650
- class: V(["u-dict-show", { "u-dict-loading": l.value }])
1651
- }, P(e.value), 3));
1652
- }
1653
- }), It = /* @__PURE__ */ D(At, [["__scopeId", "data-v-908045c4"]]), Ft = /* @__PURE__ */ S({
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(a) {
1662
- const t = a, e = g(() => t.useYesNo ? "是" : t.trueText), l = g(() => t.useYesNo ? "否" : t.falseText), s = g(() => t.modelValue === !0 || t.modelValue === "true" ? e.value : t.modelValue === !1 || t.modelValue === "false" ? l.value : String(t.modelValue ?? "")), d = g(() => t.modelValue === !0 || t.modelValue === "true" ? "toggle-true" : t.modelValue === !1 || t.modelValue === "false" ? "toggle-false" : "toggle-default");
1663
- return (o, c) => (f(), p("div", {
1664
- class: V(["u-toggle-show", d.value])
1665
- }, P(s.value), 3));
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
- }), Lt = /* @__PURE__ */ D(Ft, [["__scopeId", "data-v-bac05efc"]]), qt = /* @__PURE__ */ S({
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(a) {
1676
- const t = a, e = L(""), l = L(!1), s = async () => {
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 d = t.modelValue;
2178
+ const r = t.modelValue;
1682
2179
  if (t.cascaderKey) {
1683
- l.value = !0;
2180
+ o.value = !0;
1684
2181
  try {
1685
- const o = await ee(t.cascaderKey), n = d.map((r) => {
1686
- const i = o.find((u) => u.value === r || String(u.value) === String(r));
1687
- return i ? i.label : t.showRawValue ? String(r) : "";
1688
- }).filter((r) => r !== "");
1689
- e.value = n.join(t.separator);
1690
- } catch (o) {
1691
- console.error("[UCascaderShow] 翻译失败:", o), e.value = t.showRawValue ? d.join(t.separator) : "";
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
- l.value = !1;
2190
+ o.value = !1;
1694
2191
  }
1695
2192
  } else
1696
- e.value = d.join(t.separator);
2193
+ e.value = r.join(t.separator);
1697
2194
  };
1698
- return M(() => t.modelValue, s, { immediate: !0 }), Z(() => {
1699
- s();
1700
- }), (d, o) => (f(), p("div", {
1701
- class: V(["u-cascader-show", { "u-cascader-loading": l.value }])
1702
- }, P(e.value), 3));
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
- }), Mt = /* @__PURE__ */ D(qt, [["__scopeId", "data-v-5d84df67"]]), Wt = /* @__PURE__ */ S({
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(a) {
1715
- const t = a, e = g(() => t.locale === "en-US" ? t.mode === "range" ? " - " : ", " : t.mode === "range" ? t.rangeSeparator : t.separator), l = g(() => {
1716
- const o = t.modelValue;
1717
- return t.mode === "single" ? o ? s(o, t.format) : "" : t.mode === "multiple" ? o ? Array.isArray(o) ? o.map((c) => s(c, t.format)).join(e.value) : String(o) : "" : t.mode === "range" ? o ? typeof o == "object" && o.from && o.to ? `${s(o.from, t.format)}${e.value}${s(o.to, t.format)}` : Array.isArray(o) && o.length >= 2 ? `${s(o[0], t.format)}${e.value}${s(o[1], t.format)}` : String(o) : "" : String(o ?? "");
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 s(o, c) {
1720
- return o || "";
2216
+ function c(d, s) {
2217
+ return d || "";
1721
2218
  }
1722
- const d = g(() => !l.value);
1723
- return (o, c) => (f(), p("div", {
1724
- class: V(["u-date-show", { "u-date-empty": d.value }])
1725
- }, P(l.value || (a.locale === "en-US" ? "Empty" : "暂无")), 3));
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
- }), zt = /* @__PURE__ */ D(Wt, [["__scopeId", "data-v-930657df"]]), Nt = /* @__PURE__ */ S({
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(a) {
1745
- const t = a, e = g(() => {
2241
+ setup(l) {
2242
+ const t = l, e = v(() => {
1746
2243
  if (!t.text) return null;
1747
- const o = t.text.split("/");
1748
- return o.length >= 2 ? {
1749
- trueText: o[0].trim(),
1750
- falseText: o[1].trim()
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
- }), l = g(() => {
1753
- var o;
1754
- return t.trueText || ((o = e.value) == null ? void 0 : o.trueText) || "开启";
1755
- }), s = g(() => {
1756
- var o;
1757
- return t.falseText || ((o = e.value) == null ? void 0 : o.falseText) || "关闭";
1758
- }), d = g(() => {
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 (o, c) => (f(), E(ie(d.value === "UDictShow" ? It : d.value === "UToggleShow" ? Lt : d.value === "UCascaderShow" ? Mt : d.value === "UDateShow" ? zt : Bt), {
1775
- "model-value": a.modelValue,
1776
- "dict-type": a.type === "dict" ? a.dictType : void 0,
1777
- "cascader-key": a.type === "cascader" ? a.cascaderKey : void 0,
1778
- mode: a.type === "date" ? a.mode : void 0,
1779
- locale: a.type === "date" ? a.locale : void 0,
1780
- format: a.type === "date" ? a.format : void 0,
1781
- "true-text": a.type === "switch" ? l.value : void 0,
1782
- "false-text": a.type === "switch" ? s.value : void 0,
1783
- "use-yes-no": a.type === "switch" ? a.useYesNo : void 0,
1784
- multiline: a.type === "input" || a.type === "text" ? a.multiline : void 0,
1785
- "default-text": a.type === "dict" ? a.defaultText : void 0
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
- }), se = /* @__PURE__ */ D(Nt, [["__scopeId", "data-v-fedb54d7"]]), Ot = { class: "table-grid" }, jt = /* @__PURE__ */ S({
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: ["selectionChange", "rowEdit", "rowDelete", "rowClick"],
1802
- setup(a, { emit: t }) {
1803
- const e = a, l = t, s = g(() => e.formId && (!e.actions || e.actions.edit !== !1)), d = g(() => e.apiDelete && (!e.actions || e.actions.delete !== !1)), o = g(() => {
1804
- var i;
1805
- return ((i = e.actions) == null ? void 0 : i.edit) || "编辑";
1806
- }), c = g(() => {
1807
- var i;
1808
- return ((i = e.actions) == null ? void 0 : i.delete) || "删除";
1809
- }), n = g(() => {
1810
- const i = e.columns.map((u) => {
1811
- const m = {
1812
- prop: u.field,
1813
- label: u.label
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 u.width == "number" && (m.width = u.width), m;
2316
+ return typeof n.width == "number" && (i.width = n.width), i;
1816
2317
  });
1817
- return (s.value || d.value) && i.push({
2318
+ return r.value.actionList.length > 0 && a.push({
1818
2319
  prop: "actions",
1819
2320
  label: "操作",
1820
- width: 120,
2321
+ width: r.value.actionColumnWidth,
1821
2322
  fixed: "right"
1822
- }), i;
1823
- }), r = {
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(i) {
1826
- return !i || i.length < 7 ? i : i.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
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(i) {
1830
- return !i || i.length < 8 ? i : i.replace(/(\d{3})\d{11}(\d{4})/, "$1***********$2");
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(i) {
1834
- const u = Number(i);
1835
- return isNaN(u) ? String(i) : u.toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
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(i, u) {
1839
- if (!i)
2364
+ formatByType(a, n) {
2365
+ if (!a)
1840
2366
  return "";
1841
- switch (u) {
2367
+ switch (n) {
1842
2368
  case "phone":
1843
- return r.maskPhone(i);
2369
+ return s.maskPhone(a);
1844
2370
  case "idcard":
1845
- return r.maskIdCard(i);
2371
+ return s.maskIdCard(a);
1846
2372
  case "money":
1847
- return r.formatMoney(i);
2373
+ return s.formatMoney(a);
1848
2374
  case "percent":
1849
- return String(i * 100) + "%";
2375
+ return String(a * 100) + "%";
1850
2376
  default:
1851
- return u && u.includes("{}") ? u.replace("{}", String(i)) : String(i);
2377
+ return n && n.includes("{}") ? n.replace("{}", String(a)) : String(a);
1852
2378
  }
1853
2379
  },
1854
2380
  // 获取嵌套字段值
1855
- getNestedValue(i, u) {
1856
- if (!u.includes("."))
1857
- return i[u];
1858
- const m = u.split(".");
1859
- let y = i;
1860
- for (const w of m)
1861
- if (y && typeof y == "object" && w in y)
1862
- y = y[w];
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 y;
2391
+ return f;
1866
2392
  },
1867
2393
  // 判断是否需要使用 UFieldView 组件
1868
- useFieldView(i) {
1869
- return i.type ? ["dict", "switch", "cascader", "date", "input", "text"].includes(i.type) : !1;
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(i) {
1873
- l("selectionChange", i);
2404
+ onSelectionChange(a) {
2405
+ c("selectionChange", a);
1874
2406
  },
1875
2407
  // 行点击
1876
- onRowClick(i) {
1877
- l("rowClick", i);
1878
- },
1879
- // 编辑
1880
- onRowEdit(i) {
1881
- l("rowEdit", i);
2408
+ onRowClick(a) {
2409
+ c("rowClick", a);
1882
2410
  },
1883
- // 删除
1884
- onRowDelete(i) {
1885
- l("rowDelete", i);
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 (i, u) => {
1889
- const m = Ie, y = Q, w = Ae;
1890
- return f(), p("div", Ot, [
1891
- x(w, {
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
- onSelectionChange: r.onSelectionChange,
1896
- onRowClick: u[0] || (u[0] = (h) => r.onRowClick(h)),
1897
- stripe: "",
1898
- border: ""
1899
- }, {
1900
- empty: _(() => [...u[1] || (u[1] = [
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
- })) : T("", !0),
1909
- (f(!0), p($, null, F(n.value, (h) => (f(), E(m, {
1910
- key: h.prop,
1911
- prop: h.prop,
1912
- label: h.label,
1913
- width: h.width,
1914
- fixed: h.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: _(({ row: k }) => [
1917
- h.prop === "actions" ? (f(), p($, { key: 0 }, [
1918
- Object.keys(k).length > 0 ? (f(), p($, { key: 0 }, [
1919
- s.value ? (f(), E(y, {
1920
- key: 0,
1921
- link: "",
1922
- type: "primary",
1923
- size: "small",
1924
- onClick: fe((b) => r.onRowEdit(k), ["stop"])
1925
- }, {
1926
- default: _(() => [
1927
- U(P(o.value), 1)
1928
- ]),
1929
- _: 1
1930
- }, 8, ["onClick"])) : T("", !0),
1931
- d.value ? (f(), E(y, {
1932
- key: 1,
1933
- link: "",
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
- b.field === h.prop && r.useFieldView(b) ? (f(), E(se, {
2463
+ m.field === u.prop && s.useFieldView(m) ? (h(), S(be, {
1949
2464
  key: 0,
1950
- type: b.type,
1951
- "model-value": r.getNestedValue(k, b.field),
1952
- "dict-type": b.dictType,
1953
- mode: b.mode,
1954
- locale: b.locale,
1955
- format: b.format,
1956
- text: b.text,
1957
- "true-text": b.trueText,
1958
- "false-text": b.falseText,
1959
- "use-yes-no": b.useYesNo,
1960
- "cascader-key": b.cascaderKey,
1961
- multiline: b.multiline,
1962
- "default-text": b.defaultText
1963
- }, null, 8, ["type", "model-value", "dict-type", "mode", "locale", "format", "text", "true-text", "false-text", "use-yes-no", "cascader-key", "multiline", "default-text"])) : b.field === h.prop ? (f(), p("span", {
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": b.format })
1966
- }, P(r.formatByType(r.getNestedValue(k, b.field), b.format || "")), 3)) : T("", !0)
1967
- ], 64))), 128)) : T("", !0)
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
- _: 1
1974
- }, 8, ["data", "loading", "row-key", "onSelectionChange"])
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
- }), Yt = /* @__PURE__ */ D(jt, [["__scopeId", "data-v-60cb7136"]]), Qt = { class: "table-pagination" }, Gt = { class: "page-size-select" }, Kt = { class: "total-text" }, Ht = {
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
- }, Jt = {
2511
+ }, ga = {
1982
2512
  key: 2,
1983
2513
  class: "total-text"
1984
- }, Xt = /* @__PURE__ */ S({
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(a, { emit: t }) {
1994
- const e = a, l = t, s = g(() => ({
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
- })), d = {
2529
+ })), r = {
2000
2530
  // 页码变化
2001
- onPageChange: (o) => {
2002
- l("update:page", o);
2531
+ onPageChange: (d) => {
2532
+ o("update:page", d);
2003
2533
  },
2004
2534
  // 每页条数变化
2005
- onPageSizeChange: (o) => {
2006
- l("update:pageSize", o);
2535
+ onPageSizeChange: (d) => {
2536
+ o("update:pageSize", d);
2007
2537
  }
2008
2538
  };
2009
- return (o, c) => {
2010
- const n = Fe, r = oe, i = le, u = Q;
2011
- return f(), p("div", Qt, [
2012
- s.value.showPagination ? (f(), p($, { key: 0 }, [
2013
- x(n, {
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": s.value.totalPages,
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: d.onPageChange,
2020
- onSizeChange: d.onPageSizeChange
2549
+ onCurrentChange: r.onPageChange,
2550
+ onSizeChange: r.onPageSizeChange
2021
2551
  }, null, 8, ["current-page", "page-count", "page-size", "onCurrentChange", "onSizeChange"]),
2022
- C("div", Gt, [
2023
- x(i, {
2552
+ C("div", ma, [
2553
+ _(i, {
2024
2554
  "model-value": e.pageSize,
2025
2555
  style: { width: "100px" },
2026
- onChange: d.onPageSizeChange
2556
+ onChange: r.onPageSizeChange
2027
2557
  }, {
2028
- default: _(() => [
2029
- x(r, {
2558
+ default: w(() => [
2559
+ _(n, {
2030
2560
  value: 10,
2031
2561
  label: "10条/页"
2032
2562
  }),
2033
- x(r, {
2563
+ _(n, {
2034
2564
  value: 20,
2035
2565
  label: "20条/页"
2036
2566
  }),
2037
- x(r, {
2567
+ _(n, {
2038
2568
  value: 50,
2039
2569
  label: "50条/页"
2040
2570
  }),
2041
- x(r, {
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", Kt, "共 " + P(e.total) + " 条", 1)
2578
+ C("span", pa, "共 " + T(e.total) + " 条", 1)
2049
2579
  ])
2050
- ], 64)) : e.type === "auto" ? (f(), p("div", Ht, [
2051
- x(u, {
2580
+ ], 64)) : e.type === "auto" ? (h(), y("div", ha, [
2581
+ _(f, {
2052
2582
  disabled: e.page * e.pageSize >= e.total
2053
2583
  }, {
2054
- default: _(() => [...c[0] || (c[0] = [
2055
- U("加载更多", -1)
2584
+ default: w(() => [...s[0] || (s[0] = [
2585
+ F("加载更多", -1)
2056
2586
  ])]),
2057
2587
  _: 1
2058
2588
  }, 8, ["disabled"])
2059
- ])) : e.type === "all" ? (f(), p("div", Jt, "共 " + P(e.total) + " 条", 1)) : T("", !0)
2589
+ ])) : e.type === "all" ? (h(), y("div", ga, "共 " + T(e.total) + " 条", 1)) : k("", !0)
2060
2590
  ]);
2061
2591
  };
2062
2592
  }
2063
- }), Zt = /* @__PURE__ */ D(Xt, [["__scopeId", "data-v-53e593aa"]]), ea = { class: "detail-header" }, ta = { class: "detail-title" }, aa = { class: "table-detail" }, la = {
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: "loading"
2066
- }, oa = {
2598
+ class: "detail-status"
2599
+ }, Sa = {
2067
2600
  key: 1,
2068
2601
  class: "detail-content"
2069
- }, ia = { class: "detail-label" }, na = { class: "detail-value" }, sa = {
2602
+ }, ka = { class: "detail-label" }, Ta = { class: "detail-value" }, Da = {
2070
2603
  key: 2,
2071
- class: "no-data"
2072
- }, ra = /* @__PURE__ */ S({
2604
+ class: "detail-status"
2605
+ }, Va = /* @__PURE__ */ P({
2073
2606
  __name: "TableDetail",
2074
2607
  props: {
2075
- visible: { type: Boolean },
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
- emits: ["close"],
2083
- setup(a, { emit: t }) {
2084
- const e = a, l = t, s = g(() => ({
2085
- // el-drawer 位置
2086
- direction: {
2087
- left: "ltr",
2088
- right: "rtl",
2089
- top: "ttb"
2090
- }[e.position || "right"] || "rtl"
2091
- })), d = (o, c) => {
2092
- if (!o || !c) return "";
2093
- if (!c.includes("."))
2094
- return o[c];
2095
- const n = c.split(".");
2096
- let r = o;
2097
- for (const i of n)
2098
- if (r && typeof r == "object" && i in r)
2099
- r = r[i];
2100
- else
2101
- return "";
2102
- return r;
2103
- };
2104
- return (o, c) => {
2105
- const n = Le;
2106
- return f(), E(n, {
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
- }), da = /* @__PURE__ */ D(ra, [["__scopeId", "data-v-ee569603"]]), ca = { class: "table-render" }, ua = { class: "table-body" }, fa = { class: "table-container" }, ma = /* @__PURE__ */ S({
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
- setup(a, { expose: t }) {
2158
- const e = a, l = new _t(), s = L(null), d = q({
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
- Z(async () => {
2169
- e.formId && await c.loadConfig(e.formId);
2695
+ te(async () => {
2696
+ c.formId && await p.loadConfig(c.formId);
2170
2697
  });
2171
- const o = g(() => ({
2698
+ const f = v(() => ({
2172
2699
  // 表格配置
2173
- tableConfig: l.data.tableConfig,
2700
+ tableConfig: a.data.tableConfig,
2174
2701
  // 表格数据
2175
- rows: l.data.rows,
2702
+ rows: a.data.rows,
2176
2703
  // 总数
2177
- total: l.data.total,
2704
+ total: a.data.total,
2178
2705
  // 加载状态
2179
- loading: l.data.loading,
2706
+ loading: a.data.loading,
2180
2707
  // 分页信息
2181
- pagination: l.data.pagination,
2182
- // 选中行
2183
- selectedRows: l.data.selectedRows,
2184
- // 搜索字段
2185
- searchFields: l.getSearchFields(),
2708
+ pagination: a.data.pagination,
2709
+ // 搜索字段 / 是否有搜索区(没有 search 节点就不显示)
2710
+ searchFields: a.getSearchFields(),
2711
+ hasSearch: a.hasSearch(),
2186
2712
  // 列定义
2187
- columns: l.getColumns(),
2188
- // 工具栏
2189
- toolbar: l.getToolbar(),
2190
- // 行操作
2191
- actions: l.getActions(),
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: l.hasDetail(),
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: l.data.detailVisible,
2733
+ detailVisible: a.data.detailVisible,
2196
2734
  // 详情数据
2197
- detailData: l.data.detailData,
2735
+ detailData: a.data.detailData,
2198
2736
  // 详情加载状态
2199
- detailLoading: l.data.detailLoading,
2200
- // 选择模式
2201
- selectionMode: l.showSelection() ? "multiple" : void 0,
2737
+ detailLoading: a.data.detailLoading,
2738
+ // 预览抽屉(action: preview 触发)
2739
+ previewVisible: a.data.previewVisible,
2740
+ previewRow: a.data.previewRow,
2202
2741
  // 字典数据
2203
- dictData: d.dictData
2204
- })), c = {
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(n) {
2207
- console.log("loadConfig", n);
2759
+ async loadConfig(u) {
2208
2760
  try {
2209
- await l.loadConfig(n);
2210
- } catch (r) {
2211
- B((r == null ? void 0 : r.message) || "获取表格配置失败");
2761
+ await a.loadConfig(u);
2762
+ } catch (g) {
2763
+ U((g == null ? void 0 : g.message) || "获取表格配置失败");
2212
2764
  return;
2213
2765
  }
2214
- d.searchParams = { ...l.data.searchParams }, d.loaded = !0, await c.loadDictData(), await c.handleLoadData();
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 l.loadData();
2220
- } catch (n) {
2221
- B((n == null ? void 0 : n.message) || "加载数据失败");
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 n = l.getColumns(), r = /* @__PURE__ */ new Set();
2227
- for (const i of n)
2228
- i.type === "dict" && i.dictType && r.add(i.dictType);
2229
- for (const i of r)
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 u = await R.get(z.dictApi(i));
2232
- u.status === 200 && (d.dictData[i] = ne(u.data));
2233
- } catch (u) {
2234
- console.error(`[TableRender] 加载字典 ${i} 失败:`, u);
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
- l.data.searchParams = { ...d.searchParams };
2791
+ a.data.searchParams = { ...i.searchParams };
2240
2792
  try {
2241
- await l.search();
2242
- } catch (n) {
2243
- B((n == null ? void 0 : n.message) || "查询失败");
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
- d.searchParams = {};
2800
+ i.searchParams = {};
2249
2801
  try {
2250
- await l.reset();
2251
- } catch (n) {
2252
- B((n == null ? void 0 : n.message) || "重置失败");
2802
+ await a.reset();
2803
+ } catch (u) {
2804
+ U((u == null ? void 0 : u.message) || "重置失败");
2253
2805
  }
2254
2806
  },
2255
2807
  // 更新搜索参数
2256
- updateSearchParam(n, r) {
2257
- d.searchParams[n] = r;
2808
+ updateSearchParam(u, g) {
2809
+ i.searchParams[u] = g;
2258
2810
  },
2259
- // 选择变化
2260
- handleSelectionChange(n) {
2261
- l.updateSelection(n);
2262
- },
2263
- // 新增
2264
- async handleCreate() {
2265
- var r;
2266
- const n = l.getFormId();
2267
- n && s.value && await ((r = s.value) == null ? void 0 : r.showForm(n)) != null && await c.handleLoadData();
2268
- },
2269
- // 编辑(批量)
2270
- async handleBatchEdit() {
2271
- if (o.value.selectedRows.length !== 1) {
2272
- W.warning("请选择一行数据进行编辑");
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
- await c.handleRowEdit(o.value.selectedRows[0]);
2276
- },
2277
- // 编辑(行)
2278
- async handleRowEdit(n) {
2279
- var i, u;
2280
- const r = l.getFormId();
2281
- if (r && s.value) {
2282
- const m = l.getKeyField();
2283
- await ((i = s.value) == null ? void 0 : i.showForm(r, `${m}=${n[m]}`)) != null && (await c.handleLoadData(), o.value.detailVisible && ((u = l.data.detailData) == null ? void 0 : u[m]) === n[m] && await l.openDetail(n));
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 handleBatchDelete() {
2288
- try {
2289
- await ue.confirm(
2290
- `确定要删除选中的 ${o.value.selectedRows.length} 条数据吗?`,
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 handleRowDelete(n) {
2907
+ // 删除:二次确认后删除目标行
2908
+ async handleDelete(u, g) {
2909
+ if (!u) {
2910
+ N.warning("请先点击表格中的一行数据");
2911
+ return;
2912
+ }
2308
2913
  try {
2309
- await ue.confirm(
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 l.exportData(), W.success("导出成功");
2330
- } catch (n) {
2331
- B((n == null ? void 0 : n.message) || "导出失败");
2935
+ await a.exportData(), N.success("导出成功");
2936
+ } catch (u) {
2937
+ U((u == null ? void 0 : u.message) || "导出失败");
2332
2938
  }
2333
2939
  },
2334
- // 导入
2335
- handleImport() {
2336
- W.info("导入功能开发中");
2337
- },
2338
- // 分页变化
2339
- async handlePageChange(n) {
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 l.changePage(n);
2342
- } catch (r) {
2343
- B((r == null ? void 0 : r.message) || "加载数据失败");
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 l.changePageSize(n);
2350
- } catch (r) {
2351
- B((r == null ? void 0 : r.message) || "加载数据失败");
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 Z(() => {
2364
- }), t({
2365
- loadConfig: c.loadConfig
2366
- }), (n, r) => {
2367
- var i, u, m, y, w, h, k, b, re, de, ce;
2368
- return f(), p("div", ca, [
2369
- o.value.searchFields.length > 0 ? (f(), E(Vt, {
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: o.value.searchFields,
2372
- modelValue: d.searchParams,
2373
- "onUpdate:modelValue": r[0] || (r[0] = (Se) => d.searchParams = Se),
2374
- onSearch: c.handleSearch,
2375
- onReset: c.handleReset
2376
- }, null, 8, ["fields", "modelValue", "onSearch", "onReset"])) : T("", !0),
2377
- C("div", ua, [
2378
- C("div", fa, [
2379
- x(Yt, {
2380
- rows: o.value.rows,
2381
- columns: o.value.columns,
2382
- loading: o.value.loading,
2383
- actions: o.value.actions,
2384
- "form-id": (i = o.value.tableConfig) == null ? void 0 : i.form,
2385
- "api-delete": (u = o.value.tableConfig) == null ? void 0 : u.api.delete,
2386
- "key-field": (m = o.value.tableConfig) == null ? void 0 : m.key,
2387
- selection: o.value.selectionMode,
2388
- "dict-data": o.value.dictData,
2389
- onSelectionChange: c.handleSelectionChange,
2390
- onRowEdit: c.handleRowEdit,
2391
- onRowDelete: c.handleRowDelete,
2392
- onRowClick: c.handleRowClick
2393
- }, null, 8, ["rows", "columns", "loading", "actions", "form-id", "api-delete", "key-field", "selection", "dict-data", "onSelectionChange", "onRowEdit", "onRowDelete", "onRowClick"]),
2394
- x(Zt, {
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: o.value.pagination.page,
2397
- "page-size": o.value.pagination.pageSize,
2398
- total: o.value.total,
2399
- type: (y = o.value.tableConfig) == null ? void 0 : y.pagination,
2400
- "onUpdate:page": c.handlePageChange,
2401
- "onUpdate:pageSize": c.handlePageSizeChange
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
- o.value.showDetail ? (f(), E(da, {
3021
+ f.value.showDetail && f.value.detailMode === "inline" ? (h(), S(de, {
2405
3022
  key: 0,
2406
- visible: o.value.detailVisible,
2407
- loading: o.value.detailLoading,
2408
- position: (h = (w = o.value.tableConfig) == null ? void 0 : w.detail) == null ? void 0 : h.position,
2409
- title: (b = (k = o.value.tableConfig) == null ? void 0 : k.meta) == null ? void 0 : b.title,
2410
- "row-data": o.value.detailData,
2411
- columns: o.value.columns,
2412
- onClose: c.handleDetailClose
2413
- }, null, 8, ["visible", "loading", "position", "title", "row-data", "columns", "onClose"])) : T("", !0)
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
- o.value.toolbar.length > 0 || (re = o.value.tableConfig) != null && re.form ? (f(), E(Rt, {
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
- toolbar: o.value.toolbar,
2419
- actions: o.value.actions,
2420
- "form-id": (de = o.value.tableConfig) == null ? void 0 : de.form,
2421
- "api-delete": (ce = o.value.tableConfig) == null ? void 0 : ce.api.delete,
2422
- "selected-count": o.value.selectedRows.length,
2423
- onCreate: c.handleCreate,
2424
- onImport: c.handleImport,
2425
- onExport: c.handleExport,
2426
- onBatchEdit: c.handleBatchEdit,
2427
- onBatchDelete: c.handleBatchDelete
2428
- }, null, 8, ["toolbar", "actions", "form-id", "api-delete", "selected-count", "onCreate", "onImport", "onExport", "onBatchEdit", "onBatchDelete"])) : T("", !0),
2429
- x(_e, {
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: s
3099
+ ref: n
2432
3100
  }, null, 512)
2433
- ]);
3101
+ ], 6);
2434
3102
  };
2435
3103
  }
2436
- }), pa = /* @__PURE__ */ D(ma, [["__scopeId", "data-v-91132dca"]]);
2437
- class ha {
3104
+ }), Ra = /* @__PURE__ */ $(Aa, [["__scopeId", "data-v-124fd940"]]);
3105
+ class Ia {
2438
3106
  constructor(t) {
2439
- v(this, "axiosInstance");
2440
- v(this, "baseUrl", "");
2441
- this.axiosInstance = ye.create({
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 ga {
3154
+ class Ea {
2487
3155
  //事件总线
2488
3156
  constructor() {
2489
- v(this, "emitter");
2490
- this.emitter = We();
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 ya {
3170
+ class Ua {
2503
3171
  constructor(t, e) {
2504
- v(this, "mqttClient", null);
2505
- v(this, "eventBus");
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 l = t.mqttUrl || "ws://127.0.0.1:5002/ws";
2519
- if (console.log("connect to mqtt..."), this.mqttClient = ze.connect(l, e), !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(ae, { qos: 0 }, (s) => {
2525
- console.log(s ? `mqtt subscribe [${ae}] failed` : `mqtt subscribe [${ae}] success`);
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", (s, d) => {
2528
- const o = d.toString();
2529
- if (!o) {
2530
- console.error("Received empty message", s);
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 c = null;
3201
+ let s = null;
2534
3202
  try {
2535
- c = JSON.parse(o);
2536
- } catch (n) {
2537
- console.error("Failed to parse message JSON", s, o, n);
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 (!c || c.Content === void 0 || c.Content === null || !c.PType) {
2541
- console.log("parse notice failed!", o);
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
- c.PType == ba && this.eventBus.Emit(c.Route, c.Content);
2545
- }), this.mqttClient.on(H.OffLine, () => {
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(H.Reconnect, () => {
3215
+ }), this.mqttClient.on(oe.Reconnect, () => {
2548
3216
  console.log("mqtt reconnecting...");
2549
- }), this.mqttClient.on(H.Close, () => {
3217
+ }), this.mqttClient.on(oe.Close, () => {
2550
3218
  console.log("mqtt close");
2551
- }), this.mqttClient.on(H.Error, (s) => {
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 l = "";
2559
- for (let s = 0; s < t; s++)
2560
- l += e.charAt(Math.floor(Math.random() * e.length));
2561
- return l;
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 ae = "Notice", ba = "NOTICE", H = {
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 J;
2571
- const Qa = (a) => {
2572
- if (!a)
3238
+ let ne;
3239
+ const vl = (l) => {
3240
+ if (!l)
2573
3241
  throw new Error("QfOptions is undefined");
2574
- if (!J && a && (J = new va(a)), !J)
3242
+ if (!ne && l && (ne = new Ba(l)), !ne)
2575
3243
  throw new Error("Qf not initialized, please call GetQf(options) first");
2576
- return J;
3244
+ return ne;
2577
3245
  };
2578
- class va {
3246
+ class Ba {
2579
3247
  constructor(t) {
2580
- v(this, "EventBus");
2581
- v(this, "WebApi");
2582
- v(this, "Mqtt");
2583
- v(this, "options");
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 ga(), this.WebApi = new ha(t), this.options.useMqtt && (this.Mqtt = new ya(this.EventBus, t));
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 wa = {
2626
- UInput: Y,
2627
- UInputNumber: be,
2628
- UDict: j,
2629
- UToggle: Ce,
2630
- UCascader: xe,
2631
- UDate: te,
2632
- FormRender: _e,
2633
- TableRender: pa,
2634
- UFieldView: se
2635
- }, Ga = {
2636
- install(a) {
2637
- a.use(Te);
2638
- for (const [t, e] of Object.entries(wa))
2639
- a.component(t, e);
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
- _e as FormRender,
2644
- Qa as GetQf,
2645
- pa as TableRender,
2646
- xe as UCascader,
2647
- te as UDate,
2648
- j as UDict,
2649
- se as UFieldView,
2650
- Y as UInput,
2651
- be as UInputNumber,
2652
- Ce as UToggle,
2653
- Ga as default,
2654
- W as notify,
2655
- G as notifyUtil
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
  };