yuang-framework-ui-pc 1.1.50 → 1.1.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/core-components.d.ts +1 -2
- package/es/core-components.js +2 -4
- package/es/ele-upload-list/components/list-item.d.ts +1 -0
- package/es/ele-upload-list/components/list-item.js +11 -3
- package/es/ele-upload-list/index.d.ts +2 -0
- package/es/ele-upload-list/index.js +16 -3
- package/es/ele-upload-list/types.d.ts +2 -0
- package/es/{yu-framework-attachment-image-upload → yu-framework-attachment-upload}/index.js +45 -55
- package/es/yu-framework-slider-captcha-dialog/{SliderCaptcha.js → components/SliderCaptcha.js} +1 -1
- package/es/yu-framework-slider-captcha-dialog/index.js +1 -1
- package/lib/core-components.cjs +2 -4
- package/lib/core-components.d.ts +1 -2
- package/lib/ele-upload-list/components/list-item.cjs +11 -3
- package/lib/ele-upload-list/components/list-item.d.ts +1 -0
- package/lib/ele-upload-list/index.cjs +16 -3
- package/lib/ele-upload-list/index.d.ts +2 -0
- package/lib/ele-upload-list/types.d.ts +2 -0
- package/lib/{yu-framework-attachment-image-upload → yu-framework-attachment-upload}/index.cjs +45 -55
- package/lib/yu-framework-slider-captcha-dialog/{SliderCaptcha.cjs → components/SliderCaptcha.cjs} +1 -1
- package/lib/yu-framework-slider-captcha-dialog/index.cjs +1 -1
- package/package.json +2 -2
- package/typings/global.d.ts +1 -2
- package/es/yu-framework-attachment-file-upload/CommonUpload/index.d.ts +0 -161
- package/es/yu-framework-attachment-file-upload/CommonUpload/index.js +0 -173
- package/es/yu-framework-attachment-file-upload/FileUpload/index.d.ts +0 -143
- package/es/yu-framework-attachment-file-upload/FileUpload/index.js +0 -219
- package/es/yu-framework-attachment-file-upload/index.d.ts +0 -16
- package/es/yu-framework-attachment-file-upload/index.js +0 -55
- package/lib/yu-framework-attachment-file-upload/CommonUpload/index.cjs +0 -172
- package/lib/yu-framework-attachment-file-upload/CommonUpload/index.d.ts +0 -161
- package/lib/yu-framework-attachment-file-upload/FileUpload/index.cjs +0 -218
- package/lib/yu-framework-attachment-file-upload/FileUpload/index.d.ts +0 -143
- package/lib/yu-framework-attachment-file-upload/index.cjs +0 -54
- package/lib/yu-framework-attachment-file-upload/index.d.ts +0 -16
- /package/es/{yu-framework-attachment-image-upload → yu-framework-attachment-upload}/index.d.ts +0 -0
- /package/es/yu-framework-slider-captcha-dialog/{SliderCaptcha.d.ts → components/SliderCaptcha.d.ts} +0 -0
- /package/lib/{yu-framework-attachment-image-upload → yu-framework-attachment-upload}/index.d.ts +0 -0
- /package/lib/yu-framework-slider-captcha-dialog/{SliderCaptcha.d.ts → components/SliderCaptcha.d.ts} +0 -0
package/lib/{yu-framework-attachment-image-upload → yu-framework-attachment-upload}/index.cjs
RENAMED
|
@@ -6,7 +6,7 @@ const httpConfig = require("yuang-framework-ui-common/lib/config/httpConfig");
|
|
|
6
6
|
const uuidUtils = require("yuang-framework-ui-common/lib/utils/uuidUtils");
|
|
7
7
|
const applicationConfig = require("yuang-framework-ui-common/lib/config/applicationConfig");
|
|
8
8
|
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
9
|
-
...{ name: "
|
|
9
|
+
...{ name: "YuFrameworkAttachmentUpload" },
|
|
10
10
|
__name: "index",
|
|
11
11
|
props: /* @__PURE__ */ vue.mergeModels({
|
|
12
12
|
modelValue: {},
|
|
@@ -17,19 +17,30 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
17
17
|
}),
|
|
18
18
|
emits: /* @__PURE__ */ vue.mergeModels(["change"], ["update:modelValue"]),
|
|
19
19
|
setup(__props, { emit: __emit }) {
|
|
20
|
+
const props = __props;
|
|
20
21
|
const emit = __emit;
|
|
22
|
+
props.param.mode = props.param.mode ?? "file";
|
|
23
|
+
props.param.maxCount = props.param.maxCount ?? 5;
|
|
24
|
+
props.param.maxSize = props.param.maxSize ?? 5;
|
|
21
25
|
const images = vue.ref([]);
|
|
26
|
+
const listType = vue.ref(props.param.mode);
|
|
27
|
+
const accept = vue.ref("");
|
|
28
|
+
if (props.param.mode == "file") {
|
|
29
|
+
accept.value = ".txt,.xlsx";
|
|
30
|
+
} else if (props.param.mode == "image") {
|
|
31
|
+
accept.value = ".png,.jpg,.jpeg,.gif,.svg";
|
|
32
|
+
}
|
|
22
33
|
const isLoading = vue.ref(false);
|
|
23
34
|
const checkFile = (file) => {
|
|
24
35
|
if (!file) {
|
|
25
36
|
return;
|
|
26
37
|
}
|
|
27
|
-
if (!file.type.startsWith("image")) {
|
|
38
|
+
if (props.param.mode === "image" && !file.type.startsWith("image")) {
|
|
28
39
|
message.EleMessage.error("只能选择图片");
|
|
29
40
|
return;
|
|
30
41
|
}
|
|
31
|
-
if (file.size / 1024 / 1024 >
|
|
32
|
-
message.EleMessage.error(
|
|
42
|
+
if (file.size / 1024 / 1024 > props.param.maxSize) {
|
|
43
|
+
message.EleMessage.error(`图片大小不能超过${props.param.maxSize}MB`);
|
|
33
44
|
return;
|
|
34
45
|
}
|
|
35
46
|
return true;
|
|
@@ -37,6 +48,10 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
37
48
|
const model = vue.useModel(__props, "modelValue");
|
|
38
49
|
model.value = model.value ?? uuidUtils.getShortUuid();
|
|
39
50
|
vue.onMounted(() => {
|
|
51
|
+
init();
|
|
52
|
+
});
|
|
53
|
+
const init = () => {
|
|
54
|
+
images.value = [];
|
|
40
55
|
httpConfig.http.post(`${applicationConfig.application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/selectPage`, { code: model.value, pageSize: 100 }).then((res) => {
|
|
41
56
|
let attachemtList = res.data.data.records;
|
|
42
57
|
for (let i = 0; i < attachemtList.length; i++) {
|
|
@@ -49,15 +64,15 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
49
64
|
});
|
|
50
65
|
}
|
|
51
66
|
});
|
|
52
|
-
}
|
|
53
|
-
const handleUpload = (
|
|
54
|
-
if (!checkFile(
|
|
67
|
+
};
|
|
68
|
+
const handleUpload = (uploadItem, retry) => {
|
|
69
|
+
if (!checkFile(uploadItem.file)) {
|
|
55
70
|
return;
|
|
56
71
|
}
|
|
57
72
|
if (!retry) {
|
|
58
|
-
images.value.push({ ...
|
|
73
|
+
images.value.push({ ...uploadItem });
|
|
59
74
|
}
|
|
60
|
-
const item = images.value.find((t) => t.key ===
|
|
75
|
+
const item = images.value.find((t) => t.key === uploadItem.key);
|
|
61
76
|
console.log(JSON.parse(JSON.stringify(item)));
|
|
62
77
|
if (!item) {
|
|
63
78
|
return;
|
|
@@ -66,7 +81,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
66
81
|
item.progress = 0;
|
|
67
82
|
let formData = new FormData();
|
|
68
83
|
formData.append("code", model.value);
|
|
69
|
-
formData.append("multipartFile",
|
|
84
|
+
formData.append("multipartFile", uploadItem.file, uploadItem.file.name);
|
|
70
85
|
httpConfig.http({
|
|
71
86
|
url: `${applicationConfig.application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/uploadAttachment`,
|
|
72
87
|
method: "post",
|
|
@@ -78,11 +93,9 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
78
93
|
message.EleMessage.success(res.data.message);
|
|
79
94
|
item.progress = 100;
|
|
80
95
|
item.status = "done";
|
|
96
|
+
item.id = res.data.data.id;
|
|
81
97
|
item.url = res.data.data.fullUrl;
|
|
82
|
-
|
|
83
|
-
let attachemtList = res2.data.data.records;
|
|
84
|
-
emit("change", attachemtList);
|
|
85
|
-
});
|
|
98
|
+
emitChange();
|
|
86
99
|
}).catch((e) => {
|
|
87
100
|
item.status = "exception";
|
|
88
101
|
message.EleMessage.error(e.message);
|
|
@@ -117,56 +130,30 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
117
130
|
oldItem.status = void 0;
|
|
118
131
|
oldItem.progress = 0;
|
|
119
132
|
}
|
|
133
|
+
emitChange();
|
|
120
134
|
}).catch((e) => {
|
|
121
135
|
item.status = "exception";
|
|
122
136
|
message.EleMessage.error(e.message);
|
|
123
137
|
});
|
|
124
138
|
};
|
|
125
|
-
const
|
|
126
|
-
|
|
139
|
+
const emitChange = () => {
|
|
140
|
+
httpConfig.http.post(`${applicationConfig.application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/selectPage`, { code: model.value, pageSize: 100 }).then((res) => {
|
|
141
|
+
let attachemtList = res.data.data.records;
|
|
142
|
+
emit("change", attachemtList);
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
const handleRemove = (uploadItem) => {
|
|
146
|
+
let id = uploadItem.id;
|
|
127
147
|
es.ElMessageBox.confirm("确定要删除吗?", "系统提示", { type: "warning", draggable: true }).then(() => {
|
|
128
148
|
httpConfig.http.get(`${applicationConfig.application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/deleteInfo`, { params: { id } }).then((res) => {
|
|
129
149
|
message.EleMessage.success(res.data.message);
|
|
130
|
-
images.value.splice(images.value.indexOf(
|
|
150
|
+
images.value.splice(images.value.indexOf(uploadItem), 1);
|
|
151
|
+
emitChange();
|
|
131
152
|
});
|
|
132
153
|
});
|
|
133
154
|
};
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
if (item.progress == null) {
|
|
137
|
-
item.progress = 20;
|
|
138
|
-
}
|
|
139
|
-
const timer = setInterval(
|
|
140
|
-
() => {
|
|
141
|
-
if (Math.round(Math.random() * 10) < 3) {
|
|
142
|
-
item.status = "exception";
|
|
143
|
-
message.EleMessage.error("上传失败, 服务器繁忙,请重试");
|
|
144
|
-
clearInterval(timer);
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
if (item.progress == null) {
|
|
148
|
-
item.progress = 20;
|
|
149
|
-
} else {
|
|
150
|
-
item.progress += 20;
|
|
151
|
-
}
|
|
152
|
-
if (item.progress === 100) {
|
|
153
|
-
item.status = "done";
|
|
154
|
-
clearInterval(timer);
|
|
155
|
-
if (checkDone()) {
|
|
156
|
-
submitForm();
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
Math.round(Math.random() * 2500) + 500
|
|
161
|
-
);
|
|
162
|
-
};
|
|
163
|
-
const checkDone = () => {
|
|
164
|
-
return !images.value.some((d) => d.status !== "done");
|
|
165
|
-
};
|
|
166
|
-
const submitForm = () => {
|
|
167
|
-
message.EleMessage.success("已全部上传完毕");
|
|
168
|
-
console.log(JSON.parse(JSON.stringify(images.value)));
|
|
169
|
-
isLoading.value = false;
|
|
155
|
+
const handleRetryUpload = (uploadItem) => {
|
|
156
|
+
handleUpload(uploadItem, true);
|
|
170
157
|
};
|
|
171
158
|
return (_ctx, _cache) => {
|
|
172
159
|
const _component_ele_upload_list = vue.resolveComponent("ele-upload-list");
|
|
@@ -176,14 +163,17 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
176
163
|
tools: true,
|
|
177
164
|
modelValue: images.value,
|
|
178
165
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => images.value = $event),
|
|
166
|
+
limit: _ctx.param.maxCount,
|
|
167
|
+
listType: listType.value,
|
|
168
|
+
accept: accept.value,
|
|
179
169
|
readonly: isLoading.value,
|
|
180
170
|
disabled: _ctx.param.type != "edit",
|
|
181
171
|
sortable: { forceFallback: true },
|
|
182
172
|
onUpload: handleUpload,
|
|
183
|
-
onRetry:
|
|
173
|
+
onRetry: handleRetryUpload,
|
|
184
174
|
onRemove: handleRemove,
|
|
185
175
|
onEditUpload: handleEditUpload
|
|
186
|
-
}, null, 8, ["modelValue", "readonly", "disabled"])
|
|
176
|
+
}, null, 8, ["modelValue", "limit", "listType", "accept", "readonly", "disabled"])
|
|
187
177
|
]);
|
|
188
178
|
};
|
|
189
179
|
}
|
package/lib/yu-framework-slider-captcha-dialog/{SliderCaptcha.cjs → components/SliderCaptcha.cjs}
RENAMED
|
@@ -3,7 +3,7 @@ const vue = require("vue");
|
|
|
3
3
|
const httpConfig = require("yuang-framework-ui-common/lib/config/httpConfig");
|
|
4
4
|
const applicationConfig = require("yuang-framework-ui-common/lib/config/applicationConfig");
|
|
5
5
|
const iconsVue = require("@element-plus/icons-vue");
|
|
6
|
-
const icons = require("
|
|
6
|
+
const icons = require("../../icons");
|
|
7
7
|
const _hoisted_1 = { class: "yu-framework-slider-captcha" };
|
|
8
8
|
const _hoisted_2 = { class: "yu-framework-slider-captcha-title" };
|
|
9
9
|
const _hoisted_3 = ["width", "height"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuang-framework-ui-pc",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.52",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite --host --config vite.global.ts --mode dev",
|
|
@@ -188,6 +188,6 @@
|
|
|
188
188
|
"repository": "",
|
|
189
189
|
"license": "",
|
|
190
190
|
"dependencies": {
|
|
191
|
-
"yuang-framework-ui-common": "^1.0.
|
|
191
|
+
"yuang-framework-ui-common": "^1.0.62"
|
|
192
192
|
}
|
|
193
193
|
}
|
package/typings/global.d.ts
CHANGED
|
@@ -60,8 +60,7 @@ declare module '@vue/runtime-core' {
|
|
|
60
60
|
EleVirtualTable: (typeof import('yuang-framework-ui-pc'))['EleVirtualTable'];
|
|
61
61
|
EleWatermark: (typeof import('yuang-framework-ui-pc'))['EleWatermark'];
|
|
62
62
|
EleXgPlayer: (typeof import('yuang-framework-ui-pc'))['EleXgPlayer'];
|
|
63
|
-
|
|
64
|
-
YuFrameworkAttachmentImageUpload: (typeof import('yuang-framework-ui-pc'))['YuFrameworkAttachmentImageUpload'];
|
|
63
|
+
YuFrameworkAttachmentUpload: (typeof import('yuang-framework-ui-pc'))['YuFrameworkAttachmentUpload'];
|
|
65
64
|
YuFrameworkSliderCaptchaDialog: (typeof import('yuang-framework-ui-pc'))['YuFrameworkSliderCaptchaDialog'];
|
|
66
65
|
YuTest: (typeof import('yuang-framework-ui-pc'))['YuTest'];
|
|
67
66
|
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { CSSProperties } from 'vue';
|
|
2
|
-
import { ElProgressProps, ElImageProps } from '../../ele-app/el';
|
|
3
|
-
import { EleImageViewerProps } from '../../ele-app/plus';
|
|
4
|
-
import { UploadItem, ListType, BeforeUploadClick, BeforeItemEdit, UploadLocale } from '../../ele-upload-list/types';
|
|
5
|
-
|
|
6
|
-
declare function __VLS_template(): Partial<Record<string, (_: any) => any>>;
|
|
7
|
-
declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
8
|
-
modelValue: import('vue').PropType<UploadItem[]>;
|
|
9
|
-
drag: {
|
|
10
|
-
type: import('vue').PropType<boolean>;
|
|
11
|
-
default: boolean;
|
|
12
|
-
};
|
|
13
|
-
disabled: {
|
|
14
|
-
type: import('vue').PropType<boolean>;
|
|
15
|
-
};
|
|
16
|
-
readonly: {
|
|
17
|
-
type: import('vue').PropType<boolean>;
|
|
18
|
-
};
|
|
19
|
-
sortable: {
|
|
20
|
-
type: import('vue').PropType<boolean | Record<string | number | symbol, any>>;
|
|
21
|
-
default: () => {
|
|
22
|
-
forceFallback: boolean;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
multiple: {
|
|
26
|
-
type: import('vue').PropType<boolean>;
|
|
27
|
-
};
|
|
28
|
-
preview: {
|
|
29
|
-
type: import('vue').PropType<boolean>;
|
|
30
|
-
default: boolean;
|
|
31
|
-
};
|
|
32
|
-
accept: {
|
|
33
|
-
type: import('vue').PropType<string>;
|
|
34
|
-
default: string;
|
|
35
|
-
};
|
|
36
|
-
tools: {
|
|
37
|
-
type: import('vue').PropType<boolean>;
|
|
38
|
-
default: boolean;
|
|
39
|
-
};
|
|
40
|
-
beforeUploadClick: {
|
|
41
|
-
type: import('vue').PropType<BeforeUploadClick>;
|
|
42
|
-
};
|
|
43
|
-
locale: {
|
|
44
|
-
type: import('vue').PropType<Partial<UploadLocale>>;
|
|
45
|
-
};
|
|
46
|
-
imageProps: {
|
|
47
|
-
type: import('vue').PropType<ElImageProps>;
|
|
48
|
-
};
|
|
49
|
-
progressProps: {
|
|
50
|
-
type: import('vue').PropType<ElProgressProps>;
|
|
51
|
-
};
|
|
52
|
-
listType: {
|
|
53
|
-
type: import('vue').PropType<ListType>;
|
|
54
|
-
};
|
|
55
|
-
limit: {
|
|
56
|
-
type: import('vue').PropType<number>;
|
|
57
|
-
};
|
|
58
|
-
itemStyle: {
|
|
59
|
-
type: import('vue').PropType<CSSProperties>;
|
|
60
|
-
};
|
|
61
|
-
buttonStyle: {
|
|
62
|
-
type: import('vue').PropType<CSSProperties>;
|
|
63
|
-
};
|
|
64
|
-
previewProps: {
|
|
65
|
-
type: import('vue').PropType<EleImageViewerProps>;
|
|
66
|
-
};
|
|
67
|
-
beforeItemEdit: {
|
|
68
|
-
type: import('vue').PropType<BeforeItemEdit>;
|
|
69
|
-
};
|
|
70
|
-
fileLimit: {
|
|
71
|
-
type: import('vue').PropType<number>;
|
|
72
|
-
default: number;
|
|
73
|
-
};
|
|
74
|
-
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
75
|
-
itemClick: (item: UploadItem) => void;
|
|
76
|
-
preview: (item: UploadItem) => void;
|
|
77
|
-
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
78
|
-
modelValue: import('vue').PropType<UploadItem[]>;
|
|
79
|
-
drag: {
|
|
80
|
-
type: import('vue').PropType<boolean>;
|
|
81
|
-
default: boolean;
|
|
82
|
-
};
|
|
83
|
-
disabled: {
|
|
84
|
-
type: import('vue').PropType<boolean>;
|
|
85
|
-
};
|
|
86
|
-
readonly: {
|
|
87
|
-
type: import('vue').PropType<boolean>;
|
|
88
|
-
};
|
|
89
|
-
sortable: {
|
|
90
|
-
type: import('vue').PropType<boolean | Record<string | number | symbol, any>>;
|
|
91
|
-
default: () => {
|
|
92
|
-
forceFallback: boolean;
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
multiple: {
|
|
96
|
-
type: import('vue').PropType<boolean>;
|
|
97
|
-
};
|
|
98
|
-
preview: {
|
|
99
|
-
type: import('vue').PropType<boolean>;
|
|
100
|
-
default: boolean;
|
|
101
|
-
};
|
|
102
|
-
accept: {
|
|
103
|
-
type: import('vue').PropType<string>;
|
|
104
|
-
default: string;
|
|
105
|
-
};
|
|
106
|
-
tools: {
|
|
107
|
-
type: import('vue').PropType<boolean>;
|
|
108
|
-
default: boolean;
|
|
109
|
-
};
|
|
110
|
-
beforeUploadClick: {
|
|
111
|
-
type: import('vue').PropType<BeforeUploadClick>;
|
|
112
|
-
};
|
|
113
|
-
locale: {
|
|
114
|
-
type: import('vue').PropType<Partial<UploadLocale>>;
|
|
115
|
-
};
|
|
116
|
-
imageProps: {
|
|
117
|
-
type: import('vue').PropType<ElImageProps>;
|
|
118
|
-
};
|
|
119
|
-
progressProps: {
|
|
120
|
-
type: import('vue').PropType<ElProgressProps>;
|
|
121
|
-
};
|
|
122
|
-
listType: {
|
|
123
|
-
type: import('vue').PropType<ListType>;
|
|
124
|
-
};
|
|
125
|
-
limit: {
|
|
126
|
-
type: import('vue').PropType<number>;
|
|
127
|
-
};
|
|
128
|
-
itemStyle: {
|
|
129
|
-
type: import('vue').PropType<CSSProperties>;
|
|
130
|
-
};
|
|
131
|
-
buttonStyle: {
|
|
132
|
-
type: import('vue').PropType<CSSProperties>;
|
|
133
|
-
};
|
|
134
|
-
previewProps: {
|
|
135
|
-
type: import('vue').PropType<EleImageViewerProps>;
|
|
136
|
-
};
|
|
137
|
-
beforeItemEdit: {
|
|
138
|
-
type: import('vue').PropType<BeforeItemEdit>;
|
|
139
|
-
};
|
|
140
|
-
fileLimit: {
|
|
141
|
-
type: import('vue').PropType<number>;
|
|
142
|
-
default: number;
|
|
143
|
-
};
|
|
144
|
-
}>> & Readonly<{
|
|
145
|
-
onItemClick?: ((item: UploadItem) => any) | undefined;
|
|
146
|
-
onPreview?: ((item: UploadItem) => any) | undefined;
|
|
147
|
-
}>, {
|
|
148
|
-
drag: boolean;
|
|
149
|
-
sortable: boolean | Record<keyof any, any>;
|
|
150
|
-
preview: boolean;
|
|
151
|
-
accept: string;
|
|
152
|
-
tools: boolean;
|
|
153
|
-
fileLimit: number;
|
|
154
|
-
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
155
|
-
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
156
|
-
export default _default;
|
|
157
|
-
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
158
|
-
new (): {
|
|
159
|
-
$slots: S;
|
|
160
|
-
};
|
|
161
|
-
};
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { defineComponent, mergeModels, useModel, resolveComponent, createBlock, openBlock, createSlots, renderList, withCtx, renderSlot, normalizeProps, guardReactiveProps } from "vue";
|
|
2
|
-
import { EleMessage } from "../../utils/message";
|
|
3
|
-
import { ElMessageBox } from "element-plus/es";
|
|
4
|
-
import { http } from "yuang-framework-ui-common/lib/config/httpConfig";
|
|
5
|
-
import { getShortUuid } from "yuang-framework-ui-common/lib/utils/uuidUtils";
|
|
6
|
-
import { application } from "yuang-framework-ui-common/lib/config/applicationConfig";
|
|
7
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
8
|
-
...{ name: "CommonUpload" },
|
|
9
|
-
__name: "index",
|
|
10
|
-
props: /* @__PURE__ */ mergeModels({
|
|
11
|
-
fileLimit: { default: 100 },
|
|
12
|
-
readonly: { type: Boolean },
|
|
13
|
-
disabled: { type: Boolean },
|
|
14
|
-
preview: { type: Boolean, default: true },
|
|
15
|
-
limit: {},
|
|
16
|
-
multiple: { type: Boolean },
|
|
17
|
-
drag: { type: Boolean, default: true },
|
|
18
|
-
accept: { default: "" },
|
|
19
|
-
itemStyle: {},
|
|
20
|
-
buttonStyle: {},
|
|
21
|
-
sortable: { type: [Boolean, Object], default: () => ({ forceFallback: true }) },
|
|
22
|
-
imageProps: {},
|
|
23
|
-
progressProps: {},
|
|
24
|
-
previewProps: {},
|
|
25
|
-
tools: { type: Boolean, default: true },
|
|
26
|
-
listType: {},
|
|
27
|
-
beforeUploadClick: {},
|
|
28
|
-
beforeItemEdit: {},
|
|
29
|
-
locale: {}
|
|
30
|
-
}, {
|
|
31
|
-
"modelValue": {
|
|
32
|
-
type: Array,
|
|
33
|
-
default: () => []
|
|
34
|
-
},
|
|
35
|
-
"modelModifiers": {}
|
|
36
|
-
}),
|
|
37
|
-
emits: /* @__PURE__ */ mergeModels(["itemClick", "preview"], ["update:modelValue"]),
|
|
38
|
-
setup(__props, { emit: __emit }) {
|
|
39
|
-
const props = __props;
|
|
40
|
-
const emit = __emit;
|
|
41
|
-
const images = useModel(__props, "modelValue");
|
|
42
|
-
const checkFile = (file) => {
|
|
43
|
-
if (!file) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (props.accept === "image/*") {
|
|
47
|
-
if (!file.type.startsWith("image")) {
|
|
48
|
-
EleMessage.error("只能选择图片");
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
} else if (props.accept === ".xls,.xlsx") {
|
|
52
|
-
if (![
|
|
53
|
-
"application/vnd.ms-excel",
|
|
54
|
-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
55
|
-
].includes(file.type)) {
|
|
56
|
-
EleMessage.error("只能选择 excel 文件");
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
if (props.fileLimit && file.size / 1024 / 1024 > props.fileLimit) {
|
|
61
|
-
EleMessage.error(`大小不能超过 ${props.fileLimit}MB`);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
return true;
|
|
65
|
-
};
|
|
66
|
-
const handleItemUpload = (uploadItem, retry) => {
|
|
67
|
-
if (!uploadItem.file || !checkFile(uploadItem.file)) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (!retry) {
|
|
71
|
-
images.value.push({ ...uploadItem });
|
|
72
|
-
}
|
|
73
|
-
const item = images.value.find((t) => t.key === uploadItem.key);
|
|
74
|
-
if (!item) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
item.status = "uploading";
|
|
78
|
-
item.progress = 0;
|
|
79
|
-
debugger;
|
|
80
|
-
let formData = new FormData();
|
|
81
|
-
formData.append("code", getShortUuid());
|
|
82
|
-
formData.append("multipartFile", uploadItem.file, uploadItem.file.name);
|
|
83
|
-
http({
|
|
84
|
-
url: `/framework-api/core/framework-attachment/uploadAttachment`,
|
|
85
|
-
method: "post",
|
|
86
|
-
headers: {
|
|
87
|
-
"Content-Type": "multipart/form-data"
|
|
88
|
-
},
|
|
89
|
-
data: formData
|
|
90
|
-
}).then((res) => {
|
|
91
|
-
EleMessage.success(res.data.message);
|
|
92
|
-
item.progress = 100;
|
|
93
|
-
item.status = "done";
|
|
94
|
-
item.url = res.data.data.fullUrl;
|
|
95
|
-
}).catch((e) => {
|
|
96
|
-
item.status = "exception";
|
|
97
|
-
EleMessage.error(e.message);
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
const handleItemEditUpload = ({ item, newItem }) => {
|
|
101
|
-
if (!checkFile(newItem.file)) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const oldItem = images.value.find((t) => t.key === item.key);
|
|
105
|
-
if (oldItem) {
|
|
106
|
-
oldItem.url = void 0;
|
|
107
|
-
oldItem.name = newItem.name;
|
|
108
|
-
oldItem.file = newItem.file;
|
|
109
|
-
oldItem.progress = 0;
|
|
110
|
-
oldItem.status = void 0;
|
|
111
|
-
handleItemUpload(oldItem, true);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
const handleItemRemove = (uploadItem) => {
|
|
115
|
-
let id = uploadItem.id;
|
|
116
|
-
ElMessageBox.confirm("确定要删除吗?", "系统提示", { type: "warning", draggable: true }).then(() => {
|
|
117
|
-
http.get(`${application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/deleteInfo`, { params: { id } }).then((res) => {
|
|
118
|
-
EleMessage.success(res.data.message);
|
|
119
|
-
images.value.splice(images.value.indexOf(uploadItem), 1);
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
const handleItemClick = (item) => {
|
|
124
|
-
emit("itemClick", item);
|
|
125
|
-
};
|
|
126
|
-
const handleItemPreview = (item) => {
|
|
127
|
-
emit("preview", item);
|
|
128
|
-
};
|
|
129
|
-
return (_ctx, _cache) => {
|
|
130
|
-
const _component_EleUploadList = resolveComponent("EleUploadList");
|
|
131
|
-
return openBlock(), createBlock(_component_EleUploadList, {
|
|
132
|
-
modelValue: images.value,
|
|
133
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => images.value = $event),
|
|
134
|
-
readonly: _ctx.readonly,
|
|
135
|
-
disabled: _ctx.disabled,
|
|
136
|
-
preview: _ctx.preview,
|
|
137
|
-
limit: _ctx.limit,
|
|
138
|
-
multiple: _ctx.multiple,
|
|
139
|
-
drag: _ctx.drag,
|
|
140
|
-
accept: _ctx.accept,
|
|
141
|
-
itemStyle: _ctx.itemStyle,
|
|
142
|
-
buttonStyle: _ctx.buttonStyle,
|
|
143
|
-
sortable: _ctx.sortable,
|
|
144
|
-
imageProps: _ctx.imageProps,
|
|
145
|
-
progressProps: _ctx.progressProps,
|
|
146
|
-
previewProps: _ctx.previewProps,
|
|
147
|
-
tools: _ctx.tools,
|
|
148
|
-
listType: _ctx.listType,
|
|
149
|
-
beforeUploadClick: _ctx.beforeUploadClick,
|
|
150
|
-
beforeItemEdit: _ctx.beforeItemEdit,
|
|
151
|
-
locale: _ctx.locale,
|
|
152
|
-
onUpload: handleItemUpload,
|
|
153
|
-
onRetry: _cache[1] || (_cache[1] = (item) => handleItemUpload(item, true)),
|
|
154
|
-
onRemove: handleItemRemove,
|
|
155
|
-
onEditUpload: handleItemEditUpload,
|
|
156
|
-
onItemClick: handleItemClick,
|
|
157
|
-
onPreview: handleItemPreview
|
|
158
|
-
}, createSlots({ _: 2 }, [
|
|
159
|
-
renderList(Object.keys(_ctx.$slots), (name) => {
|
|
160
|
-
return {
|
|
161
|
-
name,
|
|
162
|
-
fn: withCtx((slotProps) => [
|
|
163
|
-
renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(slotProps || {})))
|
|
164
|
-
])
|
|
165
|
-
};
|
|
166
|
-
})
|
|
167
|
-
]), 1032, ["modelValue", "readonly", "disabled", "preview", "limit", "multiple", "drag", "accept", "itemStyle", "buttonStyle", "sortable", "imageProps", "progressProps", "previewProps", "tools", "listType", "beforeUploadClick", "beforeItemEdit", "locale"]);
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
export {
|
|
172
|
-
_sfc_main as default
|
|
173
|
-
};
|