el-plus 0.0.47 → 0.0.50

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 (71) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/index.css +1 -1
  3. package/dist/index.full.js +453 -276
  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 +453 -276
  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/header/index.d.ts +15 -0
  20. package/es/components/header/src/header.d.ts +4 -0
  21. package/es/components/header/src/header.mjs +6 -1
  22. package/es/components/header/src/header.mjs.map +1 -1
  23. package/es/components/header/src/header.vue.d.ts +9 -0
  24. package/es/components/header/src/header.vue2.mjs +6 -1
  25. package/es/components/header/src/header.vue2.mjs.map +1 -1
  26. package/es/components/header/src/use-header.mjs +42 -44
  27. package/es/components/header/src/use-header.mjs.map +1 -1
  28. package/es/hooks/dialog/use-dialog.mjs.map +1 -1
  29. package/es/locale/lang/en.d.ts +12 -0
  30. package/es/locale/lang/en.mjs +12 -0
  31. package/es/locale/lang/en.mjs.map +1 -1
  32. package/es/locale/lang/zh-cn.d.ts +12 -0
  33. package/es/locale/lang/zh-cn.mjs +12 -0
  34. package/es/locale/lang/zh-cn.mjs.map +1 -1
  35. package/es/package.json.mjs +1 -1
  36. package/es/utils/file.d.ts +1 -1
  37. package/es/utils/file.mjs.map +1 -1
  38. package/lib/components/attachment/index.d.ts +24 -3
  39. package/lib/components/attachment/src/attachment.d.ts +4 -0
  40. package/lib/components/attachment/src/attachment.js +5 -0
  41. package/lib/components/attachment/src/attachment.js.map +1 -1
  42. package/lib/components/attachment/src/attachment.vue.d.ts +12 -1
  43. package/lib/components/attachment/src/attachment.vue2.js +68 -28
  44. package/lib/components/attachment/src/attachment.vue2.js.map +1 -1
  45. package/lib/components/attachment/src/use-attachment.d.ts +32 -24
  46. package/lib/components/attachment/src/use-attachment.js +63 -10
  47. package/lib/components/attachment/src/use-attachment.js.map +1 -1
  48. package/lib/components/header/index.d.ts +15 -0
  49. package/lib/components/header/src/header.d.ts +4 -0
  50. package/lib/components/header/src/header.js +6 -1
  51. package/lib/components/header/src/header.js.map +1 -1
  52. package/lib/components/header/src/header.vue.d.ts +9 -0
  53. package/lib/components/header/src/header.vue2.js +6 -1
  54. package/lib/components/header/src/header.vue2.js.map +1 -1
  55. package/lib/components/header/src/use-header.js +42 -44
  56. package/lib/components/header/src/use-header.js.map +1 -1
  57. package/lib/hooks/dialog/use-dialog.js.map +1 -1
  58. package/lib/locale/lang/en.d.ts +12 -0
  59. package/lib/locale/lang/en.js +12 -0
  60. package/lib/locale/lang/en.js.map +1 -1
  61. package/lib/locale/lang/zh-cn.d.ts +12 -0
  62. package/lib/locale/lang/zh-cn.js +12 -0
  63. package/lib/locale/lang/zh-cn.js.map +1 -1
  64. package/lib/package.json.js +1 -1
  65. package/lib/utils/file.d.ts +1 -1
  66. package/lib/utils/file.js.map +1 -1
  67. package/package.json +1 -1
  68. package/theme-chalk/attachment.css +1 -0
  69. package/theme-chalk/index.css +1 -1
  70. package/theme-chalk/src/attachment.scss +37 -0
  71. package/theme-chalk/src/index.scss +2 -1
@@ -32,12 +32,18 @@ export declare const EpAttachment: {
32
32
  readonly type: BooleanConstructor;
33
33
  readonly default: false;
34
34
  };
35
+ isShowOpenDialogButton: {
36
+ readonly type: BooleanConstructor;
37
+ readonly default: false;
38
+ };
35
39
  modelValue: {
36
40
  type: import("vue").PropType<any[]>;
37
41
  };
