|
@@ -13,7 +13,7 @@
|
|
|
<span>上传素材</span>
|
|
<span>上传素材</span>
|
|
|
<i class="iconfont icon-material_prompt hover-tips hover-tips-upload-icon">
|
|
<i class="iconfont icon-material_prompt hover-tips hover-tips-upload-icon">
|
|
|
<div>
|
|
<div>
|
|
|
- <div class="remark">请上传120MB以内、jpg/png格式的图片</div>
|
|
|
|
|
|
|
+ <div class="remark">请上传10MB以内、jpg/png格式的图片</div>
|
|
|
</div>
|
|
</div>
|
|
|
</i>
|
|
</i>
|
|
|
<upload
|
|
<upload
|
|
@@ -59,7 +59,7 @@
|
|
|
{{ data.name }}
|
|
{{ data.name }}
|
|
|
</div>
|
|
</div>
|
|
|
<div slot-scope="{ data, item, sub }" slot="item" style="width: 100%">
|
|
<div slot-scope="{ data, item, sub }" slot="item" style="width: 100%">
|
|
|
- <div class="handle" v-if="sub.canclick">
|
|
|
|
|
|
|
+ <div v-if="sub.canclick" class="handle">
|
|
|
<i
|
|
<i
|
|
|
class="iconfont iconbs_list_edit hover-tips"
|
|
class="iconfont iconbs_list_edit hover-tips"
|
|
|
@click="(showRename = true), (popupItem = item)"
|
|
@click="(showRename = true), (popupItem = item)"
|
|
@@ -74,27 +74,26 @@
|
|
|
</div>
|
|
</div>
|
|
|
</i>
|
|
</i>
|
|
|
</div>
|
|
</div>
|
|
|
- <div class="img" v-else-if="sub.type == 'image'">
|
|
|
|
|
|
|
+ <div v-else-if="sub.type == 'image'" class="img">
|
|
|
<img
|
|
<img
|
|
|
:id="'img' + item.id"
|
|
:id="'img' + item.id"
|
|
|
- v-viewer
|
|
|
|
|
:src="data + `?${Math.random()}`"
|
|
:src="data + `?${Math.random()}`"
|
|
|
alt=""
|
|
alt=""
|
|
|
|
|
+ @click="previewImage(item)"
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
<span
|
|
<span
|
|
|
v-else
|
|
v-else
|
|
|
- @click="sub.fontweight && viewImg('img' + item.id)"
|
|
|
|
|
:style="{ fontWeight: sub.fontweight, color: '#202020' }"
|
|
:style="{ fontWeight: sub.fontweight, color: '#202020' }"
|
|
|
>{{ data || "-" }}</span
|
|
>{{ data || "-" }}</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="AUDIO" :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="" />
|
|
|
- <span>未搜索到结果</span>
|
|
|
|
|
|
|
+ <span>未搜索到结果~</span>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="nodata" v-if="list.length == 0 && !hasMoreData && !lastestUsedSearchKey">
|
|
<div class="nodata" v-if="list.length == 0 && !hasMoreData && !lastestUsedSearchKey">
|
|
|
<img :src="config.empty" alt="" />
|
|
<img :src="config.empty" alt="" />
|
|
@@ -110,9 +109,12 @@
|
|
|
@close="showRename = false"
|
|
@close="showRename = false"
|
|
|
/>
|
|
/>
|
|
|
<preview
|
|
<preview
|
|
|
- :item="popupItem"
|
|
|
|
|
- :show="showPreview"
|
|
|
|
|
- @close="showPreview = false"
|
|
|
|
|
|
|
+ ref="image-previewer"
|
|
|
|
|
+ :ifShow="showPreview"
|
|
|
|
|
+ :canFullScreen="false"
|
|
|
|
|
+ :imageList="list.map(item => item.icon)"
|
|
|
|
|
+ :imageTitleList="list.map(item => item.fileName)"
|
|
|
|
|
+ @click-delete="onClickDeleteInPreview"
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
@@ -126,8 +128,9 @@ import rename from "../popup/rename";
|
|
|
import UploadTaskList from "../components/uploadList1.1.0.vue";
|
|
import UploadTaskList from "../components/uploadList1.1.0.vue";
|
|
|
import Upload from "@/components/shared/uploads/UploadMultiple";
|
|
import Upload from "@/components/shared/uploads/UploadMultiple";
|
|
|
import { changeByteUnit } from "@/utils/file";
|
|
import { changeByteUnit } from "@/utils/file";
|
|
|
-import preview from "../popup/preview";
|
|
|
|
|
|
|
+import preview from "../popup/imagePreviewer.vue";
|
|
|
import { debounce } from "@/utils/other.js"
|
|
import { debounce } from "@/utils/other.js"
|
|
|
|
|
+import { mapState } from 'vuex';
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
|
getMaterialList,
|
|
getMaterialList,
|
|
@@ -149,7 +152,7 @@ export default {
|
|
|
},
|
|
},
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
- config,
|
|
|
|
|
|
|
+ config, // TODO: 没必要这么弄
|
|
|
showPreview: false,
|
|
showPreview: false,
|
|
|
showRename: false,
|
|
showRename: false,
|
|
|
showList: false,
|
|
showList: false,
|
|
@@ -170,10 +173,13 @@ export default {
|
|
|
list: [],
|
|
list: [],
|
|
|
hasMoreData: true,
|
|
hasMoreData: true,
|
|
|
isRequestingMoreData: false,
|
|
isRequestingMoreData: false,
|
|
|
- uploadTaskList: [],
|
|
|
|
|
- uploadHandlerList: [],
|
|
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
|
|
+ computed: {
|
|
|
|
|
+ ...mapState({
|
|
|
|
|
+ uploadListForUI: 'uploadStatusListImage',
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
mounted() {
|
|
mounted() {
|
|
|
},
|
|
},
|
|
|
watch: {
|
|
watch: {
|
|
@@ -197,10 +203,6 @@ export default {
|
|
|
this.hasMoreData = true
|
|
this.hasMoreData = true
|
|
|
this.$refs['table-list'].requestMoreData()
|
|
this.$refs['table-list'].requestMoreData()
|
|
|
}, 700, false),
|
|
}, 700, false),
|
|
|
- viewImg(id) {
|
|
|
|
|
- const viewer = this.$el.querySelector("#" + id).$viewer;
|
|
|
|
|
- viewer.show();
|
|
|
|
|
- },
|
|
|
|
|
handleRename(newName) {
|
|
handleRename(newName) {
|
|
|
editMaterial(
|
|
editMaterial(
|
|
|
{
|
|
{
|
|
@@ -268,9 +270,13 @@ export default {
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
|
|
+ previewImage(targetItem) {
|
|
|
|
|
+ const index = this.list.findIndex((eachItem) => {
|
|
|
|
|
+ return eachItem.id === targetItem.id
|
|
|
|
|
+ })
|
|
|
|
|
+ this.$refs['image-previewer'].show(index)
|
|
|
|
|
+ },
|
|
|
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 &&
|
|
@@ -296,65 +302,55 @@ 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,
|
|
|
};
|
|
};
|
|
|
- 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) => {
|
|
|
|
|
- this.uploadTaskList[index].status = 'SUCCESS'
|
|
|
|
|
- this.uploadTaskList[index].statusText = '素材上传成功'
|
|
|
|
|
- resolve(response);
|
|
|
|
|
- },
|
|
|
|
|
- (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,
|
|
|
|
|
+ },
|
|
|
|
|
+ () => { // 上传成功
|
|
|
|
|
+ const index = this.uploadListForUI.findIndex((eachItem) => {
|
|
|
|
|
+ eachItem.uid === itemInUploadList.uid
|
|
|
|
|
+ })
|
|
|
|
|
+ this.uploadListForUI.splice(index, 1)
|
|
|
|
|
+ this.refreshListDebounced()
|
|
|
|
|
+ },
|
|
|
|
|
+ (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(() => {
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- this.uploadTaskList = []
|
|
|
|
|
- this.uploadHandlerList = []
|
|
|
|
|
- this.refreshListDebounced()
|
|
|
|
|
- }, 1000);
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ (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() {
|
|
getMoreMaterialItem() {
|
|
|
this.isRequestingMoreData = true
|
|
this.isRequestingMoreData = true
|
|
@@ -384,6 +380,9 @@ export default {
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
},
|
|
},
|
|
|
|
|
+ onClickDeleteInPreview(index) {
|
|
|
|
|
+ this.del(this.list[index])
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
</script>
|
|
</script>
|