feat(FileUpload): 添加文件上传中的 loading 效果
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
<div style="margin-top:10px;margin-bottom: 8px;margin-left: 15px;display: flex">
|
<div style="margin-top:10px;margin-bottom: 8px;margin-left: 15px;display: flex">
|
||||||
<!-- <el-button color="#DED0B2" @click="handleUpload">上传附件</el-button>-->
|
<!-- <el-button color="#DED0B2" @click="handleUpload">上传附件</el-button>-->
|
||||||
<file-upload v-if="!isLineBtn&&uploadState&&activeName!='plus'&&activeName!='all'" @getFile="getFile"/>
|
<file-upload v-if="!isLineBtn&&uploadState&&activeName!='plus'&&activeName!='all'" @beforeUpload="beforeUpload" @getFile="getFile"/>
|
||||||
|
|
||||||
<el-button color="#DED0B2" @click="handleEditTag"
|
<el-button color="#DED0B2" @click="handleEditTag"
|
||||||
v-if="activeName!='all'&&activeName!='plus'&&uploadState&&!isDefault"
|
v-if="activeName!='all'&&activeName!='plus'&&uploadState&&!isDefault"
|
||||||
@@ -138,7 +138,7 @@ const executeTableConfig = reactive({
|
|||||||
<div>
|
<div>
|
||||||
<el-button type="primary" link onClick={() => handleDownload(row)}>下载</el-button>
|
<el-button type="primary" link onClick={() => handleDownload(row)}>下载</el-button>
|
||||||
{
|
{
|
||||||
uploadState.value ?
|
uploadState.value ?
|
||||||
<popover-delete name={row.originalFileName} type={'文件'} btnType={'danger'}
|
<popover-delete name={row.originalFileName} type={'文件'} btnType={'danger'}
|
||||||
onDelete={() => deleteSingleFile(row)}/> : ''
|
onDelete={() => deleteSingleFile(row)}/> : ''
|
||||||
}
|
}
|
||||||
@@ -157,6 +157,7 @@ const filePreviewParam = ref({
|
|||||||
fileType: 'pdf'
|
fileType: 'pdf'
|
||||||
})
|
})
|
||||||
const filePreviewShow = ref(false)
|
const filePreviewShow = ref(false)
|
||||||
|
const uploadLoading = ref(false)
|
||||||
const isEdit = ref(false)
|
const isEdit = ref(false)
|
||||||
const isCloseByList = (index) => {
|
const isCloseByList = (index) => {
|
||||||
// otherAttachmentList.length>0?false:true
|
// otherAttachmentList.length>0?false:true
|
||||||
@@ -173,24 +174,24 @@ const handleDownload = (row) => {
|
|||||||
}
|
}
|
||||||
const deleteSingleFile = (row) => {
|
const deleteSingleFile = (row) => {
|
||||||
console.log("🚀 ~ file: ", row)
|
console.log("🚀 ~ file: ", row)
|
||||||
deleteFile(row.fileId).then(res => {
|
deleteFile(row.fileId).then(res => {
|
||||||
ElNotification({
|
ElNotification({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
message: res.msg,
|
message: res.msg,
|
||||||
type: res.code === 1000 ? 'success' : 'error'
|
type: res.code === 1000 ? 'success' : 'error'
|
||||||
})
|
})
|
||||||
if (res.code === 1000) {
|
if (res.code === 1000) {
|
||||||
if (row.newFile) {
|
if (row.newFile) {
|
||||||
const finalList = getLocalList().filter(item => item.fileId !== row.fileId);
|
const finalList = getLocalList().filter(item => item.fileId !== row.fileId);
|
||||||
localStorage.setItem(`implementAllFileList-${route.query.projectId}`, JSON.stringify(finalList))
|
localStorage.setItem(`implementAllFileList-${route.query.projectId}`, JSON.stringify(finalList))
|
||||||
}else{
|
} else {
|
||||||
otherAttachmentList.value.splice(otherAttachmentList.value.findIndex((item) => item.fileId === row.fileId), 1);
|
otherAttachmentList.value.splice(otherAttachmentList.value.findIndex((item) => item.fileId === row.fileId), 1);
|
||||||
}
|
|
||||||
|
|
||||||
getAttachmentList()
|
|
||||||
activeName.value = 'all'
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
getAttachmentList()
|
||||||
|
activeName.value = 'all'
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeTag = async () => {
|
const changeTag = async () => {
|
||||||
@@ -266,7 +267,7 @@ const getTagName = (name) => {
|
|||||||
}
|
}
|
||||||
return tagName
|
return tagName
|
||||||
}
|
}
|
||||||
const handleTabClick = (item) => {
|
const handleTabClick = (item, e) => {
|
||||||
const defaultArray = tagsOption.value.filter(item1 => item1.tagId == item.props.name)
|
const defaultArray = tagsOption.value.filter(item1 => item1.tagId == item.props.name)
|
||||||
if (defaultArray && defaultArray.length > 0) {
|
if (defaultArray && defaultArray.length > 0) {
|
||||||
isDefault.value = defaultArray[0].isDefault == 1
|
isDefault.value = defaultArray[0].isDefault == 1
|
||||||
@@ -306,14 +307,21 @@ const compositeParam = (item) => {
|
|||||||
tag: getTagName(activeName.value) || '项目实施',
|
tag: getTagName(activeName.value) || '项目实施',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const beforeUpload=()=>{
|
||||||
|
// uploadLoading.value= ElLoading.service({fullscreen: true})
|
||||||
|
}
|
||||||
const getFile = (val) => {
|
const getFile = (val) => {
|
||||||
|
|
||||||
console.log('上传文件', val)
|
console.log('上传文件', val)
|
||||||
fileList.value=getLocalList()
|
fileList.value = getLocalList()
|
||||||
let fileObj = compositeParam(val)
|
let fileObj = compositeParam(val)
|
||||||
fileList.value.push(fileObj)
|
fileList.value.push(fileObj)
|
||||||
localStorage.setItem(`implementAllFileList-${route.query.projectId}`, JSON.stringify(fileList.value))
|
localStorage.setItem(`implementAllFileList-${route.query.projectId}`, JSON.stringify(fileList.value))
|
||||||
otherAttachmentList.value.push(fileObj)
|
otherAttachmentList.value.push(fileObj)
|
||||||
// handleSubmit([fileObj])
|
// handleSubmit([fileObj])
|
||||||
|
// nextTick(() => {
|
||||||
|
// uploadLoading.value.close()
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
@@ -372,6 +380,8 @@ const changeFileList = (tag, flag) => {
|
|||||||
// targetId: route.query.projectId,
|
// targetId: route.query.projectId,
|
||||||
// targetState: "30",
|
// targetState: "30",
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
otherAttachmentList.value = [...otherAttachmentList.value, ...getLocalList()];
|
||||||
} else {
|
} else {
|
||||||
const filw = getLocalList().filter(item1 => item1.tag === tag);
|
const filw = getLocalList().filter(item1 => item1.tag === tag);
|
||||||
const filteredAllFiles = allFiles.value.filter(item1 => item1.tag === tag);
|
const filteredAllFiles = allFiles.value.filter(item1 => item1.tag === tag);
|
||||||
|
|||||||
@@ -19,8 +19,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ElMessageBox, ElNotification} from "element-plus";
|
import {ElLoading, ElMessageBox, ElNotification} from "element-plus";
|
||||||
import {getToken} from '@/utils/auth'
|
import {getToken} from '@/utils/auth'
|
||||||
|
import {nextTick} from "vue";
|
||||||
|
|
||||||
const baseURL = import.meta.env.VITE_BASE_URL
|
const baseURL = import.meta.env.VITE_BASE_URL
|
||||||
const uploadFileUrl = ref(baseURL + "/workflow/process/file/upload")
|
const uploadFileUrl = ref(baseURL + "/workflow/process/file/upload")
|
||||||
@@ -55,7 +56,7 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(["input", "getFile", "delete"])
|
const emit = defineEmits(["input", "beforeUpload","getFile", "delete"])
|
||||||
const fileList = ref([])
|
const fileList = ref([])
|
||||||
const _value = computed({
|
const _value = computed({
|
||||||
get() {
|
get() {
|
||||||
@@ -73,11 +74,16 @@ const beforeRemove = (file) => {
|
|||||||
}).then(() => true)
|
}).then(() => true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const uploadLoading = ref(false)
|
||||||
const handleRemove = (file) => {
|
const handleRemove = (file) => {
|
||||||
emit("delete", file.response.data.id)
|
emit("delete", file.response.data.id)
|
||||||
}
|
}
|
||||||
const beforeUpload = () => {
|
const beforeUpload = () => {
|
||||||
|
console.log("🚀 ~ file:'beforeUpload ")
|
||||||
|
|
||||||
|
uploadLoading.value= ElLoading.service({fullscreen: true})
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
// emit("beforeUpload")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
const handleUploadSuccess = (res) => {
|
const handleUploadSuccess = (res) => {
|
||||||
@@ -91,6 +97,10 @@ const handleUploadSuccess = (res) => {
|
|||||||
let data = res.data
|
let data = res.data
|
||||||
fileList.value.push(data)
|
fileList.value.push(data)
|
||||||
emit("getFile", res.data)
|
emit("getFile", res.data)
|
||||||
|
nextTick(() => {
|
||||||
|
uploadLoading.value.close()
|
||||||
|
uploadLoading.value=null
|
||||||
|
})
|
||||||
}
|
}
|
||||||
const uploadError = () => {
|
const uploadError = () => {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
|||||||
Reference in New Issue
Block a user