hy-dispatch-ui-v3 0.2.32 → 0.2.33

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.
Files changed (62) hide show
  1. package/dist/tailwind.css +168 -448
  2. package/es/components/hyAudioPlayer/audioPlayer.vue.mjs +4 -4
  3. package/es/components/hyAudioPlayer/style/audioPlayer.scss +11 -12
  4. package/es/components/hyButton/button.vue.mjs +1 -1
  5. package/es/components/hyButton/style/button.scss +16 -3
  6. package/es/components/hyConfirmDialog/confirmDialog.vue.mjs +1 -1
  7. package/es/components/hyForm/form.vue.mjs +2 -1
  8. package/es/components/hyForm/style/form.scss +56 -54
  9. package/es/components/hyIcon/style/icon.scss +1 -1
  10. package/es/components/hyIconBox/style/iconBox.scss +19 -18
  11. package/es/components/hyInput/input.vue.mjs +4 -1
  12. package/es/components/hySearch/style/search.scss +50 -50
  13. package/es/components/hyTable/cpns/virtualTable.vue.mjs +12 -1
  14. package/es/components/hyTable/js/index.mjs +12 -0
  15. package/es/components/hyTable/table.vue.mjs +21 -5
  16. package/es/components/hyTableForm/batchTableForm.vue.mjs +478 -0
  17. package/es/components/hyTableForm/index.mjs +4 -1
  18. package/es/components/hyTableForm/js/index.mjs +123 -0
  19. package/es/components/hyTableForm/js/useAppTableForm.mjs +47 -0
  20. package/es/components/hyTableForm/style/batchTableForm.scss +127 -0
  21. package/es/components/hyTableForm/style/tableForm.scss +42 -0
  22. package/es/components/hyTableForm/tableForm.vue.mjs +452 -7
  23. package/es/components/hyTooltip/tooltip.vue.mjs +2 -2
  24. package/es/components/hyVideoPlayer/cpns/mediaLoading.vue.mjs +1 -1
  25. package/es/components/hyVideoPlayer/style/mediaLoading.scss +5 -5
  26. package/es/components/hyVideoPlayer/style/videoPlayer.scss +7 -6
  27. package/es/components/hyVideoPlayer/videoPlayer.vue.mjs +6 -6
  28. package/es/components/index.mjs +2 -1
  29. package/es/index.mjs +2 -1
  30. package/es/style/tailwind.scss +133 -1
  31. package/es/version.mjs +1 -1
  32. package/lib/components/hyAudioPlayer/audioPlayer.vue.js +4 -4
  33. package/lib/components/hyAudioPlayer/style/audioPlayer.scss +11 -12
  34. package/lib/components/hyButton/button.vue.js +1 -1
  35. package/lib/components/hyButton/style/button.scss +16 -3
  36. package/lib/components/hyConfirmDialog/confirmDialog.vue.js +1 -1
  37. package/lib/components/hyForm/form.vue.js +2 -1
  38. package/lib/components/hyForm/style/form.scss +56 -54
  39. package/lib/components/hyIcon/style/icon.scss +1 -1
  40. package/lib/components/hyIconBox/style/iconBox.scss +19 -18
  41. package/lib/components/hyInput/input.vue.js +4 -1
  42. package/lib/components/hySearch/style/search.scss +50 -50
  43. package/lib/components/hyTable/cpns/virtualTable.vue.js +12 -1
  44. package/lib/components/hyTable/js/index.js +12 -0
  45. package/lib/components/hyTable/table.vue.js +21 -5
  46. package/lib/components/hyTableForm/batchTableForm.vue.js +482 -0
  47. package/lib/components/hyTableForm/index.js +5 -0
  48. package/lib/components/hyTableForm/js/index.js +127 -0
  49. package/lib/components/hyTableForm/js/useAppTableForm.js +49 -0
  50. package/lib/components/hyTableForm/style/batchTableForm.scss +127 -0
  51. package/lib/components/hyTableForm/style/tableForm.scss +42 -0
  52. package/lib/components/hyTableForm/tableForm.vue.js +451 -6
  53. package/lib/components/hyTooltip/tooltip.vue.js +2 -2
  54. package/lib/components/hyVideoPlayer/cpns/mediaLoading.vue.js +1 -1
  55. package/lib/components/hyVideoPlayer/style/mediaLoading.scss +5 -5
  56. package/lib/components/hyVideoPlayer/style/videoPlayer.scss +7 -6
  57. package/lib/components/hyVideoPlayer/videoPlayer.vue.js +6 -6
  58. package/lib/components/index.js +33 -30
  59. package/lib/index.js +33 -30
  60. package/lib/style/tailwind.scss +133 -1
  61. package/lib/version.js +1 -1
  62. package/package.json +5 -3
