xto-fronted 0.4.88 → 0.4.90

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.
@@ -0,0 +1,515 @@
1
+ import { defineComponent as R, ref as f, reactive as z, computed as j, onMounted as K, openBlock as h, createElementBlock as y, createElementVNode as e, createVNode as a, unref as l, withCtx as o, withKeys as G, createTextVNode as m, toDisplayString as u, Fragment as A, renderList as N, createBlock as J, normalizeClass as Q } from "vue";
2
+ import { Form as S, FormItem as c, Input as x, Select as W, Switch as U } from "@xto/form";
3
+ import { Tag as X, Pagination as Y } from "@xto/data";
4
+ import { Popconfirm as Z, Modal as ee, Message as C } from "@xto/feedback";
5
+ import { Space as D, Button as g } from "@xto/base";
6
+ import { S as d, a as te, _ as le } from "./index-A_B_Ap_A.js";
7
+ const se = { class: "user-page" }, ae = { class: "search-section" }, oe = { class: "table-section" }, ne = { class: "table-toolbar" }, ie = { class: "toolbar-left" }, de = { class: "toolbar-right" }, re = { class: "table-count" }, ue = { class: "table-wrapper" }, me = { class: "data-table" }, ce = { key: 0 }, pe = { key: 1 }, ve = { class: "col-id" }, fe = { class: "id-badge" }, he = { class: "col-user" }, ge = { class: "user-info" }, ke = { class: "user-avatar" }, _e = { class: "user-detail" }, ye = { class: "user-nickname" }, xe = { class: "user-username" }, Ve = { class: "col-contact" }, be = { class: "contact-info" }, Ee = { class: "contact-email" }, Be = { class: "contact-phone" }, Ce = { class: "col-roles" }, De = { class: "role-tags" }, Le = { class: "col-status" }, we = { class: "status-switch" }, ze = { class: "col-time" }, Ae = { class: "time-text" }, Ne = { class: "col-actions" }, Se = { class: "pagination-wrapper" }, Ue = { class: "status-field" }, Me = { class: "status-label" }, Te = /* @__PURE__ */ R({
8
+ __name: "index",
9
+ setup(Ie) {
10
+ const M = [
11
+ { id: 1, username: "admin", nickname: "管理员", email: "admin@example.com", phone: "13800138001", status: d.ENABLED, roles: ["admin"], createTime: "2024-01-01 10:00:00" },
12
+ { id: 2, username: "zhangsan", nickname: "张三", email: "zhangsan@example.com", phone: "13800138002", status: d.ENABLED, roles: ["editor"], createTime: "2024-01-02 10:00:00" },
13
+ { id: 3, username: "lisi", nickname: "李四", email: "lisi@example.com", phone: "13800138003", status: d.DISABLED, roles: ["viewer"], createTime: "2024-01-03 10:00:00" },
14
+ { id: 4, username: "wangwu", nickname: "王五", email: "wangwu@example.com", phone: "13800138004", status: d.ENABLED, roles: ["editor"], createTime: "2024-01-04 10:00:00" },
15
+ { id: 5, username: "zhaoliu", nickname: "赵六", email: "zhaoliu@example.com", phone: "13800138005", status: d.ENABLED, roles: ["viewer"], createTime: "2024-01-05 10:00:00" }
16
+ ], b = f(!1), E = f([]), B = f(0), k = f(1), V = f(10), r = z({
17
+ keyword: "",
18
+ status: void 0
19
+ }), _ = f(!1), T = j(() => n.id ? "编辑用户" : "新增用户"), n = z({
20
+ id: 0,
21
+ username: "",
22
+ nickname: "",
23
+ email: "",
24
+ phone: "",
25
+ status: d.ENABLED,
26
+ roles: []
27
+ }), I = {
28
+ username: [
29
+ { required: !0, message: "请输入用户名", trigger: "blur" }
30
+ ],
31
+ nickname: [
32
+ { required: !0, message: "请输入昵称", trigger: "blur" }
33
+ ],
34
+ email: [
35
+ { required: !0, message: "请输入邮箱", trigger: "blur" },
36
+ { type: "email", message: "请输入正确的邮箱格式", trigger: "blur" }
37
+ ]
38
+ }, L = f(), p = () => {
39
+ b.value = !0, setTimeout(() => {
40
+ let i = [...M];
41
+ r.keyword && (i = i.filter(
42
+ (t) => t.username.includes(r.keyword) || t.nickname.includes(r.keyword)
43
+ )), r.status !== void 0 && (i = i.filter((t) => t.status === r.status)), B.value = i.length, E.value = i.slice((k.value - 1) * V.value, k.value * V.value), b.value = !1;
44
+ }, 300);
45
+ }, w = () => {
46
+ k.value = 1, p();
47
+ }, H = () => {
48
+ r.keyword = "", r.status = void 0, k.value = 1, p();
49
+ }, $ = () => {
50
+ Object.assign(n, {
51
+ id: 0,
52
+ username: "",
53
+ nickname: "",
54
+ email: "",
55
+ phone: "",
56
+ status: d.ENABLED,
57
+ roles: []
58
+ }), _.value = !0;
59
+ }, F = (i) => {
60
+ Object.assign(n, i), _.value = !0;
61
+ }, P = (i) => {
62
+ C.success("删除成功"), p();
63
+ }, q = async () => {
64
+ var i;
65
+ try {
66
+ await ((i = L.value) == null ? void 0 : i.validate()), C.success(n.id ? "编辑成功" : "新增成功"), _.value = !1, p();
67
+ } catch (t) {
68
+ console.error(t);
69
+ }
70
+ }, O = (i) => {
71
+ C.success(`已${i.status === d.ENABLED ? "启用" : "禁用"}用户 ${i.username}`);
72
+ };
73
+ return K(() => {
74
+ p();
75
+ }), (i, t) => (h(), y("div", se, [
76
+ e("div", ae, [
77
+ a(l(S), {
78
+ model: r,
79
+ inline: "",
80
+ class: "search-form"
81
+ }, {
82
+ default: o(() => [
83
+ a(l(c), { label: "关键词" }, {
84
+ default: o(() => [
85
+ a(l(x), {
86
+ modelValue: r.keyword,
87
+ "onUpdate:modelValue": t[0] || (t[0] = (s) => r.keyword = s),
88
+ placeholder: "用户名/昵称",
89
+ clearable: "",
90
+ onKeyup: G(w, ["enter"])
91
+ }, null, 8, ["modelValue"])
92
+ ]),
93
+ _: 1
94
+ }),
95
+ a(l(c), { label: "状态" }, {
96
+ default: o(() => [
97
+ a(l(W), {
98
+ modelValue: r.status,
99
+ "onUpdate:modelValue": t[1] || (t[1] = (s) => r.status = s),
100
+ options: l(te),
101
+ placeholder: "请选择",
102
+ clearable: ""
103
+ }, null, 8, ["modelValue", "options"])
104
+ ]),
105
+ _: 1
106
+ }),
107
+ a(l(c), null, {
108
+ default: o(() => [
109
+ a(l(D), null, {
110
+ default: o(() => [
111
+ a(l(g), {
112
+ type: "primary",
113
+ onClick: w
114
+ }, {
115
+ icon: o(() => [...t[11] || (t[11] = [
116
+ e("svg", {
117
+ viewBox: "0 0 24 24",
118
+ fill: "none",
119
+ stroke: "currentColor",
120
+ "stroke-width": "2"
121
+ }, [
122
+ e("circle", {
123
+ cx: "11",
124
+ cy: "11",
125
+ r: "8"
126
+ }),
127
+ e("path", { d: "M21 21l-4.35-4.35" })
128
+ ], -1)
129
+ ])]),
130
+ default: o(() => [
131
+ t[12] || (t[12] = m(" 搜索 ", -1))
132
+ ]),
133
+ _: 1
134
+ }),
135
+ a(l(g), { onClick: H }, {
136
+ icon: o(() => [...t[13] || (t[13] = [
137
+ e("svg", {
138
+ viewBox: "0 0 24 24",
139
+ fill: "none",
140
+ stroke: "currentColor",
141
+ "stroke-width": "2"
142
+ }, [
143
+ e("path", { d: "M3 12a9 9 0 109-9 9.75 9.75 0 00-6.74 2.74L3 8" }),
144
+ e("path", { d: "M3 3v5h5" })
145
+ ], -1)
146
+ ])]),
147
+ default: o(() => [
148
+ t[14] || (t[14] = m(" 重置 ", -1))
149
+ ]),
150
+ _: 1
151
+ })
152
+ ]),
153
+ _: 1
154
+ })
155
+ ]),
156
+ _: 1
157
+ })
158
+ ]),
159
+ _: 1
160
+ }, 8, ["model"])
161
+ ]),
162
+ e("div", oe, [
163
+ e("div", ne, [
164
+ e("div", ie, [
165
+ a(l(g), {
166
+ type: "primary",
167
+ onClick: $
168
+ }, {
169
+ icon: o(() => [...t[15] || (t[15] = [
170
+ e("svg", {
171
+ viewBox: "0 0 24 24",
172
+ fill: "none",
173
+ stroke: "currentColor",
174
+ "stroke-width": "2"
175
+ }, [
176
+ e("line", {
177
+ x1: "12",
178
+ y1: "5",
179
+ x2: "12",
180
+ y2: "19"
181
+ }),
182
+ e("line", {
183
+ x1: "5",
184
+ y1: "12",
185
+ x2: "19",
186
+ y2: "12"
187
+ })
188
+ ], -1)
189
+ ])]),
190
+ default: o(() => [
191
+ t[16] || (t[16] = m(" 新增用户 ", -1))
192
+ ]),
193
+ _: 1
194
+ })
195
+ ]),
196
+ e("div", de, [
197
+ e("span", re, "共 " + u(B.value) + " 条数据", 1)
198
+ ])
199
+ ]),
200
+ e("div", ue, [
201
+ e("table", me, [
202
+ t[23] || (t[23] = e("thead", null, [
203
+ e("tr", null, [
204
+ e("th", { class: "col-id" }, "ID"),
205
+ e("th", { class: "col-user" }, "用户信息"),
206
+ e("th", { class: "col-contact" }, "联系方式"),
207
+ e("th", { class: "col-roles" }, "角色"),
208
+ e("th", { class: "col-status" }, "状态"),
209
+ e("th", { class: "col-time" }, "创建时间"),
210
+ e("th", { class: "col-actions" }, "操作")
211
+ ])
212
+ ], -1)),
213
+ e("tbody", null, [
214
+ b.value ? (h(), y("tr", ce, [...t[17] || (t[17] = [
215
+ e("td", {
216
+ colspan: "7",
217
+ class: "loading-cell"
218
+ }, [
219
+ e("div", { class: "loading-content" }, [
220
+ e("div", { class: "loading-spinner" }),
221
+ e("span", null, "加载中...")
222
+ ])
223
+ ], -1)
224
+ ])])) : E.value.length === 0 ? (h(), y("tr", pe, [...t[18] || (t[18] = [
225
+ e("td", {
226
+ colspan: "7",
227
+ class: "empty-cell"
228
+ }, [
229
+ e("div", { class: "empty-content" }, [
230
+ e("svg", {
231
+ viewBox: "0 0 64 41",
232
+ fill: "none"
233
+ }, [
234
+ e("g", { transform: "translate(0 1)" }, [
235
+ e("ellipse", {
236
+ fill: "#f5f5f5",
237
+ cx: "32",
238
+ cy: "33",
239
+ rx: "32",
240
+ ry: "7"
241
+ }),
242
+ e("g", {
243
+ stroke: "var(--color-text-placeholder)",
244
+ "stroke-width": "2"
245
+ }, [
246
+ e("path", { d: "M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z" }),
247
+ e("path", {
248
+ d: "M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35H11.95C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z",
249
+ fill: "var(--color-fill)"
250
+ })
251
+ ])
252
+ ])
253
+ ]),
254
+ e("span", null, "暂无数据")
255
+ ])
256
+ ], -1)
257
+ ])])) : (h(!0), y(A, { key: 2 }, N(E.value, (s) => (h(), y("tr", {
258
+ key: s.id,
259
+ class: "data-row"
260
+ }, [
261
+ e("td", ve, [
262
+ e("span", fe, u(s.id), 1)
263
+ ]),
264
+ e("td", he, [
265
+ e("div", ge, [
266
+ e("div", ke, u(s.nickname.charAt(0)), 1),
267
+ e("div", _e, [
268
+ e("span", ye, u(s.nickname), 1),
269
+ e("span", xe, "@" + u(s.username), 1)
270
+ ])
271
+ ])
272
+ ]),
273
+ e("td", Ve, [
274
+ e("div", be, [
275
+ e("span", Ee, u(s.email), 1),
276
+ e("span", Be, u(s.phone), 1)
277
+ ])
278
+ ]),
279
+ e("td", Ce, [
280
+ e("div", De, [
281
+ (h(!0), y(A, null, N(s.roles, (v) => (h(), J(l(X), {
282
+ key: v,
283
+ size: "small",
284
+ type: v === "admin" ? "primary" : "info"
285
+ }, {
286
+ default: o(() => [
287
+ m(u(v), 1)
288
+ ]),
289
+ _: 2
290
+ }, 1032, ["type"]))), 128))
291
+ ])
292
+ ]),
293
+ e("td", Le, [
294
+ e("div", we, [
295
+ a(l(U), {
296
+ "model-value": s.status === l(d).ENABLED,
297
+ "onUpdate:modelValue": (v) => {
298
+ s.status = v ? l(d).ENABLED : l(d).DISABLED, O(s);
299
+ }
300
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
301
+ e("span", {
302
+ class: Q(["status-text", { enabled: s.status === l(d).ENABLED }])
303
+ }, u(s.status === l(d).ENABLED ? "已启用" : "已禁用"), 3)
304
+ ])
305
+ ]),
306
+ e("td", ze, [
307
+ e("span", Ae, u(s.createTime), 1)
308
+ ]),
309
+ e("td", Ne, [
310
+ a(l(D), { class: "action-buttons" }, {
311
+ default: o(() => [
312
+ a(l(g), {
313
+ type: "primary",
314
+ link: "",
315
+ size: "small",
316
+ onClick: (v) => F(s)
317
+ }, {
318
+ icon: o(() => [...t[19] || (t[19] = [
319
+ e("svg", {
320
+ viewBox: "0 0 24 24",
321
+ fill: "none",
322
+ stroke: "currentColor",
323
+ "stroke-width": "2"
324
+ }, [
325
+ e("path", { d: "M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7" }),
326
+ e("path", { d: "M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z" })
327
+ ], -1)
328
+ ])]),
329
+ default: o(() => [
330
+ t[20] || (t[20] = m(" 编辑 ", -1))
331
+ ]),
332
+ _: 1
333
+ }, 8, ["onClick"]),
334
+ a(l(Z), {
335
+ title: "确定删除该用户吗?",
336
+ onConfirm: (v) => P(s.id)
337
+ }, {
338
+ default: o(() => [
339
+ a(l(g), {
340
+ type: "danger",
341
+ link: "",
342
+ size: "small"
343
+ }, {
344
+ icon: o(() => [...t[21] || (t[21] = [
345
+ e("svg", {
346
+ viewBox: "0 0 24 24",
347
+ fill: "none",
348
+ stroke: "currentColor",
349
+ "stroke-width": "2"
350
+ }, [
351
+ e("polyline", { points: "3,6 5,6 21,6" }),
352
+ e("path", { d: "M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2" }),
353
+ e("line", {
354
+ x1: "10",
355
+ y1: "11",
356
+ x2: "10",
357
+ y2: "17"
358
+ }),
359
+ e("line", {
360
+ x1: "14",
361
+ y1: "11",
362
+ x2: "14",
363
+ y2: "17"
364
+ })
365
+ ], -1)
366
+ ])]),
367
+ default: o(() => [
368
+ t[22] || (t[22] = m(" 删除 ", -1))
369
+ ]),
370
+ _: 1
371
+ })
372
+ ]),
373
+ _: 1
374
+ }, 8, ["onConfirm"])
375
+ ]),
376
+ _: 2
377
+ }, 1024)
378
+ ])
379
+ ]))), 128))
380
+ ])
381
+ ])
382
+ ]),
383
+ e("div", Se, [
384
+ a(l(Y), {
385
+ "current-page": k.value,
386
+ "onUpdate:currentPage": t[2] || (t[2] = (s) => k.value = s),
387
+ "page-size": V.value,
388
+ "onUpdate:pageSize": t[3] || (t[3] = (s) => V.value = s),
389
+ total: B.value,
390
+ "page-sizes": [10, 20, 50, 100],
391
+ layout: "total, sizes, prev, pager, next",
392
+ onCurrentChange: p,
393
+ onSizeChange: p
394
+ }, null, 8, ["current-page", "page-size", "total"])
395
+ ])
396
+ ]),
397
+ a(l(ee), {
398
+ modelValue: _.value,
399
+ "onUpdate:modelValue": t[10] || (t[10] = (s) => _.value = s),
400
+ title: T.value,
401
+ width: "520px",
402
+ class: "user-modal"
403
+ }, {
404
+ footer: o(() => [
405
+ a(l(D), null, {
406
+ default: o(() => [
407
+ a(l(g), {
408
+ onClick: t[9] || (t[9] = (s) => _.value = !1)
409
+ }, {
410
+ default: o(() => [...t[24] || (t[24] = [
411
+ m("取消", -1)
412
+ ])]),
413
+ _: 1
414
+ }),
415
+ a(l(g), {
416
+ type: "primary",
417
+ onClick: q
418
+ }, {
419
+ default: o(() => [...t[25] || (t[25] = [
420
+ m("确定", -1)
421
+ ])]),
422
+ _: 1
423
+ })
424
+ ]),
425
+ _: 1
426
+ })
427
+ ]),
428
+ default: o(() => [
429
+ a(l(S), {
430
+ ref_key: "formRef",
431
+ ref: L,
432
+ model: n,
433
+ rules: I,
434
+ "label-width": "80px",
435
+ class: "user-form"
436
+ }, {
437
+ default: o(() => [
438
+ a(l(c), {
439
+ label: "用户名",
440
+ prop: "username"
441
+ }, {
442
+ default: o(() => [
443
+ a(l(x), {
444
+ modelValue: n.username,
445
+ "onUpdate:modelValue": t[4] || (t[4] = (s) => n.username = s),
446
+ placeholder: "请输入用户名"
447
+ }, null, 8, ["modelValue"])
448
+ ]),
449
+ _: 1
450
+ }),
451
+ a(l(c), {
452
+ label: "昵称",
453
+ prop: "nickname"
454
+ }, {
455
+ default: o(() => [
456
+ a(l(x), {
457
+ modelValue: n.nickname,
458
+ "onUpdate:modelValue": t[5] || (t[5] = (s) => n.nickname = s),
459
+ placeholder: "请输入昵称"
460
+ }, null, 8, ["modelValue"])
461
+ ]),
462
+ _: 1
463
+ }),
464
+ a(l(c), {
465
+ label: "邮箱",
466
+ prop: "email"
467
+ }, {
468
+ default: o(() => [
469
+ a(l(x), {
470
+ modelValue: n.email,
471
+ "onUpdate:modelValue": t[6] || (t[6] = (s) => n.email = s),
472
+ placeholder: "请输入邮箱"
473
+ }, null, 8, ["modelValue"])
474
+ ]),
475
+ _: 1
476
+ }),
477
+ a(l(c), {
478
+ label: "手机号",
479
+ prop: "phone"
480
+ }, {
481
+ default: o(() => [
482
+ a(l(x), {
483
+ modelValue: n.phone,
484
+ "onUpdate:modelValue": t[7] || (t[7] = (s) => n.phone = s),
485
+ placeholder: "请输入手机号"
486
+ }, null, 8, ["modelValue"])
487
+ ]),
488
+ _: 1
489
+ }),
490
+ a(l(c), { label: "状态" }, {
491
+ default: o(() => [
492
+ e("div", Ue, [
493
+ a(l(U), {
494
+ modelValue: n.status,
495
+ "onUpdate:modelValue": t[8] || (t[8] = (s) => n.status = s),
496
+ "active-value": l(d).ENABLED,
497
+ "inactive-value": l(d).DISABLED
498
+ }, null, 8, ["modelValue", "active-value", "inactive-value"]),
499
+ e("span", Me, u(n.status === l(d).ENABLED ? "启用" : "禁用"), 1)
500
+ ])
501
+ ]),
502
+ _: 1
503
+ })
504
+ ]),
505
+ _: 1
506
+ }, 8, ["model"])
507
+ ]),
508
+ _: 1
509
+ }, 8, ["modelValue", "title"])
510
+ ]));
511
+ }
512
+ }), Re = /* @__PURE__ */ le(Te, [["__scopeId", "data-v-da50b35c"]]);
513
+ export {
514
+ Re as default
515
+ };