|
@@ -106,7 +106,7 @@
|
|
|
</span>
|
|
</span>
|
|
|
</div>
|
|
</div>
|
|
|
</tableList>
|
|
</tableList>
|
|
|
- <UploadTaskList class="upload-list-new" v-show="uploadTaskList.length != 0" fileType="AUDIO" :taskList="uploadTaskList" @cancel-task="onCancelTask"></UploadTaskList>
|
|
|
|
|
|
|
+ <UploadTaskList class="upload-list-new" fileType="IMAGE" :taskList="uploadListForUI" @cancel-task="onCancelTask"></UploadTaskList>
|
|
|
<div class="total-number" v-if="list.length !== 0 || hasMoreData">已加载{{list.length}}条</div>
|
|
<div class="total-number" v-if="list.length !== 0 || hasMoreData">已加载{{list.length}}条</div>
|
|
|
<div class="nodata" v-if="list.length == 0 && !hasMoreData && lastestUsedSearchKey">
|
|
<div class="nodata" v-if="list.length == 0 && !hasMoreData && lastestUsedSearchKey">
|
|
|
<img :src="$noresult" alt="" />
|
|
<img :src="$noresult" alt="" />
|
|
@@ -151,6 +151,7 @@ import Upload from "@/components/shared/uploads/UploadMultiple";
|
|
|
import { getImgWH, changeByteUnit } from "@/utils/file";
|
|
import { getImgWH, changeByteUnit } from "@/utils/file";
|
|
|
import UploadTaskList from "../components/uploadList1.1.0.vue";
|
|
import UploadTaskList from "../components/uploadList1.1.0.vue";
|
|
|
import { debounce } from "@/utils/other.js"
|
|
import { debounce } from "@/utils/other.js"
|
|
|
|
|
+import { mapState } from 'vuex';
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
|
getMaterialList,
|
|
getMaterialList,
|
|
@@ -178,7 +179,6 @@ export default {
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
config,
|
|
config,
|
|
|
- longPollingSwitch: false,
|
|
|
|
|
showRename: false,
|
|
showRename: false,
|
|
|
showPreview: false,
|
|
showPreview: false,
|
|
|
showCover: false,
|
|
showCover: false,
|
|
@@ -202,14 +202,22 @@ export default {
|
|
|
hasMoreData: true,
|
|
hasMoreData: true,
|
|
|
isRequestingMoreData: false,
|
|
isRequestingMoreData: false,
|
|
|
uploadList: [],
|
|
uploadList: [],
|
|
|
- uploadTaskList: [],
|
|
|
|
|
- uploadHandlerList: [],
|
|
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
|
|
+ computed: {
|
|
|
|
|
+ ...mapState({
|
|
|
|
|
+ uploadListForUI: 'uploadStatusListPano',
|
|
|
|
|
+ }),
|
|
|
|
|
+ needLongPolling() {
|
|
|
|
|
+ return this.uploadListForUI.some((item) => {
|
|
|
|
|
+ return item.status === 'LOADING' && item.ifKnowProgress === false
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
mounted() {
|
|
mounted() {
|
|
|
},
|
|
},
|
|
|
watch: {
|
|
watch: {
|
|
|
- longPollingSwitch: {
|
|
|
|
|
|
|
+ needLongPolling: {
|
|
|
handler: function (newVal) {
|
|
handler: function (newVal) {
|
|
|
if (!newVal) {
|
|
if (!newVal) {
|
|
|
this.clearinter();
|
|
this.clearinter();
|
|
@@ -323,34 +331,26 @@ export default {
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
_checkMStatus() {
|
|
_checkMStatus() {
|
|
|
- let loadingTaskList = this.uploadTaskList.filter((item) => item.status === 'LOADING');
|
|
|
|
|
- if (loadingTaskList.length > 0) {
|
|
|
|
|
|
|
+ let needPollingTaskList = this.uploadListForUI.filter((item) => item.status === 'LOADING' && item.ifKnowProgress === false);
|
|
|
|
|
+ if (needPollingTaskList.length > 0) {
|
|
|
checkMStatus(
|
|
checkMStatus(
|
|
|
{
|
|
{
|
|
|
- ids: this.uploadTaskList.map((item) => item.backendId),
|
|
|
|
|
|
|
+ ids: needPollingTaskList.map((item) => item.backendId),
|
|
|
islongpolling: true,
|
|
islongpolling: true,
|
|
|
},
|
|
},
|
|
|
(res) => {
|
|
(res) => {
|
|
|
// 1切图中,2失败,3成功
|
|
// 1切图中,2失败,3成功
|
|
|
res.data.forEach(eachRes => {
|
|
res.data.forEach(eachRes => {
|
|
|
if (eachRes.status === 2) {
|
|
if (eachRes.status === 2) {
|
|
|
- const index = this.uploadTaskList.findIndex(eachTask => eachTask.backendId === eachRes.id)
|
|
|
|
|
- index >= 0 && (this.uploadTaskList[index].status = 'FAIL')
|
|
|
|
|
- index >= 0 && (this.uploadTaskList[index].statusText = '素材切图失败')
|
|
|
|
|
|
|
+ const index = this.uploadListForUI.findIndex(eachTask => eachTask.backendId === eachRes.id)
|
|
|
|
|
+ index >= 0 && (this.uploadListForUI[index].status = 'FAIL')
|
|
|
|
|
+ index >= 0 && (this.uploadListForUI[index].statusText = '素材切图失败')
|
|
|
} else if (eachRes.status === 3) {
|
|
} else if (eachRes.status === 3) {
|
|
|
- const index = this.uploadTaskList.findIndex(eachTask => eachTask.backendId === eachRes.id)
|
|
|
|
|
- index >= 0 && (this.uploadTaskList[index].status = 'SUCCESS')
|
|
|
|
|
- index >= 0 && (this.uploadTaskList[index].statusText = '切图成功')
|
|
|
|
|
|
|
+ const index = this.uploadListForUI.findIndex(eachTask => eachTask.backendId === eachRes.id)
|
|
|
|
|
+ index >= 0 && (this.uploadListForUI.splice(index, 1))
|
|
|
|
|
+ index >= 0 && this.refreshListDebounced()
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- if (!this.uploadTaskList.some((item) => item.status === 'LOADING')) {
|
|
|
|
|
- this.longPollingSwitch = false;
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- this.uploadTaskList = []
|
|
|
|
|
- this.uploadHandlerList = []
|
|
|
|
|
- this.refreshListDebounced()
|
|
|
|
|
- }, 1000);
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
@@ -402,8 +402,6 @@ export default {
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
onFileChange(e) {
|
|
onFileChange(e) {
|
|
|
- let uploadFileList = [];
|
|
|
|
|
-
|
|
|
|
|
e.files.forEach((eachFile, i) => {
|
|
e.files.forEach((eachFile, i) => {
|
|
|
if (
|
|
if (
|
|
|
eachFile.name.toLowerCase().indexOf("jpeg") <= -1 &&
|
|
eachFile.name.toLowerCase().indexOf("jpeg") <= -1 &&
|
|
@@ -428,75 +426,54 @@ export default {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- let tmp = {
|
|
|
|
|
|
|
+ let itemInUploadList = {
|
|
|
title: eachFile.name,
|
|
title: eachFile.name,
|
|
|
ifKnowProgress: true,
|
|
ifKnowProgress: true,
|
|
|
progress: 0,
|
|
progress: 0,
|
|
|
status: 'LOADING',
|
|
status: 'LOADING',
|
|
|
statusStr: "正在上传素材",
|
|
statusStr: "正在上传素材",
|
|
|
uid: `u_${this.$randomWord(true, 8, 8)}`,
|
|
uid: `u_${this.$randomWord(true, 8, 8)}`,
|
|
|
|
|
+ abortHandler: null,
|
|
|
|
|
+ backendId: '',
|
|
|
};
|
|
};
|
|
|
- this.uploadTaskList.push(tmp);
|
|
|
|
|
- uploadFileList.push({
|
|
|
|
|
- file: eachFile,
|
|
|
|
|
- list: { ...tmp },
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
|
|
|
|
|
- let uploadPromiseList = [];
|
|
|
|
|
- uploadFileList.forEach((data, index) => {
|
|
|
|
|
- let promise = new Promise((resolve, reject) => {
|
|
|
|
|
- const handler = uploadMaterial(
|
|
|
|
|
- {
|
|
|
|
|
- file: data.file
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- type: TYPE,
|
|
|
|
|
- uid: data.list.uid,
|
|
|
|
|
- },
|
|
|
|
|
- (response) => {
|
|
|
|
|
- if (response.data.id) {
|
|
|
|
|
- this.uploadTaskList[index].statusText = '正在切图处理'
|
|
|
|
|
- this.uploadTaskList[index].ifKnowProgress = false
|
|
|
|
|
- this.uploadTaskList[index].backendId = response.data.id
|
|
|
|
|
- resolve(response);
|
|
|
|
|
- } else {
|
|
|
|
|
- this.uploadTaskList[index].status = 'FAIL'
|
|
|
|
|
- this.uploadTaskList[index].statusText = '素材上传失败'
|
|
|
|
|
- reject('拿不到上传后文件id')
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- (err) => {
|
|
|
|
|
- if (err.status === 0) { // 用户取消了上传任务。TODO:判断依据不够完美。
|
|
|
|
|
- this.uploadTaskList[index].status = 'CANCELLED'
|
|
|
|
|
- this.uploadTaskList[index].statusText = '已取消'
|
|
|
|
|
- } else {
|
|
|
|
|
- this.uploadTaskList[index].status = 'FAIL'
|
|
|
|
|
- this.uploadTaskList[index].statusText = '素材上传失败'
|
|
|
|
|
- }
|
|
|
|
|
- reject(err);
|
|
|
|
|
- },
|
|
|
|
|
- (progress) => {
|
|
|
|
|
- this.uploadTaskList[index].progress = progress
|
|
|
|
|
|
|
+ itemInUploadList.abortHandler = uploadMaterial(
|
|
|
|
|
+ {
|
|
|
|
|
+ file: eachFile
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ type: TYPE,
|
|
|
|
|
+ uid: itemInUploadList.uid,
|
|
|
|
|
+ },
|
|
|
|
|
+ (response) => { // 上传成功
|
|
|
|
|
+ itemInUploadList.statusText = '正在切图处理'
|
|
|
|
|
+ itemInUploadList.ifKnowProgress = false
|
|
|
|
|
+ itemInUploadList.backendId = response.data.id
|
|
|
|
|
+ },
|
|
|
|
|
+ (err) => {
|
|
|
|
|
+ if (err.statusText === 'abort') { // 用户取消了上传任务。
|
|
|
|
|
+ const index = this.uploadListForUI.findIndex((eachItem) => {
|
|
|
|
|
+ eachItem.uid === itemInUploadList.uid
|
|
|
|
|
+ })
|
|
|
|
|
+ this.uploadListForUI.splice(index, 1)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ itemInUploadList.status = 'FAIL'
|
|
|
|
|
+ itemInUploadList.statusText = '素材上传失败'
|
|
|
}
|
|
}
|
|
|
- );
|
|
|
|
|
- this.uploadHandlerList.push(handler)
|
|
|
|
|
- });
|
|
|
|
|
- uploadPromiseList.push(promise);
|
|
|
|
|
- });
|
|
|
|
|
- Promise.allSettled(uploadPromiseList).then(() => {
|
|
|
|
|
- if (!this.uploadTaskList.some((item) => item.status === 'LOADING')) {
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- this.uploadTaskList = []
|
|
|
|
|
- this.uploadHandlerList = []
|
|
|
|
|
- }, 1000);
|
|
|
|
|
- } else {
|
|
|
|
|
- this.longPollingSwitch = true
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ (progress) => {
|
|
|
|
|
+ itemInUploadList.progress = progress
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ this.uploadListForUI.push(itemInUploadList);
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
- onCancelTask(index) {
|
|
|
|
|
- this.uploadHandlerList[index].abort()
|
|
|
|
|
|
|
+ onCancelTask(uid) {
|
|
|
|
|
+ const index = this.uploadListForUI.findIndex((eachItem) => {
|
|
|
|
|
+ return eachItem.uid === uid
|
|
|
|
|
+ })
|
|
|
|
|
+ this.uploadListForUI[index].abortHandler.abort()
|
|
|
},
|
|
},
|
|
|
getMoreMaterialItem(islongpolling = null) {
|
|
getMoreMaterialItem(islongpolling = null) {
|
|
|
this.isRequestingMoreData = true
|
|
this.isRequestingMoreData = true
|