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