c-admin-kit 1.0.0
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 +232 -0
- package/dist/c-admin-kit.css +1 -0
- package/dist/c-admin-kit.js +2482 -0
- package/dist/c-admin-kit.umd.cjs +10 -0
- package/dist/components/AsyncButton/index.vue.d.ts +48 -0
- package/dist/components/CollapsibleContainer/index.vue.d.ts +73 -0
- package/dist/components/CustomDrawer/index.vue.d.ts +149 -0
- package/dist/components/ImagePreview/index.vue.d.ts +34 -0
- package/dist/components/SearchBox/index.vue.d.ts +122 -0
- package/dist/components/SelectWithAll/index.vue.d.ts +169 -0
- package/dist/components/SelectWithPage/index.vue.d.ts +78 -0
- package/dist/components/SimpleTable/index.vue.d.ts +337 -0
- package/dist/components/SimpleTable/useTableColumnConfig.d.ts +5 -0
- package/dist/components/diff/index.vue.d.ts +33 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/composables/index.d.ts +6 -0
- package/dist/composables/useConfirmAction.d.ts +5 -0
- package/dist/composables/useConfirmSubmit.d.ts +5 -0
- package/dist/composables/useDialog.d.ts +5 -0
- package/dist/composables/useDownload.d.ts +5 -0
- package/dist/composables/useForm.d.ts +5 -0
- package/dist/composables/useListPage.d.ts +5 -0
- package/dist/index.d.ts +9 -0
- package/dist/types.d.ts +282 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/scroll-to.d.ts +7 -0
- package/dist/utils/searchFieldFactory.d.ts +34 -0
- package/dist/utils/treeManager.d.ts +64 -0
- package/dist/utils/validate.d.ts +30 -0
- package/package.json +86 -0
- package/src/components/AsyncButton/index.vue +58 -0
- package/src/components/CollapsibleContainer/index.vue +240 -0
- package/src/components/CustomDrawer/index.vue +167 -0
- package/src/components/ImagePreview/index.vue +88 -0
- package/src/components/SearchBox/index.vue +582 -0
- package/src/components/SelectWithAll/index.vue +281 -0
- package/src/components/SelectWithPage/index.vue +204 -0
- package/src/components/SimpleTable/index.vue +781 -0
- package/src/components/SimpleTable/useTableColumnConfig.ts +139 -0
- package/src/components/diff/index.vue +265 -0
- package/src/components/index.ts +35 -0
- package/src/composables/index.ts +6 -0
- package/src/composables/useConfirmAction.ts +62 -0
- package/src/composables/useConfirmSubmit.ts +68 -0
- package/src/composables/useDialog.ts +48 -0
- package/src/composables/useDownload.ts +83 -0
- package/src/composables/useForm.ts +114 -0
- package/src/composables/useListPage.ts +243 -0
- package/src/env.d.ts +7 -0
- package/src/index.ts +44 -0
- package/src/types.ts +344 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/scroll-to.ts +60 -0
- package/src/utils/searchFieldFactory.ts +302 -0
- package/src/utils/treeManager.ts +218 -0
- package/src/utils/validate.ts +64 -0
|
@@ -0,0 +1,2482 @@
|
|
|
1
|
+
import { defineComponent as me, ref as P, computed as q, resolveComponent as K, openBlock as x, createBlock as z, mergeProps as de, withCtx as A, renderSlot as ie, watch as fe, onMounted as ke, onBeforeUnmount as Fe, createVNode as H, withModifiers as Ue, createTextVNode as ae, toDisplayString as oe, createCommentVNode as re, createElementBlock as U, Fragment as ue, renderList as pe, createElementVNode as Q, unref as ee, useCssVars as Me, reactive as $e, normalizeClass as xe, resolveDynamicComponent as Re, withKeys as qe, withDirectives as Ee, vShow as Ze, createSlots as Le, nextTick as ge, onUnmounted as Je, resolveDirective as Ve, isRef as Xe } from "vue";
|
|
2
|
+
import { Loading as Qe, ArrowUp as Ge, ArrowDown as et, Expand as tt, Fold as at, Setting as lt, Rank as nt, PictureFilled as ot } from "@element-plus/icons-vue";
|
|
3
|
+
import rt from "sortablejs";
|
|
4
|
+
import Be from "dayjs";
|
|
5
|
+
import { ElMessage as X, ElMessageBox as _e } from "element-plus";
|
|
6
|
+
const st = /* @__PURE__ */ me({
|
|
7
|
+
name: "CAsyncButton",
|
|
8
|
+
__name: "index",
|
|
9
|
+
props: {
|
|
10
|
+
/** 接收一个可能是异步的点击处理函数,返回 Promise 时自动开启 loading */
|
|
11
|
+
onClick: {
|
|
12
|
+
type: Function,
|
|
13
|
+
default: null
|
|
14
|
+
},
|
|
15
|
+
/** 手动强制 loading,优先级最高 */
|
|
16
|
+
loading: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: !1
|
|
19
|
+
},
|
|
20
|
+
disabled: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: !1
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
setup(e) {
|
|
26
|
+
const o = e, a = P(!1), t = q(() => o.loading || a.value), s = q(() => o.disabled || t.value);
|
|
27
|
+
async function i(l) {
|
|
28
|
+
if (!o.onClick || s.value) return;
|
|
29
|
+
const p = o.onClick(l);
|
|
30
|
+
if (p && typeof p.then == "function") {
|
|
31
|
+
a.value = !0;
|
|
32
|
+
try {
|
|
33
|
+
await p;
|
|
34
|
+
} finally {
|
|
35
|
+
a.value = !1;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return (l, p) => {
|
|
40
|
+
const d = K("el-button");
|
|
41
|
+
return x(), z(d, de(l.$attrs, {
|
|
42
|
+
loading: t.value,
|
|
43
|
+
disabled: s.value,
|
|
44
|
+
onClick: i
|
|
45
|
+
}), {
|
|
46
|
+
default: A(() => [
|
|
47
|
+
ie(l.$slots, "default")
|
|
48
|
+
]),
|
|
49
|
+
_: 3
|
|
50
|
+
}, 16, ["loading", "disabled"]);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}), it = { class: "empty-text" }, De = "__SELECT_ALL__", ut = /* @__PURE__ */ me({
|
|
54
|
+
name: "CSelectWithAll",
|
|
55
|
+
__name: "index",
|
|
56
|
+
props: {
|
|
57
|
+
modelValue: {
|
|
58
|
+
type: Array,
|
|
59
|
+
default: () => []
|
|
60
|
+
},
|
|
61
|
+
options: {
|
|
62
|
+
type: Array,
|
|
63
|
+
default: () => []
|
|
64
|
+
},
|
|
65
|
+
// 是否显示全选选项
|
|
66
|
+
showSelectAll: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
default: !0
|
|
69
|
+
},
|
|
70
|
+
// 全选文本
|
|
71
|
+
selectAllLabel: {
|
|
72
|
+
type: String,
|
|
73
|
+
default: "全选"
|
|
74
|
+
},
|
|
75
|
+
// 占位符
|
|
76
|
+
placeholder: {
|
|
77
|
+
type: String,
|
|
78
|
+
default: "请选择"
|
|
79
|
+
},
|
|
80
|
+
// 选项的标签字段名
|
|
81
|
+
labelKey: {
|
|
82
|
+
type: String,
|
|
83
|
+
default: "label"
|
|
84
|
+
},
|
|
85
|
+
// 选项的值字段名
|
|
86
|
+
valueKey: {
|
|
87
|
+
type: String,
|
|
88
|
+
default: "value"
|
|
89
|
+
},
|
|
90
|
+
// 是否启用远程搜索
|
|
91
|
+
remote: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
default: !1
|
|
94
|
+
},
|
|
95
|
+
// 远程搜索方法(返回 Promise)
|
|
96
|
+
remoteMethod: {
|
|
97
|
+
type: Function,
|
|
98
|
+
default: null
|
|
99
|
+
},
|
|
100
|
+
// 传给后端的搜索关键词参数名
|
|
101
|
+
remoteSearchKey: {
|
|
102
|
+
type: String,
|
|
103
|
+
default: "keyword"
|
|
104
|
+
},
|
|
105
|
+
// 传给后端的其他额外参数
|
|
106
|
+
remoteParams: {
|
|
107
|
+
type: Object,
|
|
108
|
+
default: () => ({})
|
|
109
|
+
},
|
|
110
|
+
// 防抖延迟时间(ms)
|
|
111
|
+
debounceDelay: {
|
|
112
|
+
type: Number,
|
|
113
|
+
default: 300
|
|
114
|
+
},
|
|
115
|
+
// 加载中文本
|
|
116
|
+
loadingText: {
|
|
117
|
+
type: String,
|
|
118
|
+
default: "加载中..."
|
|
119
|
+
},
|
|
120
|
+
// 无数据文本
|
|
121
|
+
emptyText: {
|
|
122
|
+
type: String,
|
|
123
|
+
default: "暂无数据"
|
|
124
|
+
},
|
|
125
|
+
// 是否在打开下拉框时自动搜索
|
|
126
|
+
searchOnOpen: {
|
|
127
|
+
type: Boolean,
|
|
128
|
+
default: !1
|
|
129
|
+
},
|
|
130
|
+
// 初始搜索关键词(用于打开时的默认搜索)
|
|
131
|
+
initialSearchKeyword: {
|
|
132
|
+
type: String,
|
|
133
|
+
default: ""
|
|
134
|
+
},
|
|
135
|
+
dataKey: {
|
|
136
|
+
type: String,
|
|
137
|
+
default: "data"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
emits: ["update:modelValue", "change", "remote-search"],
|
|
141
|
+
setup(e, { emit: o }) {
|
|
142
|
+
const a = e, t = o, s = P([...a.modelValue]), i = P([]), l = P(!1);
|
|
143
|
+
let p = null;
|
|
144
|
+
const d = q(() => a.remote ? i.value : a.options), b = q(() => d.value.filter((u) => !u.disabled).map((u) => u[a.valueKey])), g = q(() => b.value.length === 0 ? !1 : b.value.every((u) => s.value.includes(u))), v = q(() => {
|
|
145
|
+
const u = s.value.filter(
|
|
146
|
+
(c) => b.value.includes(c)
|
|
147
|
+
).length;
|
|
148
|
+
return u > 0 && u < b.value.length;
|
|
149
|
+
}), k = (u) => {
|
|
150
|
+
u ? s.value = [.../* @__PURE__ */ new Set([...b.value])] : s.value = [], t("update:modelValue", s.value), t("change", s.value);
|
|
151
|
+
}, F = (u) => {
|
|
152
|
+
const c = u.filter((f) => f !== De);
|
|
153
|
+
s.value = c, t("update:modelValue", c), t("change", c);
|
|
154
|
+
}, n = (u = "") => {
|
|
155
|
+
p && clearTimeout(p), p = setTimeout(async () => {
|
|
156
|
+
if (a.remoteMethod) {
|
|
157
|
+
l.value = !0;
|
|
158
|
+
try {
|
|
159
|
+
const c = {
|
|
160
|
+
...a.remoteParams,
|
|
161
|
+
[a.remoteSearchKey]: u || ""
|
|
162
|
+
}, f = await a.remoteMethod(c);
|
|
163
|
+
let C = [];
|
|
164
|
+
f && f.code === 200 ? C = f[a.dataKey] || f.data || [] : Array.isArray(f) && (C = f), i.value = Array.isArray(C) ? C : [], t("remote-search", { query: u, result: i.value });
|
|
165
|
+
} catch (c) {
|
|
166
|
+
console.error("CSelectWithAll 远程搜索失败:", c), i.value = [];
|
|
167
|
+
} finally {
|
|
168
|
+
l.value = !1;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}, a.debounceDelay);
|
|
172
|
+
}, r = (u) => {
|
|
173
|
+
u && a.remote && a.searchOnOpen && n(a.initialSearchKeyword);
|
|
174
|
+
};
|
|
175
|
+
return fe(
|
|
176
|
+
() => a.modelValue,
|
|
177
|
+
(u) => {
|
|
178
|
+
s.value = [...u || []];
|
|
179
|
+
},
|
|
180
|
+
{ deep: !0 }
|
|
181
|
+
), ke(() => {
|
|
182
|
+
a.remote && a.searchOnOpen && n();
|
|
183
|
+
}), Fe(() => {
|
|
184
|
+
p && clearTimeout(p);
|
|
185
|
+
}), (u, c) => {
|
|
186
|
+
const f = K("el-checkbox"), C = K("el-option"), $ = K("el-select");
|
|
187
|
+
return x(), z($, de({
|
|
188
|
+
modelValue: s.value,
|
|
189
|
+
"onUpdate:modelValue": c[1] || (c[1] = (S) => s.value = S)
|
|
190
|
+
}, u.$attrs, {
|
|
191
|
+
multiple: "",
|
|
192
|
+
"collapse-tags": "",
|
|
193
|
+
"collapse-tags-tooltip": "",
|
|
194
|
+
filterable: "",
|
|
195
|
+
placeholder: e.placeholder,
|
|
196
|
+
remote: e.remote,
|
|
197
|
+
"remote-method": e.remote ? n : void 0,
|
|
198
|
+
loading: l.value,
|
|
199
|
+
"loading-text": e.loadingText,
|
|
200
|
+
onChange: F,
|
|
201
|
+
onVisibleChange: r
|
|
202
|
+
}), {
|
|
203
|
+
empty: A(() => [
|
|
204
|
+
Q("div", it, oe(e.emptyText), 1)
|
|
205
|
+
]),
|
|
206
|
+
default: A(() => [
|
|
207
|
+
e.showSelectAll ? (x(), z(C, {
|
|
208
|
+
key: 0,
|
|
209
|
+
value: De,
|
|
210
|
+
label: e.selectAllLabel,
|
|
211
|
+
class: "select-all-option"
|
|
212
|
+
}, {
|
|
213
|
+
default: A(() => [
|
|
214
|
+
H(f, {
|
|
215
|
+
"model-value": g.value,
|
|
216
|
+
indeterminate: v.value,
|
|
217
|
+
onChange: k,
|
|
218
|
+
onClick: c[0] || (c[0] = Ue(() => {
|
|
219
|
+
}, ["stop"]))
|
|
220
|
+
}, {
|
|
221
|
+
default: A(() => [
|
|
222
|
+
ae(oe(e.selectAllLabel), 1)
|
|
223
|
+
]),
|
|
224
|
+
_: 1
|
|
225
|
+
}, 8, ["model-value", "indeterminate"])
|
|
226
|
+
]),
|
|
227
|
+
_: 1
|
|
228
|
+
}, 8, ["label"])) : re("", !0),
|
|
229
|
+
(x(!0), U(ue, null, pe(d.value, (S) => (x(), z(C, {
|
|
230
|
+
key: S[e.valueKey],
|
|
231
|
+
label: S[e.labelKey],
|
|
232
|
+
value: S[e.valueKey],
|
|
233
|
+
disabled: S.disabled
|
|
234
|
+
}, null, 8, ["label", "value", "disabled"]))), 128))
|
|
235
|
+
]),
|
|
236
|
+
_: 1
|
|
237
|
+
}, 16, ["modelValue", "placeholder", "remote", "remote-method", "loading", "loading-text"]);
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
}), ve = (e, o) => {
|
|
241
|
+
const a = e.__vccOpts || e;
|
|
242
|
+
for (const [t, s] of o)
|
|
243
|
+
a[t] = s;
|
|
244
|
+
return a;
|
|
245
|
+
}, ct = /* @__PURE__ */ ve(ut, [["__scopeId", "data-v-904634e0"]]), dt = { class: "remote-select-wrapper" }, pt = { class: "loading-text" }, ft = /* @__PURE__ */ me({
|
|
246
|
+
name: "CSelectWithPage",
|
|
247
|
+
__name: "index",
|
|
248
|
+
props: {
|
|
249
|
+
modelValue: {
|
|
250
|
+
type: [String, Number],
|
|
251
|
+
default: ""
|
|
252
|
+
},
|
|
253
|
+
placeholder: {
|
|
254
|
+
type: String,
|
|
255
|
+
default: "请输入关键词搜索"
|
|
256
|
+
},
|
|
257
|
+
labelKey: {
|
|
258
|
+
type: String,
|
|
259
|
+
default: "keyword"
|
|
260
|
+
},
|
|
261
|
+
valueKey: {
|
|
262
|
+
type: String,
|
|
263
|
+
default: "id"
|
|
264
|
+
},
|
|
265
|
+
fetchApi: {
|
|
266
|
+
type: Function,
|
|
267
|
+
required: !0
|
|
268
|
+
},
|
|
269
|
+
// 外部传入的初始选项,用于回显 label
|
|
270
|
+
initialOptions: {
|
|
271
|
+
type: Array,
|
|
272
|
+
default: () => []
|
|
273
|
+
},
|
|
274
|
+
debounceDelay: {
|
|
275
|
+
type: Number,
|
|
276
|
+
default: 300
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
emits: ["update:modelValue", "selectItem", "clear"],
|
|
280
|
+
setup(e, { emit: o }) {
|
|
281
|
+
const a = e, t = o, s = P(a.modelValue), i = P([...a.initialOptions]), l = P(!1), p = P("");
|
|
282
|
+
let d = null;
|
|
283
|
+
const b = P(null), g = async (n = "") => {
|
|
284
|
+
if (!(l.value || !a.fetchApi)) {
|
|
285
|
+
l.value = !0;
|
|
286
|
+
try {
|
|
287
|
+
const r = await a.fetchApi({
|
|
288
|
+
keyword: n.trim(),
|
|
289
|
+
pageNum: 1,
|
|
290
|
+
pageSize: 2e3
|
|
291
|
+
}), u = ((r == null ? void 0 : r.rows) || (r == null ? void 0 : r.data) || []).slice(0, 1e3);
|
|
292
|
+
if (i.value = Array.isArray(u) ? u : [], s.value) {
|
|
293
|
+
const c = i.value.find((f) => f[a.valueKey] === s.value);
|
|
294
|
+
c && (b.value = c);
|
|
295
|
+
}
|
|
296
|
+
} catch (r) {
|
|
297
|
+
console.error("CSelectWithPage 加载数据失败:", r), i.value = [];
|
|
298
|
+
} finally {
|
|
299
|
+
l.value = !1;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}, v = (n) => {
|
|
303
|
+
if (d && clearTimeout(d), p.value = n, !n.trim()) {
|
|
304
|
+
i.value = [...a.initialOptions];
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
d = setTimeout(() => {
|
|
308
|
+
g(n);
|
|
309
|
+
}, a.debounceDelay);
|
|
310
|
+
}, k = () => {
|
|
311
|
+
p.value = "", i.value = [...a.initialOptions], b.value = null, s.value = "", t("update:modelValue", ""), t("selectItem", null), t("clear");
|
|
312
|
+
}, F = (n) => {
|
|
313
|
+
const r = i.value.find((u) => u[a.valueKey] === n);
|
|
314
|
+
b.value = r || null, t("update:modelValue", n || ""), t("selectItem", b.value);
|
|
315
|
+
};
|
|
316
|
+
return fe(
|
|
317
|
+
() => a.modelValue,
|
|
318
|
+
async (n) => {
|
|
319
|
+
n !== s.value && (s.value = n, n && !i.value.some((r) => r[a.valueKey] === n) && await g(""), b.value = i.value.find((r) => r[a.valueKey] === n) || null);
|
|
320
|
+
},
|
|
321
|
+
{ immediate: !0 }
|
|
322
|
+
), fe(s, (n) => {
|
|
323
|
+
n !== a.modelValue && t("update:modelValue", n || "");
|
|
324
|
+
}), Fe(() => {
|
|
325
|
+
d && clearTimeout(d);
|
|
326
|
+
}), (n, r) => {
|
|
327
|
+
const u = K("el-option"), c = K("el-icon"), f = K("el-select");
|
|
328
|
+
return x(), U("div", dt, [
|
|
329
|
+
H(f, de({
|
|
330
|
+
modelValue: s.value,
|
|
331
|
+
"onUpdate:modelValue": r[0] || (r[0] = (C) => s.value = C),
|
|
332
|
+
filterable: "",
|
|
333
|
+
remote: "",
|
|
334
|
+
"remote-method": v,
|
|
335
|
+
loading: l.value,
|
|
336
|
+
placeholder: e.placeholder,
|
|
337
|
+
clearable: ""
|
|
338
|
+
}, n.$attrs, {
|
|
339
|
+
onClear: k,
|
|
340
|
+
onChange: F
|
|
341
|
+
}), {
|
|
342
|
+
default: A(() => [
|
|
343
|
+
(x(!0), U(ue, null, pe(i.value, (C) => (x(), z(u, {
|
|
344
|
+
key: C[e.valueKey],
|
|
345
|
+
label: C[e.labelKey],
|
|
346
|
+
value: C[e.valueKey]
|
|
347
|
+
}, null, 8, ["label", "value"]))), 128)),
|
|
348
|
+
l.value ? (x(), z(u, {
|
|
349
|
+
key: 0,
|
|
350
|
+
disabled: "",
|
|
351
|
+
value: ""
|
|
352
|
+
}, {
|
|
353
|
+
default: A(() => [
|
|
354
|
+
Q("div", pt, [
|
|
355
|
+
H(c, { class: "is-loading" }, {
|
|
356
|
+
default: A(() => [
|
|
357
|
+
H(ee(Qe))
|
|
358
|
+
]),
|
|
359
|
+
_: 1
|
|
360
|
+
}),
|
|
361
|
+
r[1] || (r[1] = ae(" 加载中... ", -1))
|
|
362
|
+
])
|
|
363
|
+
]),
|
|
364
|
+
_: 1
|
|
365
|
+
})) : re("", !0),
|
|
366
|
+
!l.value && i.value.length === 0 && p.value ? (x(), z(u, {
|
|
367
|
+
key: 1,
|
|
368
|
+
disabled: "",
|
|
369
|
+
value: ""
|
|
370
|
+
}, {
|
|
371
|
+
default: A(() => [...r[2] || (r[2] = [
|
|
372
|
+
Q("div", { class: "no-data-text" }, "暂无数据", -1)
|
|
373
|
+
])]),
|
|
374
|
+
_: 1
|
|
375
|
+
})) : re("", !0),
|
|
376
|
+
!l.value && i.value.length === 0 && !p.value ? (x(), z(u, {
|
|
377
|
+
key: 2,
|
|
378
|
+
disabled: "",
|
|
379
|
+
value: ""
|
|
380
|
+
}, {
|
|
381
|
+
default: A(() => [...r[3] || (r[3] = [
|
|
382
|
+
Q("div", { class: "no-data-text" }, "请输入关键词进行搜索", -1)
|
|
383
|
+
])]),
|
|
384
|
+
_: 1
|
|
385
|
+
})) : re("", !0)
|
|
386
|
+
]),
|
|
387
|
+
_: 1
|
|
388
|
+
}, 16, ["modelValue", "loading", "placeholder"])
|
|
389
|
+
]);
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
}), mt = /* @__PURE__ */ ve(ft, [["__scopeId", "data-v-dea4bdcf"]]), ht = { class: "search-box" }, gt = { class: "button-group" }, vt = /* @__PURE__ */ me({
|
|
393
|
+
name: "CSearchBox",
|
|
394
|
+
__name: "index",
|
|
395
|
+
props: {
|
|
396
|
+
fields: {
|
|
397
|
+
type: Array,
|
|
398
|
+
default: () => []
|
|
399
|
+
},
|
|
400
|
+
searchText: {
|
|
401
|
+
type: String,
|
|
402
|
+
default: "查询"
|
|
403
|
+
},
|
|
404
|
+
resetText: {
|
|
405
|
+
type: String,
|
|
406
|
+
default: "重置"
|
|
407
|
+
},
|
|
408
|
+
exportText: {
|
|
409
|
+
type: String,
|
|
410
|
+
default: "导出"
|
|
411
|
+
},
|
|
412
|
+
showExport: {
|
|
413
|
+
type: Boolean,
|
|
414
|
+
default: !1
|
|
415
|
+
},
|
|
416
|
+
initialValues: {
|
|
417
|
+
type: Object,
|
|
418
|
+
default: () => ({})
|
|
419
|
+
},
|
|
420
|
+
fieldsPerRow: {
|
|
421
|
+
type: Number,
|
|
422
|
+
default: 4
|
|
423
|
+
},
|
|
424
|
+
labelWidth: {
|
|
425
|
+
type: String,
|
|
426
|
+
default: "80px"
|
|
427
|
+
},
|
|
428
|
+
defaultExpanded: {
|
|
429
|
+
type: Boolean,
|
|
430
|
+
default: !1
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
emits: ["search", "reset", "export", "field-change"],
|
|
434
|
+
setup(e, { expose: o, emit: a }) {
|
|
435
|
+
Me((m) => ({
|
|
436
|
+
v7dbee7c4: e.labelWidth
|
|
437
|
+
}));
|
|
438
|
+
const t = e, s = a, i = P(!1), l = P(t.defaultExpanded), p = $e({}), d = (m) => m.visible === void 0 ? !0 : typeof m.visible == "function" ? m.visible(r.value) : ee(m.visible), b = q(() => t.fields.filter((m) => d(m))), g = q(() => Math.floor(24 / t.fieldsPerRow)), v = q(() => 2 * t.fieldsPerRow), k = q(() => b.value.length > v.value), F = q(() => l.value || !k.value ? b.value : b.value.slice(0, v.value)), n = () => {
|
|
439
|
+
const m = {};
|
|
440
|
+
return t.fields.forEach((h) => {
|
|
441
|
+
if (t.initialValues[h.prop] !== void 0)
|
|
442
|
+
m[h.prop] = t.initialValues[h.prop];
|
|
443
|
+
else
|
|
444
|
+
switch (h.type) {
|
|
445
|
+
case "select":
|
|
446
|
+
m[h.prop] = h.multiple ? [] : "";
|
|
447
|
+
break;
|
|
448
|
+
case "daterange":
|
|
449
|
+
m[h.prop] = [];
|
|
450
|
+
break;
|
|
451
|
+
case "number":
|
|
452
|
+
m[h.prop] = h.defaultValue ?? null;
|
|
453
|
+
break;
|
|
454
|
+
default:
|
|
455
|
+
m[h.prop] = h.defaultValue ?? "";
|
|
456
|
+
}
|
|
457
|
+
}), m;
|
|
458
|
+
}, r = P(n()), u = async (m, h) => {
|
|
459
|
+
if (!m.relation) return;
|
|
460
|
+
const { getOptions: N } = m.relation;
|
|
461
|
+
if (h === void 0 || h === "" || h === null) {
|
|
462
|
+
p[m.prop] = m.defaultOptions || [];
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
try {
|
|
466
|
+
let E = [];
|
|
467
|
+
if (typeof N == "function") {
|
|
468
|
+
const G = N(h, r.value);
|
|
469
|
+
E = G instanceof Promise ? await G : G;
|
|
470
|
+
} else typeof N == "object" && N[h] && (E = N[h]);
|
|
471
|
+
p[m.prop] = E || [];
|
|
472
|
+
} catch (E) {
|
|
473
|
+
console.error(`加载字段 ${m.prop} 选项失败:`, E), p[m.prop] = [];
|
|
474
|
+
}
|
|
475
|
+
}, c = () => {
|
|
476
|
+
t.fields.forEach((m) => {
|
|
477
|
+
if (m.relation) {
|
|
478
|
+
const { dependOn: h } = m.relation, N = r.value[h];
|
|
479
|
+
u(m, N);
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
}, f = (m) => ({
|
|
483
|
+
...{
|
|
484
|
+
clearable: m.clearable !== !1,
|
|
485
|
+
placeholder: m.placeholder || `请${m.type === "input" || m.type === "number" ? "输入" : "选择"}${m.label}`
|
|
486
|
+
},
|
|
487
|
+
...m.props
|
|
488
|
+
}), C = (m) => m.relation ? p[m.prop] || m.defaultOptions || [] : m.options || [], $ = (m, h) => {
|
|
489
|
+
t.fields.filter(
|
|
490
|
+
(E) => E.relation && E.relation.dependOn === m
|
|
491
|
+
).forEach((E) => {
|
|
492
|
+
E.multiple ? r.value[E.prop] = [] : r.value[E.prop] = "", u(E, h);
|
|
493
|
+
}), s("field-change", { prop: m, value: h, form: { ...r.value } });
|
|
494
|
+
}, S = () => {
|
|
495
|
+
l.value = !l.value;
|
|
496
|
+
}, M = (m) => {
|
|
497
|
+
const h = {};
|
|
498
|
+
return t.fields.forEach((N) => {
|
|
499
|
+
if (!d(N)) return;
|
|
500
|
+
const E = m[N.prop];
|
|
501
|
+
if (N.dateRange) {
|
|
502
|
+
if (Array.isArray(E) && E.length === 2 && E[0] && E[1]) {
|
|
503
|
+
const { startField: G, endField: ne, format: w } = N.dateRange;
|
|
504
|
+
typeof w == "function" ? (h[G] = w(E[0]), h[ne] = w(E[1])) : (h[G] = E[0], h[ne] = E[1]);
|
|
505
|
+
}
|
|
506
|
+
} else if (N.returnAllIds) {
|
|
507
|
+
const { fileIds: G } = N;
|
|
508
|
+
if (E) {
|
|
509
|
+
const T = Array.isArray(E) ? E : [E];
|
|
510
|
+
G == null || G.forEach((L, J) => {
|
|
511
|
+
const Y = T[J];
|
|
512
|
+
Y && (h[L] = Y);
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
const ne = Array.isArray(E) ? E : [E], w = ne[ne.length - 1];
|
|
516
|
+
w && (h.currentKey = w, h[N.prop] = w);
|
|
517
|
+
} else if (E !== "" && E !== null && E !== void 0) {
|
|
518
|
+
if (Array.isArray(E) && E.length === 0) return;
|
|
519
|
+
h[N.prop] = E;
|
|
520
|
+
}
|
|
521
|
+
}), h;
|
|
522
|
+
}, R = () => {
|
|
523
|
+
i.value = !0;
|
|
524
|
+
const m = M(r.value);
|
|
525
|
+
s("search", m), setTimeout(() => {
|
|
526
|
+
i.value = !1;
|
|
527
|
+
}, 300);
|
|
528
|
+
}, W = () => {
|
|
529
|
+
r.value = n(), c();
|
|
530
|
+
const m = M(r.value);
|
|
531
|
+
s("reset", m);
|
|
532
|
+
}, le = () => {
|
|
533
|
+
const m = M(r.value);
|
|
534
|
+
s("export", m);
|
|
535
|
+
};
|
|
536
|
+
fe(
|
|
537
|
+
() => t.fields,
|
|
538
|
+
(m, h) => {
|
|
539
|
+
(!h || m.length !== h.length ? !0 : m.some((E, G) => {
|
|
540
|
+
const ne = h[G];
|
|
541
|
+
if (!ne) return !0;
|
|
542
|
+
const { options: w, ...T } = E, { options: L, ...J } = ne;
|
|
543
|
+
return JSON.stringify(T) !== JSON.stringify(J);
|
|
544
|
+
})) && (r.value = n()), c();
|
|
545
|
+
},
|
|
546
|
+
{ deep: !0 }
|
|
547
|
+
), fe(
|
|
548
|
+
() => t.initialValues,
|
|
549
|
+
(m) => {
|
|
550
|
+
Object.keys(m || {}).forEach((h) => {
|
|
551
|
+
h in r.value && (r.value[h] = m[h]);
|
|
552
|
+
}), c();
|
|
553
|
+
},
|
|
554
|
+
{ deep: !0 }
|
|
555
|
+
);
|
|
556
|
+
const be = (m) => {
|
|
557
|
+
if (m.key === "Enter") {
|
|
558
|
+
const h = m.target;
|
|
559
|
+
if (!h) return;
|
|
560
|
+
const N = h.tagName === "INPUT" || h.tagName === "TEXTAREA", E = h.closest(".el-popper") || h.closest(".el-select-dropdown");
|
|
561
|
+
N && !E && R();
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
return ke(() => {
|
|
565
|
+
c();
|
|
566
|
+
}), o({
|
|
567
|
+
search: R,
|
|
568
|
+
reset: W,
|
|
569
|
+
export: le,
|
|
570
|
+
getParams: () => M(r.value),
|
|
571
|
+
getAllParams: () => ({ ...r.value }),
|
|
572
|
+
setValues: (m) => {
|
|
573
|
+
Object.keys(m || {}).forEach((h) => {
|
|
574
|
+
h in r.value && (r.value[h] = m[h]);
|
|
575
|
+
}), c();
|
|
576
|
+
},
|
|
577
|
+
toggleExpand: () => {
|
|
578
|
+
k.value && S();
|
|
579
|
+
}
|
|
580
|
+
}), (m, h) => {
|
|
581
|
+
const N = K("el-option"), E = K("el-radio"), G = K("el-checkbox"), ne = K("el-form-item"), w = K("el-col"), T = K("el-row"), L = K("el-button"), J = K("el-icon"), Y = K("el-form");
|
|
582
|
+
return x(), U("div", ht, [
|
|
583
|
+
H(Y, {
|
|
584
|
+
model: r.value,
|
|
585
|
+
"label-width": e.labelWidth,
|
|
586
|
+
class: "search-form",
|
|
587
|
+
onKeyup: be
|
|
588
|
+
}, {
|
|
589
|
+
default: A(() => [
|
|
590
|
+
H(T, {
|
|
591
|
+
gutter: 16,
|
|
592
|
+
class: "search-fields"
|
|
593
|
+
}, {
|
|
594
|
+
default: A(() => [
|
|
595
|
+
(x(!0), U(ue, null, pe(F.value, (D) => {
|
|
596
|
+
var ye, Se, Te, Ce;
|
|
597
|
+
return x(), z(w, {
|
|
598
|
+
key: D.prop,
|
|
599
|
+
xs: 24,
|
|
600
|
+
sm: ((ye = D.props) == null ? void 0 : ye.span) || 12,
|
|
601
|
+
md: ((Se = D.props) == null ? void 0 : Se.span) || g.value,
|
|
602
|
+
lg: ((Te = D.props) == null ? void 0 : Te.span) || g.value,
|
|
603
|
+
xl: ((Ce = D.props) == null ? void 0 : Ce.span) || g.value,
|
|
604
|
+
class: "field-col"
|
|
605
|
+
}, {
|
|
606
|
+
default: A(() => [
|
|
607
|
+
H(ne, {
|
|
608
|
+
label: D.label,
|
|
609
|
+
prop: D.prop,
|
|
610
|
+
class: xe({ "is-required": D.required })
|
|
611
|
+
}, {
|
|
612
|
+
default: A(() => [
|
|
613
|
+
(x(), z(Re(D.component || D.type), de({
|
|
614
|
+
modelValue: r.value[D.prop],
|
|
615
|
+
"onUpdate:modelValue": (Z) => r.value[D.prop] = Z
|
|
616
|
+
}, { ref_for: !0 }, f(D), {
|
|
617
|
+
style: { width: "100%" },
|
|
618
|
+
onChange: (Z) => $(D.prop, Z),
|
|
619
|
+
onKeydown: qe((Z) => D.component === "el-input" ? R : null, ["enter"])
|
|
620
|
+
}), {
|
|
621
|
+
default: A(() => [
|
|
622
|
+
D.component === "el-select" || D.type === "select" ? (x(!0), U(ue, { key: 0 }, pe(C(D), (Z) => (x(), z(N, {
|
|
623
|
+
key: Z.value,
|
|
624
|
+
label: Z.label,
|
|
625
|
+
value: Z.value
|
|
626
|
+
}, null, 8, ["label", "value"]))), 128)) : D.component === "el-radio-group" || D.type === "radio" ? (x(!0), U(ue, { key: 1 }, pe(C(D), (Z) => (x(), z(E, {
|
|
627
|
+
key: Z.value,
|
|
628
|
+
label: Z.value
|
|
629
|
+
}, {
|
|
630
|
+
default: A(() => [
|
|
631
|
+
ae(oe(Z.label), 1)
|
|
632
|
+
]),
|
|
633
|
+
_: 2
|
|
634
|
+
}, 1032, ["label"]))), 128)) : D.component === "el-checkbox-group" || D.type === "checkbox" ? (x(!0), U(ue, { key: 2 }, pe(C(D), (Z) => (x(), z(G, {
|
|
635
|
+
key: Z.value,
|
|
636
|
+
label: Z.value
|
|
637
|
+
}, {
|
|
638
|
+
default: A(() => [
|
|
639
|
+
ae(oe(Z.label), 1)
|
|
640
|
+
]),
|
|
641
|
+
_: 2
|
|
642
|
+
}, 1032, ["label"]))), 128)) : re("", !0)
|
|
643
|
+
]),
|
|
644
|
+
_: 2
|
|
645
|
+
}, 1040, ["modelValue", "onUpdate:modelValue", "onChange", "onKeydown"])),
|
|
646
|
+
D.type === "slot" ? ie(m.$slots, D.slotName, {
|
|
647
|
+
value: r.value[D.prop],
|
|
648
|
+
onChange: (Z) => r.value[D.prop] = Z
|
|
649
|
+
}, void 0, !0, 0) : re("", !0)
|
|
650
|
+
]),
|
|
651
|
+
_: 2
|
|
652
|
+
}, 1032, ["label", "prop", "class"])
|
|
653
|
+
]),
|
|
654
|
+
_: 2
|
|
655
|
+
}, 1032, ["sm", "md", "lg", "xl"]);
|
|
656
|
+
}), 128))
|
|
657
|
+
]),
|
|
658
|
+
_: 3
|
|
659
|
+
}),
|
|
660
|
+
H(T, { class: "action-row" }, {
|
|
661
|
+
default: A(() => [
|
|
662
|
+
H(w, {
|
|
663
|
+
span: 24,
|
|
664
|
+
class: "action-col"
|
|
665
|
+
}, {
|
|
666
|
+
default: A(() => [
|
|
667
|
+
Q("div", gt, [
|
|
668
|
+
H(L, {
|
|
669
|
+
type: "primary",
|
|
670
|
+
loading: i.value,
|
|
671
|
+
onClick: R
|
|
672
|
+
}, {
|
|
673
|
+
default: A(() => [
|
|
674
|
+
ae(oe(e.searchText), 1)
|
|
675
|
+
]),
|
|
676
|
+
_: 1
|
|
677
|
+
}, 8, ["loading"]),
|
|
678
|
+
H(L, { onClick: W }, {
|
|
679
|
+
default: A(() => [
|
|
680
|
+
ae(oe(e.resetText), 1)
|
|
681
|
+
]),
|
|
682
|
+
_: 1
|
|
683
|
+
}),
|
|
684
|
+
e.showExport ? (x(), z(L, {
|
|
685
|
+
key: 0,
|
|
686
|
+
type: "success",
|
|
687
|
+
onClick: le
|
|
688
|
+
}, {
|
|
689
|
+
default: A(() => [
|
|
690
|
+
ae(oe(e.exportText), 1)
|
|
691
|
+
]),
|
|
692
|
+
_: 1
|
|
693
|
+
})) : re("", !0),
|
|
694
|
+
k.value ? (x(), z(L, {
|
|
695
|
+
key: 1,
|
|
696
|
+
type: "text",
|
|
697
|
+
class: "toggle-btn",
|
|
698
|
+
onClick: S
|
|
699
|
+
}, {
|
|
700
|
+
default: A(() => [
|
|
701
|
+
ae(oe(l.value ? "收起" : "展开") + " ", 1),
|
|
702
|
+
H(J, { class: "toggle-icon" }, {
|
|
703
|
+
default: A(() => [
|
|
704
|
+
l.value ? (x(), z(ee(Ge), { key: 0 })) : (x(), z(ee(et), { key: 1 }))
|
|
705
|
+
]),
|
|
706
|
+
_: 1
|
|
707
|
+
})
|
|
708
|
+
]),
|
|
709
|
+
_: 1
|
|
710
|
+
})) : re("", !0)
|
|
711
|
+
])
|
|
712
|
+
]),
|
|
713
|
+
_: 1
|
|
714
|
+
})
|
|
715
|
+
]),
|
|
716
|
+
_: 1
|
|
717
|
+
})
|
|
718
|
+
]),
|
|
719
|
+
_: 3
|
|
720
|
+
}, 8, ["model", "label-width"])
|
|
721
|
+
]);
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
}), yt = /* @__PURE__ */ ve(vt, [["__scopeId", "data-v-760b27aa"]]), bt = { class: "collapsible-container" }, wt = { class: "left-content" }, Ct = { class: "right-panel" }, _t = { class: "right-content" }, xt = /* @__PURE__ */ me({
|
|
725
|
+
name: "CCollapsibleContainer",
|
|
726
|
+
__name: "index",
|
|
727
|
+
props: {
|
|
728
|
+
defaultCollapsed: {
|
|
729
|
+
type: Boolean,
|
|
730
|
+
default: !1
|
|
731
|
+
},
|
|
732
|
+
defaultWidth: {
|
|
733
|
+
type: Number,
|
|
734
|
+
default: 240
|
|
735
|
+
},
|
|
736
|
+
minWidth: {
|
|
737
|
+
type: Number,
|
|
738
|
+
default: 200
|
|
739
|
+
},
|
|
740
|
+
maxWidth: {
|
|
741
|
+
type: Number,
|
|
742
|
+
default: 600
|
|
743
|
+
},
|
|
744
|
+
height: {
|
|
745
|
+
type: String,
|
|
746
|
+
default: "calc(100vh - 84px)"
|
|
747
|
+
}
|
|
748
|
+
},
|
|
749
|
+
emits: ["collapse-change", "width-change"],
|
|
750
|
+
setup(e, { expose: o, emit: a }) {
|
|
751
|
+
Me((k) => ({
|
|
752
|
+
v5dad642c: d.value,
|
|
753
|
+
v1c2deffa: e.height,
|
|
754
|
+
v72e9676c: b.value
|
|
755
|
+
}));
|
|
756
|
+
const t = e, s = a, i = P(t.defaultCollapsed), l = P(t.defaultWidth), p = P(!1), d = q(() => i.value ? "48px 1fr" : `${l.value}px 1fr`), b = q(() => i.value ? "48px" : `${l.value}px`), g = () => {
|
|
757
|
+
i.value = !i.value, s("collapse-change", i.value);
|
|
758
|
+
}, v = (k) => {
|
|
759
|
+
k.preventDefault(), p.value = !0;
|
|
760
|
+
const F = k.clientX, n = l.value;
|
|
761
|
+
let r = null, u = null;
|
|
762
|
+
const c = () => {
|
|
763
|
+
u !== null && (l.value = u, s("width-change", u), u = null), r = null;
|
|
764
|
+
}, f = ($) => {
|
|
765
|
+
const S = $.clientX - F, M = n + S;
|
|
766
|
+
u = Math.max(t.minWidth, Math.min(t.maxWidth, M)), r === null && (r = requestAnimationFrame(c));
|
|
767
|
+
}, C = () => {
|
|
768
|
+
p.value = !1, r !== null && cancelAnimationFrame(r), u !== null && (l.value = u, s("width-change", u)), document.removeEventListener("mousemove", f), document.removeEventListener("mouseup", C), document.body.style.cursor = "", document.body.style.userSelect = "";
|
|
769
|
+
};
|
|
770
|
+
document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", f), document.addEventListener("mouseup", C);
|
|
771
|
+
};
|
|
772
|
+
return o({
|
|
773
|
+
toggleCollapse: g,
|
|
774
|
+
isCollapsed: i,
|
|
775
|
+
leftPanelWidth: l
|
|
776
|
+
}), (k, F) => {
|
|
777
|
+
const n = K("el-icon");
|
|
778
|
+
return x(), U("div", bt, [
|
|
779
|
+
Q("div", {
|
|
780
|
+
class: xe(["left-panel", { collapsed: i.value, resizing: p.value }])
|
|
781
|
+
}, [
|
|
782
|
+
Q("div", {
|
|
783
|
+
class: "toggle-btn",
|
|
784
|
+
onClick: g
|
|
785
|
+
}, [
|
|
786
|
+
H(n, null, {
|
|
787
|
+
default: A(() => [
|
|
788
|
+
i.value ? (x(), z(ee(tt), { key: 0 })) : (x(), z(ee(at), { key: 1 }))
|
|
789
|
+
]),
|
|
790
|
+
_: 1
|
|
791
|
+
})
|
|
792
|
+
]),
|
|
793
|
+
Ee(Q("div", wt, [
|
|
794
|
+
ie(k.$slots, "left", {}, void 0, !0)
|
|
795
|
+
], 512), [
|
|
796
|
+
[Ze, !i.value]
|
|
797
|
+
]),
|
|
798
|
+
i.value ? re("", !0) : (x(), U("div", {
|
|
799
|
+
key: 0,
|
|
800
|
+
class: "resize-handle",
|
|
801
|
+
onMousedown: v
|
|
802
|
+
}, null, 32))
|
|
803
|
+
], 2),
|
|
804
|
+
Q("div", Ct, [
|
|
805
|
+
Q("div", _t, [
|
|
806
|
+
ie(k.$slots, "right", {}, void 0, !0)
|
|
807
|
+
])
|
|
808
|
+
])
|
|
809
|
+
]);
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
}), St = /* @__PURE__ */ ve(xt, [["__scopeId", "data-v-d7447c42"]]), Tt = { class: "drawer-footer" }, At = /* @__PURE__ */ me({
|
|
813
|
+
name: "CCustomDrawer",
|
|
814
|
+
__name: "index",
|
|
815
|
+
props: {
|
|
816
|
+
modelValue: {
|
|
817
|
+
type: Boolean,
|
|
818
|
+
default: !1
|
|
819
|
+
},
|
|
820
|
+
title: {
|
|
821
|
+
type: String,
|
|
822
|
+
default: ""
|
|
823
|
+
},
|
|
824
|
+
size: {
|
|
825
|
+
type: [String, Number],
|
|
826
|
+
default: "30%"
|
|
827
|
+
},
|
|
828
|
+
direction: {
|
|
829
|
+
type: String,
|
|
830
|
+
default: "rtl",
|
|
831
|
+
validator: (e) => ["rtl", "ltr", "ttb", "btt"].includes(e)
|
|
832
|
+
},
|
|
833
|
+
showFooter: {
|
|
834
|
+
type: Boolean,
|
|
835
|
+
default: !1
|
|
836
|
+
},
|
|
837
|
+
closeOnClickModal: {
|
|
838
|
+
type: Boolean,
|
|
839
|
+
default: !0
|
|
840
|
+
},
|
|
841
|
+
closeOnPressEscape: {
|
|
842
|
+
type: Boolean,
|
|
843
|
+
default: !0
|
|
844
|
+
},
|
|
845
|
+
destroyOnClose: {
|
|
846
|
+
type: Boolean,
|
|
847
|
+
default: !1
|
|
848
|
+
},
|
|
849
|
+
confirmLoading: {
|
|
850
|
+
type: Boolean,
|
|
851
|
+
default: !1
|
|
852
|
+
},
|
|
853
|
+
beforeClose: {
|
|
854
|
+
type: Function,
|
|
855
|
+
default: null
|
|
856
|
+
},
|
|
857
|
+
onClose: {
|
|
858
|
+
type: Function,
|
|
859
|
+
default: null
|
|
860
|
+
},
|
|
861
|
+
onConfirm: {
|
|
862
|
+
type: Function,
|
|
863
|
+
default: null
|
|
864
|
+
},
|
|
865
|
+
onCancel: {
|
|
866
|
+
type: Function,
|
|
867
|
+
default: null
|
|
868
|
+
}
|
|
869
|
+
},
|
|
870
|
+
emits: ["update:modelValue", "close", "confirm", "cancel"],
|
|
871
|
+
setup(e, { expose: o, emit: a }) {
|
|
872
|
+
const t = e, s = a, i = q({
|
|
873
|
+
get: () => t.modelValue,
|
|
874
|
+
set: (g) => s("update:modelValue", g)
|
|
875
|
+
}), l = (g) => {
|
|
876
|
+
t.beforeClose ? t.beforeClose(g) : g();
|
|
877
|
+
}, p = () => {
|
|
878
|
+
t.onClose && t.onClose(), s("close");
|
|
879
|
+
}, d = () => {
|
|
880
|
+
t.onConfirm && t.onConfirm(), s("confirm");
|
|
881
|
+
}, b = () => {
|
|
882
|
+
i.value = !1, t.onCancel && t.onCancel(), s("cancel");
|
|
883
|
+
};
|
|
884
|
+
return o({
|
|
885
|
+
open: () => {
|
|
886
|
+
i.value = !0;
|
|
887
|
+
},
|
|
888
|
+
close: () => {
|
|
889
|
+
i.value = !1;
|
|
890
|
+
}
|
|
891
|
+
}), (g, v) => {
|
|
892
|
+
const k = K("el-button"), F = K("el-drawer");
|
|
893
|
+
return x(), z(F, {
|
|
894
|
+
modelValue: i.value,
|
|
895
|
+
"onUpdate:modelValue": v[0] || (v[0] = (n) => i.value = n),
|
|
896
|
+
title: e.title,
|
|
897
|
+
size: e.size,
|
|
898
|
+
direction: e.direction,
|
|
899
|
+
"before-close": l,
|
|
900
|
+
"close-on-click-modal": e.closeOnClickModal,
|
|
901
|
+
"close-on-press-escape": e.closeOnPressEscape,
|
|
902
|
+
"destroy-on-close": e.destroyOnClose,
|
|
903
|
+
onClosed: p,
|
|
904
|
+
class: xe({ "drawer-with-footer": e.showFooter })
|
|
905
|
+
}, Le({
|
|
906
|
+
default: A(() => [
|
|
907
|
+
Q("div", {
|
|
908
|
+
class: xe(["drawer-content", { "has-footer": e.showFooter }])
|
|
909
|
+
}, [
|
|
910
|
+
ie(g.$slots, "default", {}, void 0, !0)
|
|
911
|
+
], 2)
|
|
912
|
+
]),
|
|
913
|
+
_: 2
|
|
914
|
+
}, [
|
|
915
|
+
e.showFooter ? {
|
|
916
|
+
name: "footer",
|
|
917
|
+
fn: A(() => [
|
|
918
|
+
Q("div", Tt, [
|
|
919
|
+
H(k, {
|
|
920
|
+
onClick: b,
|
|
921
|
+
size: "default"
|
|
922
|
+
}, {
|
|
923
|
+
default: A(() => [...v[1] || (v[1] = [
|
|
924
|
+
ae(" 取消 ", -1)
|
|
925
|
+
])]),
|
|
926
|
+
_: 1
|
|
927
|
+
}),
|
|
928
|
+
H(k, {
|
|
929
|
+
type: "primary",
|
|
930
|
+
loading: e.confirmLoading,
|
|
931
|
+
onClick: d,
|
|
932
|
+
size: "default"
|
|
933
|
+
}, {
|
|
934
|
+
default: A(() => [...v[2] || (v[2] = [
|
|
935
|
+
ae(" 确定 ", -1)
|
|
936
|
+
])]),
|
|
937
|
+
_: 1
|
|
938
|
+
}, 8, ["loading"])
|
|
939
|
+
])
|
|
940
|
+
]),
|
|
941
|
+
key: "0"
|
|
942
|
+
} : void 0
|
|
943
|
+
]), 1032, ["modelValue", "title", "size", "direction", "close-on-click-modal", "close-on-press-escape", "destroy-on-close", "class"]);
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
}), kt = /* @__PURE__ */ ve(At, [["__scopeId", "data-v-4f318c2b"]]);
|
|
947
|
+
function $t(e, o) {
|
|
948
|
+
const a = q(() => (e.columns || []).map((n, r) => ({
|
|
949
|
+
...n,
|
|
950
|
+
_key: n.prop || n.slot || n.type || n.label || `col_${r}`
|
|
951
|
+
}))), t = q(() => a.value.filter(
|
|
952
|
+
(n) => n.type !== "selection" && n.type !== "drag" && n.label
|
|
953
|
+
)), s = P([]), i = P([]), l = P(null), p = P(!1), d = q(() => e.tableKey ? a.value.filter((n) => t.value.some((u) => u._key === n._key) ? s.value.includes(n._key) : !0) : a.value), b = () => `c_table_hide_cols_${e.tableKey}`;
|
|
954
|
+
return {
|
|
955
|
+
computedColumns: d,
|
|
956
|
+
settingColumns: t,
|
|
957
|
+
visibleColKeys: s,
|
|
958
|
+
tempVisibleColKeys: i,
|
|
959
|
+
popoverRef: l,
|
|
960
|
+
savingColumns: p,
|
|
961
|
+
initTableConfig: async () => {
|
|
962
|
+
if (s.value = t.value.map((n) => n._key), !!e.tableKey)
|
|
963
|
+
try {
|
|
964
|
+
let n = [];
|
|
965
|
+
if (typeof e.getColumnConfigApi == "function") {
|
|
966
|
+
const r = await e.getColumnConfigApi({ tableKey: e.tableKey });
|
|
967
|
+
n = (r == null ? void 0 : r.data) || r || [];
|
|
968
|
+
} else {
|
|
969
|
+
const r = localStorage.getItem(b());
|
|
970
|
+
r && (n = JSON.parse(r));
|
|
971
|
+
}
|
|
972
|
+
Array.isArray(n) && n.length > 0 && (s.value = t.value.filter((r) => !n.includes(r._key)).map((r) => r._key));
|
|
973
|
+
} catch (n) {
|
|
974
|
+
console.warn("CSimpleTable: 获取表格隐藏列配置失败", n);
|
|
975
|
+
}
|
|
976
|
+
},
|
|
977
|
+
handlePopoverShow: () => {
|
|
978
|
+
i.value = [...s.value];
|
|
979
|
+
},
|
|
980
|
+
handleCancelSettings: () => {
|
|
981
|
+
l.value && l.value.hide();
|
|
982
|
+
},
|
|
983
|
+
handleConfirmSettings: async () => {
|
|
984
|
+
if (p.value = !0, e.tableKey) {
|
|
985
|
+
const n = t.value.filter((r) => !i.value.includes(r._key)).map((r) => r._key);
|
|
986
|
+
try {
|
|
987
|
+
typeof e.saveColumnConfigApi == "function" ? await e.saveColumnConfigApi({
|
|
988
|
+
tableKey: e.tableKey,
|
|
989
|
+
hideFields: n
|
|
990
|
+
}) : localStorage.setItem(b(), JSON.stringify(n)), s.value = [...i.value], o && ge(() => {
|
|
991
|
+
o();
|
|
992
|
+
}), l.value && l.value.hide();
|
|
993
|
+
} catch (r) {
|
|
994
|
+
console.error("CSimpleTable: 保存表格隐藏列配置失败", r);
|
|
995
|
+
} finally {
|
|
996
|
+
p.value = !1;
|
|
997
|
+
}
|
|
998
|
+
} else
|
|
999
|
+
s.value = [...i.value], p.value = !1, l.value && l.value.hide();
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
}
|
|
1003
|
+
const Et = {
|
|
1004
|
+
key: 0,
|
|
1005
|
+
class: "table-header"
|
|
1006
|
+
}, Ot = { class: "header-left" }, Pt = { class: "header-right" }, Dt = { class: "column-setting-list" }, Ft = { style: { "text-align": "right", "margin-top": "10px" } }, Mt = {
|
|
1007
|
+
class: "drag-handle",
|
|
1008
|
+
style: { cursor: "move" }
|
|
1009
|
+
}, Rt = { key: 2 }, Lt = { key: 3 }, Vt = {
|
|
1010
|
+
key: 1,
|
|
1011
|
+
class: "table-pagination"
|
|
1012
|
+
}, Bt = /* @__PURE__ */ me({
|
|
1013
|
+
name: "CSimpleTable",
|
|
1014
|
+
__name: "index",
|
|
1015
|
+
props: {
|
|
1016
|
+
scrollY: {
|
|
1017
|
+
type: [Number, String],
|
|
1018
|
+
default: ""
|
|
1019
|
+
},
|
|
1020
|
+
autoHeight: {
|
|
1021
|
+
type: Boolean,
|
|
1022
|
+
default: !1
|
|
1023
|
+
},
|
|
1024
|
+
bottomOffset: {
|
|
1025
|
+
type: Number,
|
|
1026
|
+
default: 20
|
|
1027
|
+
},
|
|
1028
|
+
minHeight: {
|
|
1029
|
+
type: Number,
|
|
1030
|
+
default: 300
|
|
1031
|
+
},
|
|
1032
|
+
api: {
|
|
1033
|
+
type: Function,
|
|
1034
|
+
required: !1
|
|
1035
|
+
},
|
|
1036
|
+
columns: {
|
|
1037
|
+
type: Array,
|
|
1038
|
+
required: !0,
|
|
1039
|
+
default: () => []
|
|
1040
|
+
},
|
|
1041
|
+
emptyCellText: {
|
|
1042
|
+
type: String,
|
|
1043
|
+
default: "-"
|
|
1044
|
+
},
|
|
1045
|
+
showPagination: {
|
|
1046
|
+
type: Boolean,
|
|
1047
|
+
default: !0
|
|
1048
|
+
},
|
|
1049
|
+
pageSizes: {
|
|
1050
|
+
type: Array,
|
|
1051
|
+
default: () => [10, 20, 50, 100]
|
|
1052
|
+
},
|
|
1053
|
+
layout: {
|
|
1054
|
+
type: String,
|
|
1055
|
+
default: "total, sizes, prev, pager, next, jumper"
|
|
1056
|
+
},
|
|
1057
|
+
background: {
|
|
1058
|
+
type: Boolean,
|
|
1059
|
+
default: !1
|
|
1060
|
+
},
|
|
1061
|
+
dataKey: {
|
|
1062
|
+
type: String,
|
|
1063
|
+
default: "data"
|
|
1064
|
+
},
|
|
1065
|
+
totalKey: {
|
|
1066
|
+
type: String,
|
|
1067
|
+
default: "total"
|
|
1068
|
+
},
|
|
1069
|
+
immediate: {
|
|
1070
|
+
type: Boolean,
|
|
1071
|
+
default: !0
|
|
1072
|
+
},
|
|
1073
|
+
initialPage: {
|
|
1074
|
+
type: Number,
|
|
1075
|
+
default: 1
|
|
1076
|
+
},
|
|
1077
|
+
initialPageSize: {
|
|
1078
|
+
type: Number,
|
|
1079
|
+
default: 10
|
|
1080
|
+
},
|
|
1081
|
+
params: {
|
|
1082
|
+
type: Object,
|
|
1083
|
+
default: () => ({})
|
|
1084
|
+
},
|
|
1085
|
+
border: {
|
|
1086
|
+
type: Boolean,
|
|
1087
|
+
default: !0
|
|
1088
|
+
},
|
|
1089
|
+
dataHandler: {
|
|
1090
|
+
type: Function,
|
|
1091
|
+
default: null
|
|
1092
|
+
},
|
|
1093
|
+
selectable: {
|
|
1094
|
+
type: Function,
|
|
1095
|
+
default: null
|
|
1096
|
+
},
|
|
1097
|
+
dragSort: {
|
|
1098
|
+
type: Boolean,
|
|
1099
|
+
default: !1
|
|
1100
|
+
},
|
|
1101
|
+
dragOptions: {
|
|
1102
|
+
type: Object,
|
|
1103
|
+
default: () => ({})
|
|
1104
|
+
},
|
|
1105
|
+
rowKey: {
|
|
1106
|
+
type: String,
|
|
1107
|
+
default: "id"
|
|
1108
|
+
},
|
|
1109
|
+
keepSelection: {
|
|
1110
|
+
type: Boolean,
|
|
1111
|
+
default: !0
|
|
1112
|
+
},
|
|
1113
|
+
defaultStatusMap: {
|
|
1114
|
+
type: Object,
|
|
1115
|
+
default: () => ({
|
|
1116
|
+
1: { text: "停用", type: "danger" },
|
|
1117
|
+
0: { text: "启用", type: "success" }
|
|
1118
|
+
})
|
|
1119
|
+
},
|
|
1120
|
+
tableKey: {
|
|
1121
|
+
type: String,
|
|
1122
|
+
default: ""
|
|
1123
|
+
},
|
|
1124
|
+
getColumnConfigApi: {
|
|
1125
|
+
type: Function,
|
|
1126
|
+
default: null
|
|
1127
|
+
},
|
|
1128
|
+
saveColumnConfigApi: {
|
|
1129
|
+
type: Function,
|
|
1130
|
+
default: null
|
|
1131
|
+
}
|
|
1132
|
+
},
|
|
1133
|
+
emits: [
|
|
1134
|
+
"selection-change",
|
|
1135
|
+
"refresh",
|
|
1136
|
+
"error",
|
|
1137
|
+
"drag-sort",
|
|
1138
|
+
"drag-start",
|
|
1139
|
+
"drag-end"
|
|
1140
|
+
],
|
|
1141
|
+
setup(e, { expose: o, emit: a }) {
|
|
1142
|
+
const t = e, s = a, i = P(null), l = P([]), p = P(!1), d = P(t.initialPage), b = P(t.initialPageSize), g = P(0), v = P({});
|
|
1143
|
+
let k = null;
|
|
1144
|
+
const F = P(null), n = P(null);
|
|
1145
|
+
let r = null, u = null;
|
|
1146
|
+
const c = q(() => t.autoHeight ? n.value : t.scrollY || null), f = () => {
|
|
1147
|
+
if (!t.autoHeight || !F.value) return;
|
|
1148
|
+
const _ = F.value.getBoundingClientRect(), O = window.innerHeight, V = _.top;
|
|
1149
|
+
let B = t.bottomOffset;
|
|
1150
|
+
t.showPagination && (B += 60);
|
|
1151
|
+
const I = F.value.querySelector(".table-header");
|
|
1152
|
+
I && (B += I.offsetHeight);
|
|
1153
|
+
const j = O - V - B, se = Math.max(t.minHeight, j);
|
|
1154
|
+
(n.value === null || Math.abs(n.value - se) > 2) && (n.value = se);
|
|
1155
|
+
}, C = (_, O) => {
|
|
1156
|
+
if (!(!_ || !O))
|
|
1157
|
+
return O in _ ? _[O] : O.split(".").reduce((V, B) => V != null ? V[B] : void 0, _);
|
|
1158
|
+
}, $ = (_, O) => {
|
|
1159
|
+
const V = C(_, O.prop);
|
|
1160
|
+
return V == null || V === "" ? O.emptyText || t.emptyCellText : String(V);
|
|
1161
|
+
}, M = ((_, O = 150) => {
|
|
1162
|
+
let V = null;
|
|
1163
|
+
const B = function(...I) {
|
|
1164
|
+
V && clearTimeout(V), V = setTimeout(() => {
|
|
1165
|
+
_.apply(this, I);
|
|
1166
|
+
}, O);
|
|
1167
|
+
};
|
|
1168
|
+
return B.cancel = () => {
|
|
1169
|
+
V && (clearTimeout(V), V = null);
|
|
1170
|
+
}, B;
|
|
1171
|
+
})(f, 150), {
|
|
1172
|
+
computedColumns: R,
|
|
1173
|
+
settingColumns: W,
|
|
1174
|
+
tempVisibleColKeys: le,
|
|
1175
|
+
popoverRef: be,
|
|
1176
|
+
savingColumns: m,
|
|
1177
|
+
initTableConfig: h,
|
|
1178
|
+
handlePopoverShow: N,
|
|
1179
|
+
handleCancelSettings: E,
|
|
1180
|
+
handleConfirmSettings: G
|
|
1181
|
+
} = $t(t, f), ne = (_, O) => {
|
|
1182
|
+
var B;
|
|
1183
|
+
return ((B = (O || t.defaultStatusMap)[_]) == null ? void 0 : B.type) || "info";
|
|
1184
|
+
}, w = (_, O) => {
|
|
1185
|
+
var B;
|
|
1186
|
+
return ((B = (O || t.defaultStatusMap)[_]) == null ? void 0 : B.text) || _;
|
|
1187
|
+
}, T = async (_ = {}) => {
|
|
1188
|
+
var O, V;
|
|
1189
|
+
if (t.api) {
|
|
1190
|
+
p.value = !0;
|
|
1191
|
+
try {
|
|
1192
|
+
const B = {
|
|
1193
|
+
pageNum: d.value,
|
|
1194
|
+
pageSize: b.value,
|
|
1195
|
+
...v.value,
|
|
1196
|
+
...t.params,
|
|
1197
|
+
..._
|
|
1198
|
+
};
|
|
1199
|
+
t.showPagination || (delete B.pageNum, delete B.pageSize);
|
|
1200
|
+
const I = await t.api(B);
|
|
1201
|
+
let j = null;
|
|
1202
|
+
I && I.code === 200 ? Array.isArray(I.data) ? j = { data: I.data } : I.data ? j = I.data : j = I : Array.isArray(I) ? j = { data: I } : I != null && I.rows ? j = { data: I.rows, total: I.total } : j = I, j && (l.value = j[t.dataKey] || ((O = j.data) == null ? void 0 : O[t.dataKey]) || j.rows || [], t.dataHandler && (l.value = t.dataHandler(l.value)), g.value = j[t.totalKey] || ((V = j.data) == null ? void 0 : V[t.totalKey]) || j.total || 0);
|
|
1203
|
+
} catch (B) {
|
|
1204
|
+
console.error("CSimpleTable fetchData error:", B), l.value = [], g.value = 0, s("error", B);
|
|
1205
|
+
} finally {
|
|
1206
|
+
p.value = !1, ge(() => {
|
|
1207
|
+
f(), t.dragSort && L();
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
}, L = () => {
|
|
1212
|
+
var B;
|
|
1213
|
+
if (!i.value) return;
|
|
1214
|
+
k && k.destroy();
|
|
1215
|
+
const _ = (B = i.value.$el) == null ? void 0 : B.querySelector(".el-table__body-wrapper tbody");
|
|
1216
|
+
if (!_) return;
|
|
1217
|
+
const V = { ...{
|
|
1218
|
+
animation: 150,
|
|
1219
|
+
handle: ".drag-handle",
|
|
1220
|
+
ghostClass: "sortable-ghost",
|
|
1221
|
+
chosenClass: "sortable-chosen",
|
|
1222
|
+
dragClass: "sortable-drag",
|
|
1223
|
+
forceFallback: !0,
|
|
1224
|
+
onStart: (I) => {
|
|
1225
|
+
s("drag-start", {
|
|
1226
|
+
oldIndex: I.oldIndex,
|
|
1227
|
+
element: I.item
|
|
1228
|
+
});
|
|
1229
|
+
},
|
|
1230
|
+
onEnd: (I) => {
|
|
1231
|
+
const { oldIndex: j, newIndex: se } = I;
|
|
1232
|
+
if (j === void 0 || se === void 0 || j === se) {
|
|
1233
|
+
s("drag-end", {
|
|
1234
|
+
oldIndex: j,
|
|
1235
|
+
newIndex: se,
|
|
1236
|
+
changed: !1
|
|
1237
|
+
});
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
const ce = l.value.splice(j, 1)[0];
|
|
1241
|
+
l.value.splice(se, 0, ce), s("drag-sort", {
|
|
1242
|
+
oldIndex: j,
|
|
1243
|
+
newIndex: se,
|
|
1244
|
+
movedItem: ce,
|
|
1245
|
+
data: l.value
|
|
1246
|
+
}), s("drag-end", {
|
|
1247
|
+
oldIndex: j,
|
|
1248
|
+
newIndex: se,
|
|
1249
|
+
changed: !0,
|
|
1250
|
+
movedItem: ce
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
}, ...t.dragOptions };
|
|
1254
|
+
k = rt.create(_, V);
|
|
1255
|
+
}, J = () => {
|
|
1256
|
+
T(), s("refresh");
|
|
1257
|
+
}, Y = () => {
|
|
1258
|
+
d.value = t.initialPage, v.value = {}, T();
|
|
1259
|
+
}, D = (_ = {}) => {
|
|
1260
|
+
d.value = t.initialPage, v.value = { ..._ }, T();
|
|
1261
|
+
}, ye = (_) => {
|
|
1262
|
+
d.value = _, T();
|
|
1263
|
+
}, Se = (_) => {
|
|
1264
|
+
b.value = _, d.value = t.initialPage, T();
|
|
1265
|
+
}, Te = (_) => {
|
|
1266
|
+
s("selection-change", _);
|
|
1267
|
+
}, Ce = () => {
|
|
1268
|
+
i.value && i.value.clearSelection();
|
|
1269
|
+
}, Z = (_, O) => {
|
|
1270
|
+
i.value && i.value.toggleRowSelection(_, O);
|
|
1271
|
+
}, Ke = () => {
|
|
1272
|
+
i.value && i.value.toggleAllSelection();
|
|
1273
|
+
}, ze = () => i.value ? i.value.getSelectionRows() : [], Ne = (_ = []) => {
|
|
1274
|
+
!i.value || !Array.isArray(_) || (Ce(), ge(() => {
|
|
1275
|
+
l.value.forEach((O) => {
|
|
1276
|
+
var V;
|
|
1277
|
+
_.includes(O[t.rowKey]) && ((V = i.value) == null || V.toggleRowSelection(O, !0));
|
|
1278
|
+
});
|
|
1279
|
+
}));
|
|
1280
|
+
};
|
|
1281
|
+
fe(
|
|
1282
|
+
() => t.params,
|
|
1283
|
+
(_) => {
|
|
1284
|
+
d.value = t.initialPage, v.value = { ..._ }, T();
|
|
1285
|
+
},
|
|
1286
|
+
{ deep: !0 }
|
|
1287
|
+
), fe(
|
|
1288
|
+
() => t.dragSort,
|
|
1289
|
+
(_) => {
|
|
1290
|
+
_ ? ge(() => {
|
|
1291
|
+
L();
|
|
1292
|
+
}) : k && (k.destroy(), k = null);
|
|
1293
|
+
}
|
|
1294
|
+
), fe(
|
|
1295
|
+
() => t.autoHeight,
|
|
1296
|
+
(_) => {
|
|
1297
|
+
_ ? (Oe(), ge(f)) : Pe();
|
|
1298
|
+
}
|
|
1299
|
+
);
|
|
1300
|
+
const Oe = () => {
|
|
1301
|
+
var O, V, B;
|
|
1302
|
+
if (!t.autoHeight) return;
|
|
1303
|
+
window.addEventListener("resize", M), r || (r = new ResizeObserver(M)), (O = F.value) != null && O.parentElement && r.observe(F.value.parentElement);
|
|
1304
|
+
const _ = (V = F.value) == null ? void 0 : V.previousElementSibling;
|
|
1305
|
+
_ && r.observe(_), u || (u = new MutationObserver(() => {
|
|
1306
|
+
ge(M);
|
|
1307
|
+
})), (B = F.value) != null && B.parentElement && u.observe(F.value.parentElement, {
|
|
1308
|
+
childList: !0,
|
|
1309
|
+
subtree: !0,
|
|
1310
|
+
attributes: !0,
|
|
1311
|
+
attributeFilter: ["style", "class"]
|
|
1312
|
+
});
|
|
1313
|
+
}, Pe = () => {
|
|
1314
|
+
window.removeEventListener("resize", M), r && r.disconnect(), u && u.disconnect();
|
|
1315
|
+
};
|
|
1316
|
+
return o({
|
|
1317
|
+
refresh: J,
|
|
1318
|
+
reset: Y,
|
|
1319
|
+
search: D,
|
|
1320
|
+
fetchData: T,
|
|
1321
|
+
clearSelection: Ce,
|
|
1322
|
+
toggleRowSelection: Z,
|
|
1323
|
+
toggleAllSelection: Ke,
|
|
1324
|
+
getSelectionRows: ze,
|
|
1325
|
+
setSelectionByKeys: Ne,
|
|
1326
|
+
tableData: l,
|
|
1327
|
+
tableRef: i,
|
|
1328
|
+
recalculateHeight: f
|
|
1329
|
+
}), ke(() => {
|
|
1330
|
+
t.immediate && T(), h(), ge(() => {
|
|
1331
|
+
f();
|
|
1332
|
+
}), t.autoHeight && Oe();
|
|
1333
|
+
}), Je(() => {
|
|
1334
|
+
Pe(), M.cancel(), k && (k.destroy(), k = null);
|
|
1335
|
+
}), (_, O) => {
|
|
1336
|
+
const V = K("el-icon"), B = K("el-button"), I = K("el-checkbox"), j = K("el-checkbox-group"), se = K("el-popover"), ce = K("el-table-column"), Ie = K("el-tag"), He = K("el-table"), Ye = K("el-pagination"), je = Ve("loading");
|
|
1337
|
+
return x(), U("div", {
|
|
1338
|
+
class: "c-simple-table",
|
|
1339
|
+
ref_key: "tableContainerRef",
|
|
1340
|
+
ref: F
|
|
1341
|
+
}, [
|
|
1342
|
+
_.$slots.headerLeft || _.$slots.headerRight || e.tableKey ? (x(), U("div", Et, [
|
|
1343
|
+
Q("div", Ot, [
|
|
1344
|
+
ie(_.$slots, "headerLeft", {}, void 0, !0)
|
|
1345
|
+
]),
|
|
1346
|
+
Q("div", Pt, [
|
|
1347
|
+
ie(_.$slots, "headerRight", {}, void 0, !0),
|
|
1348
|
+
e.tableKey ? (x(), z(se, {
|
|
1349
|
+
key: 0,
|
|
1350
|
+
ref_key: "popoverRef",
|
|
1351
|
+
ref: be,
|
|
1352
|
+
placement: "bottom-end",
|
|
1353
|
+
title: "自定义列",
|
|
1354
|
+
width: 200,
|
|
1355
|
+
trigger: "click",
|
|
1356
|
+
onShow: ee(N)
|
|
1357
|
+
}, {
|
|
1358
|
+
reference: A(() => [
|
|
1359
|
+
H(B, { size: "small" }, {
|
|
1360
|
+
default: A(() => [
|
|
1361
|
+
H(V, null, {
|
|
1362
|
+
default: A(() => [
|
|
1363
|
+
H(ee(lt))
|
|
1364
|
+
]),
|
|
1365
|
+
_: 1
|
|
1366
|
+
}),
|
|
1367
|
+
O[3] || (O[3] = ae(" 自定义列 ", -1))
|
|
1368
|
+
]),
|
|
1369
|
+
_: 1
|
|
1370
|
+
})
|
|
1371
|
+
]),
|
|
1372
|
+
default: A(() => [
|
|
1373
|
+
Q("div", Dt, [
|
|
1374
|
+
H(j, {
|
|
1375
|
+
modelValue: ee(le),
|
|
1376
|
+
"onUpdate:modelValue": O[0] || (O[0] = (y) => Xe(le) ? le.value = y : null)
|
|
1377
|
+
}, {
|
|
1378
|
+
default: A(() => [
|
|
1379
|
+
(x(!0), U(ue, null, pe(ee(W), (y) => (x(), U("div", {
|
|
1380
|
+
key: y._key,
|
|
1381
|
+
class: "column-setting-item"
|
|
1382
|
+
}, [
|
|
1383
|
+
H(I, {
|
|
1384
|
+
value: y._key,
|
|
1385
|
+
label: y._key
|
|
1386
|
+
}, {
|
|
1387
|
+
default: A(() => [
|
|
1388
|
+
ae(oe(y.label), 1)
|
|
1389
|
+
]),
|
|
1390
|
+
_: 2
|
|
1391
|
+
}, 1032, ["value", "label"])
|
|
1392
|
+
]))), 128))
|
|
1393
|
+
]),
|
|
1394
|
+
_: 1
|
|
1395
|
+
}, 8, ["modelValue"])
|
|
1396
|
+
]),
|
|
1397
|
+
Q("div", Ft, [
|
|
1398
|
+
H(B, {
|
|
1399
|
+
size: "small",
|
|
1400
|
+
onClick: ee(E)
|
|
1401
|
+
}, {
|
|
1402
|
+
default: A(() => [...O[4] || (O[4] = [
|
|
1403
|
+
ae("取消", -1)
|
|
1404
|
+
])]),
|
|
1405
|
+
_: 1
|
|
1406
|
+
}, 8, ["onClick"]),
|
|
1407
|
+
H(B, {
|
|
1408
|
+
size: "small",
|
|
1409
|
+
type: "primary",
|
|
1410
|
+
loading: ee(m),
|
|
1411
|
+
onClick: ee(G)
|
|
1412
|
+
}, {
|
|
1413
|
+
default: A(() => [...O[5] || (O[5] = [
|
|
1414
|
+
ae("确定", -1)
|
|
1415
|
+
])]),
|
|
1416
|
+
_: 1
|
|
1417
|
+
}, 8, ["loading", "onClick"])
|
|
1418
|
+
])
|
|
1419
|
+
]),
|
|
1420
|
+
_: 1
|
|
1421
|
+
}, 8, ["onShow"])) : re("", !0)
|
|
1422
|
+
])
|
|
1423
|
+
])) : re("", !0),
|
|
1424
|
+
Ee((x(), z(He, de({
|
|
1425
|
+
ref_key: "tableRef",
|
|
1426
|
+
ref: i,
|
|
1427
|
+
data: l.value,
|
|
1428
|
+
border: e.border,
|
|
1429
|
+
style: { width: "100%" },
|
|
1430
|
+
"row-key": e.rowKey
|
|
1431
|
+
}, _.$attrs, {
|
|
1432
|
+
onSelectionChange: Te,
|
|
1433
|
+
"max-height": c.value,
|
|
1434
|
+
height: e.autoHeight ? c.value : e.scrollY
|
|
1435
|
+
}), {
|
|
1436
|
+
default: A(() => [
|
|
1437
|
+
(x(!0), U(ue, null, pe(ee(R), (y, We) => (x(), U(ue, {
|
|
1438
|
+
key: y._key || We
|
|
1439
|
+
}, [
|
|
1440
|
+
y.type === "drag" ? (x(), z(ce, {
|
|
1441
|
+
key: 0,
|
|
1442
|
+
width: y.width || 55,
|
|
1443
|
+
align: y.align || "center",
|
|
1444
|
+
fixed: y.fixed
|
|
1445
|
+
}, {
|
|
1446
|
+
header: A(() => [
|
|
1447
|
+
Q("span", null, oe(y.label || "排序"), 1)
|
|
1448
|
+
]),
|
|
1449
|
+
default: A(() => [
|
|
1450
|
+
Q("div", Mt, [
|
|
1451
|
+
H(V, null, {
|
|
1452
|
+
default: A(() => [
|
|
1453
|
+
H(ee(nt))
|
|
1454
|
+
]),
|
|
1455
|
+
_: 1
|
|
1456
|
+
})
|
|
1457
|
+
])
|
|
1458
|
+
]),
|
|
1459
|
+
_: 2
|
|
1460
|
+
}, 1032, ["width", "align", "fixed"])) : y.type === "selection" ? (x(), z(ce, {
|
|
1461
|
+
key: 1,
|
|
1462
|
+
selectable: e.selectable,
|
|
1463
|
+
"reserve-selection": e.keepSelection,
|
|
1464
|
+
type: "selection",
|
|
1465
|
+
width: y.width || 55,
|
|
1466
|
+
align: y.align || "center"
|
|
1467
|
+
}, null, 8, ["selectable", "reserve-selection", "width", "align"])) : y.type === "index" ? (x(), z(ce, {
|
|
1468
|
+
key: 2,
|
|
1469
|
+
type: "index",
|
|
1470
|
+
label: y.label || "序号",
|
|
1471
|
+
width: y.width || 60,
|
|
1472
|
+
align: y.align || "center"
|
|
1473
|
+
}, null, 8, ["label", "width", "align"])) : y.type === "status" ? (x(), z(ce, {
|
|
1474
|
+
key: 3,
|
|
1475
|
+
prop: y.prop,
|
|
1476
|
+
label: y.label || "状态",
|
|
1477
|
+
width: y.width || 100,
|
|
1478
|
+
align: y.align || "center",
|
|
1479
|
+
fixed: y.fixed,
|
|
1480
|
+
sortable: y.sortable
|
|
1481
|
+
}, {
|
|
1482
|
+
default: A((te) => [
|
|
1483
|
+
y.slot ? ie(_.$slots, y.slot, de({ ref_for: !0 }, te), void 0, !0, 0) : (x(), z(Ie, {
|
|
1484
|
+
key: 1,
|
|
1485
|
+
type: ne(C(te.row, y.prop), y.statusMap),
|
|
1486
|
+
effect: y.effect || "light",
|
|
1487
|
+
size: y.size || "default"
|
|
1488
|
+
}, {
|
|
1489
|
+
default: A(() => [
|
|
1490
|
+
ae(oe(w(C(te.row, y.prop), y.statusMap)), 1)
|
|
1491
|
+
]),
|
|
1492
|
+
_: 2
|
|
1493
|
+
}, 1032, ["type", "effect", "size"]))
|
|
1494
|
+
]),
|
|
1495
|
+
_: 2
|
|
1496
|
+
}, 1032, ["prop", "label", "width", "align", "fixed", "sortable"])) : (x(), z(ce, {
|
|
1497
|
+
key: 4,
|
|
1498
|
+
prop: y.prop,
|
|
1499
|
+
label: y.label,
|
|
1500
|
+
width: y.width,
|
|
1501
|
+
"min-width": y.minWidth,
|
|
1502
|
+
align: y.align || "left",
|
|
1503
|
+
fixed: y.fixed,
|
|
1504
|
+
sortable: y.sortable,
|
|
1505
|
+
"show-overflow-tooltip": y.showOverflowTooltip !== !1
|
|
1506
|
+
}, Le({
|
|
1507
|
+
default: A((te) => [
|
|
1508
|
+
y.slot ? ie(_.$slots, y.slot, de({ ref_for: !0 }, te), void 0, !0, 0) : y.render ? (x(), z(Re(y.render(te.row, te.column, te.$index)), { key: 1 })) : y.formatter ? (x(), U("span", Rt, oe(y.formatter(
|
|
1509
|
+
te.row,
|
|
1510
|
+
te.column,
|
|
1511
|
+
C(te.row, y.prop),
|
|
1512
|
+
te.$index
|
|
1513
|
+
)), 1)) : (x(), U("span", Lt, oe($(te.row, y)), 1))
|
|
1514
|
+
]),
|
|
1515
|
+
_: 2
|
|
1516
|
+
}, [
|
|
1517
|
+
y.headerSlot ? {
|
|
1518
|
+
name: "header",
|
|
1519
|
+
fn: A((te) => [
|
|
1520
|
+
ie(_.$slots, y.headerSlot, de({ ref_for: !0 }, te), void 0, !0)
|
|
1521
|
+
]),
|
|
1522
|
+
key: "0"
|
|
1523
|
+
} : void 0
|
|
1524
|
+
]), 1032, ["prop", "label", "width", "min-width", "align", "fixed", "sortable", "show-overflow-tooltip"]))
|
|
1525
|
+
], 64))), 128)),
|
|
1526
|
+
ie(_.$slots, "default", {}, void 0, !0)
|
|
1527
|
+
]),
|
|
1528
|
+
_: 3
|
|
1529
|
+
}, 16, ["data", "border", "row-key", "max-height", "height"])), [
|
|
1530
|
+
[je, p.value]
|
|
1531
|
+
]),
|
|
1532
|
+
e.showPagination ? (x(), U("div", Vt, [
|
|
1533
|
+
H(Ye, {
|
|
1534
|
+
"current-page": d.value,
|
|
1535
|
+
"onUpdate:currentPage": O[1] || (O[1] = (y) => d.value = y),
|
|
1536
|
+
"page-size": b.value,
|
|
1537
|
+
"onUpdate:pageSize": O[2] || (O[2] = (y) => b.value = y),
|
|
1538
|
+
"page-sizes": e.pageSizes,
|
|
1539
|
+
total: g.value,
|
|
1540
|
+
layout: e.layout,
|
|
1541
|
+
background: e.background,
|
|
1542
|
+
onSizeChange: Se,
|
|
1543
|
+
onCurrentChange: ye
|
|
1544
|
+
}, null, 8, ["current-page", "page-size", "page-sizes", "total", "layout", "background"])
|
|
1545
|
+
])) : re("", !0)
|
|
1546
|
+
], 512);
|
|
1547
|
+
};
|
|
1548
|
+
}
|
|
1549
|
+
}), Kt = /* @__PURE__ */ ve(Bt, [["__scopeId", "data-v-c7177925"]]), zt = { class: "c-diff-container" }, Nt = ["title", "innerHTML"], It = /* @__PURE__ */ me({
|
|
1550
|
+
name: "CDiff",
|
|
1551
|
+
__name: "index",
|
|
1552
|
+
props: {
|
|
1553
|
+
oldText: { type: String, default: "" },
|
|
1554
|
+
newText: { type: String, default: "" },
|
|
1555
|
+
similarityThreshold: { type: Number, default: 0.6 }
|
|
1556
|
+
},
|
|
1557
|
+
setup(e) {
|
|
1558
|
+
const o = e, a = P(!1), t = P([]), s = (n) => String(n).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), i = (n, r) => {
|
|
1559
|
+
const u = Array(n.length + 1).fill(null).map(() => Array(r.length + 1).fill(0));
|
|
1560
|
+
for (let c = 0; c <= n.length; c++) u[c][0] = c;
|
|
1561
|
+
for (let c = 0; c <= r.length; c++) u[0][c] = c;
|
|
1562
|
+
for (let c = 1; c <= n.length; c++)
|
|
1563
|
+
for (let f = 1; f <= r.length; f++)
|
|
1564
|
+
u[c][f] = n[c - 1] === r[f - 1] ? u[c - 1][f - 1] : 1 + Math.min(u[c - 1][f], u[c][f - 1], u[c - 1][f - 1]);
|
|
1565
|
+
return u[n.length][r.length];
|
|
1566
|
+
}, l = (n, r) => {
|
|
1567
|
+
if (!n && !r) return 1;
|
|
1568
|
+
if (!n || !r) return 0;
|
|
1569
|
+
const u = n.length > r.length ? n : r;
|
|
1570
|
+
return (u.length - i(n, r)) / u.length;
|
|
1571
|
+
}, p = (n, r) => {
|
|
1572
|
+
const u = Array.from(n), c = Array.from(r);
|
|
1573
|
+
if (u.length * c.length > 1e6)
|
|
1574
|
+
return [
|
|
1575
|
+
...n ? [{ type: "removed", value: n }] : [],
|
|
1576
|
+
...r ? [{ type: "added", value: r }] : []
|
|
1577
|
+
];
|
|
1578
|
+
const f = Array(u.length + 1).fill(null).map(() => new Int32Array(c.length + 1));
|
|
1579
|
+
for (let R = 0; R <= u.length; R++)
|
|
1580
|
+
for (let W = 0; W <= c.length; W++)
|
|
1581
|
+
R === 0 ? f[R][W] = W : W === 0 ? f[R][W] = R : u[R - 1] === c[W - 1] ? f[R][W] = f[R - 1][W - 1] : f[R][W] = 1 + Math.min(f[R - 1][W], f[R][W - 1], f[R - 1][W - 1]);
|
|
1582
|
+
const C = [];
|
|
1583
|
+
let $ = u.length, S = c.length;
|
|
1584
|
+
for (; $ > 0 || S > 0; )
|
|
1585
|
+
$ > 0 && S > 0 && u[$ - 1] === c[S - 1] ? (C.push({ type: "unchanged", value: u[$ - 1] }), $--, S--) : $ > 0 && (S === 0 || f[$][S] === f[$ - 1][S] + 1) ? (C.push({ type: "removed", value: u[$ - 1] }), $--) : (C.push({ type: "added", value: c[S - 1] }), S--);
|
|
1586
|
+
const M = [];
|
|
1587
|
+
for (const R of C.reverse())
|
|
1588
|
+
M.length && M[M.length - 1].type === R.type ? M[M.length - 1].value += R.value : M.push({ ...R });
|
|
1589
|
+
return M;
|
|
1590
|
+
}, d = (n) => n ? n.split(/\r?\n/) : [], b = (n, r) => {
|
|
1591
|
+
const u = d(n), c = d(r), f = [];
|
|
1592
|
+
let C = 0, $ = 0;
|
|
1593
|
+
for (; C < u.length || $ < c.length; ) {
|
|
1594
|
+
if (C >= u.length) {
|
|
1595
|
+
f.push({ type: "added", value: c[$++] + `
|
|
1596
|
+
` });
|
|
1597
|
+
continue;
|
|
1598
|
+
}
|
|
1599
|
+
if ($ >= c.length) {
|
|
1600
|
+
f.push({ type: "removed", value: u[C++] + `
|
|
1601
|
+
` });
|
|
1602
|
+
continue;
|
|
1603
|
+
}
|
|
1604
|
+
const S = u[C], M = c[$], R = S.trim(), W = M.trim(), le = l(R, W), be = Math.min(S.length, M.length) / Math.max(S.length, M.length || 1), m = C + 1 < u.length ? l(u[C + 1].trim(), W) : 0, h = $ + 1 < c.length ? l(R, c[$ + 1].trim()) : 0, N = Math.max(le, m, h);
|
|
1605
|
+
le >= o.similarityThreshold && le === N && be > 0.5 ? (S === M ? f.push({ type: "unchanged", value: S + `
|
|
1606
|
+
` }) : (f.push(...p(S, M)), f.push({ type: "unchanged", value: `
|
|
1607
|
+
` })), C++, $++) : m > le && m >= o.similarityThreshold ? (f.push({ type: "removed", value: S + `
|
|
1608
|
+
` }), C++) : h > le && h >= o.similarityThreshold ? (f.push({ type: "added", value: M + `
|
|
1609
|
+
` }), $++) : le < 0.3 ? (f.push({ type: "removed", value: S + `
|
|
1610
|
+
` }), f.push({ type: "added", value: M + `
|
|
1611
|
+
` }), C++, $++) : (f.push(...p(S, M)), f.push({ type: "unchanged", value: `
|
|
1612
|
+
` }), C++, $++);
|
|
1613
|
+
}
|
|
1614
|
+
return f;
|
|
1615
|
+
};
|
|
1616
|
+
let g = !1;
|
|
1617
|
+
const v = async () => {
|
|
1618
|
+
if (a.value = !0, g = !1, await ge(), await new Promise((n) => setTimeout(n, 10)), !g)
|
|
1619
|
+
try {
|
|
1620
|
+
t.value = b(o.oldText, o.newText);
|
|
1621
|
+
} catch (n) {
|
|
1622
|
+
console.error("CDiff compute error:", n), t.value = [{ type: "unchanged", value: "Diff 计算出错" }];
|
|
1623
|
+
} finally {
|
|
1624
|
+
g || (a.value = !1);
|
|
1625
|
+
}
|
|
1626
|
+
};
|
|
1627
|
+
fe(
|
|
1628
|
+
() => [o.oldText, o.newText],
|
|
1629
|
+
() => {
|
|
1630
|
+
g = !0, v();
|
|
1631
|
+
},
|
|
1632
|
+
{ immediate: !0 }
|
|
1633
|
+
);
|
|
1634
|
+
const k = (n) => ({
|
|
1635
|
+
"diff-removed": n.type === "removed",
|
|
1636
|
+
"diff-added": n.type === "added"
|
|
1637
|
+
}), F = (n) => n.type === "removed" ? "已删除" : n.type === "added" ? "已添加" : "";
|
|
1638
|
+
return (n, r) => {
|
|
1639
|
+
const u = Ve("loading");
|
|
1640
|
+
return Ee((x(), U("div", zt, [
|
|
1641
|
+
(x(!0), U(ue, null, pe(t.value, (c, f) => (x(), U("span", {
|
|
1642
|
+
key: f,
|
|
1643
|
+
class: xe(k(c)),
|
|
1644
|
+
title: F(c),
|
|
1645
|
+
innerHTML: s(c.value)
|
|
1646
|
+
}, null, 10, Nt))), 128))
|
|
1647
|
+
])), [
|
|
1648
|
+
[u, a.value]
|
|
1649
|
+
]);
|
|
1650
|
+
};
|
|
1651
|
+
}
|
|
1652
|
+
}), Ht = /* @__PURE__ */ ve(It, [["__scopeId", "data-v-29510e70"]]), Yt = { class: "image-slot" }, jt = /* @__PURE__ */ me({
|
|
1653
|
+
name: "CImagePreview",
|
|
1654
|
+
__name: "index",
|
|
1655
|
+
props: {
|
|
1656
|
+
src: {
|
|
1657
|
+
type: [String, Array],
|
|
1658
|
+
default: ""
|
|
1659
|
+
},
|
|
1660
|
+
width: {
|
|
1661
|
+
type: [Number, String],
|
|
1662
|
+
default: "60px"
|
|
1663
|
+
},
|
|
1664
|
+
height: {
|
|
1665
|
+
type: [Number, String],
|
|
1666
|
+
default: "60px"
|
|
1667
|
+
}
|
|
1668
|
+
},
|
|
1669
|
+
setup(e) {
|
|
1670
|
+
const o = e, a = q(() => o.src ? Array.isArray(o.src) ? o.src.map((l) => String(l).trim()).filter(Boolean) : String(o.src).split(",").map((l) => l.trim()).filter(Boolean) : []), t = q(() => a.value[0] || ""), s = q(
|
|
1671
|
+
() => typeof o.width == "string" ? o.width : `${o.width}px`
|
|
1672
|
+
), i = q(
|
|
1673
|
+
() => typeof o.height == "string" ? o.height : `${o.height}px`
|
|
1674
|
+
);
|
|
1675
|
+
return (l, p) => {
|
|
1676
|
+
const d = K("el-icon"), b = K("el-image");
|
|
1677
|
+
return x(), z(b, de({
|
|
1678
|
+
src: t.value,
|
|
1679
|
+
fit: "cover",
|
|
1680
|
+
style: `width:${s.value};height:${i.value};`,
|
|
1681
|
+
"preview-src-list": a.value,
|
|
1682
|
+
"preview-teleported": ""
|
|
1683
|
+
}, l.$attrs), {
|
|
1684
|
+
error: A(() => [
|
|
1685
|
+
Q("div", Yt, [
|
|
1686
|
+
H(d, null, {
|
|
1687
|
+
default: A(() => [
|
|
1688
|
+
H(ee(ot))
|
|
1689
|
+
]),
|
|
1690
|
+
_: 1
|
|
1691
|
+
})
|
|
1692
|
+
])
|
|
1693
|
+
]),
|
|
1694
|
+
_: 1
|
|
1695
|
+
}, 16, ["src", "style", "preview-src-list"]);
|
|
1696
|
+
};
|
|
1697
|
+
}
|
|
1698
|
+
}), Wt = /* @__PURE__ */ ve(jt, [["__scopeId", "data-v-cd23dea8"]]), Ut = [
|
|
1699
|
+
st,
|
|
1700
|
+
ct,
|
|
1701
|
+
mt,
|
|
1702
|
+
yt,
|
|
1703
|
+
St,
|
|
1704
|
+
kt,
|
|
1705
|
+
Kt,
|
|
1706
|
+
Ht,
|
|
1707
|
+
Wt
|
|
1708
|
+
];
|
|
1709
|
+
function ia(e = {}) {
|
|
1710
|
+
const {
|
|
1711
|
+
apiList: o,
|
|
1712
|
+
apiChangeState: a,
|
|
1713
|
+
apiDelete: t,
|
|
1714
|
+
apiBatchDelete: s,
|
|
1715
|
+
apiExport: i,
|
|
1716
|
+
addPath: l,
|
|
1717
|
+
editPath: p,
|
|
1718
|
+
navigate: d,
|
|
1719
|
+
exportFileName: b = "数据导出",
|
|
1720
|
+
stateKey: g = "state",
|
|
1721
|
+
idKey: v = "id",
|
|
1722
|
+
activeValue: k = 1,
|
|
1723
|
+
inactiveValue: F = 0,
|
|
1724
|
+
statusMap: n = { 0: "启用", 1: "停用" },
|
|
1725
|
+
deleteConfirmText: r = "确定要删除该数据吗?删除后将无法恢复!",
|
|
1726
|
+
deleteSuccessText: u = "删除成功",
|
|
1727
|
+
deleteErrorText: c = "删除失败",
|
|
1728
|
+
openDialog: f
|
|
1729
|
+
} = e, C = P(null), $ = P({}), S = (w) => {
|
|
1730
|
+
typeof d == "function" ? d(w) : console.warn("useListPage: 未提供 navigate 函数,如需路由跳转请在 options 中传入 navigate: (loc) => router.push(loc)");
|
|
1731
|
+
};
|
|
1732
|
+
return {
|
|
1733
|
+
tableRef: C,
|
|
1734
|
+
searchParams: $,
|
|
1735
|
+
handleSearch: (w) => {
|
|
1736
|
+
var T, L;
|
|
1737
|
+
$.value = w || {}, (L = (T = C.value) == null ? void 0 : T.search) == null || L.call(T, $.value);
|
|
1738
|
+
},
|
|
1739
|
+
handleReset: () => {
|
|
1740
|
+
var w, T;
|
|
1741
|
+
$.value = {}, (T = (w = C.value) == null ? void 0 : w.reset) == null || T.call(w);
|
|
1742
|
+
},
|
|
1743
|
+
changeState: async (w, T) => {
|
|
1744
|
+
var L, J;
|
|
1745
|
+
if (!a) {
|
|
1746
|
+
console.warn("useListPage: 未提供 apiChangeState 接口");
|
|
1747
|
+
return;
|
|
1748
|
+
}
|
|
1749
|
+
try {
|
|
1750
|
+
const D = w[g] === k ? F : k, ye = n[D] || "更新";
|
|
1751
|
+
await _e.confirm(`确定要${ye}该数据吗?`, "提示", {
|
|
1752
|
+
type: "warning"
|
|
1753
|
+
}), await a({
|
|
1754
|
+
[v]: w[v],
|
|
1755
|
+
[g]: D
|
|
1756
|
+
}), X.success(`${ye}成功`), (J = (L = C.value) == null ? void 0 : L.refresh) == null || J.call(L), T == null || T(w);
|
|
1757
|
+
} catch (Y) {
|
|
1758
|
+
Y !== "cancel" && Y !== "close" && X.error("操作失败");
|
|
1759
|
+
}
|
|
1760
|
+
},
|
|
1761
|
+
handleDelete: async (w, T) => {
|
|
1762
|
+
var L, J;
|
|
1763
|
+
if (!t) {
|
|
1764
|
+
console.warn("useListPage: 未提供 apiDelete 接口");
|
|
1765
|
+
return;
|
|
1766
|
+
}
|
|
1767
|
+
try {
|
|
1768
|
+
await _e.confirm(r, "警告", {
|
|
1769
|
+
confirmButtonText: "确定",
|
|
1770
|
+
cancelButtonText: "取消",
|
|
1771
|
+
type: "error",
|
|
1772
|
+
distinguishCancelAndClose: !0
|
|
1773
|
+
}), await t({ [v]: w[v] }), X.success(u), (J = (L = C.value) == null ? void 0 : L.refresh) == null || J.call(L), T == null || T(w);
|
|
1774
|
+
} catch (Y) {
|
|
1775
|
+
Y !== "cancel" && Y !== "close" && X.error(c);
|
|
1776
|
+
}
|
|
1777
|
+
},
|
|
1778
|
+
handleBatchDelete: async (w, T) => {
|
|
1779
|
+
var L, J;
|
|
1780
|
+
if (!t) {
|
|
1781
|
+
console.warn("useListPage: 未提供 apiDelete 接口");
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
if (!w || w.length === 0) {
|
|
1785
|
+
X.warning("请选择要删除的数据");
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1788
|
+
try {
|
|
1789
|
+
await _e.confirm(
|
|
1790
|
+
`确定要删除选中的 ${w.length} 条数据吗?删除后将无法恢复!`,
|
|
1791
|
+
"警告",
|
|
1792
|
+
{
|
|
1793
|
+
confirmButtonText: "确定",
|
|
1794
|
+
cancelButtonText: "取消",
|
|
1795
|
+
type: "error",
|
|
1796
|
+
distinguishCancelAndClose: !0
|
|
1797
|
+
}
|
|
1798
|
+
);
|
|
1799
|
+
const Y = w.map((D) => D[v]);
|
|
1800
|
+
s ? await s({ ids: Y }) : t.batch ? await t.batch({ ids: Y }) : await Promise.all(Y.map((D) => t({ [v]: D }))), X.success(`成功删除 ${w.length} 条数据`), (J = (L = C.value) == null ? void 0 : L.refresh) == null || J.call(L), T == null || T(w);
|
|
1801
|
+
} catch (Y) {
|
|
1802
|
+
Y !== "cancel" && Y !== "close" && X.error("删除失败");
|
|
1803
|
+
}
|
|
1804
|
+
},
|
|
1805
|
+
handleDialog: (w) => {
|
|
1806
|
+
typeof f == "function" && f(w);
|
|
1807
|
+
},
|
|
1808
|
+
exportExcel: async () => {
|
|
1809
|
+
if (!i) {
|
|
1810
|
+
console.warn("useListPage: 未提供 apiExport 接口");
|
|
1811
|
+
return;
|
|
1812
|
+
}
|
|
1813
|
+
try {
|
|
1814
|
+
const w = await i($.value), T = (w == null ? void 0 : w.data) || w, L = T instanceof Blob ? T : new Blob([T], {
|
|
1815
|
+
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
1816
|
+
}), J = window.URL.createObjectURL(L), Y = document.createElement("a");
|
|
1817
|
+
Y.href = J, Y.download = `${b}_${Date.now()}.xlsx`, document.body.appendChild(Y), Y.click(), document.body.removeChild(Y), window.URL.revokeObjectURL(J), X.success("导出成功");
|
|
1818
|
+
} catch {
|
|
1819
|
+
X.error("导出失败");
|
|
1820
|
+
}
|
|
1821
|
+
},
|
|
1822
|
+
handleAdd: (w = {}) => {
|
|
1823
|
+
if (!l) {
|
|
1824
|
+
console.warn("useListPage: 未提供 addPath");
|
|
1825
|
+
return;
|
|
1826
|
+
}
|
|
1827
|
+
S({ path: l, query: w });
|
|
1828
|
+
},
|
|
1829
|
+
handleEdit: (w, T = {}) => {
|
|
1830
|
+
if (!p) {
|
|
1831
|
+
console.warn("useListPage: 未提供 editPath");
|
|
1832
|
+
return;
|
|
1833
|
+
}
|
|
1834
|
+
S({
|
|
1835
|
+
path: p,
|
|
1836
|
+
query: { id: w[v], ...T }
|
|
1837
|
+
});
|
|
1838
|
+
},
|
|
1839
|
+
handleView: (w, T, L = {}) => {
|
|
1840
|
+
if (!T) {
|
|
1841
|
+
console.warn("useListPage: 未提供 detailPath");
|
|
1842
|
+
return;
|
|
1843
|
+
}
|
|
1844
|
+
S({
|
|
1845
|
+
path: T,
|
|
1846
|
+
query: { id: w[v], ...L }
|
|
1847
|
+
});
|
|
1848
|
+
},
|
|
1849
|
+
refresh: () => {
|
|
1850
|
+
var w, T;
|
|
1851
|
+
(T = (w = C.value) == null ? void 0 : w.refresh) == null || T.call(w);
|
|
1852
|
+
},
|
|
1853
|
+
apiList: o
|
|
1854
|
+
};
|
|
1855
|
+
}
|
|
1856
|
+
function ua(e = {}) {
|
|
1857
|
+
const {
|
|
1858
|
+
initFormData: o = {},
|
|
1859
|
+
rules: a = {},
|
|
1860
|
+
onSuccess: t,
|
|
1861
|
+
onError: s,
|
|
1862
|
+
transform: i
|
|
1863
|
+
} = e, l = P(null), p = () => typeof o == "function" ? o() : o, d = $e({ ...p() }), b = P(!1), g = async (c, f = "操作成功", C, $ = !1) => {
|
|
1864
|
+
if (!(!l.value && !$))
|
|
1865
|
+
try {
|
|
1866
|
+
if (!$ && !await v()) {
|
|
1867
|
+
X.warning("请检查表单填写是否正确");
|
|
1868
|
+
return;
|
|
1869
|
+
}
|
|
1870
|
+
b.value = !0;
|
|
1871
|
+
const S = C || i, M = S ? S(d) : d, R = await c(M);
|
|
1872
|
+
return f && X.success(f), t == null || t(R), R;
|
|
1873
|
+
} catch (S) {
|
|
1874
|
+
throw console.error("useForm submit error:", S), s == null || s(S), S;
|
|
1875
|
+
} finally {
|
|
1876
|
+
b.value = !1;
|
|
1877
|
+
}
|
|
1878
|
+
}, v = async () => {
|
|
1879
|
+
if (!l.value) return !1;
|
|
1880
|
+
try {
|
|
1881
|
+
return await l.value.validate(), !0;
|
|
1882
|
+
} catch {
|
|
1883
|
+
return !1;
|
|
1884
|
+
}
|
|
1885
|
+
};
|
|
1886
|
+
return {
|
|
1887
|
+
formRef: l,
|
|
1888
|
+
formData: d,
|
|
1889
|
+
loading: b,
|
|
1890
|
+
rules: a,
|
|
1891
|
+
submit: g,
|
|
1892
|
+
validate: v,
|
|
1893
|
+
validateField: (c, f) => {
|
|
1894
|
+
l.value && l.value.validateField(c, f);
|
|
1895
|
+
},
|
|
1896
|
+
reset: () => {
|
|
1897
|
+
var c;
|
|
1898
|
+
(c = l.value) == null || c.resetFields();
|
|
1899
|
+
},
|
|
1900
|
+
clearValidate: (c) => {
|
|
1901
|
+
var f;
|
|
1902
|
+
(f = l.value) == null || f.clearValidate(c);
|
|
1903
|
+
},
|
|
1904
|
+
setFormData: (c) => {
|
|
1905
|
+
Object.assign(d, c);
|
|
1906
|
+
},
|
|
1907
|
+
resetFormData: () => {
|
|
1908
|
+
Object.keys(d).forEach((c) => {
|
|
1909
|
+
delete d[c];
|
|
1910
|
+
}), Object.assign(d, p());
|
|
1911
|
+
}
|
|
1912
|
+
};
|
|
1913
|
+
}
|
|
1914
|
+
function ca(e, o = {}) {
|
|
1915
|
+
const {
|
|
1916
|
+
onSuccess: a,
|
|
1917
|
+
onError: t,
|
|
1918
|
+
confirmTitle: s = "提示",
|
|
1919
|
+
confirmButtonText: i = "确认",
|
|
1920
|
+
cancelButtonText: l = "取消",
|
|
1921
|
+
confirmType: p = "warning"
|
|
1922
|
+
} = o, d = P(!1);
|
|
1923
|
+
return {
|
|
1924
|
+
execute: async (g) => {
|
|
1925
|
+
try {
|
|
1926
|
+
d.value = !0;
|
|
1927
|
+
const v = { ...g, confirm: 0 }, k = await e(v);
|
|
1928
|
+
if (k && k.code === 200 && k.msg) {
|
|
1929
|
+
await _e.confirm(
|
|
1930
|
+
k.msg,
|
|
1931
|
+
s,
|
|
1932
|
+
{
|
|
1933
|
+
confirmButtonText: i,
|
|
1934
|
+
cancelButtonText: l,
|
|
1935
|
+
type: p
|
|
1936
|
+
}
|
|
1937
|
+
);
|
|
1938
|
+
const F = { ...g, confirm: 1 }, n = await e(F);
|
|
1939
|
+
return a == null || a(n), n;
|
|
1940
|
+
} else
|
|
1941
|
+
return a == null || a(k), k;
|
|
1942
|
+
} catch (v) {
|
|
1943
|
+
throw t == null || t(v), v;
|
|
1944
|
+
} finally {
|
|
1945
|
+
d.value = !1;
|
|
1946
|
+
}
|
|
1947
|
+
},
|
|
1948
|
+
loading: d
|
|
1949
|
+
};
|
|
1950
|
+
}
|
|
1951
|
+
function da(e, o, a = {}) {
|
|
1952
|
+
const {
|
|
1953
|
+
title: t = "提示",
|
|
1954
|
+
message: s = "确定要执行此操作吗?",
|
|
1955
|
+
confirmButtonText: i = "确定",
|
|
1956
|
+
cancelButtonText: l = "取消",
|
|
1957
|
+
type: p = "warning",
|
|
1958
|
+
successMessage: d = "操作成功",
|
|
1959
|
+
cancelMessage: b = "已取消操作",
|
|
1960
|
+
errorMessage: g = "操作失败",
|
|
1961
|
+
showCancelMessage: v = !0,
|
|
1962
|
+
messageBoxOptions: k = {}
|
|
1963
|
+
} = a;
|
|
1964
|
+
return async (...n) => {
|
|
1965
|
+
try {
|
|
1966
|
+
await _e.confirm(s, t, {
|
|
1967
|
+
confirmButtonText: i,
|
|
1968
|
+
cancelButtonText: l,
|
|
1969
|
+
type: p,
|
|
1970
|
+
...k
|
|
1971
|
+
});
|
|
1972
|
+
const r = await e(...n);
|
|
1973
|
+
return d && X({
|
|
1974
|
+
type: "success",
|
|
1975
|
+
message: d
|
|
1976
|
+
}), o && o(r), r;
|
|
1977
|
+
} catch (r) {
|
|
1978
|
+
throw r === "cancel" || r === "close" ? v && X({
|
|
1979
|
+
type: "info",
|
|
1980
|
+
message: b
|
|
1981
|
+
}) : (console.error("Confirm submit error:", r), X({
|
|
1982
|
+
type: "error",
|
|
1983
|
+
message: g
|
|
1984
|
+
})), r;
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
}
|
|
1988
|
+
const pa = (e, o = {}) => {
|
|
1989
|
+
const {
|
|
1990
|
+
filename: a = "导出数据",
|
|
1991
|
+
fileExtension: t = "xlsx",
|
|
1992
|
+
mimeType: s = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8",
|
|
1993
|
+
timeout: i = 6e4,
|
|
1994
|
+
loadingMessage: l = "正在导出,请稍候...",
|
|
1995
|
+
successMessage: p = "导出成功!"
|
|
1996
|
+
} = o, d = P(!1);
|
|
1997
|
+
return { download: async (g = {}) => {
|
|
1998
|
+
var v, k, F;
|
|
1999
|
+
d.value = !0;
|
|
2000
|
+
try {
|
|
2001
|
+
l && X.info(l);
|
|
2002
|
+
const n = await e(g, {
|
|
2003
|
+
responseType: "blob",
|
|
2004
|
+
timeout: i
|
|
2005
|
+
});
|
|
2006
|
+
let r = `${a}_${Be().format("YYYYMMDDHHmmss")}.${t}`;
|
|
2007
|
+
const u = ((v = n == null ? void 0 : n.headers) == null ? void 0 : v["content-disposition"]) || ((k = n == null ? void 0 : n.headers) == null ? void 0 : k["Content-Disposition"]);
|
|
2008
|
+
if (u) {
|
|
2009
|
+
const S = u.match(/filename\*?=(?:UTF-8'')?([^;]+)/i);
|
|
2010
|
+
S && S[1] && (r = decodeURIComponent(S[1].replace(/['"]/g, "").trim()));
|
|
2011
|
+
}
|
|
2012
|
+
const c = (n == null ? void 0 : n.data) || n, f = c instanceof Blob ? c : new Blob([c], { type: s }), C = URL.createObjectURL(f), $ = document.createElement("a");
|
|
2013
|
+
$.href = C, $.download = r, document.body.appendChild($), $.click(), document.body.removeChild($), URL.revokeObjectURL(C), p && X.success(p);
|
|
2014
|
+
} catch (n) {
|
|
2015
|
+
if (((F = n == null ? void 0 : n.response) == null ? void 0 : F.data) instanceof Blob) {
|
|
2016
|
+
const r = new FileReader();
|
|
2017
|
+
r.onload = (u) => {
|
|
2018
|
+
try {
|
|
2019
|
+
const c = JSON.parse(u.target.result).message;
|
|
2020
|
+
X.error(`导出失败:${c}`);
|
|
2021
|
+
} catch {
|
|
2022
|
+
X.error("导出失败:服务器返回异常");
|
|
2023
|
+
}
|
|
2024
|
+
}, r.readAsText(n.response.data);
|
|
2025
|
+
} else
|
|
2026
|
+
X.error((n == null ? void 0 : n.message) || "导出失败:网络异常或接口错误");
|
|
2027
|
+
console.error("useDownload error:", n);
|
|
2028
|
+
} finally {
|
|
2029
|
+
d.value = !1;
|
|
2030
|
+
}
|
|
2031
|
+
}, downloading: d };
|
|
2032
|
+
};
|
|
2033
|
+
function fa(e = {}) {
|
|
2034
|
+
const { width: o = "50%", title: a = "Dialog", beforeClose: t } = e, s = P(!1), i = P(a), l = $e({});
|
|
2035
|
+
return {
|
|
2036
|
+
visible: s,
|
|
2037
|
+
dialogTitle: i,
|
|
2038
|
+
dialogData: l,
|
|
2039
|
+
width: o,
|
|
2040
|
+
open: (g = {}, v) => {
|
|
2041
|
+
v && (i.value = v), Object.assign(l, g), s.value = !0;
|
|
2042
|
+
},
|
|
2043
|
+
close: () => {
|
|
2044
|
+
s.value = !1, setTimeout(() => {
|
|
2045
|
+
Object.keys(l).forEach((g) => {
|
|
2046
|
+
delete l[g];
|
|
2047
|
+
});
|
|
2048
|
+
}, 300);
|
|
2049
|
+
},
|
|
2050
|
+
handleClose: (g) => {
|
|
2051
|
+
t ? t(g) : g();
|
|
2052
|
+
}
|
|
2053
|
+
};
|
|
2054
|
+
}
|
|
2055
|
+
const Ae = {
|
|
2056
|
+
DATE: "YYYY-MM-DD",
|
|
2057
|
+
DATETIME: "YYYY-MM-DD HH:mm:ss",
|
|
2058
|
+
TIME: "HH:mm:ss",
|
|
2059
|
+
MONTH: "YYYY-MM",
|
|
2060
|
+
YEAR: "YYYY",
|
|
2061
|
+
DATE_CN: "YYYY年MM月DD日",
|
|
2062
|
+
DATETIME_CN: "YYYY年MM月DD日 HH:mm:ss"
|
|
2063
|
+
}, he = (e, o = {}) => {
|
|
2064
|
+
const { ...a } = o;
|
|
2065
|
+
return {
|
|
2066
|
+
...e,
|
|
2067
|
+
...a
|
|
2068
|
+
};
|
|
2069
|
+
}, we = {
|
|
2070
|
+
dateRange(e = {}) {
|
|
2071
|
+
const {
|
|
2072
|
+
prop: o = "updateTime",
|
|
2073
|
+
label: a = "更新时间",
|
|
2074
|
+
startField: t = "updateStartTime",
|
|
2075
|
+
endField: s = "updateEndTime",
|
|
2076
|
+
format: i = Ae.DATETIME,
|
|
2077
|
+
props: l = {}
|
|
2078
|
+
} = e, p = {
|
|
2079
|
+
prop: o,
|
|
2080
|
+
label: a,
|
|
2081
|
+
component: "el-date-picker",
|
|
2082
|
+
dateRange: {
|
|
2083
|
+
startField: t,
|
|
2084
|
+
endField: s,
|
|
2085
|
+
format: (d) => d ? Be(d).format(i) : ""
|
|
2086
|
+
},
|
|
2087
|
+
props: {
|
|
2088
|
+
type: "datetimerange",
|
|
2089
|
+
rangeSeparator: "至",
|
|
2090
|
+
startPlaceholder: "开始日期",
|
|
2091
|
+
endPlaceholder: "结束日期",
|
|
2092
|
+
valueFormat: Ae.DATETIME,
|
|
2093
|
+
clearable: !0,
|
|
2094
|
+
defaultTime: [
|
|
2095
|
+
new Date(2e3, 1, 1, 0, 0, 0),
|
|
2096
|
+
new Date(2e3, 1, 1, 23, 59, 59)
|
|
2097
|
+
],
|
|
2098
|
+
...l
|
|
2099
|
+
}
|
|
2100
|
+
};
|
|
2101
|
+
return he(p, e);
|
|
2102
|
+
},
|
|
2103
|
+
input(e = {}) {
|
|
2104
|
+
const { prop: o, label: a, placeholder: t, maxlength: s, props: i = {} } = e;
|
|
2105
|
+
if (!o || !a)
|
|
2106
|
+
return console.error("input 字段配置缺少必填参数 prop 或 label:", e), null;
|
|
2107
|
+
const l = {
|
|
2108
|
+
label: a,
|
|
2109
|
+
prop: o,
|
|
2110
|
+
component: "el-input",
|
|
2111
|
+
props: {
|
|
2112
|
+
placeholder: t || `请输入${a}`,
|
|
2113
|
+
clearable: !0,
|
|
2114
|
+
maxlength: s,
|
|
2115
|
+
showWordLimit: !!s,
|
|
2116
|
+
...i
|
|
2117
|
+
}
|
|
2118
|
+
};
|
|
2119
|
+
return he(l, e);
|
|
2120
|
+
},
|
|
2121
|
+
select(e = {}) {
|
|
2122
|
+
const { prop: o, label: a, options: t = [], multiple: s = !1, props: i = {} } = e;
|
|
2123
|
+
if (!o || !a)
|
|
2124
|
+
return console.error("select 字段配置缺少必填参数 prop 或 label:", e), null;
|
|
2125
|
+
const l = {
|
|
2126
|
+
label: a,
|
|
2127
|
+
prop: o,
|
|
2128
|
+
component: "el-select",
|
|
2129
|
+
options: t,
|
|
2130
|
+
props: {
|
|
2131
|
+
placeholder: `请选择${a}`,
|
|
2132
|
+
clearable: !0,
|
|
2133
|
+
multiple: s,
|
|
2134
|
+
collapseTags: s,
|
|
2135
|
+
collapseTagsTooltip: s,
|
|
2136
|
+
filterable: !0,
|
|
2137
|
+
...i
|
|
2138
|
+
}
|
|
2139
|
+
};
|
|
2140
|
+
return he(l, e);
|
|
2141
|
+
},
|
|
2142
|
+
cascadeSelect(e = {}) {
|
|
2143
|
+
const {
|
|
2144
|
+
prop: o,
|
|
2145
|
+
label: a,
|
|
2146
|
+
dependOn: t,
|
|
2147
|
+
getOptions: s,
|
|
2148
|
+
defaultOptions: i = [],
|
|
2149
|
+
multiple: l = !1,
|
|
2150
|
+
props: p = {}
|
|
2151
|
+
} = e;
|
|
2152
|
+
if (!o || !a || !t || !s)
|
|
2153
|
+
return console.error("cascadeSelect 配置不完整:", e), null;
|
|
2154
|
+
const d = {
|
|
2155
|
+
label: a,
|
|
2156
|
+
prop: o,
|
|
2157
|
+
component: "el-select",
|
|
2158
|
+
options: [],
|
|
2159
|
+
relation: { dependOn: t, getOptions: s },
|
|
2160
|
+
defaultOptions: i,
|
|
2161
|
+
props: {
|
|
2162
|
+
placeholder: `请选择${a}`,
|
|
2163
|
+
clearable: !0,
|
|
2164
|
+
multiple: l,
|
|
2165
|
+
collapseTags: l,
|
|
2166
|
+
collapseTagsTooltip: l,
|
|
2167
|
+
...p
|
|
2168
|
+
}
|
|
2169
|
+
};
|
|
2170
|
+
return he(d, e);
|
|
2171
|
+
},
|
|
2172
|
+
cascader(e = {}) {
|
|
2173
|
+
const {
|
|
2174
|
+
prop: o,
|
|
2175
|
+
label: a,
|
|
2176
|
+
options: t = [],
|
|
2177
|
+
labelKey: s = "name",
|
|
2178
|
+
valueKey: i = "id",
|
|
2179
|
+
checkStrictly: l = !0,
|
|
2180
|
+
returnAllIds: p = !0,
|
|
2181
|
+
props: d = {}
|
|
2182
|
+
} = e;
|
|
2183
|
+
if (!o || !a)
|
|
2184
|
+
return console.error("cascader 字段配置缺少必填参数 prop 或 label:", e), null;
|
|
2185
|
+
const b = {
|
|
2186
|
+
label: a,
|
|
2187
|
+
prop: o,
|
|
2188
|
+
component: "el-cascader",
|
|
2189
|
+
returnAllIds: p,
|
|
2190
|
+
props: {
|
|
2191
|
+
options: t,
|
|
2192
|
+
placeholder: `请选择${a}`,
|
|
2193
|
+
clearable: !0,
|
|
2194
|
+
props: {
|
|
2195
|
+
label: s,
|
|
2196
|
+
value: i,
|
|
2197
|
+
children: "children",
|
|
2198
|
+
checkStrictly: l
|
|
2199
|
+
},
|
|
2200
|
+
...d
|
|
2201
|
+
}
|
|
2202
|
+
};
|
|
2203
|
+
return he(b, e);
|
|
2204
|
+
},
|
|
2205
|
+
number(e = {}) {
|
|
2206
|
+
const { prop: o, label: a, min: t, max: s, step: i = 1, props: l = {} } = e;
|
|
2207
|
+
if (!o || !a)
|
|
2208
|
+
return console.error("number 字段配置缺少必填参数 prop 或 label:", e), null;
|
|
2209
|
+
const p = {
|
|
2210
|
+
label: a,
|
|
2211
|
+
prop: o,
|
|
2212
|
+
component: "el-input-number",
|
|
2213
|
+
props: {
|
|
2214
|
+
placeholder: `请输入${a}`,
|
|
2215
|
+
min: t,
|
|
2216
|
+
max: s,
|
|
2217
|
+
step: i,
|
|
2218
|
+
controlsPosition: "right",
|
|
2219
|
+
style: { width: "100%" },
|
|
2220
|
+
...l
|
|
2221
|
+
}
|
|
2222
|
+
};
|
|
2223
|
+
return he(p, e);
|
|
2224
|
+
},
|
|
2225
|
+
date(e = {}) {
|
|
2226
|
+
const { prop: o, label: a, format: t = Ae.DATE, props: s = {} } = e;
|
|
2227
|
+
if (!o || !a)
|
|
2228
|
+
return console.error("date 字段配置缺少必填参数 prop 或 label:", e), null;
|
|
2229
|
+
const i = {
|
|
2230
|
+
prop: o,
|
|
2231
|
+
label: a,
|
|
2232
|
+
component: "el-date-picker",
|
|
2233
|
+
props: {
|
|
2234
|
+
type: "date",
|
|
2235
|
+
placeholder: `请选择${a}`,
|
|
2236
|
+
valueFormat: t,
|
|
2237
|
+
clearable: !0,
|
|
2238
|
+
...s
|
|
2239
|
+
}
|
|
2240
|
+
};
|
|
2241
|
+
return he(i, e);
|
|
2242
|
+
},
|
|
2243
|
+
switch(e = {}) {
|
|
2244
|
+
const {
|
|
2245
|
+
prop: o,
|
|
2246
|
+
label: a,
|
|
2247
|
+
activeValue: t = 1,
|
|
2248
|
+
inactiveValue: s = 0,
|
|
2249
|
+
props: i = {}
|
|
2250
|
+
} = e;
|
|
2251
|
+
if (!o || !a)
|
|
2252
|
+
return console.error("switch 字段配置缺少必填参数 prop 或 label:", e), null;
|
|
2253
|
+
const l = {
|
|
2254
|
+
label: a,
|
|
2255
|
+
prop: o,
|
|
2256
|
+
component: "el-switch",
|
|
2257
|
+
props: {
|
|
2258
|
+
activeValue: t,
|
|
2259
|
+
inactiveValue: s,
|
|
2260
|
+
...i
|
|
2261
|
+
}
|
|
2262
|
+
};
|
|
2263
|
+
return he(l, e);
|
|
2264
|
+
}
|
|
2265
|
+
}, ma = {
|
|
2266
|
+
updateTimeRange(e = {}) {
|
|
2267
|
+
return we.dateRange({ ...e });
|
|
2268
|
+
},
|
|
2269
|
+
createTimeRange(e = {}) {
|
|
2270
|
+
return we.dateRange(Object.assign({ prop: "createTime", label: "创建时间" }, e));
|
|
2271
|
+
},
|
|
2272
|
+
status(e, o = {}) {
|
|
2273
|
+
return we.select(Object.assign({ prop: "state", label: "状态" }, o, { options: e }));
|
|
2274
|
+
},
|
|
2275
|
+
keyword(e = {}) {
|
|
2276
|
+
return we.input(Object.assign({ prop: "keyword", label: "关键词" }, e));
|
|
2277
|
+
},
|
|
2278
|
+
name(e = {}) {
|
|
2279
|
+
return we.input(Object.assign({ prop: "name", label: "名称" }, e));
|
|
2280
|
+
},
|
|
2281
|
+
category(e, o = {}) {
|
|
2282
|
+
return we.cascader(Object.assign({ prop: "categoryId", label: "目录" }, o, { options: e }));
|
|
2283
|
+
}
|
|
2284
|
+
};
|
|
2285
|
+
function ha(e, o) {
|
|
2286
|
+
const a = e.replace(/\//g, "\\/").replace(/\*\*/g, ".*").replace(/\*/g, "[^\\/]*");
|
|
2287
|
+
return new RegExp(`^${a}$`).test(o);
|
|
2288
|
+
}
|
|
2289
|
+
function ga(e) {
|
|
2290
|
+
return e == null || e === "" || e === void 0 || e === "undefined";
|
|
2291
|
+
}
|
|
2292
|
+
function va(e) {
|
|
2293
|
+
return !e || typeof e != "string" ? !1 : e.indexOf("http://") !== -1 || e.indexOf("https://") !== -1;
|
|
2294
|
+
}
|
|
2295
|
+
function ya(e) {
|
|
2296
|
+
return /^(https?:|mailto:|tel:)/.test(e);
|
|
2297
|
+
}
|
|
2298
|
+
function ba(e) {
|
|
2299
|
+
return /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/.test(e);
|
|
2300
|
+
}
|
|
2301
|
+
function wa(e) {
|
|
2302
|
+
return /^(([^<>()[\]\\.,;:\s@"]+(\.[[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e);
|
|
2303
|
+
}
|
|
2304
|
+
function Ca(e) {
|
|
2305
|
+
return /^1[3-9]\d{9}$/.test(e);
|
|
2306
|
+
}
|
|
2307
|
+
function _a(e) {
|
|
2308
|
+
return typeof e == "string" || e instanceof String;
|
|
2309
|
+
}
|
|
2310
|
+
function xa(e) {
|
|
2311
|
+
return Array.isArray(e);
|
|
2312
|
+
}
|
|
2313
|
+
function qt(e, o, a, t) {
|
|
2314
|
+
return e /= t / 2, e < 1 ? a / 2 * e * e + o : (e--, -a / 2 * (e * (e - 2) - 1) + o);
|
|
2315
|
+
}
|
|
2316
|
+
const Zt = (function() {
|
|
2317
|
+
return typeof window > "u" ? (e) => 0 : window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(e) {
|
|
2318
|
+
return window.setTimeout(e, 1e3 / 60);
|
|
2319
|
+
};
|
|
2320
|
+
})();
|
|
2321
|
+
function Jt(e) {
|
|
2322
|
+
typeof document > "u" || (document.documentElement.scrollTop = e, document.body.parentNode && (document.body.parentNode.scrollTop = e), document.body.scrollTop = e);
|
|
2323
|
+
}
|
|
2324
|
+
function Xt() {
|
|
2325
|
+
var e;
|
|
2326
|
+
return typeof document > "u" ? 0 : document.documentElement.scrollTop || ((e = document.body.parentNode) == null ? void 0 : e.scrollTop) || document.body.scrollTop || 0;
|
|
2327
|
+
}
|
|
2328
|
+
function Sa(e, o = 500, a) {
|
|
2329
|
+
const t = Xt(), s = e - t, i = 20;
|
|
2330
|
+
let l = 0;
|
|
2331
|
+
const p = function() {
|
|
2332
|
+
l += i;
|
|
2333
|
+
const d = qt(l, t, s, o);
|
|
2334
|
+
Jt(d), l < o ? Zt(p) : typeof a == "function" && a();
|
|
2335
|
+
};
|
|
2336
|
+
p();
|
|
2337
|
+
}
|
|
2338
|
+
function Qt(e = [], o, a = "children") {
|
|
2339
|
+
for (const t of e) {
|
|
2340
|
+
if (o(t)) return t;
|
|
2341
|
+
const s = t[a];
|
|
2342
|
+
if (s && s.length > 0) {
|
|
2343
|
+
const i = Qt(s, o, a);
|
|
2344
|
+
if (i) return i;
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
return null;
|
|
2348
|
+
}
|
|
2349
|
+
function Ta(e = [], o, a = "id", t = "children") {
|
|
2350
|
+
const s = (i, l, p = []) => {
|
|
2351
|
+
for (const d of i) {
|
|
2352
|
+
const b = [...p, d[a]];
|
|
2353
|
+
if (d[a] === l)
|
|
2354
|
+
return b;
|
|
2355
|
+
const g = d[t];
|
|
2356
|
+
if (g && g.length > 0) {
|
|
2357
|
+
const v = s(g, l, b);
|
|
2358
|
+
if (v.length > 0) return v;
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
return [];
|
|
2362
|
+
};
|
|
2363
|
+
return s(e, o);
|
|
2364
|
+
}
|
|
2365
|
+
function Aa(e = [], o, a = "children", t = "id") {
|
|
2366
|
+
const s = typeof o == "function" ? o : (l) => l[t] === o, i = (l, p = []) => {
|
|
2367
|
+
for (const d of l) {
|
|
2368
|
+
const b = [...p, d];
|
|
2369
|
+
if (s(d))
|
|
2370
|
+
return b;
|
|
2371
|
+
const g = d[a];
|
|
2372
|
+
if (g && g.length > 0) {
|
|
2373
|
+
const v = i(g, b);
|
|
2374
|
+
if (v.length > 0) return v;
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
return [];
|
|
2378
|
+
};
|
|
2379
|
+
return i(e);
|
|
2380
|
+
}
|
|
2381
|
+
function Gt(e = [], o = "children") {
|
|
2382
|
+
const a = [], t = (s) => {
|
|
2383
|
+
s.forEach((i) => {
|
|
2384
|
+
a.push(i);
|
|
2385
|
+
const l = i[o];
|
|
2386
|
+
l && l.length > 0 && t(l);
|
|
2387
|
+
});
|
|
2388
|
+
};
|
|
2389
|
+
return t(e), a;
|
|
2390
|
+
}
|
|
2391
|
+
const ka = Gt;
|
|
2392
|
+
function $a(e = [], o = {}) {
|
|
2393
|
+
const {
|
|
2394
|
+
id: a = "id",
|
|
2395
|
+
pid: t = "parentId",
|
|
2396
|
+
children: s = "children",
|
|
2397
|
+
rootPid: i = [0, "0", null, void 0, ""]
|
|
2398
|
+
} = o, l = /* @__PURE__ */ new Map(), p = [];
|
|
2399
|
+
return e.forEach((d) => {
|
|
2400
|
+
l.set(d[a], { ...d, [s]: [] });
|
|
2401
|
+
}), e.forEach((d) => {
|
|
2402
|
+
const b = l.get(d[a]), g = d[t];
|
|
2403
|
+
if (i.includes(g) || !l.has(g))
|
|
2404
|
+
p.push(b);
|
|
2405
|
+
else {
|
|
2406
|
+
const v = l.get(g);
|
|
2407
|
+
v && v[s].push(b);
|
|
2408
|
+
}
|
|
2409
|
+
}), p;
|
|
2410
|
+
}
|
|
2411
|
+
function Ea(e = [], o, a = "children") {
|
|
2412
|
+
const t = (s) => s.map((i) => {
|
|
2413
|
+
const l = { ...i }, p = l[a];
|
|
2414
|
+
if (p && p.length > 0) {
|
|
2415
|
+
const b = t(p);
|
|
2416
|
+
l[a] = b.length > 0 ? b : void 0;
|
|
2417
|
+
}
|
|
2418
|
+
const d = l[a];
|
|
2419
|
+
return o(l) || d && d.length > 0 ? l : null;
|
|
2420
|
+
}).filter(Boolean);
|
|
2421
|
+
return t(e);
|
|
2422
|
+
}
|
|
2423
|
+
function ea(e = [], o, a = "children") {
|
|
2424
|
+
return e.map((t) => {
|
|
2425
|
+
const s = o(t), i = t[a];
|
|
2426
|
+
return i && i.length > 0 && (s[a] = ea(i, o, a)), s;
|
|
2427
|
+
});
|
|
2428
|
+
}
|
|
2429
|
+
function ta(e) {
|
|
2430
|
+
return e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
2431
|
+
}
|
|
2432
|
+
const aa = (e) => {
|
|
2433
|
+
Ut.forEach((o) => {
|
|
2434
|
+
if (o.name) {
|
|
2435
|
+
e.component(o.name, o);
|
|
2436
|
+
const a = ta(o.name);
|
|
2437
|
+
a !== o.name && e.component(a, o);
|
|
2438
|
+
}
|
|
2439
|
+
});
|
|
2440
|
+
}, Oa = {
|
|
2441
|
+
install: aa
|
|
2442
|
+
};
|
|
2443
|
+
export {
|
|
2444
|
+
st as CAsyncButton,
|
|
2445
|
+
St as CCollapsibleContainer,
|
|
2446
|
+
kt as CCustomDrawer,
|
|
2447
|
+
Ht as CDiff,
|
|
2448
|
+
Wt as CImagePreview,
|
|
2449
|
+
yt as CSearchBox,
|
|
2450
|
+
ct as CSelectWithAll,
|
|
2451
|
+
mt as CSelectWithPage,
|
|
2452
|
+
Kt as CSimpleTable,
|
|
2453
|
+
ma as CommonSearchFields,
|
|
2454
|
+
Ae as DATE_FORMAT,
|
|
2455
|
+
we as SearchFieldFactory,
|
|
2456
|
+
Ut as components,
|
|
2457
|
+
Oa as default,
|
|
2458
|
+
Ea as filterTree,
|
|
2459
|
+
Ta as findNodePath,
|
|
2460
|
+
Aa as findParentNodes,
|
|
2461
|
+
Qt as findTreeNode,
|
|
2462
|
+
Gt as flattenTree,
|
|
2463
|
+
xa as isArray,
|
|
2464
|
+
ga as isEmpty,
|
|
2465
|
+
ya as isExternal,
|
|
2466
|
+
va as isHttp,
|
|
2467
|
+
ha as isPathMatch,
|
|
2468
|
+
_a as isString,
|
|
2469
|
+
$a as listToTree,
|
|
2470
|
+
ea as mapTree,
|
|
2471
|
+
Sa as scrollTo,
|
|
2472
|
+
ka as treeToList,
|
|
2473
|
+
ca as useConfirmAction,
|
|
2474
|
+
da as useConfirmSubmit,
|
|
2475
|
+
fa as useDialog,
|
|
2476
|
+
pa as useDownload,
|
|
2477
|
+
ua as useForm,
|
|
2478
|
+
ia as useListPage,
|
|
2479
|
+
wa as validEmail,
|
|
2480
|
+
Ca as validPhone,
|
|
2481
|
+
ba as validURL
|
|
2482
|
+
};
|