yuang-framework-ui-pc 1.1.76 → 1.1.78
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/yu-framework-attachment-upload/index.d.ts +7 -20
- package/es/yu-framework-attachment-upload/index.js +70 -35
- package/es/yu-uims-role-dialog/index.js +1 -1
- package/es/yu-uims-user-dialog/index.js +1 -1
- package/lib/yu-framework-attachment-upload/index.cjs +69 -34
- package/lib/yu-framework-attachment-upload/index.d.ts +7 -20
- package/lib/yu-uims-role-dialog/index.cjs +1 -1
- package/lib/yu-uims-user-dialog/index.cjs +1 -1
- package/package.json +2 -1
|
@@ -1,35 +1,22 @@
|
|
|
1
|
-
import { FrameworkAttachmentComponentParam } from 'yuang-framework-ui-common/lib/interface/component/ComponentParam';
|
|
2
1
|
import { FrameworkAttachment } from 'yuang-framework-ui-common/lib/interface/framework/frameworkAttachment';
|
|
3
2
|
|
|
4
3
|
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
5
|
-
modelValue: import('vue').PropType<
|
|
4
|
+
modelValue: import('vue').PropType<string>;
|
|
6
5
|
param: {
|
|
7
|
-
type: import('vue').PropType<
|
|
8
|
-
|
|
9
|
-
default: {
|
|
10
|
-
type: string;
|
|
11
|
-
mode: string;
|
|
12
|
-
maxCount: number;
|
|
13
|
-
maxSize: number;
|
|
14
|
-
};
|
|
6
|
+
type: import('vue').PropType<{}>;
|
|
7
|
+
default: any;
|
|
15
8
|
};
|
|
16
9
|
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
17
10
|
change: (frameworkAttachment: FrameworkAttachment) => void;
|
|
18
11
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
19
|
-
modelValue: import('vue').PropType<
|
|
12
|
+
modelValue: import('vue').PropType<string>;
|
|
20
13
|
param: {
|
|
21
|
-
type: import('vue').PropType<
|
|
22
|
-
|
|
23
|
-
default: {
|
|
24
|
-
type: string;
|
|
25
|
-
mode: string;
|
|
26
|
-
maxCount: number;
|
|
27
|
-
maxSize: number;
|
|
28
|
-
};
|
|
14
|
+
type: import('vue').PropType<{}>;
|
|
15
|
+
default: any;
|
|
29
16
|
};
|
|
30
17
|
}>> & Readonly<{
|
|
31
18
|
onChange?: ((frameworkAttachment: FrameworkAttachment) => any) | undefined;
|
|
32
19
|
}>, {
|
|
33
|
-
param:
|
|
20
|
+
param: {};
|
|
34
21
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
35
22
|
export default _default;
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import { defineComponent, mergeModels,
|
|
1
|
+
import { defineComponent, mergeModels, useModel, computed, ref, onMounted, watch, resolveComponent, createBlock, openBlock } from "vue";
|
|
2
2
|
import { ElMessageBox } from "element-plus/es";
|
|
3
3
|
import { EleMessage } from "../utils/message";
|
|
4
4
|
import { http } from "yuang-framework-ui-common/lib/config/httpConfig";
|
|
5
|
-
import { getShortUuid } from "yuang-framework-ui-common/lib/utils/uuidUtils";
|
|
6
5
|
import { application } from "yuang-framework-ui-common/lib/config/applicationConfig";
|
|
6
|
+
import require$$0 from "/Users/mac/Work/yuang-union/source-code/yuang-framework/yuang-framework-ui-pc/node_modules/image-conversion/build/conversion.js";
|
|
7
|
+
var imageConversion = require$$0;
|
|
7
8
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
8
9
|
...{ name: "YuFrameworkAttachmentUpload" },
|
|
9
10
|
__name: "index",
|
|
10
11
|
props: /* @__PURE__ */ mergeModels({
|
|
11
|
-
|
|
12
|
-
param: { default: {
|
|
13
|
-
type: "edit",
|
|
14
|
-
mode: "file",
|
|
15
|
-
maxCount: 5,
|
|
16
|
-
maxSize: 5
|
|
17
|
-
} }
|
|
12
|
+
param: { default: {} }
|
|
18
13
|
}, {
|
|
19
14
|
"modelValue": {},
|
|
20
15
|
"modelModifiers": {}
|
|
@@ -23,44 +18,62 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
23
18
|
setup(__props, { emit: __emit }) {
|
|
24
19
|
const props = __props;
|
|
25
20
|
const emit = __emit;
|
|
21
|
+
const modelValue = useModel(__props, "modelValue");
|
|
22
|
+
const componentParam = computed(() => ({
|
|
23
|
+
modelValue: modelValue.value,
|
|
24
|
+
// 类型,默认值:edit
|
|
25
|
+
type: "edit",
|
|
26
|
+
// 模式,默认值:file
|
|
27
|
+
mode: "file",
|
|
28
|
+
// 最大数量,默认值:5
|
|
29
|
+
maxCount: 5,
|
|
30
|
+
// 最大大小,默认值:5,单位:M
|
|
31
|
+
maxSize: 5,
|
|
32
|
+
// 是否压缩图片,默认值:false
|
|
33
|
+
isCompressImage: false,
|
|
34
|
+
...props.param
|
|
35
|
+
}));
|
|
26
36
|
const fileList = ref([]);
|
|
27
|
-
const listType = ref(
|
|
37
|
+
const listType = ref(componentParam.value.mode);
|
|
28
38
|
const accept = ref("");
|
|
29
|
-
if (
|
|
30
|
-
accept.value = ".
|
|
31
|
-
} else if (
|
|
32
|
-
accept.value = ".
|
|
39
|
+
if (componentParam.value.mode == "file") {
|
|
40
|
+
accept.value = [".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".wps", ".dps", ".et", ".htm", ".html", ".js", ".css", ".svg", ".txt", ".sql", ".zip", ".rar", ".gz", ".bz2", ".mp3", ".mp4", ".mov", ".gif", ".jpg", ".jpeg", ".png", ".bmp"].join(",");
|
|
41
|
+
} else if (componentParam.value.mode == "image") {
|
|
42
|
+
accept.value = [".gif", ".jpg", ".jpeg", ".png", ".bmp"].join(",");
|
|
33
43
|
}
|
|
34
44
|
const isLoading = ref(false);
|
|
35
45
|
const checkFile = (file) => {
|
|
36
46
|
if (!file) {
|
|
37
47
|
return;
|
|
38
48
|
}
|
|
39
|
-
if (
|
|
49
|
+
if (componentParam.value.mode === "image" && !file.type.startsWith("image")) {
|
|
40
50
|
EleMessage.error("只能选择图片");
|
|
41
51
|
return;
|
|
42
52
|
}
|
|
43
|
-
if (file.size / 1024 / 1024 >
|
|
44
|
-
EleMessage.error(`图片大小不能超过${
|
|
53
|
+
if (file.size / 1024 / 1024 > componentParam.value.maxSize) {
|
|
54
|
+
EleMessage.error(`图片大小不能超过${componentParam.value.maxSize}MB`);
|
|
45
55
|
return;
|
|
46
56
|
}
|
|
47
57
|
return true;
|
|
48
58
|
};
|
|
49
|
-
const model = useModel(__props, "modelValue");
|
|
50
|
-
model.value = model.value ?? getShortUuid();
|
|
51
59
|
let isExecuting = false;
|
|
52
60
|
let pendingExecute = false;
|
|
53
61
|
onMounted(() => {
|
|
54
62
|
init();
|
|
55
63
|
});
|
|
56
64
|
const init = () => {
|
|
65
|
+
console.log("modelValue.value", modelValue.value);
|
|
66
|
+
console.log("componentParam.value", componentParam.value);
|
|
67
|
+
if (!modelValue.value) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
57
70
|
if (isExecuting) {
|
|
58
71
|
pendingExecute = true;
|
|
59
72
|
return;
|
|
60
73
|
}
|
|
61
74
|
isExecuting = true;
|
|
62
75
|
fileList.value = [];
|
|
63
|
-
http.post(`${application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/selectPage`, { codeForEqual:
|
|
76
|
+
http.post(`${application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/selectPage`, { codeForEqual: modelValue.value, pageSize: 100 }).then((res) => {
|
|
64
77
|
let attachemtList = res.data.data.records;
|
|
65
78
|
for (let i = 0; i < attachemtList.length; i++) {
|
|
66
79
|
fileList.value.push({
|
|
@@ -79,7 +92,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
79
92
|
}
|
|
80
93
|
});
|
|
81
94
|
};
|
|
82
|
-
const handleUpload = (uploadItem, retry) => {
|
|
95
|
+
const handleUpload = async (uploadItem, retry) => {
|
|
83
96
|
if (!checkFile(uploadItem.file)) {
|
|
84
97
|
return;
|
|
85
98
|
}
|
|
@@ -93,9 +106,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
93
106
|
}
|
|
94
107
|
item.status = "uploading";
|
|
95
108
|
item.progress = 0;
|
|
109
|
+
let uploadFile = uploadItem.file;
|
|
110
|
+
if (componentParam.value.mode === "image" && componentParam.value.isCompressImage && uploadFile) {
|
|
111
|
+
let beforeCompressSize = uploadFile.size;
|
|
112
|
+
try {
|
|
113
|
+
const compressBlob = await imageConversion.compressAccurately(uploadFile, 512);
|
|
114
|
+
uploadFile = new File([compressBlob], uploadFile.name, { type: uploadFile.type });
|
|
115
|
+
console.log(`压缩前:${(beforeCompressSize / 1024).toFixed(2)}KB | 压缩后:${(uploadFile.size / 1024).toFixed(2)}KB`);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
EleMessage.warning("图片压缩失败,将上传原图");
|
|
118
|
+
console.error("图片压缩异常:", error);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
96
121
|
let formData = new FormData();
|
|
97
|
-
formData.append("code",
|
|
98
|
-
formData.append("multipartFile",
|
|
122
|
+
formData.append("code", modelValue.value);
|
|
123
|
+
formData.append("multipartFile", uploadFile, uploadFile.name);
|
|
99
124
|
http({
|
|
100
125
|
url: `${application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/uploadAttachment`,
|
|
101
126
|
method: "post",
|
|
@@ -115,7 +140,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
115
140
|
EleMessage.error(e.message);
|
|
116
141
|
});
|
|
117
142
|
};
|
|
118
|
-
const handleEditUpload = ({ item, newItem }) => {
|
|
143
|
+
const handleEditUpload = async ({ item, newItem }) => {
|
|
119
144
|
if (!checkFile(newItem.file)) {
|
|
120
145
|
return;
|
|
121
146
|
}
|
|
@@ -123,10 +148,22 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
123
148
|
console.log("newItem", newItem);
|
|
124
149
|
newItem.status = "uploading";
|
|
125
150
|
newItem.progress = 0;
|
|
151
|
+
let uploadFile = newItem.file;
|
|
152
|
+
if (componentParam.value.mode === "image" && componentParam.value.isCompressImage && uploadFile) {
|
|
153
|
+
let beforeCompressSize = uploadFile.size;
|
|
154
|
+
try {
|
|
155
|
+
const compressBlob = await imageConversion.compressAccurately(uploadFile, 512);
|
|
156
|
+
uploadFile = new File([compressBlob], uploadFile.name, { type: uploadFile.type });
|
|
157
|
+
console.log(`压缩前:${(beforeCompressSize / 1024).toFixed(2)}KB | 压缩后:${(uploadFile.size / 1024).toFixed(2)}KB`);
|
|
158
|
+
} catch (error) {
|
|
159
|
+
EleMessage.warning("图片压缩失败,将上传原图");
|
|
160
|
+
console.error("图片压缩异常:", error);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
126
163
|
let formData = new FormData();
|
|
127
164
|
formData.append("id", item.id);
|
|
128
|
-
formData.append("code",
|
|
129
|
-
formData.append("multipartFile",
|
|
165
|
+
formData.append("code", modelValue.value);
|
|
166
|
+
formData.append("multipartFile", uploadFile, uploadFile.name);
|
|
130
167
|
http({
|
|
131
168
|
url: `${application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/uploadAttachment`,
|
|
132
169
|
method: "post",
|
|
@@ -151,7 +188,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
151
188
|
});
|
|
152
189
|
};
|
|
153
190
|
const emitChange = () => {
|
|
154
|
-
|
|
191
|
+
if (!modelValue.value) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
http.post(`${application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/selectPage`, { codeForEqual: modelValue.value, pageSize: 100 }).then((res) => {
|
|
155
195
|
let attachemtList = res.data.data.records;
|
|
156
196
|
emit("change", attachemtList);
|
|
157
197
|
});
|
|
@@ -170,17 +210,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
170
210
|
handleUpload(uploadItem, true);
|
|
171
211
|
};
|
|
172
212
|
watch(
|
|
173
|
-
() =>
|
|
174
|
-
() => {
|
|
175
|
-
init();
|
|
176
|
-
}
|
|
177
|
-
);
|
|
178
|
-
watch(
|
|
179
|
-
() => props.param,
|
|
213
|
+
() => componentParam,
|
|
180
214
|
() => {
|
|
215
|
+
console.log("props.param发生改变", props.param);
|
|
181
216
|
init();
|
|
182
217
|
},
|
|
183
|
-
{ deep: true }
|
|
218
|
+
{ deep: true, immediate: true }
|
|
184
219
|
);
|
|
185
220
|
return (_ctx, _cache) => {
|
|
186
221
|
const _component_ele_upload_list = resolveComponent("ele-upload-list");
|
|
@@ -3,19 +3,14 @@ const vue = require("vue");
|
|
|
3
3
|
const es = require("element-plus/es");
|
|
4
4
|
const message = require("../utils/message");
|
|
5
5
|
const httpConfig = require("yuang-framework-ui-common/lib/config/httpConfig");
|
|
6
|
-
const uuidUtils = require("yuang-framework-ui-common/lib/utils/uuidUtils");
|
|
7
6
|
const applicationConfig = require("yuang-framework-ui-common/lib/config/applicationConfig");
|
|
7
|
+
const require$$0 = require("/Users/mac/Work/yuang-union/source-code/yuang-framework/yuang-framework-ui-pc/node_modules/image-conversion/build/conversion.js");
|
|
8
|
+
var imageConversion = require$$0;
|
|
8
9
|
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
9
10
|
...{ name: "YuFrameworkAttachmentUpload" },
|
|
10
11
|
__name: "index",
|
|
11
12
|
props: /* @__PURE__ */ vue.mergeModels({
|
|
12
|
-
|
|
13
|
-
param: { default: {
|
|
14
|
-
type: "edit",
|
|
15
|
-
mode: "file",
|
|
16
|
-
maxCount: 5,
|
|
17
|
-
maxSize: 5
|
|
18
|
-
} }
|
|
13
|
+
param: { default: {} }
|
|
19
14
|
}, {
|
|
20
15
|
"modelValue": {},
|
|
21
16
|
"modelModifiers": {}
|
|
@@ -24,44 +19,62 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
24
19
|
setup(__props, { emit: __emit }) {
|
|
25
20
|
const props = __props;
|
|
26
21
|
const emit = __emit;
|
|
22
|
+
const modelValue = vue.useModel(__props, "modelValue");
|
|
23
|
+
const componentParam = vue.computed(() => ({
|
|
24
|
+
modelValue: modelValue.value,
|
|
25
|
+
// 类型,默认值:edit
|
|
26
|
+
type: "edit",
|
|
27
|
+
// 模式,默认值:file
|
|
28
|
+
mode: "file",
|
|
29
|
+
// 最大数量,默认值:5
|
|
30
|
+
maxCount: 5,
|
|
31
|
+
// 最大大小,默认值:5,单位:M
|
|
32
|
+
maxSize: 5,
|
|
33
|
+
// 是否压缩图片,默认值:false
|
|
34
|
+
isCompressImage: false,
|
|
35
|
+
...props.param
|
|
36
|
+
}));
|
|
27
37
|
const fileList = vue.ref([]);
|
|
28
|
-
const listType = vue.ref(
|
|
38
|
+
const listType = vue.ref(componentParam.value.mode);
|
|
29
39
|
const accept = vue.ref("");
|
|
30
|
-
if (
|
|
31
|
-
accept.value = ".
|
|
32
|
-
} else if (
|
|
33
|
-
accept.value = ".
|
|
40
|
+
if (componentParam.value.mode == "file") {
|
|
41
|
+
accept.value = [".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".wps", ".dps", ".et", ".htm", ".html", ".js", ".css", ".svg", ".txt", ".sql", ".zip", ".rar", ".gz", ".bz2", ".mp3", ".mp4", ".mov", ".gif", ".jpg", ".jpeg", ".png", ".bmp"].join(",");
|
|
42
|
+
} else if (componentParam.value.mode == "image") {
|
|
43
|
+
accept.value = [".gif", ".jpg", ".jpeg", ".png", ".bmp"].join(",");
|
|
34
44
|
}
|
|
35
45
|
const isLoading = vue.ref(false);
|
|
36
46
|
const checkFile = (file) => {
|
|
37
47
|
if (!file) {
|
|
38
48
|
return;
|
|
39
49
|
}
|
|
40
|
-
if (
|
|
50
|
+
if (componentParam.value.mode === "image" && !file.type.startsWith("image")) {
|
|
41
51
|
message.EleMessage.error("只能选择图片");
|
|
42
52
|
return;
|
|
43
53
|
}
|
|
44
|
-
if (file.size / 1024 / 1024 >
|
|
45
|
-
message.EleMessage.error(`图片大小不能超过${
|
|
54
|
+
if (file.size / 1024 / 1024 > componentParam.value.maxSize) {
|
|
55
|
+
message.EleMessage.error(`图片大小不能超过${componentParam.value.maxSize}MB`);
|
|
46
56
|
return;
|
|
47
57
|
}
|
|
48
58
|
return true;
|
|
49
59
|
};
|
|
50
|
-
const model = vue.useModel(__props, "modelValue");
|
|
51
|
-
model.value = model.value ?? uuidUtils.getShortUuid();
|
|
52
60
|
let isExecuting = false;
|
|
53
61
|
let pendingExecute = false;
|
|
54
62
|
vue.onMounted(() => {
|
|
55
63
|
init();
|
|
56
64
|
});
|
|
57
65
|
const init = () => {
|
|
66
|
+
console.log("modelValue.value", modelValue.value);
|
|
67
|
+
console.log("componentParam.value", componentParam.value);
|
|
68
|
+
if (!modelValue.value) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
58
71
|
if (isExecuting) {
|
|
59
72
|
pendingExecute = true;
|
|
60
73
|
return;
|
|
61
74
|
}
|
|
62
75
|
isExecuting = true;
|
|
63
76
|
fileList.value = [];
|
|
64
|
-
httpConfig.http.post(`${applicationConfig.application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/selectPage`, { codeForEqual:
|
|
77
|
+
httpConfig.http.post(`${applicationConfig.application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/selectPage`, { codeForEqual: modelValue.value, pageSize: 100 }).then((res) => {
|
|
65
78
|
let attachemtList = res.data.data.records;
|
|
66
79
|
for (let i = 0; i < attachemtList.length; i++) {
|
|
67
80
|
fileList.value.push({
|
|
@@ -80,7 +93,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
80
93
|
}
|
|
81
94
|
});
|
|
82
95
|
};
|
|
83
|
-
const handleUpload = (uploadItem, retry) => {
|
|
96
|
+
const handleUpload = async (uploadItem, retry) => {
|
|
84
97
|
if (!checkFile(uploadItem.file)) {
|
|
85
98
|
return;
|
|
86
99
|
}
|
|
@@ -94,9 +107,21 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
94
107
|
}
|
|
95
108
|
item.status = "uploading";
|
|
96
109
|
item.progress = 0;
|
|
110
|
+
let uploadFile = uploadItem.file;
|
|
111
|
+
if (componentParam.value.mode === "image" && componentParam.value.isCompressImage && uploadFile) {
|
|
112
|
+
let beforeCompressSize = uploadFile.size;
|
|
113
|
+
try {
|
|
114
|
+
const compressBlob = await imageConversion.compressAccurately(uploadFile, 512);
|
|
115
|
+
uploadFile = new File([compressBlob], uploadFile.name, { type: uploadFile.type });
|
|
116
|
+
console.log(`压缩前:${(beforeCompressSize / 1024).toFixed(2)}KB | 压缩后:${(uploadFile.size / 1024).toFixed(2)}KB`);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
message.EleMessage.warning("图片压缩失败,将上传原图");
|
|
119
|
+
console.error("图片压缩异常:", error);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
97
122
|
let formData = new FormData();
|
|
98
|
-
formData.append("code",
|
|
99
|
-
formData.append("multipartFile",
|
|
123
|
+
formData.append("code", modelValue.value);
|
|
124
|
+
formData.append("multipartFile", uploadFile, uploadFile.name);
|
|
100
125
|
httpConfig.http({
|
|
101
126
|
url: `${applicationConfig.application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/uploadAttachment`,
|
|
102
127
|
method: "post",
|
|
@@ -116,7 +141,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
116
141
|
message.EleMessage.error(e.message);
|
|
117
142
|
});
|
|
118
143
|
};
|
|
119
|
-
const handleEditUpload = ({ item, newItem }) => {
|
|
144
|
+
const handleEditUpload = async ({ item, newItem }) => {
|
|
120
145
|
if (!checkFile(newItem.file)) {
|
|
121
146
|
return;
|
|
122
147
|
}
|
|
@@ -124,10 +149,22 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
124
149
|
console.log("newItem", newItem);
|
|
125
150
|
newItem.status = "uploading";
|
|
126
151
|
newItem.progress = 0;
|
|
152
|
+
let uploadFile = newItem.file;
|
|
153
|
+
if (componentParam.value.mode === "image" && componentParam.value.isCompressImage && uploadFile) {
|
|
154
|
+
let beforeCompressSize = uploadFile.size;
|
|
155
|
+
try {
|
|
156
|
+
const compressBlob = await imageConversion.compressAccurately(uploadFile, 512);
|
|
157
|
+
uploadFile = new File([compressBlob], uploadFile.name, { type: uploadFile.type });
|
|
158
|
+
console.log(`压缩前:${(beforeCompressSize / 1024).toFixed(2)}KB | 压缩后:${(uploadFile.size / 1024).toFixed(2)}KB`);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
message.EleMessage.warning("图片压缩失败,将上传原图");
|
|
161
|
+
console.error("图片压缩异常:", error);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
127
164
|
let formData = new FormData();
|
|
128
165
|
formData.append("id", item.id);
|
|
129
|
-
formData.append("code",
|
|
130
|
-
formData.append("multipartFile",
|
|
166
|
+
formData.append("code", modelValue.value);
|
|
167
|
+
formData.append("multipartFile", uploadFile, uploadFile.name);
|
|
131
168
|
httpConfig.http({
|
|
132
169
|
url: `${applicationConfig.application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/uploadAttachment`,
|
|
133
170
|
method: "post",
|
|
@@ -152,7 +189,10 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
152
189
|
});
|
|
153
190
|
};
|
|
154
191
|
const emitChange = () => {
|
|
155
|
-
|
|
192
|
+
if (!modelValue.value) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
httpConfig.http.post(`${applicationConfig.application.gatewayServerBaseUrl}/framework-api/core/framework-attachment/selectPage`, { codeForEqual: modelValue.value, pageSize: 100 }).then((res) => {
|
|
156
196
|
let attachemtList = res.data.data.records;
|
|
157
197
|
emit("change", attachemtList);
|
|
158
198
|
});
|
|
@@ -171,17 +211,12 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
171
211
|
handleUpload(uploadItem, true);
|
|
172
212
|
};
|
|
173
213
|
vue.watch(
|
|
174
|
-
() =>
|
|
175
|
-
() => {
|
|
176
|
-
init();
|
|
177
|
-
}
|
|
178
|
-
);
|
|
179
|
-
vue.watch(
|
|
180
|
-
() => props.param,
|
|
214
|
+
() => componentParam,
|
|
181
215
|
() => {
|
|
216
|
+
console.log("props.param发生改变", props.param);
|
|
182
217
|
init();
|
|
183
218
|
},
|
|
184
|
-
{ deep: true }
|
|
219
|
+
{ deep: true, immediate: true }
|
|
185
220
|
);
|
|
186
221
|
return (_ctx, _cache) => {
|
|
187
222
|
const _component_ele_upload_list = vue.resolveComponent("ele-upload-list");
|
|
@@ -1,35 +1,22 @@
|
|
|
1
|
-
import { FrameworkAttachmentComponentParam } from 'yuang-framework-ui-common/lib/interface/component/ComponentParam';
|
|
2
1
|
import { FrameworkAttachment } from 'yuang-framework-ui-common/lib/interface/framework/frameworkAttachment';
|
|
3
2
|
|
|
4
3
|
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
5
|
-
modelValue: import('vue').PropType<
|
|
4
|
+
modelValue: import('vue').PropType<string>;
|
|
6
5
|
param: {
|
|
7
|
-
type: import('vue').PropType<
|
|
8
|
-
|
|
9
|
-
default: {
|
|
10
|
-
type: string;
|
|
11
|
-
mode: string;
|
|
12
|
-
maxCount: number;
|
|
13
|
-
maxSize: number;
|
|
14
|
-
};
|
|
6
|
+
type: import('vue').PropType<{}>;
|
|
7
|
+
default: any;
|
|
15
8
|
};
|
|
16
9
|
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
17
10
|
change: (frameworkAttachment: FrameworkAttachment) => void;
|
|
18
11
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
19
|
-
modelValue: import('vue').PropType<
|
|
12
|
+
modelValue: import('vue').PropType<string>;
|
|
20
13
|
param: {
|
|
21
|
-
type: import('vue').PropType<
|
|
22
|
-
|
|
23
|
-
default: {
|
|
24
|
-
type: string;
|
|
25
|
-
mode: string;
|
|
26
|
-
maxCount: number;
|
|
27
|
-
maxSize: number;
|
|
28
|
-
};
|
|
14
|
+
type: import('vue').PropType<{}>;
|
|
15
|
+
default: any;
|
|
29
16
|
};
|
|
30
17
|
}>> & Readonly<{
|
|
31
18
|
onChange?: ((frameworkAttachment: FrameworkAttachment) => any) | undefined;
|
|
32
19
|
}>, {
|
|
33
|
-
param:
|
|
20
|
+
param: {};
|
|
34
21
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
35
22
|
export default _default;
|
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.78",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite --host --config vite.global.ts --mode dev",
|
|
@@ -188,6 +188,7 @@
|
|
|
188
188
|
"repository": "",
|
|
189
189
|
"license": "",
|
|
190
190
|
"dependencies": {
|
|
191
|
+
"image-conversion": "^2.1.1",
|
|
191
192
|
"yuang-framework-ui-common": "^1.0.86"
|
|
192
193
|
}
|
|
193
194
|
}
|