el-plus 0.0.47 → 0.0.51

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 (113) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/index.css +1 -1
  3. package/dist/index.full.js +496 -285
  4. package/dist/index.full.min.js +1 -1
  5. package/dist/index.full.min.js.map +1 -1
  6. package/dist/index.full.min.mjs +1 -1
  7. package/dist/index.full.min.mjs.map +1 -1
  8. package/dist/index.full.mjs +496 -285
  9. package/es/components/attachment/index.d.ts +24 -3
  10. package/es/components/attachment/src/attachment.d.ts +4 -0
  11. package/es/components/attachment/src/attachment.mjs +5 -0
  12. package/es/components/attachment/src/attachment.mjs.map +1 -1
  13. package/es/components/attachment/src/attachment.vue.d.ts +12 -1
  14. package/es/components/attachment/src/attachment.vue2.mjs +69 -29
  15. package/es/components/attachment/src/attachment.vue2.mjs.map +1 -1
  16. package/es/components/attachment/src/use-attachment.d.ts +32 -24
  17. package/es/components/attachment/src/use-attachment.mjs +65 -12
  18. package/es/components/attachment/src/use-attachment.mjs.map +1 -1
  19. package/es/components/custom-column/src/custom-column.vue2.mjs +1 -1
  20. package/es/components/custom-column/src/custom-column.vue2.mjs.map +1 -1
  21. package/es/components/header/index.d.ts +15 -0
  22. package/es/components/header/src/header.d.ts +4 -0
  23. package/es/components/header/src/header.mjs +6 -1
  24. package/es/components/header/src/header.mjs.map +1 -1
  25. package/es/components/header/src/header.vue.d.ts +9 -0
  26. package/es/components/header/src/header.vue2.mjs +6 -1
  27. package/es/components/header/src/header.vue2.mjs.map +1 -1
  28. package/es/components/header/src/use-header.mjs +42 -44
  29. package/es/components/header/src/use-header.mjs.map +1 -1
  30. package/es/components/search-list-page/index.d.ts +11 -3
  31. package/es/components/search-list-page/index.mjs.map +1 -1
  32. package/es/components/search-list-page/src/search-list-page.vue.d.ts +3 -1
  33. package/es/components/search-list-page/src/use-search-list-page.d.ts +3 -1
  34. package/es/components/search-list-page/src/use-search-list-page.mjs +1 -1
  35. package/es/components/search-list-page/src/use-search-list-page.mjs.map +1 -1
  36. package/es/components/table/index.d.ts +3 -0
  37. package/es/components/table/src/table.vue.d.ts +1 -0
  38. package/es/components/table/src/table.vue2.mjs +2 -0
  39. package/es/components/table/src/table.vue2.mjs.map +1 -1
  40. package/es/components/table/src/use-table.d.ts +1 -0
  41. package/es/components/table/src/use-table.mjs +4 -0
  42. package/es/components/table/src/use-table.mjs.map +1 -1
  43. package/es/hooks/dialog/use-choose-dialog.mjs +18 -3
  44. package/es/hooks/dialog/use-choose-dialog.mjs.map +1 -1
  45. package/es/hooks/dialog/use-dialog.mjs.map +1 -1
  46. package/es/hooks/dialog/use-form-dialog.mjs +14 -2
  47. package/es/hooks/dialog/use-form-dialog.mjs.map +1 -1
  48. package/es/hooks/use-request.mjs +4 -3
  49. package/es/hooks/use-request.mjs.map +1 -1
  50. package/es/locale/lang/en.d.ts +12 -0
  51. package/es/locale/lang/en.mjs +12 -0
  52. package/es/locale/lang/en.mjs.map +1 -1
  53. package/es/locale/lang/zh-cn.d.ts +12 -0
  54. package/es/locale/lang/zh-cn.mjs +12 -0
  55. package/es/locale/lang/zh-cn.mjs.map +1 -1
  56. package/es/package.json.mjs +1 -1
  57. package/es/utils/file.d.ts +1 -1
  58. package/es/utils/file.mjs.map +1 -1
  59. package/lib/components/attachment/index.d.ts +24 -3
  60. package/lib/components/attachment/src/attachment.d.ts +4 -0
  61. package/lib/components/attachment/src/attachment.js +5 -0
  62. package/lib/components/attachment/src/attachment.js.map +1 -1
  63. package/lib/components/attachment/src/attachment.vue.d.ts +12 -1
  64. package/lib/components/attachment/src/attachment.vue2.js +68 -28
  65. package/lib/components/attachment/src/attachment.vue2.js.map +1 -1
  66. package/lib/components/attachment/src/use-attachment.d.ts +32 -24
  67. package/lib/components/attachment/src/use-attachment.js +63 -10
  68. package/lib/components/attachment/src/use-attachment.js.map +1 -1
  69. package/lib/components/custom-column/src/custom-column.vue2.js +1 -1
  70. package/lib/components/custom-column/src/custom-column.vue2.js.map +1 -1
  71. package/lib/components/header/index.d.ts +15 -0
  72. package/lib/components/header/src/header.d.ts +4 -0
  73. package/lib/components/header/src/header.js +6 -1
  74. package/lib/components/header/src/header.js.map +1 -1
  75. package/lib/components/header/src/header.vue.d.ts +9 -0
  76. package/lib/components/header/src/header.vue2.js +6 -1
  77. package/lib/components/header/src/header.vue2.js.map +1 -1
  78. package/lib/components/header/src/use-header.js +42 -44
  79. package/lib/components/header/src/use-header.js.map +1 -1
  80. package/lib/components/search-list-page/index.d.ts +11 -3
  81. package/lib/components/search-list-page/index.js.map +1 -1
  82. package/lib/components/search-list-page/src/search-list-page.vue.d.ts +3 -1
  83. package/lib/components/search-list-page/src/use-search-list-page.d.ts +3 -1
  84. package/lib/components/search-list-page/src/use-search-list-page.js +1 -1
  85. package/lib/components/search-list-page/src/use-search-list-page.js.map +1 -1
  86. package/lib/components/table/index.d.ts +3 -0
  87. package/lib/components/table/src/table.vue.d.ts +1 -0
  88. package/lib/components/table/src/table.vue2.js +2 -0
  89. package/lib/components/table/src/table.vue2.js.map +1 -1
  90. package/lib/components/table/src/use-table.d.ts +1 -0
  91. package/lib/components/table/src/use-table.js +4 -0
  92. package/lib/components/table/src/use-table.js.map +1 -1
  93. package/lib/hooks/dialog/use-choose-dialog.js +17 -2
  94. package/lib/hooks/dialog/use-choose-dialog.js.map +1 -1
  95. package/lib/hooks/dialog/use-dialog.js.map +1 -1
  96. package/lib/hooks/dialog/use-form-dialog.js +14 -2
  97. package/lib/hooks/dialog/use-form-dialog.js.map +1 -1
  98. package/lib/hooks/use-request.js +4 -3
  99. package/lib/hooks/use-request.js.map +1 -1
  100. package/lib/locale/lang/en.d.ts +12 -0
  101. package/lib/locale/lang/en.js +12 -0
  102. package/lib/locale/lang/en.js.map +1 -1
  103. package/lib/locale/lang/zh-cn.d.ts +12 -0
  104. package/lib/locale/lang/zh-cn.js +12 -0
  105. package/lib/locale/lang/zh-cn.js.map +1 -1
  106. package/lib/package.json.js +1 -1
  107. package/lib/utils/file.d.ts +1 -1
  108. package/lib/utils/file.js.map +1 -1
  109. package/package.json +1 -1
  110. package/theme-chalk/attachment.css +1 -0
  111. package/theme-chalk/index.css +1 -1
  112. package/theme-chalk/src/attachment.scss +37 -0
  113. package/theme-chalk/src/index.scss +2 -1
