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