|
@@ -48,6 +48,8 @@
|
|
|
|
|
|
<script setup>
|
|
|
import { getToken } from "@/utils/auth";
|
|
|
+import Compressor from 'compressorjs';
|
|
|
+import {uploadImg} from "@/api/system/config";
|
|
|
|
|
|
const props = defineProps({
|
|
|
modelValue: [String, Object, Array],
|
|
@@ -116,7 +118,6 @@ function handleRemove(file, files) {
|
|
|
// 上传成功回调
|
|
|
function handleUploadSuccess(res) {
|
|
|
uploadList.value.push({ name: res.fileName, url: res.fileName });
|
|
|
- debugger
|
|
|
if (uploadList.value.length === number.value) {
|
|
|
fileList.value = fileList.value.filter(f => f.url !== undefined).concat(uploadList.value);
|
|
|
uploadList.value = [];
|
|
@@ -155,10 +156,38 @@ function handleBeforeUpload(file) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 执行上传
|
|
|
proxy.$modal.loading("正在上传图片,请稍候...");
|
|
|
number.value++;
|
|
|
+
|
|
|
+ return new Promise((resolve,reject) => {
|
|
|
+
|
|
|
+ new Compressor(file, {
|
|
|
+ quality: file.size>1024*1024*1?0.6:1, // 压缩质量
|
|
|
+ success: (result) => {
|
|
|
+ // 替换原文件
|
|
|
+ file = result;
|
|
|
+ uploadImg(file).then(res => {
|
|
|
+ handleUploadSuccess(res);
|
|
|
+ });
|
|
|
+
|
|
|
+ reject("sssss")
|
|
|
+ // resolve(result);
|
|
|
+ },
|
|
|
+ error: (err) => {
|
|
|
+ console.log(err.message);
|
|
|
+ },
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// 文件个数超出
|
|
|
function handleExceed() {
|
|
|
proxy.$modal.msgError(`上传文件数量不能超过 ${props.limit} 个!`);
|
|
@@ -187,6 +216,9 @@ function listToString(list, separator) {
|
|
|
}
|
|
|
return strs != "" ? strs.substr(0, strs.length - 1) : "";
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
</script>
|
|
|
<style>
|
|
|
.el-upload-dragger{
|