@@ -1,4 +1,4 @@
1
- /*! ElPlus v0.0.47 */
1
+ /*! ElPlus v0.0.51 */
2
2
 
3
3
  import { useAttrs, getCurrentInstance, inject, provide, ref, nextTick, defineComponent, computed, createVNode, Fragment, withDirectives, resolveComponent, mergeProps, resolveDirective, useTemplateRef, createTextVNode, h, mergeModels, useModel, createElementBlock, openBlock, normalizeStyle, normalizeClass, unref, createCommentVNode, withCtx, renderSlot, renderList, createBlock, vShow, toDisplayString, reactive, useSlots, watch, onMounted, createSlots, normalizeProps, guardReactiveProps, markRaw, Transition, shallowReactive, isVNode, render, createElementVNode, toRaw } from 'vue';
4
4
  import { buttonProps, useLocale as useLocale$1, ElLoading, ElMessage, ElMessageBox, formProps as formProps$1, formEmits as formEmits$1, ElTooltip, formItemProps as formItemProps$1, ElFormItem, ElForm, ElRow, ElCol, inputProps as inputProps$1, inputEmits as inputEmits$1, configProviderContextKey, ElConfigProvider, ElDialog, ElButton, ElTable, ElIcon, selectProps as selectProps$1, selectEmits as selectEmits$1, ElPageHeader, datePickerProps, linkProps as linkProps$1, ElSkeleton } from 'element-plus';
@@ -281,6 +281,18 @@ var zhCn = {
281
281
  notFound: "\u672A\u627E\u5230, \u8BF7\u6C42\u7684\u8D44\u6E90\u4E0D\u5B58\u5728",
282
282
  //
283
283
  serverError: "\u5185\u90E8\u670D\u52A1\u5668\u9519\u8BEF\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5"
284
+ },
285
+ attachment: {
286
+ addAttachment: "\u6DFB\u52A0\u9644\u4EF6",
287
+ manageAttachment: "\u9644\u4EF6\u7BA1\u7406",
288
+ operation: "\u64CD\u4F5C",
289
+ download: "\u4E0B\u8F7D",
290
+ delete: "\u5220\u9664",
291
+ attachmentType: "\u9644\u4EF6\u7C7B\u578B",
292
+ fileName: "\u6587\u4EF6\u540D\u79F0",
293
+ creator: "\u521B\u5EFA\u4EBA",
294
+ createTime: "\u521B\u5EFA\u65F6\u95F4",
295
+ description: "\u8BF4\u660E"
284
296
  }
285
297
  }
286
298
  };