@@ -0,0 +1,478 @@
1
+ import { defineComponent, useTemplateRef, ref, openBlock, createElementBlock, createElementVNode, createVNode, unref as unref$1, withCtx, Fragment, renderList, createCommentVNode, toDisplayString, renderSlot, createBlock, createTextVNode, createSlots, normalizeProps, guardReactiveProps, normalizeStyle, nextTick } from 'vue';
2
+ import { ElUpload, ElMessage } from 'element-plus';
3
+ import _sfc_main$1 from './tableForm.vue.mjs';
4
+ import { downloadTemplateHandler, doReadExcel } from './js/index.mjs';
5
+ import { useApi } from '../../hooks/useApi.mjs';
6
+ import { useLocale } from '../../hooks/useLocale.mjs';
7
+ import { HyIcon } from '../hyIcon/index.mjs';
8
+ import { HyButton } from '../hyButton/index.mjs';
9
+ import { HyConfirmDialog } from '../hyConfirmDialog/index.mjs';
10
+
11
+ import "./style/batchTableForm.scss";
12
+
13
+ const __default__ = defineComponent({
14
+ name: "HyBatchTableForm"
15
+ });
16
+ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
17
+ props: {
18
+ // 表格配置项
19
+ tableColumns: {
20
+ // 表格的列
21
+ type: Array,
22
+ required: true,
23
+ default: () => []
24
+ },
25
+ formColumns: {
26
+ type: Array,
27
+ default: () => []
28
+ },
29
+ rules: {
30
+ type: Object,
31
+ default: () => ({})
32
+ },
33
+ emptyText: {
34
+ // 空数据时显示的文本内容
35
+ type: String
36
+ },
37
+ fontSize: {
38
+ // 字体大小
39
+ type: Number,
40
+ default: 14
41
+ },
42
+ rowClickExpand: {
43
+ // 点击行展开
44
+ type: Boolean,
45
+ required: false,
46
+ default: true
47
+ },
48
+ // 表单配置项
49
+ columnNum: {
50
+ type: Number,
51
+ default: 2
52
+ },
53
+ size: {
54
+ type: String,
55
+ default: "default"
56
+ // 'large' | 'default' | 'small'
57
+ },
58
+ // 其他配置项
59
+ beforeDataHandle: {
60
+ type: Function
61
+ },
62
+ templateConfig: {
63
+ type: Object,
64
+ default: () => ({
65
+ title: "\u4E0B\u8F7D\u6A21\u677F",
66
+ url: "",
67
+ fileName: ""
68
+ })
69
+ },
70
+ url: {
71
+ type: String
72
+ },
73
+ submitParams: {
74
+ type: Object
75
+ },
76
+ submitHandler: {
77
+ type: Function
78
+ }
79
+ },
80
+ emits: ["submitting", "submit"],
81
+ setup(__props, { expose: __expose, emit: __emit }) {
82
+ const props = __props;
83
+ const emits = __emit;
84
+ const { api } = useApi();
85
+ const { t } = useLocale();
86
+ const containerRef = useTemplateRef("containerRef");
87
+ const tableRef = useTemplateRef("tableRef");
88
+ const active = ref(1);
89
+ const stepList = [
90
+ {
91
+ title: "\u4E0A\u4F20\u5BFC\u5165\u6587\u4EF6",
92
+ description: "\u4E0A\u4F20\u5DF2\u586B\u5199\u5B8C\u6210\u7684<br/>\u6DFB\u52A0\u6A21\u677F\u6587\u4EF6"
93
+ },
94
+ {
95
+ title: "\u81EA\u52A8\u89E3\u6790\u4E0E\u6821\u9A8C",
96
+ description: "\u7CFB\u7EDF\u5C06\u81EA\u52A8\u89E3\u6790\u60A8<br/>\u4E0A\u4F20\u540E\u7684\u6587\u4EF6\u8FDB\u884C\u663E\u793A"
97
+ },
98
+ {
99
+ title: "\u652F\u6301\u4FEE\u6B63\u5F02\u5E38",
100
+ description: "\u5F02\u5E38\u6570\u636E\u5C06\u6807\u8BB0\u63D0\u793A<br/>\u652F\u6301\u4FEE\u6539\u5E76\u5373\u65F6\u6821\u9A8C"
101
+ },
102
+ {
103
+ title: "\u786E\u8BA4\u5BFC\u5165\u6570\u636E",
104
+ description: "\u4EE5\u5F53\u524D\u6570\u636E\u4E3A\u51C6<br/>\u6267\u884C\u6279\u91CF\u5BFC\u5165\u6DFB\u52A0\u6570\u636E"
105
+ }
106
+ ];
107
+ const templateFileName = ref("");
108
+ const submitNumber = ref(0);
109
+ const submitting = ref(false);
110
+ const submitProgress = ref(0);
111
+ function setData(data = []) {
112
+ if (!tableRef.value) return;
113
+ tableRef.value.setData(data);
114
+ }
115
+ function deleteData(data = []) {
116
+ if (!tableRef.value) return;
117
+ tableRef.value.deleteData(data);
118
+ }
119
+ function getTableDataSource() {
120
+ if (!tableRef.value) return [];
121
+ return tableRef.value.getTableDataSource();
122
+ }
123
+ function validate() {
124
+ if (!tableRef.value) return {};
125
+ return tableRef.value.validate();
126
+ }
127
+ async function onUploadChange(file) {
128
+ const type = file.raw.type;
129
+ if (file.raw.size > 1024 * 1024 * 10) {
130
+ ElMessage.error(`\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC710M\uFF01`);
131
+ return false;
132
+ } else {
133
+ if (type.indexOf("application") !== -1) {
134
+ const files = { 0: file.raw };
135
+ try {
136
+ const data = await doReadExcel(files, props);
137
+ if (!data) {
138
+ ElMessage.warning("\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25");
139
+ return;
140
+ }
141
+ active.value++;
142
+ await nextTick();
143
+ setData(data);
144
+ templateFileName.value = file.name;
145
+ } catch (err) {
146
+ console.error(err);
147
+ return;
148
+ }
149
+ } else {
150
+ ElMessage.error("\u6587\u4EF6\u683C\u5F0F\u6709\u8BEF");
151
+ }
152
+ }
153
+ }
154
+ async function onResetUpload() {
155
+ if (tableRef.value) {
156
+ const { total } = tableRef.value.getStatistics();
157
+ if (total) {
158
+ try {
159
+ await new Promise((resolve, reject) => {
160
+ HyConfirmDialog.confirm({
161
+ content: submitNumber.value ? `\u672C\u6B21\u5DF2\u6210\u529F\u5BFC\u5165 ${submitNumber.value} \u6761\u6570\u636E\uFF0C\u91CD\u65B0\u4E0A\u4F20\u5C06\u4E0D\u4F1A\u64A4\u9500\u8FD9\u4E9B\u6570\u636E\u3002\u5269\u4F59\u672A\u5BFC\u5165\u6570\u636E\u5C06\u4F1A\u88AB\u6E05\u7A7A` : `\u91CD\u65B0\u4E0A\u4F20\u5C06\u6E05\u7A7A\u5F53\u524D ${total} \u6761\u6570\u636E, <br />\u662F\u5426\u786E\u8BA4\u91CD\u65B0\u4E0A\u4F20`,
162
+ onClose: reject,
163
+ onCancel: reject,
164
+ onSubmit: resolve
165
+ });
166
+ });
167
+ } catch {
168
+ return;
169
+ }
170
+ }
171
+ }
172
+ templateFileName.value = "";
173
+ active.value = 1;
174
+ submitNumber.value = 0;
175
+ }
176
+ async function submitDataSource() {
177
+ if (!props.url && !props.submitHandler) {
178
+ ElMessage.warning("\u8BF7\u914D\u7F6E\u63D0\u4EA4\u8868\u5355\u5730\u5740");
179
+ return Promise.reject();
180
+ }
181
+ if (submitting.value) {
182
+ HyConfirmDialog.tip({
183
+ content: `\u6570\u636E\u6B63\u5728\u5904\u7406\u4E2D\uFF0C<br/>\u8BF7\u7B49\u5F85\u6570\u636E\u5904\u7406\u5B8C\u6210\u540E\u518D\u5173\u95ED\u5F39\u7A97`
184
+ });
185
+ return Promise.reject();
186
+ }
187
+ const res = validate();
188
+ let { dataSource, total, success, failed } = res;
189
+ if (!total) {
190
+ ElMessage.warning("\u8BF7\u6DFB\u52A0\u6570\u636E");
191
+ return;
192
+ }
193
+ if (!success) {
194
+ ElMessage.warning("\u8BF7\u586B\u5199\u6709\u6548\u4E0A\u4F20\u6570\u636E");
195
+ return;
196
+ }
197
+ if (failed) {
198
+ try {
199
+ await new Promise((resolve, reject) => {
200
+ HyConfirmDialog.confirm({
201
+ content: `\u5F53\u524D\u5B58\u5728<span class="text-danger-2"> ${failed} \u6761\u6570\u636E\u5F02\u5E38</span>\uFF0C\u672C\u6B21\u5C06\u4EC5\u5BFC\u5165 ${success} \u6761\u5BFC\u5165\u5C31\u7EEA\u6570\u636E\uFF0C\u5F02\u5E38\u6570\u636E\u5C06\u88AB\u5FFD\u7565`,
202
+ onClose: reject,
203
+ onCancel: reject,
204
+ onSubmit: resolve
205
+ });
206
+ });
207
+ } catch {
208
+ return Promise.reject();
209
+ }
210
+ }
211
+ const submitList = [];
212
+ submitProgress.value = 0;
213
+ submitting.value = true;
214
+ emits("submitting");
215
+ for (let i = 0; i <= dataSource.length - 1; i++) {
216
+ const target = dataSource[i];
217
+ const { onlyId, errorMsg, errorMap, children, ...data } = target;
218
+ submitProgress.value = Math.floor((i + 1) / total * 100);
219
+ if (errorMsg) {
220
+ continue;
221
+ }
222
+ let res2;
223
+ try {
224
+ if (props.submitHandler) {
225
+ res2 = await props.submitHandler(data);
226
+ } else {
227
+ res2 = await unref(api).post(props.url, props.submitParams);
228
+ }
229
+ if (res2.code === 200) {
230
+ submitNumber.value++;
231
+ submitList.push(target);
232
+ } else {
233
+ target.errorMsg = {
234
+ prop: null,
235
+ message: res2.msg
236
+ };
237
+ }
238
+ } catch (err) {
239
+ target.errorMsg = {
240
+ prop: null,
241
+ message: err?.msg ? err.msg : err
242
+ };
243
+ console.error(err);
244
+ }
245
+ }
246
+ deleteData(submitList);
247
+ submitting.value = false;
248
+ const submitResult = {
249
+ total,
250
+ success: submitList.length,
251
+ failed: total - submitList.length,
252
+ result: submitList.length === total
253
+ };
254
+ if (submitResult.result) {
255
+ ElMessage.success(`${submitResult.total} \u6761\u6570\u636E\u5BFC\u5165\u5B8C\u6210\uFF0C\u5DF2\u66F4\u65B0`);
256
+ emits("submit", submitResult);
257
+ onResetUpload();
258
+ } else {
259
+ ElMessage.warning(
260
+ `${submitResult.success} \u6761\u6570\u636E\u5BFC\u5165\u6210\u529F\uFF0C ${submitResult.failed} \u6761\u6570\u636E\u5F02\u5E38\uFF0C\u8BF7\u8C03\u6574`
261
+ );
262
+ emits("submit", submitResult);
263
+ }
264
+ }
265
+ __expose({
266
+ setData,
267
+ deleteData,
268
+ getTableDataSource,
269
+ validate,
270
+ submitDataSource
271
+ });
272
+ return (_ctx, _cache) => {
273
+ return openBlock(), createElementBlock(
274
+ "div",
275
+ {
276
+ ref_key: "containerRef",
277
+ ref: containerRef,
278
+ class: "hy-batch-table-form"
279
+ },
280
+ [
281
+ active.value === 1 ? (openBlock(), createElementBlock("div", {
282
+ key: 0,
283
+ class: "max-h-full overflow-y-auto scroll-body"
284
+ }, [
285
+ createElementVNode("div", { class: "hy-batch-table-form-upload-box" }, [
286
+ createVNode(unref$1(ElUpload), {
287
+ accept: ".xls,.xlsx",
288
+ drag: "",
289
+ multiple: false,
290
+ "auto-upload": false,
291
+ "show-file-list": false,
292
+ class: "w-full h-full",
293
+ "on-change": onUploadChange
294
+ }, {
295
+ default: withCtx(() => [
296
+ createVNode(unref$1(HyIcon), {
297
+ "svg-name": "analytics-echarts-sos",
298
+ "class-name": "!w-[58px] !h-[66px] mb-4"
299
+ }),
300
+ createElementVNode("div", { class: "mb-1.5 text-main" }, [
301
+ createElementVNode("span", null, "\u70B9\u51FB\u6216\u5C06 \u6587\u4EF6 \u62D6\u62FD\u5230\u6B64\u5904\u4E0A\u4F20")
302
+ ]),
303
+ createElementVNode("div", { class: "text-auxiliary text-xs" }, "\u4E00\u6B21\u4EC5\u652F\u6301\u4E0A\u4F20\u4E00\u4E2A\u6587\u4EF6"),
304
+ createElementVNode("div", { class: "w-full text-main absolute left-1/2 bottom-4 transform -translate-x-1/2" }, [
305
+ createElementVNode("div", { class: "flex items-center justify-center text-xs text-auxiliary gap-2" }, [
306
+ createElementVNode("span", null, "\u6587\u4EF6\u652F\u6301\uFF1A"),
307
+ createElementVNode("div", { class: "border border-border rounded py-1 px-2.5 bg-background-4" }, " .xls "),
308
+ createElementVNode("div", { class: "border border-border rounded py-1 px-2.5 bg-background-4" }, " .xlsx "),
309
+ createElementVNode("span", null, "\u5355\u6587\u4EF6\u4E0D\u8D85\u8FC7 10 MB")
310
+ ])
311
+ ])
312
+ ]),
313
+ _: 1
314
+ /* STABLE */
315
+ })
316
+ ]),
317
+ createElementVNode("div", { class: "hy-batch-table-form-step-box" }, [
318
+ createElementVNode("div", { class: "text-auxiliary text-center mb-[30px]" }, [
319
+ createElementVNode("span", null, "\u6279\u91CF\u6DFB\u52A0\u5BFC\u5165\u6D41\u7A0B\u8BF4\u660E")
320
+ ]),
321
+ createElementVNode("div", { class: "w-full flex" }, [
322
+ (openBlock(), createElementBlock(
323
+ Fragment,
324
+ null,
325
+ renderList(stepList, (item, index) => {
326
+ return createElementVNode("div", {
327
+ key: index,
328
+ class: "w-0 flex-1 flex flex-col items-center relative"
329
+ }, [
330
+ index < stepList.length - 1 ? (openBlock(), createElementBlock("div", {
331
+ key: 0,
332
+ class: "w-3/4 absolute top-[19px] left-full transform -translate-x-1/2",
333
+ style: { "border-top": "2px dashed rgba(var(--hy-border))" }
334
+ })) : createCommentVNode("v-if", true),
335
+ createElementVNode("div", { class: "w-[38px] h-[38px] flex items-center justify-center border border-solid border-border rounded-full bg-background box-border" }, [
336
+ createElementVNode(
337
+ "span",
338
+ { class: "text-base text-main" },
339
+ toDisplayString(index + 1),
340
+ 1
341
+ /* TEXT */
342
+ )
343
+ ]),
344
+ createElementVNode(
345
+ "span",
346
+ { class: "text-main font-bold text-sm mt-3 mb-2" },
347
+ toDisplayString(item.title),
348
+ 1
349
+ /* TEXT */
350
+ ),
351
+ createElementVNode("div", {
352
+ innerHTML: item.description,
353
+ class: "text-auxiliary text-center mb-3 whitespace-nowrap"
354
+ }, null, 8, ["innerHTML"]),
355
+ renderSlot(_ctx.$slots, "template-down", {}, () => [
356
+ index === 0 ? (openBlock(), createBlock(unref$1(HyButton), {
357
+ key: 0,
358
+ type: "primary",
359
+ link: "",
360
+ onClick: () => unref$1(downloadTemplateHandler)(props)
361
+ }, {
362
+ default: withCtx(() => [
363
+ createTextVNode(
364
+ toDisplayString(__props.templateConfig ? __props.templateConfig.title : "\u4E0B\u8F7D\u6A21\u677F"),
365
+ 1
366
+ /* TEXT */
367
+ )
368
+ ]),
369
+ _: 1
370
+ /* STABLE */
371
+ }, 8, ["onClick"])) : createCommentVNode("v-if", true)
372
+ ])
373
+ ]);
374
+ }),
375
+ 64
376
+ /* STABLE_FRAGMENT */
377
+ ))
378
+ ])
379
+ ])
380
+ ])) : active.value === 2 ? (openBlock(), createElementBlock("div", {
381
+ key: 1,
382
+ class: "h-full flex flex-col"
383
+ }, [
384
+ createElementVNode("div", { class: "hy-batch-table-form-template-box" }, [
385
+ createElementVNode("div", { class: "flex items-center gap-2" }, [
386
+ createVNode(unref$1(HyIcon), {
387
+ "svg-name": "analytics-echarts-sos",
388
+ "class-name": "!w-[18px] !h-[22px]"
389
+ }),
390
+ createElementVNode(
391
+ "span",
392
+ { class: "text-theme" },
393
+ toDisplayString(templateFileName.value),
394
+ 1
395
+ /* TEXT */
396
+ ),
397
+ createElementVNode("span", { class: "text-auxiliary" }, "\u89E3\u6790\u5B8C\u6210")
398
+ ]),
399
+ createVNode(unref$1(HyButton), {
400
+ type: "primary",
401
+ link: "",
402
+ size: "small",
403
+ onClick: onResetUpload
404
+ }, {
405
+ default: withCtx(() => [
406
+ createTextVNode("\u91CD\u65B0\u4E0A\u4F20\u6587\u4EF6")
407
+ ]),
408
+ _: 1
409
+ /* STABLE */
410
+ })
411
+ ]),
412
+ createVNode(_sfc_main$1, {
413
+ ref_key: "tableRef",
414
+ ref: tableRef,
415
+ tableColumns: __props.tableColumns,
416
+ formColumns: __props.formColumns,
417
+ rules: __props.rules,
418
+ rowClickExpand: __props.rowClickExpand,
419
+ columnNum: __props.columnNum,
420
+ size: __props.size,
421
+ class: "h-0 flex-1"
422
+ }, createSlots({
423
+ _: 2
424
+ /* DYNAMIC */
425
+ }, [
426
+ renderList(_ctx.$slots, (_, slotName) => {
427
+ return {
428
+ name: slotName,
429
+ fn: withCtx((scope) => [
430
+ renderSlot(_ctx.$slots, slotName, normalizeProps(guardReactiveProps(scope)))
431
+ ])
432
+ };
433
+ })
434
+ ]), 1032, ["tableColumns", "formColumns", "rules", "rowClickExpand", "columnNum", "size"])
435
+ ])) : createCommentVNode("v-if", true),
436
+ submitting.value ? (openBlock(), createElementBlock("div", {
437
+ key: 2,
438
+ class: "absolute top-0 right-0 bottom-0 left-0 z-10 flex items-center justify-center"
439
+ }, [
440
+ createElementVNode("div", { class: "w-full h-full absolute bg-[rgba(var(--hy-background-4),0.9)] backdrop-blur-sm" }),
441
+ createElementVNode("div", { class: "flex flex-col items-center text-theme text-xs relative" }, [
442
+ createVNode(unref$1(HyIcon), {
443
+ "svg-name": "analytics-echarts-sos",
444
+ "class-name": "!w-[58px] !h-[66px] mb-[18px]"
445
+ }),
446
+ createElementVNode("div", { class: "flex items-center" }, [
447
+ createElementVNode("span", null, "\u6570\u636E\u6B63\u5728\u5BFC\u5165\u4E2D"),
448
+ createElementVNode(
449
+ "span",
450
+ { class: "ml-1 mr-3" },
451
+ toDisplayString(submitProgress.value) + "%",
452
+ 1
453
+ /* TEXT */
454
+ ),
455
+ createElementVNode("div", { class: "w-[68px] h-0.5 bg-auxiliary rounded-full" }, [
456
+ createElementVNode(
457
+ "div",
458
+ {
459
+ class: "h-full bg-theme rounded-full",
460
+ style: normalizeStyle({ width: `${submitProgress.value}%` })
461
+ },
462
+ null,
463
+ 4
464
+ /* STYLE */
465
+ )
466
+ ])
467
+ ])
468
+ ])
469
+ ])) : createCommentVNode("v-if", true)
470
+ ],
471
+ 512
472
+ /* NEED_PATCH */
473
+ );
474
+ };
475
+ }
476
+ });
477
+
478
+ export { _sfc_main as default };
@@ -1,6 +1,9 @@
1
1
  import _sfc_main from './tableForm.vue.mjs';