38
42
  }>> & Readonly<{
39
43
  "onUpdate:modelValue"?: ((value: any[] | undefined) => any) | undefined;
40
- }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
44
+ }>, {
45
+ open: () => Promise<any>;
46
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
41
47
  "update:modelValue": (value: any[] | undefined) => any;
42
48
  }, import("vue").PublicProps, {
43
49
  formatColumns: Partial<import("element-plus").TableColumnCtx & {
@@ -57,6 +63,7 @@ export declare const EpAttachment: {
57
63
  openType: "dialog" | "normal";
58
64
  isType: boolean;
59
65
  isNote: boolean;
66
+ isShowOpenDialogButton: boolean;
60
67
  }, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
61
68
  P: {};
62
69
  B: {};
@@ -97,12 +104,18 @@ export declare const EpAttachment: {
97
104
  readonly type: BooleanConstructor;
98
105
  readonly default: false;
99
106
  };
107
+ isShowOpenDialogButton: {
108
+ readonly type: BooleanConstructor;
109
+ readonly default: false;
110
+ };
100
111
  modelValue: {
101
112
  type: import("vue").PropType<any[]>;
102
113
  };
103
114
  }>> & Readonly<{
104
115
  "onUpdate:modelValue"?: ((value: any[] | undefined) => any) | undefined;
105
- }>, {}, {}, {}, {}, {
116
+ }>, {
117
+ open: () => Promise<any>;
118
+ }, {}, {}, {}, {
106
119
  formatColumns: Partial<import("element-plus").TableColumnCtx & {
107
120
  [key: string]: any;
108
121
  required: boolean | (() => boolean);
@@ -120,6 +133,7 @@ export declare const EpAttachment: {
120
133
  openType: "dialog" | "normal";
121
134
  isType: boolean;
122
135
  isNote: boolean;
136
+ isShowOpenDialogButton: boolean;
123
137
  }>;
124
138
  __isFragment?: never;
125
139
  __isTeleport?: never;
@@ -144,12 +158,18 @@ export declare const EpAttachment: {
144
158
  readonly type: BooleanConstructor;
145
159
  readonly default: false;
146
160
  };
161
+ isShowOpenDialogButton: {
162
+ readonly type: BooleanConstructor;
163
+ readonly default: false;
164
+ };
147
165
  modelValue: {
148
166
  type: import("vue").PropType<any[]>;
149
167
  };
150
168
  }>> & Readonly<{
151
169
  "onUpdate:modelValue"?: ((value: any[] | undefined) => any) | undefined;
152
- }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
170
+ }>, {
171
+ open: () => Promise<any>;
172
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
153
173
  "update:modelValue": (value: any[] | undefined) => any;
154
174
  }, string, {
155
175
  formatColumns: Partial<import("element-plus").TableColumnCtx & {
@@ -169,6 +189,7 @@ export declare const EpAttachment: {
169
189
  openType: "dialog" | "normal";
170
190
  isType: boolean;
171
191
  isNote: boolean;
192
+ isShowOpenDialogButton: boolean;
172
193
  }, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & import("vue").Plugin;
173
194
  export default EpAttachment;
174
195
  export * from './src/attachment';
@@ -19,5 +19,9 @@ export declare const attachmentProps: {
19
19
  readonly type: BooleanConstructor;
20
20
  readonly default: false;
21
21
  };
22
+ readonly isShowOpenDialogButton: {
23
+ readonly type: BooleanConstructor;
24
+ readonly default: false;
25
+ };
22
26
  };
23
27
  export type AttachmentProps = ExtractPropTypes<typeof attachmentProps>;
@@ -24,6 +24,11 @@ const attachmentProps = {
24
24
  isNote: {
25
25
  type: Boolean,
26
26
  default: false
27
+ },
28
+ // 是否需要打开弹窗按钮
29
+ isShowOpenDialogButton: {
30
+ type: Boolean,
31
+ default: false
27
32
  }
28
33
  };
29
34
 
@@ -1 +1 @@
1
- {"version":3,"file":"attachment.mjs","sources":["../../../../../../packages/components/attachment/src/attachment.ts"],"sourcesContent":["import type { ExtractPropTypes, PropType } from 'vue'\nimport { tableProps } from '@el-plus/components/table'\nimport { headerProps } from '@el-plus/components/header'\nexport const attachmentProps = {\n // 格式化列\n formatColumns: {\n ...tableProps.formatColumns,\n },\n // 页面模式\n mode: {\n ...headerProps.mode,\n },\n // 展示模式\n openType: {\n type: String as PropType<'dialog' | 'normal'>,\n default: 'dialog',\n },\n // 是否需要类型\n isType: {\n type: Boolean,\n default: true,\n },\n // 是否需要备注\n isNote: {\n type: Boolean,\n default: false,\n },\n} as const\nexport type AttachmentProps = ExtractPropTypes<typeof attachmentProps>\n"],"names":[],"mappings":";;;AAGO,MAAM,eAAA,GAAkB;AAAA;AAAA,EAE7B,aAAA,EAAe;AAAA,IACb,GAAG,UAAA,CAAW;AAAA,GAChB;AAAA;AAAA,EAEA,IAAA,EAAM;AAAA,IACJ,GAAG,WAAA,CAAY;AAAA,GACjB;AAAA;AAAA,EAEA,QAAA,EAAU;AAAA,IACR,IAAA,EAAM,MAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA,EAEA,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,OAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA,EAEA,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,OAAA;AAAA,IACN,OAAA,EAAS;AAAA;AAEb;;;;"}
1
+ {"version":3,"file":"attachment.mjs","sources":["../../../../../../packages/components/attachment/src/attachment.ts"],"sourcesContent":["import type { ExtractPropTypes, PropType } from 'vue'\nimport { tableProps } from '@el-plus/components/table'\nimport { headerProps } from '@el-plus/components/header'\nexport const attachmentProps = {\n // 格式化列\n formatColumns: {\n ...tableProps.formatColumns,\n },\n // 页面模式\n mode: {\n ...headerProps.mode,\n },\n // 展示模式\n openType: {\n type: String as PropType<'dialog' | 'normal'>,\n default: 'dialog',\n },\n // 是否需要类型\n isType: {\n type: Boolean,\n default: true,\n },\n // 是否需要备注\n isNote: {\n type: Boolean,\n default: false,\n },\n // 是否需要打开弹窗按钮\n isShowOpenDialogButton: {\n type: Boolean,\n default: false,\n },\n} as const\nexport type AttachmentProps = ExtractPropTypes<typeof attachmentProps>\n"],"names":[],"mappings":";;;AAGO,MAAM,eAAA,GAAkB;AAAA;AAAA,EAE7B,aAAA,EAAe;AAAA,IACb,GAAG,UAAA,CAAW;AAAA,GAChB;AAAA;AAAA,EAEA,IAAA,EAAM;AAAA,IACJ,GAAG,WAAA,CAAY;AAAA,GACjB;AAAA;AAAA,EAEA,QAAA,EAAU;AAAA,IACR,IAAA,EAAM,MAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA,EAEA,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,OAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA,EAEA,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,OAAA;AAAA,IACN,OAAA,EAAS;AAAA,GACX;AAAA;AAAA,EAEA,sBAAA,EAAwB;AAAA,IACtB,IAAA,EAAM,OAAA;AAAA,IACN,OAAA,EAAS;AAAA;AAEb;;;;"}
@@ -18,10 +18,16 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
18
18
  readonly type: BooleanConstructor;
19
19
  readonly default: false;
20
20
  };
21
+ isShowOpenDialogButton: {
22
+ readonly type: BooleanConstructor;
23
+ readonly default: false;
24
+ };
21
25
  modelValue: {
22
26
  type: import("vue").PropType<any[]>;
23
27
  };
24
- }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
28
+ }>, {
29
+ open: () => Promise<any>;
30
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
25
31
  "update:modelValue": (value: any[] | undefined) => any;
26
32
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
27
33
  formatColumns: {
@@ -43,6 +49,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
43
49
  readonly type: BooleanConstructor;
44
50
  readonly default: false;
45
51
  };
52
+ isShowOpenDialogButton: {
53
+ readonly type: BooleanConstructor;
54
+ readonly default: false;
55
+ };
46
56
  modelValue: {
47
57
  type: import("vue").PropType<any[]>;
48
58
  };
@@ -66,6 +76,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
66
76
  openType: "dialog" | "normal";
67
77
  isType: boolean;
68
78
  isNote: boolean;
79
+ isShowOpenDialogButton: boolean;
69
80
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
70
81
  declare const _default: typeof __VLS_export;
71
82
  export default _default;
@@ -1,10 +1,12 @@
1
- import { defineComponent, mergeModels, useModel, resolveComponent, createBlock, openBlock, unref, withCtx, createCommentVNode, createVNode, createTextVNode, mergeProps } from 'vue';
1
+ import { defineComponent, mergeModels, useModel, resolveComponent, createElementBlock, openBlock, Fragment, createBlock, createCommentVNode, createVNode, unref, normalizeClass, withCtx, createTextVNode, toDisplayString, createElementVNode, mergeProps } from 'vue';
2
2
  import { createNameSpace } from '../../../utils/bem.mjs';
3
3
  import { prepareStyles, prepareClassNames } from '../../../utils/props.mjs';
4
4
  import { attachmentProps } from './attachment.mjs';
5
5
  import { EpTable } from '../../table/index.mjs';
6
6
  import { useAttachment } from './use-attachment.mjs';
7
7
  import { useDialog } from '../../../hooks/dialog/use-dialog.mjs';
8
+ import { useLocale } from '../../../hooks/use-locale.mjs';
9
+ import { ElButton } from 'element-plus';
8
10
 
9
11
  var _sfc_main = /* @__PURE__ */ defineComponent({
10
12
  ...{
@@ -17,46 +19,84 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
17
19
  "modelModifiers": {}
18
20
  }),
19
21
  emits: ["update:modelValue"],
20
- setup(__props) {
22
+ setup(__props, { expose: __expose }) {
23
+ const { t } = useLocale();
21
24
  const bem = createNameSpace("attachment");
22
25
  const props = __props;
23
26
  const modelValue = useModel(__props, "modelValue");
27
+ const { columns, addAttachment, isNormalOpen, onConfirm, onCancel } = useAttachment(props, {
28
+ data: modelValue
29
+ });
24
30
  const AttachmentDialog = useDialog({
25
- class: bem.em("dialog", props.openType === "normal" ? props.openType : ""),
26
31
  width: 850,
27
32
  center: true,
28
- title: "\u9644\u4EF6\u7BA1\u7406",
33
+ title: isNormalOpen ? "" : t("ep.attachment.manageAttachment"),
34
+ modal: !isNormalOpen,
35
+ showClose: !isNormalOpen,
36
+ showFooter: !isNormalOpen,
37
+ transition: isNormalOpen ? "" : "dialog-fade",
38
+ modalClass: bem.em(
39
+ "dialog",
40
+ props.openType === "normal" ? props.openType : ""
41
+ ),
29
42
  onConfirm: async (resolve) => {
43
+ onConfirm(resolve);
44
+ },
45
+ onCancel: (resolve) => {
46
+ onCancel(resolve);
30
47
  }
31
48
  });
32
- const { columns } = useAttachment(props, {
33
- data: modelValue
49
+ const open = AttachmentDialog.open;
50
+ if (isNormalOpen) {
51
+ open();
52
+ }
53
+ __expose({
54
+ open
34
55
  });
35
56
  return (_ctx, _cache) => {
36
- const _component_el_button = resolveComponent("el-button");
37
- return openBlock(), createBlock(unref(AttachmentDialog), null, {
38
- default: withCtx(() => [
39
- _ctx.openType === "dialog" ? (openBlock(), createBlock(_component_el_button, {
40
- key: 0,
41
- type: "primary",
42
- size: "default"
43
- }, {
44
- default: withCtx(() => [
45
- createTextVNode("\u6DFB\u52A0\u9644\u4EF6")
57
+ const _component_EpButtons = resolveComponent("EpButtons");
58
+ return openBlock(), createElementBlock(Fragment, null, [
59
+ _ctx.isShowOpenDialogButton ? (openBlock(), createBlock(unref(ElButton), {
60
+ key: 0,
61
+ type: "primary",
62
+ plain: "",
63
+ size: "small",
64
+ class: normalizeClass(unref(bem).e("handler")),
65
+ onClick: unref(open)
66
+ }, {
67
+ default: withCtx(() => [
68
+ createTextVNode(toDisplayString(unref(t)("ep.attachment.manageAttachment")) + "(" + toDisplayString(modelValue.value?.length || 0) + ") ", 1)
69
+ ]),
70
+ _: 1
71
+ }, 8, ["class", "onClick"])) : createCommentVNode("", true),
72
+ createVNode(unref(AttachmentDialog), null, {
73
+ default: withCtx(() => [
74
+ createElementVNode("div", { style: { "margin-bottom": "10px", "text-align": "right" } }, [
75
+ _ctx.openType === "dialog" ? (openBlock(), createBlock(_component_EpButtons, {
76
+ key: 0,
77
+ type: "primary",
78
+ list: [
79
+ {
80
+ name: unref(t)("ep.attachment.addAttachment"),
81
+ type: "primary",
82
+ onClick: unref(addAttachment)
83
+ }
84
+ ]
85
+ }, null, 8, ["list"])) : createCommentVNode("", true)
46
86
  ]),
47
- _: 1
48
- })) : createCommentVNode("", true),
49
- createVNode(unref(EpTable), mergeProps({
50
- class: `${unref(bem).b()} ${unref(prepareClassNames)()}`,
51
- style: {
52
- ...unref(prepareStyles)()
53
- },
54
- columns: unref(columns),
55
- data: modelValue.value
56
- }, props), null, 16, ["class", "style", "columns", "data"])
57
- ]),
58
- _: 1
59
- });
87
+ createVNode(unref(EpTable), mergeProps({
88
+ ref: "tableRef",
89
+ class: `${unref(bem).b()} ${unref(prepareClassNames)()}`,
90
+ style: {
91
+ ...unref(prepareStyles)()
92
+ },
93
+ columns: unref(columns),
94
+ data: modelValue.value
95
+ }, props), null, 16, ["class", "style", "columns", "data"])
96
+ ]),
97
+ _: 1
98
+ })
99
+ ], 64);
60
100
  };
61
101
  }
62
102
  });
@@ -1 +1 @@
1
- {"version":3,"file":"attachment.vue2.mjs","sources":["../../../../../../packages/components/attachment/src/attachment.vue"],"sourcesContent":["<template>\n <AttachmentDialog>\n <el-button v-if=\"openType === 'dialog'\" type=\"primary\" size=\"default\"\n >添加附件</el-button\n >\n <ep-table\n :class=\"`${bem.b()} ${prepareClassNames()}`\"\n :style=\"{\n ...prepareStyles(),\n }\"\n :columns=\"columns\"\n :data=\"modelValue\"\n v-bind=\"props\"\n >\n </ep-table>\n </AttachmentDialog>\n</template>\n<script setup lang=\"ts\">\nimport { createNameSpace } from '@el-plus/utils/bem'\nimport { prepareClassNames, prepareStyles } from '@el-plus/utils/props'\nimport { attachmentProps } from './attachment'\nimport EpTable from '@el-plus/components/table'\nimport { useAttachment } from './use-attachment'\nimport type { TableProps } from '@el-plus/components/table'\nimport { useDialog } from '@el-plus/hooks/dialog/use-dialog'\ndefineOptions({\n name: 'EpAttachment',\n inheritAttrs: false,\n})\nconst bem = createNameSpace('attachment')\nconst props = defineProps(attachmentProps)\nconst modelValue = defineModel<TableProps['data']>()\nconst AttachmentDialog = useDialog({\n class: bem.em('dialog', props.openType === 'normal' ? props.openType : ''),\n width: 850,\n center: true,\n title: '附件管理',\n onConfirm: async (resolve) => {},\n})\nconst { columns } = useAttachment(props, {\n data: modelValue,\n})\n</script>\n"],"names":["_useModel","_createBlock","_unref","openType","_createVNode","_mergeProps"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6BA,IAAA,MAAM,GAAA,GAAM,gBAAgB,YAAY,CAAA;AACxC,IAAA,MAAM,KAAA,GAAQ,OAAA;AACd,IAAA,MAAM,UAAA,GAAaA,QAAA,CAA+B,OAAA,EAAA,YAAC,CAAA;AACnD,IAAA,MAAM,mBAAmB,SAAA,CAAU;AAAA,MACjC,KAAA,EAAO,IAAI,EAAA,CAAG,QAAA,EAAU,MAAM,QAAA,KAAa,QAAA,GAAW,KAAA,CAAM,QAAA,GAAW,EAAE,CAAA;AAAA,MACzE,KAAA,EAAO,GAAA;AAAA,MACP,MAAA,EAAQ,IAAA;AAAA,MACR,KAAA,EAAO,0BAAA;AAAA,MACP,SAAA,EAAW,OAAO,OAAA,KAAY;AAAA,MAAC;AAAA,KAChC,CAAA;AACD,IAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,aAAA,CAAc,KAAA,EAAO;AAAA,MACvC,IAAA,EAAM;AAAA,KACP,CAAA;;;0BAxCCC,WAAA,CAcmBC,KAAA,CAAA,gBAAA,GAAA,IAAA,EAAA;AAAA,yBAbjB,MAEC;AAAA,UAFgBC,KAAAA,QAAAA,KAAQ,QAAA,iBAAzBF,YAEC,oBAAA,EAAA;AAAA;YAFuC,IAAA,EAAK,SAAA;AAAA,YAAU,IAAA,EAAK;AAAA;6BACzD,MAAI;AAAA,8BAAJ,0BAAI;AAAA;;;UAEPG,WAAA,CASWF,KAAA,WATXG,UAAA,CASW;AAAA,YARR,KAAA,EAAK,CAAA,EAAKH,KAAA,CAAA,GAAA,CAAA,CAAI,CAAA,MAAOA,KAAA,CAAA,iBAAA,CAAA,EAAiB,CAAA,CAAA;AAAA,YACtC,KAAA,EAAK;AAAA,iBAAeA,KAAA,CAAA,aAAA,CAAA;AAAa;YAGjC,OAAA,EAASA,MAAA,OAAA,CAAA;AAAA,YACT,MAAM,UAAA,CAAA;AAAA,aACC,KAAK,CAAA,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA,OAAA,EAAA,OAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAAA;;;;;;;;;"}
1
+ {"version":3,"file":"attachment.vue2.mjs","sources":["../../../../../../packages/components/attachment/src/attachment.vue"],"sourcesContent":["<template>\n <ElButton\n v-if=\"isShowOpenDialogButton\"\n type=\"primary\"\n plain\n size=\"small\"\n :class=\"bem.e('handler')\"\n @click=\"open\"\n >\n {{ t('ep.attachment.manageAttachment') }}({{ modelValue?.length || 0 }})\n </ElButton>\n <AttachmentDialog>\n <div style=\"margin-bottom: 10px; text-align: right\">\n <EpButtons\n v-if=\"openType === 'dialog'\"\n type=\"primary\"\n :list=\"[\n {\n name: t('ep.attachment.addAttachment'),\n type: 'primary',\n onClick: addAttachment,\n },\n ]\"\n />\n </div>\n\n <EpTable\n ref=\"tableRef\"\n :class=\"`${bem.b()} ${prepareClassNames()}`\"\n :style=\"{\n ...prepareStyles(),\n }\"\n :columns=\"columns\"\n :data=\"modelValue\"\n v-bind=\"props\"\n >\n </EpTable>\n </AttachmentDialog>\n</template>\n<script setup lang=\"ts\">\nimport { createNameSpace } from '@el-plus/utils/bem'\nimport { prepareClassNames, prepareStyles } from '@el-plus/utils/props'\nimport { attachmentProps } from './attachment'\nimport EpTable from '@el-plus/components/table'\nimport { useAttachment } from './use-attachment'\nimport type { TableProps } from '@el-plus/components/table'\nimport { useDialog } from '@el-plus/hooks/dialog/use-dialog'\nimport { useLocale } from '@el-plus/hooks/use-locale'\nimport { ElButton } from 'element-plus'\nconst { t } = useLocale()\ndefineOptions({\n name: 'EpAttachment',\n inheritAttrs: false,\n})\nconst bem = createNameSpace('attachment')\nconst props = defineProps(attachmentProps)\nconst modelValue = defineModel<TableProps['data']>()\nconst { columns, addAttachment, isNormalOpen, onConfirm, onCancel } =\n useAttachment(props, {\n data: modelValue,\n })\nconst AttachmentDialog = useDialog({\n width: 850,\n center: true,\n title: isNormalOpen ? '' : t('ep.attachment.manageAttachment'),\n modal: !isNormalOpen,\n showClose: !isNormalOpen,\n showFooter: !isNormalOpen,\n transition: isNormalOpen ? '' : 'dialog-fade',\n modalClass: bem.em(\n 'dialog',\n props.openType === 'normal' ? props.openType : '',\n ),\n onConfirm: async (resolve) => {\n onConfirm(resolve)\n },\n onCancel: (resolve) => {\n onCancel(resolve)\n },\n})\nconst open = AttachmentDialog.open\nif (isNormalOpen) {\n open()\n}\ndefineExpose({\n open,\n})\n</script>\n"],"names":["_useModel","isShowOpenDialogButton","_createBlock","_unref","_normalizeClass","_createTextVNode","_toDisplayString","_createVNode","_createElementVNode","openType","_mergeProps"],"mappings":"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"}
@@ -3,21 +3,22 @@ export declare const useAttachment: (props: any, { data }: {
3
3
  }) => {
4
4
  columns: import("vue").Ref<({
5
5
  type: string;
6
- label: string;
6
+ label: any;
7
7
  width: string;
8
8
  props: {
9
9
  type: string;
10
10
  list: ({
11
- name: string;
11
+ name: any;
12
12
  onClick: ({ row }: {
13
13
  row: any;
14
14
  }) => void;
15
15
  disabled?: undefined;
16
16
  } | {
17
- name: string;
17
+ name: any;
18
18
  disabled: () => boolean;
19
- onClick: ({ $index }: {
19
+ onClick: ({ $index, row }: {
20
20
  $index: any;
21
+ row: any;
21
22
  }) => void;
22
23
  })[];
23
24
  desc?: undefined;
@@ -27,7 +28,7 @@ export declare const useAttachment: (props: any, { data }: {
27
28
  show?: undefined;
28
29
  onClick?: undefined;
29
30
  } | {
30
- label: string;
31
+ label: any;
31
32
  prop: string;
32
33
  type: string;
33
34
  required: boolean;
@@ -42,7 +43,7 @@ export declare const useAttachment: (props: any, { data }: {
42
43
  width?: undefined;
43
44
  onClick?: undefined;
44
45
  } | {
45
- label: string;
46
+ label: any;
46
47
  prop: string;
47
48
  type: string;
48
49
  onClick: ({ row }: {
@@ -53,7 +54,7 @@ export declare const useAttachment: (props: any, { data }: {
53
54
  required?: undefined;
54
55
  show?: undefined;
55
56
  } | {
56
- label: string;
57
+ label: any;
57
58
  prop: string;
58
59
  type?: undefined;
59
60
  width?: undefined;
@@ -62,7 +63,7 @@ export declare const useAttachment: (props: any, { data }: {
62
63
  show?: undefined;
63
64
  onClick?: undefined;
64
65
  } | {
65
- label: string;
66
+ label: any;
66
67
  prop: string;
67
68
  type: string;
68
69
  show: () => any;
@@ -72,21 +73,22 @@ export declare const useAttachment: (props: any, { data }: {
72
73
  onClick?: undefined;
73
74
  })[], ({
74
75
  type: string;
75
- label: string;
76
+ label: any;
76
77
  width: string;
77
78
  props: {
78
79
  type: string;
79
80
  list: ({
80
- name: string;
81
+ name: any;
81
82
  onClick({ row }: {
82
83
  row: any;
83
84
  }): void;
84
85
  disabled?: undefined;
85
86
  } | {
86
- name: string;
87
+ name: any;
87
88
  disabled: () => boolean;
88
- onClick: ({ $index }: {
89
+ onClick: ({ $index, row }: {
89
90
  $index: any;
91
+ row: any;
90
92
  }) => void;
91
93
  })[];
92
94
  desc?: undefined;
@@ -96,7 +98,7 @@ export declare const useAttachment: (props: any, { data }: {
96
98
  show?: undefined;
97
99
  onClick?: undefined;
98
100
  } | {
99
- label: string;
101
+ label: any;
100
102
  prop: string;
101
103
  type: string;
102
104
  required: boolean;
@@ -111,7 +113,7 @@ export declare const useAttachment: (props: any, { data }: {
111
113
  width?: undefined;
112
114
  onClick?: undefined;
113
115
  } | {
114
- label: string;
116
+ label: any;
115
117
  prop: string;
116
118
  type: string;
117
119
  onClick({ row }: {
@@ -122,7 +124,7 @@ export declare const useAttachment: (props: any, { data }: {
122
124
  required?: undefined;
123
125
  show?: undefined;
124
126
  } | {
125
- label: string;
127
+ label: any;
126
128
  prop: string;
127
129
  type?: undefined;
128
130
  width?: undefined;
@@ -131,7 +133,7 @@ export declare const useAttachment: (props: any, { data }: {
131
133
  show?: undefined;
132
134
  onClick?: undefined;
133
135
  } | {
134
- label: string;
136
+ label: any;
135
137
  prop: string;
136
138
  type: string;
137
139
  show: () => any;
@@ -141,21 +143,22 @@ export declare const useAttachment: (props: any, { data }: {
141
143
  onClick?: undefined;
142
144
  })[] | ({
143
145
  type: string;
144
- label: string;
146
+ label: any;
145
147
  width: string;
146
148
  props: {
147
149
  type: string;
148
150
  list: ({
149
- name: string;
151
+ name: any;
150
152
  onClick: ({ row }: {
151
153
  row: any;
152
154
  }) => void;
153
155
  disabled?: undefined;
154
156
  } | {
155
- name: string;
157
+ name: any;
156
158
  disabled: () => boolean;
157
- onClick: ({ $index }: {
159
+ onClick: ({ $index, row }: {
158
160
  $index: any;
161
+ row: any;
159
162
  }) => void;
160
163
  })[];
161
164
  desc?: undefined;
@@ -165,7 +168,7 @@ export declare const useAttachment: (props: any, { data }: {
165
168
  show?: undefined;
166
169
  onClick?: undefined;
167
170
  } | {
168
- label: string;
171
+ label: any;
169
172
  prop: string;
170
173
  type: string;
171
174
  required: boolean;
@@ -180,7 +183,7 @@ export declare const useAttachment: (props: any, { data }: {
180
183
  width?: undefined;
181
184
  onClick?: undefined;
182
185
  } | {
183
- label: string;
186
+ label: any;
184
187
  prop: string;
185
188
  type: string;
186
189
  onClick: ({ row }: {
@@ -191,7 +194,7 @@ export declare const useAttachment: (props: any, { data }: {
191
194
  required?: undefined;
192
195
  show?: undefined;
193
196
  } | {
194
- label: string;
197
+ label: any;
195
198
  prop: string;
196
199
  type?: undefined;
197
200
  width?: undefined;
@@ -200,7 +203,7 @@ export declare const useAttachment: (props: any, { data }: {
200
203
  show?: undefined;
201
204
  onClick?: undefined;
202
205
  } | {
203
- label: string;
206
+ label: any;
204
207
  prop: string;
205
208
  type: string;
206
209
  show: () => any;
@@ -209,4 +212,9 @@ export declare const useAttachment: (props: any, { data }: {
209
212
  required?: undefined;
210
213
  onClick?: undefined;
211
214
  })[]>;
215
+ addAttachment: () => Promise<void>;
216
+ isNormalOpen: boolean;
217
+ isDialogOpen: boolean;
218
+ onConfirm: (resolve: any) => Promise<void>;
219
+ onCancel: (resolve: any) => void;
212
220
  };
@@ -1,22 +1,30 @@
1
- import { computed, ref } from 'vue';
1
+ import { computed, useTemplateRef, ref } from 'vue';
2
2
  import { useNavigation } from '../../../hooks/use-navigation.mjs';
3
- import { downloadFile, previewFile } from '../../../utils/file.mjs';
3
+ import { useLocale } from '../../../hooks/use-locale.mjs';
4
+ import { downloadFile, previewFile, importFile } from '../../../utils/file.mjs';
5
+ import Cookies from 'js-cookie';
4
6
 
5
7
  const useAttachment = (props, { data }) => {
6
8
  const { mode: defaultMode } = useNavigation();
9
+ const { t } = useLocale();
7
10
  const mode = computed(() => {
8
11
  return props.mode || defaultMode.value;
9
12
  });
13
+ const tableRef = useTemplateRef("tableRef");
14
+ const isNormalOpen = props.openType === "normal";
15
+ const isDialogOpen = props.openType === "dialog";
16
+ let toBeConfirmData = [];
17
+ let toBeDeleteData = {};
10
18
  const columns = ref([
11
19
  {
12
20
  type: "EpButtons",
13
- label: "\u64CD\u4F5C",
21
+ label: t("ep.attachment.operation"),
14
22
  width: "120px",
15
23
  props: {
16
24
  type: "text",
17
25
  list: [
18
26
  {
19
- name: "\u4E0B\u8F7D",
27
+ name: t("ep.attachment.download"),
20
28
  onClick({ row }) {
21
29
  downloadFile({
22
30
  src: row.filePath,
@@ -25,11 +33,14 @@ const useAttachment = (props, { data }) => {
25
33
  }
26
34
  },
27
35
  {
28
- name: "\u5220\u9664",
36
+ name: t("ep.attachment.delete"),
29
37
  disabled: () => {
30
38
  return mode.value === "browse";
31
39
  },
32
- onClick: ({ $index }) => {
40
+ onClick: ({ $index, row }) => {
41
+ if (isDialogOpen) {
42
+ toBeDeleteData[$index] = row;
43
+ }
33
44
  data.value.splice($index, 1);
34
45
  }
35
46
  }
@@ -37,7 +48,7 @@ const useAttachment = (props, { data }) => {
37
48
  }
38
49
  },
39
50
  {
40
- label: "\u9644\u4EF6\u7C7B\u578B",
51
+ label: t("ep.attachment.attachmentType"),
41
52
  prop: "type",
42
53
  type: "EpSelect",
43
54
  required: true,
@@ -49,7 +60,7 @@ const useAttachment = (props, { data }) => {
49
60
  }
50
61
  },
51
62
  {
52
- label: "\u6587\u4EF6\u540D\u79F0",
63
+ label: t("ep.attachment.fileName"),
53
64
  prop: "originalFilename",
54
65
  type: "EpLink",
55
66
  onClick({ row }) {
@@ -57,22 +68,64 @@ const useAttachment = (props, { data }) => {
57
68
  }
58
69
  },
59
70
  {
60
- label: "\u521B\u5EFA\u4EBA",
71
+ label: t("ep.attachment.creator"),
61
72
  prop: "createBy"
62
73
  },
63
74
  {
64
- label: "\u521B\u5EFA\u65F6\u95F4",
75
+ label: t("ep.attachment.createTime"),
65
76
  prop: "createTime"
66
77
  },
67
78
  {
68
- label: "\u8BF4\u660E",
79
+ label: t("ep.attachment.description"),
69
80
  prop: "note",
70
81
  type: "EpInput",
71
82
  show: () => props.isNote
72
83
  }
73
84
  ]);
85
+ const addAttachment = async () => {
86
+ toBeConfirmData = [];
87
+ const fileData = await importFile({
88
+ api: "api-f/fast/files/save",
89
+ extraData: {
90
+ createBy: Cookies.get("accountName") || ""
91
+ }
92
+ });
93
+ fileData.fileId = fileData.id;
94
+ delete fileData.id;
95
+ if (isDialogOpen) {
96
+ toBeConfirmData.push(fileData);
97
+ }
98
+ data.value.push(fileData);
99
+ };
100
+ const onConfirm = async (resolve) => {
101
+ await tableRef.value?.validate();
102
+ resolve(data.value);
103
+ };
104
+ const onCancel = (resolve) => {
105
+ if (toBeConfirmData.length) {
106
+ const index = data.value.findIndex((item) => {
107
+ return item.fileId === toBeConfirmData[0].fileId;
108
+ });
109
+ if (index !== -1) {
110
+ data.value.splice(index, 1);
111
+ }
112
+ toBeConfirmData = [];
113
+ }
114
+ if (Object.keys(toBeDeleteData).length) {
115
+ Object.keys(toBeDeleteData).forEach((oldIndex) => {
116
+ data.value.splice(Number(oldIndex), 0, toBeDeleteData[oldIndex]);
117
+ });
118
+ toBeDeleteData = {};
119
+ }
120
+ resolve();
121
+ };
74
122
  return {
75
- columns
123
+ columns,
124
+ addAttachment,
125
+ isNormalOpen,
126
+ isDialogOpen,
127
+ onConfirm,
128
+ onCancel
76
129
  };
77
130
  };
78
131