Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
data-table
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2022-12-02 10:31:29 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fd30b8486c643bd1bfac10f99eebf7bef4af4559
fd30b848
1 parent
2a6b4f7d
fix
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
6 deletions
src/components/ImageUploaderField/index.vue
src/components/ImageUploaderField/index.vue
View file @
fd30b84
...
...
@@ -106,7 +106,7 @@ const uploadQiniu = async (file, token, filename) => {
let formData = new FormData();
formData.append("file", file); // 通过append向form对象添加数据
formData.append("token", token);
formData.append("key", f
ormCode + "/" + uuid() + "." + file.name.split(".")[1]
);
formData.append("key", f
ilename
);
let config = {
headers: { "Content-Type": "multipart/form-data" },
};
...
...
@@ -136,7 +136,8 @@ const handleUpload = async (files) => {
// 获取HASH值
const hash = getEtag(files.content);
// 获取七牛token
const filename = formCode + "/" + uuid() + "." + files.file.name.split(".")[1];
const filename =
"uploadForm/" + formCode + "/" + uuid() + "." + files.file.name.split(".")[1];
const { token, key, code } = await qiniuTokenAPI({
name: filename,
hash,
...
...
@@ -148,10 +149,10 @@ const handleUpload = async (files) => {
return { imgUrl };
};
// 多选图片上传遍历
var muliUpload = async (files) => {
for (let item of files) {
const res = await handleUpload(item);
console.warn(res.imgUrl.src);
// 上传失败提示
if (!res.imgUrl.src) {
item.status = "failed";
...
...
@@ -160,7 +161,6 @@ var muliUpload = async (files) => {
} else {
item.status = "";
item.message = "";
// fileList.value.pop();
fileList.value.push({
url: res.imgUrl.src,
isImage: true,
...
...
@@ -184,7 +184,6 @@ const afterRead = async (files) => {
} else {
files.status = "";
files.message = "";
fileList.value.pop();
fileList.value.push({
url: imgUrl.src,
isImage: true,
...
...
@@ -192,6 +191,7 @@ const afterRead = async (files) => {
loading.value = false;
}
}
// 过滤非包含URL的图片
fileList.value = fileList.value.filter((item) => {
if (item.url) return item;
});
...
...
@@ -201,7 +201,6 @@ const afterRead = async (files) => {
value: fileList.value,
};
emit("active", props.item.value);
console.warn(fileList.value);
};
const beforeDelete = (files) => {
...
...
Please
register
or
login
to post a comment