2
+ import _sfc_main$1 from './batchTableForm.vue.mjs';
3
+ export { useAppTableForm } from './js/useAppTableForm.mjs';
2
4
  import { withInstall } from '../../utils/handler.mjs';
3
5
 
4
6
  const HyTableForm = withInstall(_sfc_main);
7
+ const HyBatchTableForm = withInstall(_sfc_main$1);
5
8
 
6
- export { HyTableForm, HyTableForm as default };
9
+ export { HyBatchTableForm, HyTableForm, HyTableForm as default };
@@ -0,0 +1,123 @@
1
+ import XLSX from 'xlsx';
2
+ import dayjs from 'dayjs';
3
+ import { unref } from 'vue';
4
+ import AsyncValidator from 'async-validator';
5
+ import { ElMessage } from 'element-plus';
6
+ import { columnShowHandler } from '../../hyForm/js/index.mjs';
7
+ import { useApi } from '../../../hooks/useApi.mjs';
8
+ import { setValueByProp, getValueByProp } from '../../../utils/form.mjs';
9
+ import { isArray } from '../../../utils/is.mjs';
10
+
11
+ const doValidate = async (target = {}, columns = [], ruleList = {}) => {
12
+ const data = {};
13
+ let rules = {};
14
+ const columnMap = (columns || []).reduce((columnMap2, column) => {
15
+ if (columnShowHandler({ model: data }, column)) {
16
+ columnMap2[column.prop] = column;
17
+ rules[column.prop] = column.rules || [];
18
+ setValueByProp(data, column.prop, getValueByProp(target, column.prop));
19
+ }
20
+ return columnMap2;
21
+ }, {});
22
+ Object.entries(ruleList || {}).forEach(([key, citem]) => {
23
+ if (columnMap[key]) {
24
+ rules[key] = [
25
+ ...isArray(citem) ? citem : [citem],
26
+ ...rules[key]
27
+ ].filter(Boolean);
28
+ }
29
+ });
30
+ const validator = new AsyncValidator(rules);
31
+ return validator.validate(data, { firstFields: true }).then((res) => {
32
+ return true;
33
+ }).catch((error) => {
34
+ const { errors, fields } = error;
35
+ if (!errors || !fields) {
36
+ console.error(error);
37
+ }
38
+ return Promise.reject(errors || []);
39
+ });
40
+ };
41
+ const doReadExcel = (files, props) => {
42
+ return new Promise((resolve2, reject) => {
43
+ const { formColumns, beforeDataHandle } = props;
44
+ const fileReader = new FileReader();
45
+ fileReader.onload = (ev) => {
46
+ try {
47
+ const data = ev.target.result;
48
+ const workbook = XLSX.read(data, {
49
+ type: "binary"
50
+ });
51
+ const wsname1 = workbook.SheetNames[0];
52
+ const ws1 = XLSX.utils.sheet_to_json(workbook.Sheets[wsname1]);
53
+ let content = formColumns.reduce((content2, column) => {
54
+ const title = column.import ? column.import.title : column.label;
55
+ return content2.replace(
56
+ new RegExp(`"${title}":`, "g"),
57
+ `"${column.prop}":`
58
+ );
59
+ }, JSON.stringify(ws1));
60
+ let dataSource = JSON.parse(content);
61
+ if (beforeDataHandle) {
62
+ dataSource = dataSource.map((item) => beforeDataHandle(item));
63
+ }
64
+ resolve2(dataSource);
65
+ } catch (err) {
66
+ reject(err);
67
+ }
68
+ };
69
+ fileReader.readAsBinaryString(files[0]);
70
+ });
71
+ };
72
+ const downloadTemplateHandler = async (props) => {
73
+ const { templateConfig } = props;
74
+ const { url, fileName } = templateConfig;
75
+ if (!url) {
76
+ ElMessage.warning("\u8BF7\u914D\u7F6E\u4E0B\u8F7D\u6A21\u677F\u5730\u5740");
77
+ return;
78
+ }
79
+ const { api } = useApi();
80
+ try {
81
+ const blob = await unref(api).get(url, {
82
+ responseType: "blob"
83
+ });
84
+ blobDownloadFn(blob, fileName).then(() => {
85
+ resolve();
86
+ });
87
+ } catch (err) {
88
+ console.error(err);
89
+ }
90
+ };
91
+ function blobDownloadFn(blob, name) {
92
+ return new Promise((resolve2, reject) => {
93
+ ElMessage.warning("\u5F00\u59CB\u4E0B\u8F7D");
94
+ const today = dayjs().format("YYYY-MM-DD HH:mm:ss");
95
+ const reader = new FileReader();
96
+ reader.readAsDataURL(blob);
97
+ reader.onload = function(ev) {
98
+ let url = null;
99
+ try {
100
+ if (window.navigator.msSaveOrOpenBlob) {
101
+ const blobObject = new Blob([blob]);
102
+ window.navigator.msSaveOrOpenBlob(blobObject, `${name}_${today}.xls`);
103
+ } else {
104
+ url = URL.createObjectURL(new Blob([blob]));
105
+ const a = document.createElement("a");
106
+ document.body.appendChild(a);
107
+ a.href = url;
108
+ a.download = `${name}_${today}.xls`;
109
+ a.target = "_blank";
110
+ a.click();
111
+ a.remove();
112
+ }
113
+ resolve2();
114
+ } catch (error) {
115
+ reject(error);
116
+ } finally {
117
+ if (url) URL.revokeObjectURL(url);
118
+ }
119
+ };
120
+ });
121
+ }
122
+
123
+ export { doReadExcel, doValidate, downloadTemplateHandler };
@@ -0,0 +1,47 @@
1
+ import { useAppForm } from '../../hyForm/js/useAppForm.mjs';
2
+ import { useAppTable } from '../../hyTable/js/useAppTable.mjs';
3
+ import { isString, isObject } from '../../../utils/is.mjs';
4
+
5
+ const useAppTableForm = (config = {}) => {
6
+ let { columns } = config || {};
7
+ columns = [
8
+ {
9
+ type: "expand",
10
+ slot: "expand",
11
+ expandType: "expand",
12
+ width: 48
13
+ },
14
+ ...columns.filter(
15
+ (column) => !["expand", "operator"].includes(column.type)
16
+ ),
17
+ {
18
+ label: "\u5BFC\u5165\u72B6\u6001",
19
+ prop: "validateStatus",
20
+ slot: "validateStatus"
21
+ }
22
+ ];
23
+ const { tableColumns } = useAppTable({ columns });
24
+ const { formModel, formColumns } = useAppForm(
25
+ config.formColumns,
26
+ config.formModel
27
+ );
28
+ formColumns.value.forEach((item) => {
29
+ if (isString(item.import)) {
30
+ item.import = {
31
+ title: item.import
32
+ };
33
+ } else {
34
+ item.import = {
35
+ title: item.label,
36
+ ...isObject(item.import) ? item.import : {}
37
+ };
38
+ }
39
+ });
40
+ return {
41
+ tableColumns,
42
+ formModel,
43
+ formColumns
44
+ };
45
+ };
46
+
47
+ export { useAppTableForm };