@@ -1556,9 +1568,10 @@ const useRequest = ({
1556
1568
  ...reqParams,
1557
1569
  ...config.params
1558
1570
  };
1559
- if (data.$query) {
1560
- config.data[data.$query] = data.$searchValue;
1561
- delete data.$searchValue;
1571
+ if (config.data.$query) {
1572
+ config.data[config.data.$query] = data.$searchValue;
1573
+ delete config.data.$searchValue;
1574
+ delete config.data.$query;
1562
1575
  }
1563
1576
  if (reqBefore) {
1564
1577
  reqBefore(config);
@@ -1804,7 +1817,7 @@ var _sfc_main$9 = /* @__PURE__ */ defineComponent({
1804
1817
  size: "small",
1805
1818
  onClick: open
1806
1819
  }, {
1807
- default: withCtx(() => [createTextVNode(toDisplayString(unref(t)("ep.customColumn.defineColumn")), 1)]),
1820
+ default: withCtx(() => [createTextVNode(toDisplayString(unref(t)("ep.customColumn.columnSettings")), 1)]),
1808
1821
  _: 1
1809
1822
  }, 8, ["class"])) : createCommentVNode("", true), createVNode(unref(CustomColumnDialog), null, {
1810
1823
  default: withCtx(() => [createVNode(_component_el_transfer, {
@@ -1957,7 +1970,14 @@ const useFormDialog = (options = {}) => {
1957
1970
  ...formProps
1958
1971
  } = options;
1959
1972
  const formRef = ref();
1960
- let formData = formProps.formData || reactive({});
1973
+ const isUseComFormData = !formProps.formData;
1974
+ let formData = isUseComFormData ? reactive({}) : formProps.formData;
1975
+ const isDestroy = dialogProps?.destroyOnClose;
1976
+ const resetForm = async () => {
1977
+ if (isDestroy) {
1978
+ await formRef.value?.resetFields();
1979
+ }
1980
+ };
1961
1981
  return useDialog({
1962
1982
  class: bem$1.b(),
1963
1983
  width: "80%",
@@ -1975,7 +1995,12 @@ const useFormDialog = (options = {}) => {
1975
1995
  },
1976
1996
  onConfirm: async (resolve) => {
1977
1997
  await formRef.value.validate();
1978
- resolve(formData);
1998
+ resolve(JSON.parse(JSON.stringify(formData)));
1999
+ resetForm();
2000
+ },
2001
+ onCancel: async (resolve) => {
2002
+ await resetForm();
2003
+ resolve("cancel");
1979
2004
  },
1980
2005
  ...dialogProps
1981
2006
  });
@@ -2078,6 +2103,9 @@ const useTable$1 = (props) => {
2078
2103
  const resetFields = (props2) => {
2079
2104
  return elFormRef.value.resetFields(props2);
2080
2105
  };
2106
+ const clearSelection = () => {
2107
+ return elTableRef.value.clearSelection();
2108
+ };
2081
2109
  const clearValidate = (props2) => {
2082
2110
  return elFormRef.value.clearValidate(props2);
2083
2111
  };
@@ -2096,6 +2124,7 @@ const useTable$1 = (props) => {
2096
2124
  pagination,
2097
2125
  paginationProps,
2098
2126
  validate,
2127
+ clearSelection,
2099
2128
  resetFields,
2100
2129
  clearValidate,
2101
2130
  elFormRef,
@@ -2349,6 +2378,7 @@ var _sfc_main$8 = /* @__PURE__ */ defineComponent({
2349
2378
  validate,
2350
2379
  resetFields,
2351
2380
  clearValidate,
2381
+ clearSelection,
2352
2382
  loading,
2353
2383
  search,
2354
2384
  elFormRef,
@@ -2369,6 +2399,7 @@ var _sfc_main$8 = /* @__PURE__ */ defineComponent({
2369
2399
  validate,
2370
2400
  resetFields,
2371
2401
  clearValidate,
2402
+ clearSelection,
2372
2403
  search,
2373
2404
  openCustomColumnDialog: () => {
2374
2405
  customColumnRef.value?.open();
@@ -2702,7 +2733,7 @@ const useButtons$1 = (props, { validate, resetFields, tableRef }) => {
2702
2733
  const list = mergeListByKey(defaultButtons, props.leftButtons);
2703
2734
  if (props.customColumnModule) {
2704
2735
  list.push({
2705
- name: t("ep.customColumn.defineColumn"),
2736
+ name: t("ep.customColumn.columnSettings"),
2706
2737
  prop: "customColumn",
2707
2738
  type: "primary",
2708
2739
  onClick: () => {
@@ -3163,7 +3194,12 @@ const headerProps = {
3163
3194
  default: () => []
3164
3195
  },
3165
3196
  // 工作流id
3166
- workflowId: String
3197
+ workflowId: String,
3198
+ // 是否显示附件按钮
3199
+ isShowAttachmentButton: {
3200
+ type: Boolean,
3201
+ default: false
3202
+ }
3167
3203
  };
3168
3204
  const headerEmits = {};
3169
3205
 
@@ -3262,67 +3298,452 @@ const useHeader = (props, emit) => {
3262
3298
  };
3263
3299
  };
3264
3300
  const useButtons = (props, emit) => {
3265
- const { t } = useLocale();
3301
+ const {
3302
+ t
3303
+ } = useLocale();
3304
+ const {
3305
+ mode: defaultMode
3306
+ } = useNavigation();
3307
+ const mode = computed(() => {
3308
+ return props.mode || defaultMode.value;
3309
+ });
3310
+ let defaultButtons = [{
3311
+ name: t("ep.header.edit"),
3312
+ prop: "modify",
3313
+ permission: props.name ? `${props.name}:UPDATE` : "",
3314
+ disabled: () => {
3315
+ return mode.value !== "browse";
3316
+ }
3317
+ }, {
3318
+ name: t("ep.header.save"),
3319
+ prop: "save",
3320
+ permission: props.name ? `${props.name}:SAVE` : "",
3321
+ disabled: () => {
3322
+ return !(mode.value === "edit" || mode.value === "add");
3323
+ }
3324
+ }, {
3325
+ name: t("ep.header.cancel"),
3326
+ prop: "cancel",
3327
+ disabled: () => {
3328
+ return mode.value !== "edit";
3329
+ }
3330
+ }, {
3331
+ name: t("ep.header.refresh"),
3332
+ prop: "refresh",
3333
+ permission: props.name ? `${props.name}:REFRESH` : "",
3334
+ disabled: () => {
3335
+ return mode.value !== "browse";
3336
+ }
3337
+ }, {
3338
+ name: t("ep.header.approvalLog"),
3339
+ prop: "approvalLog",
3340
+ permission: props.name ? `${props.name}:APPROVALLOG` : "",
3341
+ show: () => {
3342
+ return !!props.workflowId;
3343
+ },
3344
+ onClick: () => {
3345
+ gotoTaskTrace(props.workflowId);
3346
+ }
3347
+ }];
3348
+ if (props.defaultButtons.length) {
3349
+ defaultButtons = defaultButtons.filter((item) => {
3350
+ return props.defaultButtons.some((item1) => item1 === item.prop);
3351
+ });
3352
+ }
3353
+ const buttons = mergeListByKey(defaultButtons, props.buttons);
3354
+ return {
3355
+ buttons
3356
+ };
3357
+ };
3358
+
3359
+ const attachmentProps = {
3360
+ // 格式化列
3361
+ formatColumns: {
3362
+ ...tableProps.formatColumns
3363
+ },
3364
+ // 页面模式
3365
+ mode: {
3366
+ ...headerProps.mode
3367
+ },
3368
+ // 展示模式
3369
+ openType: {
3370
+ type: String,
3371
+ default: "dialog"
3372
+ },
3373
+ // 是否需要类型
3374
+ isType: {
3375
+ type: Boolean,
3376
+ default: true
3377
+ },
3378
+ // 是否需要备注
3379
+ isNote: {
3380
+ type: Boolean,
3381
+ default: false
3382
+ },
3383
+ // 是否需要打开弹窗按钮
3384
+ isShowOpenDialogButton: {
3385
+ type: Boolean,
3386
+ default: false
3387
+ }
3388
+ };
3389
+
3390
+ const getFullUrl = (filePath) => {
3391
+ return filePath.indexOf("hongxinshop.com") > -1 ? filePath : `${window.location.protocol}${getEnv() === "local" ? `//${getLocationEnv()}-hxjf.hongxinshop.com` : ""}/image/${filePath}`;
3392
+ };
3393
+ const downloadSrc = ({
3394
+ src,
3395
+ fileName,
3396
+ blob
3397
+ }) => {
3398
+ if (src) {
3399
+ fileName = fileName || src.split("/")[src.split("/").length - 1];
3400
+ const a = document.createElement("a");
3401
+ a.style.display = "none";
3402
+ document.body.appendChild(a);
3403
+ const event = new MouseEvent("click");
3404
+ a.download = fileName;
3405
+ a.href = blob ? src : getFullUrl(src);
3406
+ a.target = "_blank";
3407
+ a.dispatchEvent(event);
3408
+ document.body.removeChild(a);
3409
+ }
3410
+ };
3411
+ async function downloadFile({
3412
+ api = "",
3413
+ blob,
3414
+ data = {},
3415
+ src,
3416
+ fileName = "",
3417
+ config = {}
3418
+ }) {
3419
+ if (src) {
3420
+ downloadSrc({ src, fileName });
3421
+ return;
3422
+ }
3423
+ http.request(api, {
3424
+ method: config.method || "post",
3425
+ data,
3426
+ loading: true,
3427
+ responseType: blob ? "blob" : void 0,
3428
+ responseReturn: "raw",
3429
+ ...config
3430
+ }).then((res) => {
3431
+ const { headers } = res;
3432
+ if (!res.data.success) {
3433
+ return ElMessage.error(res.data.msg);
3434
+ }
3435
+ const data2 = res.data?.data || res.data?.data?.url || "";
3436
+ const lowerHeaders = {};
3437
+ for (const key in headers) {
3438
+ lowerHeaders[key.toLowerCase()] = headers[key];
3439
+ }
3440
+ let src2 = "";
3441
+ if (blob) {
3442
+ const contentDisposition = lowerHeaders["content-disposition"] || "";
3443
+ fileName = fileName || decodeURIComponent(contentDisposition.split("filename=")[1]);
3444
+ const blob2 = new Blob([data2], {
3445
+ type: headers["content-type"]
3446
+ });
3447
+ src2 = window.URL.createObjectURL(blob2);
3448
+ setTimeout(() => window.URL.revokeObjectURL(src2), 100);
3449
+ } else {
3450
+ src2 = data2;
3451
+ }
3452
+ downloadSrc({ src: src2, fileName, blob });
3453
+ });
3454
+ }
3455
+ const importFile = async ({
3456
+ accept = "*",
3457
+ multiple = false,
3458
+ fieldName = "file",
3459
+ failedFileName = "",
3460
+ extraData = {},
3461
+ api = ""
3462
+ }) => {
3463
+ return new Promise((resolve, reject) => {
3464
+ const input = document.createElement("input");
3465
+ input.type = "file";
3466
+ input.accept = accept;
3467
+ input.multiple = multiple;
3468
+ const formData = new FormData();
3469
+ Object.keys(extraData).forEach((key) => {
3470
+ formData.append(key, extraData[key]);
3471
+ });
3472
+ input.onchange = async (event) => {
3473
+ const target = event.target;
3474
+ const files = target.files;
3475
+ if (files && files.length > 0) {
3476
+ if (!multiple) {
3477
+ formData.append(fieldName, files[0]);
3478
+ } else {
3479
+ Array.from(files).forEach((file, index) => {
3480
+ formData.append(`${fieldName}${index}`, file);
3481
+ });
3482
+ }
3483
+ try {
3484
+ const { data } = await http.request(api, {
3485
+ method: "post",
3486
+ data: formData,
3487
+ loading: true,
3488
+ responseReturn: "raw",
3489
+ transformRequest: [
3490
+ function(data2) {
3491
+ return data2;
3492
+ }
3493
+ ]
3494
+ });
3495
+ if (data.success) {
3496
+ return resolve(data.data);
3497
+ }
3498
+ if (data.code === -2) {
3499
+ const fileName = failedFileName || data.data.split("/")[data.data.split("/").length - 1];
3500
+ const url = `${window.location.origin}/image/${data.data}`;
3501
+ const failedHtml = `<div style="word-break: break-all;">\u5931\u8D25\u8BE6\u60C5\uFF1A<a style="color:#409EFF;display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap" title="${url}" href="${url}" download="${fileName}">${url}</a></div>`;
3502
+ ElMessageBox.alert(failedHtml, "\u63D0\u793A", {
3503
+ confirmButtonText: "\u786E\u5B9A",
3504
+ type: "error",
3505
+ dangerouslyUseHTMLString: true
3506
+ });
3507
+ return;
3508
+ }
3509
+ return ElMessage.error(data.msg);
3510
+ } catch (error) {
3511
+ console.error(error);
3512
+ }
3513
+ input.onchange = null;
3514
+ }
3515
+ };
3516
+ input.click();
3517
+ });
3518
+ };
3519
+ const previewFile = (url) => {
3520
+ url = getFullUrl(url);
3521
+ const origin = getFullUrl("").replace("/image/", "");
3522
+ const previewUrl = `${origin}/kfv/onlinePreview?url=${encode(url)}`;
3523
+ window.open(previewUrl, "_blank");
3524
+ };
3525
+
3526
+ const useAttachment = (props, { data }) => {
3266
3527
  const { mode: defaultMode } = useNavigation();
3528
+ const { t } = useLocale();
3267
3529
  const mode = computed(() => {
3268
3530
  return props.mode || defaultMode.value;
3269
3531
  });
3270
- let defaultButtons = [
3532
+ const tableRef = useTemplateRef("tableRef");
3533
+ const isNormalOpen = props.openType === "normal";
3534
+ const isDialogOpen = props.openType === "dialog";
3535
+ let toBeConfirmData = [];
3536
+ let toBeDeleteData = {};
3537
+ const columns = ref([
3271
3538
  {
3272
- name: t("ep.header.edit"),
3273
- prop: "modify",
3274
- permission: props.name ? `${props.name}:UPDATE` : "",
3275
- disabled: () => {
3276
- return mode.value !== "browse";
3539
+ type: "EpButtons",
3540
+ label: t("ep.attachment.operation"),
3541
+ width: "120px",
3542
+ props: {
3543
+ type: "text",
3544
+ list: [
3545
+ {
3546
+ name: t("ep.attachment.download"),
3547
+ onClick({ row }) {
3548
+ downloadFile({
3549
+ src: row.filePath,
3550
+ fileName: row.originalFilename || row.originalFileName
3551
+ });
3552
+ }
3553
+ },
3554
+ {
3555
+ name: t("ep.attachment.delete"),
3556
+ disabled: () => {
3557
+ return mode.value === "browse";
3558
+ },
3559
+ onClick: ({ $index, row }) => {
3560
+ if (isDialogOpen) {
3561
+ toBeDeleteData[$index] = row;
3562
+ }
3563
+ data.value.splice($index, 1);
3564
+ }
3565
+ }
3566
+ ]
3277
3567
  }
3278
3568
  },
3279
3569
  {
3280
- name: t("ep.header.save"),
3281
- prop: "save",
3282
- permission: props.name ? `${props.name}:SAVE` : "",
3283
- disabled: () => {
3284
- return !(mode.value === "edit" || mode.value === "add");
3570
+ label: t("ep.attachment.attachmentType"),
3571
+ prop: "type",
3572
+ type: "EpSelect",
3573
+ required: true,
3574
+ show: () => props.isType,
3575
+ props: {
3576
+ desc: ({ row }) => {
3577
+ return row.typeDesc;
3578
+ }
3285
3579
  }
3286
3580
  },
3287
3581
  {
3288
- name: t("ep.header.cancel"),
3289
- prop: "cancel",
3290
- disabled: () => {
3291
- return mode.value !== "edit";
3582
+ label: t("ep.attachment.fileName"),
3583
+ prop: "originalFilename",
3584
+ type: "EpLink",
3585
+ onClick({ row }) {
3586
+ previewFile(row.filePath);
3292
3587
  }
3293
3588
  },
3294
3589
  {
3295
- name: t("ep.header.refresh"),
3296
- prop: "refresh",
3297
- permission: props.name ? `${props.name}:REFRESH` : "",
3298
- disabled: () => {
3299
- return mode.value !== "browse";
3300
- }
3590
+ label: t("ep.attachment.creator"),
3591
+ prop: "createBy"
3301
3592
  },
3302
3593
  {
3303
- name: t("ep.header.approvalLog"),
3304
- prop: "approvalLog",
3305
- permission: props.name ? `${props.name}:APPROVALLOG` : "",
3306
- show: () => {
3307
- return !!props.workflowId;
3308
- },
3309
- onClick: () => {
3310
- gotoTaskTrace(props.workflowId);
3311
- }
3594
+ label: t("ep.attachment.createTime"),
3595
+ prop: "createTime"
3596
+ },
3597
+ {
3598
+ label: t("ep.attachment.description"),
3599
+ prop: "note",
3600
+ type: "EpInput",
3601
+ show: () => props.isNote
3312
3602
  }
3313
- ];
3314
- if (props.defaultButtons.length) {
3315
- defaultButtons = defaultButtons.filter((item) => {
3316
- return props.defaultButtons.some((item1) => item1 === item.prop);
3603
+ ]);
3604
+ const addAttachment = async () => {
3605
+ toBeConfirmData = [];
3606
+ const fileData = await importFile({
3607
+ api: "api-f/fast/files/save",
3608
+ extraData: {
3609
+ createBy: Cookies.get("accountName") || ""
3610
+ }
3317
3611
  });
3318
- }
3319
- const buttons = mergeListByKey(defaultButtons, props.buttons);
3612
+ fileData.fileId = fileData.id;
3613
+ delete fileData.id;
3614
+ if (isDialogOpen) {
3615
+ toBeConfirmData.push(fileData);
3616
+ }
3617
+ data.value.push(fileData);
3618
+ };
3619
+ const onConfirm = async (resolve) => {
3620
+ await tableRef.value?.validate();
3621
+ resolve(data.value);
3622
+ };
3623
+ const onCancel = (resolve) => {
3624
+ if (toBeConfirmData.length) {
3625
+ const index = data.value.findIndex((item) => {
3626
+ return item.fileId === toBeConfirmData[0].fileId;
3627
+ });
3628
+ if (index !== -1) {
3629
+ data.value.splice(index, 1);
3630
+ }
3631
+ toBeConfirmData = [];
3632
+ }
3633
+ if (Object.keys(toBeDeleteData).length) {
3634
+ Object.keys(toBeDeleteData).forEach((oldIndex) => {
3635
+ data.value.splice(Number(oldIndex), 0, toBeDeleteData[oldIndex]);
3636
+ });
3637
+ toBeDeleteData = {};
3638
+ }
3639
+ resolve();
3640
+ };
3320
3641
  return {
3321
- buttons
3642
+ columns,
3643
+ addAttachment,
3644
+ isNormalOpen,
3645
+ isDialogOpen,
3646
+ onConfirm,
3647
+ onCancel
3322
3648
  };
3323
3649
  };
3324
3650
 
3325
3651
  var _sfc_main$4 = /* @__PURE__ */ defineComponent({
3652
+ ...{
3653
+ name: "EpAttachment",
3654
+ inheritAttrs: false
3655
+ },
3656
+ __name: "attachment",
3657
+ props: /* @__PURE__ */ mergeModels(attachmentProps, {
3658
+ "modelValue": {},
3659
+ "modelModifiers": {}
3660
+ }),
3661
+ emits: ["update:modelValue"],
3662
+ setup(__props, { expose: __expose }) {
3663
+ const { t } = useLocale();
3664
+ const bem = createNameSpace("attachment");
3665
+ const props = __props;
3666
+ const modelValue = useModel(__props, "modelValue");
3667
+ const { columns, addAttachment, isNormalOpen, onConfirm, onCancel } = useAttachment(props, {
3668
+ data: modelValue
3669
+ });
3670
+ const AttachmentDialog = useDialog({
3671
+ width: 850,
3672
+ center: true,
3673
+ title: isNormalOpen ? "" : t("ep.attachment.manageAttachment"),
3674
+ modal: !isNormalOpen,
3675
+ showClose: !isNormalOpen,
3676
+ showFooter: !isNormalOpen,
3677
+ transition: isNormalOpen ? "" : "dialog-fade",
3678
+ modalClass: bem.em(
3679
+ "dialog",
3680
+ props.openType === "normal" ? props.openType : ""
3681
+ ),
3682
+ onConfirm: async (resolve) => {
3683
+ onConfirm(resolve);
3684
+ },
3685
+ onCancel: (resolve) => {
3686
+ onCancel(resolve);
3687
+ }
3688
+ });
3689
+ const open = AttachmentDialog.open;
3690
+ if (isNormalOpen) {
3691
+ open();
3692
+ }
3693
+ __expose({
3694
+ open
3695
+ });
3696
+ return (_ctx, _cache) => {
3697
+ const _component_EpButtons = resolveComponent("EpButtons");
3698
+ return openBlock(), createElementBlock(Fragment, null, [
3699
+ _ctx.isShowOpenDialogButton ? (openBlock(), createBlock(unref(ElButton), {
3700
+ key: 0,
3701
+ type: "primary",
3702
+ plain: "",
3703
+ size: "small",
3704
+ class: normalizeClass(unref(bem).e("handler")),
3705
+ onClick: unref(open)
3706
+ }, {
3707
+ default: withCtx(() => [
3708
+ createTextVNode(toDisplayString(unref(t)("ep.attachment.manageAttachment")) + "(" + toDisplayString(modelValue.value?.length || 0) + ") ", 1)
3709
+ ]),
3710
+ _: 1
3711
+ }, 8, ["class", "onClick"])) : createCommentVNode("", true),
3712
+ createVNode(unref(AttachmentDialog), null, {
3713
+ default: withCtx(() => [
3714
+ createElementVNode("div", { style: { "margin-bottom": "10px", "text-align": "right" } }, [
3715
+ _ctx.openType === "dialog" ? (openBlock(), createBlock(_component_EpButtons, {
3716
+ key: 0,
3717
+ type: "primary",
3718
+ list: [
3719
+ {
3720
+ name: unref(t)("ep.attachment.addAttachment"),
3721
+ type: "primary",
3722
+ onClick: unref(addAttachment)
3723
+ }
3724
+ ]
3725
+ }, null, 8, ["list"])) : createCommentVNode("", true)
3726
+ ]),
3727
+ createVNode(unref(EpTable), mergeProps({
3728
+ ref: "tableRef",
3729
+ class: `${unref(bem).b()} ${unref(prepareClassNames)()}`,
3730
+ style: {
3731
+ ...unref(prepareStyles)()
3732
+ },
3733
+ columns: unref(columns),
3734
+ data: modelValue.value
3735
+ }, props), null, 16, ["class", "style", "columns", "data"])
3736
+ ]),
3737
+ _: 1
3738
+ })
3739
+ ], 64);
3740
+ };
3741
+ }
3742
+ });
3743
+
3744
+ const EpAttachment = withInstall(_sfc_main$4);
3745
+
3746
+ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
3326
3747
  ...{
3327
3748
  name: "EpHeader",
3328
3749
  inheritAttrs: false
@@ -3349,13 +3770,17 @@ var _sfc_main$4 = /* @__PURE__ */ defineComponent({
3349
3770
  content: withCtx(() => []),
3350
3771
  _: 1
3351
3772
  }, 8, ["onBack"])) : createCommentVNode("", true),
3352
- createVNode(unref(EpButtons), { list: unref(buttons) }, null, 8, ["list"])
3773
+ createVNode(unref(EpButtons), { list: unref(buttons) }, null, 8, ["list"]),
3774
+ props.isShowAttachmentButton ? (openBlock(), createBlock(unref(EpAttachment), {
3775
+ key: 1,
3776
+ "is-show-open-dialog-button": ""
3777
+ })) : createCommentVNode("", true)
3353
3778
  ], 6);
3354
3779
  };
3355
3780
  }
3356
3781
  });
3357
3782
 
3358
- const EpHeader = withInstall(_sfc_main$4);
3783
+ const EpHeader = withInstall(_sfc_main$3);
3359
3784
 
3360
3785
  const { t } = useLocale();
3361
3786
  const datePickerRangeProps = {
@@ -3425,7 +3850,7 @@ const datePickerRangeProps = {
3425
3850
  };
3426
3851
  const datePickerRangeEmits = {};
3427
3852
 
3428
- var _sfc_main$3 = /* @__PURE__ */ defineComponent({
3853
+ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
3429
3854
  ...{
3430
3855
  name: "EpDatePickerRange",
3431
3856
  inheritAttrs: false
@@ -3481,7 +3906,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
3481
3906
  }
3482
3907
  });
3483
3908
 
3484
- const EpDatePickerRange = withInstall(_sfc_main$3);
3909
+ const EpDatePickerRange = withInstall(_sfc_main$2);
3485
3910
 
3486
3911
  const linkProps = {
3487
3912
  ...linkProps$1,
@@ -3498,7 +3923,7 @@ const linkProps = {
3498
3923
  }
3499
3924
  };
3500
3925
 
3501
- var _sfc_main$2 = /* @__PURE__ */ defineComponent({
3926
+ var _sfc_main$1 = /* @__PURE__ */ defineComponent({
3502
3927
  ...{
3503
3928
  name: "EpLink",
3504
3929
  inheritAttrs: false
@@ -3543,236 +3968,7 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
3543
3968
  }
3544
3969
  });
3545
3970
 
3546
- const EpLink = withInstall(_sfc_main$2);
3547
-
3548
- const attachmentProps = {
3549
- // 格式化列
3550
- formatColumns: {
3551
- ...tableProps.formatColumns
3552
- },
3553
- // 页面模式
3554
- mode: {
3555
- ...headerProps.mode
3556
- },
3557
- // 展示模式
3558
- openType: {
3559
- type: String,
3560
- default: "dialog"
3561
- },
3562
- // 是否需要类型
3563
- isType: {
3564
- type: Boolean,
3565
- default: true
3566
- },
3567
- // 是否需要备注
3568
- isNote: {
3569
- type: Boolean,
3570
- default: false
3571
- }
3572
- };
3573
-
3574
- const getFullUrl = (filePath) => {
3575
- return filePath.indexOf("hongxinshop.com") > -1 ? filePath : `${window.location.protocol}${getEnv() === "local" ? `//${getLocationEnv()}-hxjf.hongxinshop.com` : ""}/image/${filePath}`;
3576
- };
3577
- const downloadSrc = ({
3578
- src,
3579
- fileName,
3580
- blob
3581
- }) => {
3582
- if (src) {
3583
- fileName = fileName || src.split("/")[src.split("/").length - 1];
3584
- const a = document.createElement("a");
3585
- a.style.display = "none";
3586
- document.body.appendChild(a);
3587
- const event = new MouseEvent("click");
3588
- a.download = fileName;
3589
- a.href = blob ? src : getFullUrl(src);
3590
- a.target = "_blank";
3591
- a.dispatchEvent(event);
3592
- document.body.removeChild(a);
3593
- }
3594
- };
3595
- async function downloadFile({
3596
- api = "",
3597
- blob,
3598
- data = {},
3599
- src,
3600
- fileName = "",
3601
- config = {}
3602
- }) {
3603
- if (src) {
3604
- downloadSrc({ src, fileName });
3605
- return;
3606
- }
3607
- http.request(api, {
3608
- method: config.method || "post",
3609
- data,
3610
- loading: true,
3611
- responseType: blob ? "blob" : void 0,
3612
- responseReturn: "raw",
3613
- ...config
3614
- }).then((res) => {
3615
- const { headers } = res;
3616
- if (!res.data.success) {
3617
- return ElMessage.error(res.data.msg);
3618
- }
3619
- const data2 = res.data?.data || res.data?.data?.url || "";
3620
- const lowerHeaders = {};
3621
- for (const key in headers) {
3622
- lowerHeaders[key.toLowerCase()] = headers[key];
3623
- }
3624
- let src2 = "";
3625
- if (blob) {
3626
- const contentDisposition = lowerHeaders["content-disposition"] || "";
3627
- fileName = fileName || decodeURIComponent(contentDisposition.split("filename=")[1]);
3628
- const blob2 = new Blob([data2], {
3629
- type: headers["content-type"]
3630
- });
3631
- src2 = window.URL.createObjectURL(blob2);
3632
- setTimeout(() => window.URL.revokeObjectURL(src2), 100);
3633
- } else {
3634
- src2 = data2;
3635
- }
3636
- downloadSrc({ src: src2, fileName, blob });
3637
- });
3638
- }
3639
- const previewFile = (url) => {
3640
- url = getFullUrl(url);
3641
- const origin = getFullUrl("").replace("/image/", "");
3642
- const previewUrl = `${origin}/kfv/onlinePreview?url=${encode(url)}`;
3643
- window.open(previewUrl, "_blank");
3644
- };
3645
-
3646
- const useAttachment = (props, { data }) => {
3647
- const { mode: defaultMode } = useNavigation();
3648
- const mode = computed(() => {
3649
- return props.mode || defaultMode.value;
3650
- });
3651
- const columns = ref([
3652
- {
3653
- type: "EpButtons",
3654
- label: "\u64CD\u4F5C",
3655
- width: "120px",
3656
- props: {
3657
- type: "text",
3658
- list: [
3659
- {
3660
- name: "\u4E0B\u8F7D",
3661
- onClick({ row }) {
3662
- downloadFile({
3663
- src: row.filePath,
3664
- fileName: row.originalFilename || row.originalFileName
3665
- });
3666
- }
3667
- },
3668
- {
3669
- name: "\u5220\u9664",
3670
- disabled: () => {
3671
- return mode.value === "browse";
3672
- },
3673
- onClick: ({ $index }) => {
3674
- data.value.splice($index, 1);
3675
- }
3676
- }
3677
- ]
3678
- }
3679
- },
3680
- {
3681
- label: "\u9644\u4EF6\u7C7B\u578B",
3682
- prop: "type",
3683
- type: "EpSelect",
3684
- required: true,
3685
- show: () => props.isType,
3686
- props: {
3687
- desc: ({ row }) => {
3688
- return row.typeDesc;
3689
- }
3690
- }
3691
- },
3692
- {
3693
- label: "\u6587\u4EF6\u540D\u79F0",
3694
- prop: "originalFilename",
3695
- type: "EpLink",
3696
- onClick({ row }) {
3697
- previewFile(row.filePath);
3698
- }
3699
- },
3700
- {
3701
- label: "\u521B\u5EFA\u4EBA",
3702
- prop: "createBy"
3703
- },
3704
- {
3705
- label: "\u521B\u5EFA\u65F6\u95F4",
3706
- prop: "createTime"
3707
- },
3708
- {
3709
- label: "\u8BF4\u660E",
3710
- prop: "note",
3711
- type: "EpInput",
3712
- show: () => props.isNote
3713
- }
3714
- ]);
3715
- return {
3716
- columns
3717
- };
3718
- };
3719
-
3720
- var _sfc_main$1 = /* @__PURE__ */ defineComponent({
3721
- ...{
3722
- name: "EpAttachment",
3723
- inheritAttrs: false
3724
- },
3725
- __name: "attachment",
3726
- props: /* @__PURE__ */ mergeModels(attachmentProps, {
3727
- "modelValue": {},
3728
- "modelModifiers": {}
3729
- }),
3730
- emits: ["update:modelValue"],
3731
- setup(__props) {
3732
- const bem = createNameSpace("attachment");
3733
- const props = __props;
3734
- const modelValue = useModel(__props, "modelValue");
3735
- const AttachmentDialog = useDialog({
3736
- class: bem.em("dialog", props.openType === "normal" ? props.openType : ""),
3737
- width: 850,
3738
- center: true,
3739
- title: "\u9644\u4EF6\u7BA1\u7406",
3740
- onConfirm: async (resolve) => {
3741
- }
3742
- });
3743
- const { columns } = useAttachment(props, {
3744
- data: modelValue
3745
- });
3746
- return (_ctx, _cache) => {
3747
- const _component_el_button = resolveComponent("el-button");
3748
- return openBlock(), createBlock(unref(AttachmentDialog), null, {
3749
- default: withCtx(() => [
3750
- _ctx.openType === "dialog" ? (openBlock(), createBlock(_component_el_button, {
3751
- key: 0,
3752
- type: "primary",
3753
- size: "default"
3754
- }, {
3755
- default: withCtx(() => [
3756
- createTextVNode("\u6DFB\u52A0\u9644\u4EF6")
3757
- ]),
3758
- _: 1
3759
- })) : createCommentVNode("", true),
3760
- createVNode(unref(EpTable), mergeProps({
3761
- class: `${unref(bem).b()} ${unref(prepareClassNames)()}`,
3762
- style: {
3763
- ...unref(prepareStyles)()
3764
- },
3765
- columns: unref(columns),
3766
- data: modelValue.value
3767
- }, props), null, 16, ["class", "style", "columns", "data"])
3768
- ]),
3769
- _: 1
3770
- });
3771
- };
3772
- }
3773
- });
3774
-
3775
- const EpAttachment = withInstall(_sfc_main$1);
3971
+ const EpLink = withInstall(_sfc_main$1);
3776
3972
 
3777
3973
  const componentType = ["bpm", "address"];
3778
3974
  const uniVueProps = {
@@ -3963,7 +4159,7 @@ var components = [
3963
4159
  EpUniVue
3964
4160
  ];
3965
4161
 
3966
- var version = "0.0.47";
4162
+ var version = "0.0.51";
3967
4163
 
3968
4164
  var globalProperties = {
3969
4165
  install(app) {
@@ -3997,6 +4193,11 @@ const useChooseDialog = (options = {}) => {
3997
4193
  }, [t("ep.chooseDialog.selected"), selections.value.length, t("ep.chooseDialog.unit")]);
3998
4194
  };
3999
4195
  }
4196
+ const clearSelections = async () => {
4197
+ selections.value = [];
4198
+ searchListPageRef.value?.tableRef?.clearSelection();
4199
+ };
4200
+ let searchListPageRef;
4000
4201
  return useDialog({
4001
4202
  class: bem.b(),
4002
4203
  width: "80%",
@@ -4005,12 +4206,22 @@ const useChooseDialog = (options = {}) => {
4005
4206
  title,
4006
4207
  onConfirm: (resolve) => {
4007
4208
  resolve(JSON.parse(JSON.stringify(selections.value)));
4209
+ clearSelections();
4210
+ },
4211
+ onCancel: async (resolve) => {
4212
+ clearSelections();
4213
+ resolve();
4008
4214
  },
4009
4215
  render: ({
4010
4216
  resolve
4011
4217
  }) => {
4218
+ if (!searchListPageRef) {
4219
+ searchListPageRef = useTemplateRef("searchListPage");
4220
+ }
4012
4221
  const formData = rest.formData || reactive({});
4013
- return createVNode(EpSearchListPage, {
4222
+ return createVNode(EpSearchListPage, mergeProps({
4223
+ "ref": "searchListPage"
4224
+ }, {
4014
4225
  showSelectionCol: multiple,
4015
4226
  showSingleSelectionCol,
4016
4227
  formData,
@@ -4029,7 +4240,7 @@ const useChooseDialog = (options = {}) => {
4029
4240
  resolve(toRaw(selections));
4030
4241
  }
4031
4242
  }
4032
- }, null);
4243
+ }), null);
4033
4244
  },
4034
4245
  ...dialogProps
4035
4246
  });