修改loading与上传文件逻辑

This commit is contained in:
zhujiyan
2024-09-11 20:17:38 +08:00
parent 79cb8a9897
commit d6a1b78b09
2 changed files with 58 additions and 57 deletions

View File

@@ -32,9 +32,8 @@
></el-input>
<el-button type="primary" @click="handleSearch" :icon="Search">搜索</el-button>
<el-button @click="handleRefresh" :icon="Refresh">重置</el-button>
<el-button @click="handleAddNewDir" type="primary" :icon="Plus">新建文件夹</el-button>
<el-upload
v-if="!progressVisibile"
v-if="!progressVisibile && activePath != '/'"
action=""
:auto-upload="false"
:show-file-list="false"
@@ -49,6 +48,9 @@
<el-icon class="el-icon--right"><Upload /></el-icon>
</el-button>
</el-upload>
<el-button @click="handleAddNewDir" v-if="activePath != '/'" type="primary" :icon="Plus">
新建文件夹
</el-button>
<div class="upload_progress" v-if="progressVisibile">
{{ fileName }}
<el-progress :percentage="30" :indeterminate="true">
@@ -62,28 +64,16 @@
<el-button v-if="item?.type == 'file'" size="small" @click="handleDownLoad(item)" circle>
<el-icon><Download /></el-icon>
</el-button>
<el-button v-if="activePath!='/'" type="danger" @click="handleDelDirOrFile(item)" size="small" circle>
<el-button
v-if="activePath != '/'"
type="danger"
@click="handleDelDirOrFile(item)"
size="small"
circle
>
<el-icon><Delete /></el-icon>
</el-button>
</div>
<!-- <div class="item_upload">
<el-upload
v-if="item?.type == 'dir'"
style="display: inline-block"
action=""
class="upload-demo"
:auto-upload="false"
:on-change="
(file:any, fileList:any) => {
handleUpload(file, fileList, item)
}
"
>
<el-button size="small" circle>
<el-icon><Upload /></el-icon>
</el-button>
</el-upload>
</div> -->
<img v-if="item?.type == 'dir'" @click="handleIntoDir(item)" src="@/assets/img/wenjianjia.svg" />
<img
class="img_file"
@@ -218,6 +208,7 @@ const handleSearch = () => {
const handleRefresh = () => {
filterFileName.value = ''
dirList.value = currentDirList.value
reloadCurrentMenu('')
}
//装置重启
const deviceRestartLoading = ref<boolean>(false)
@@ -310,29 +301,43 @@ const handleAddNewDir = () => {
form.value.path = ''
addDeviceDirOpen.value = true
}
//新建文件夹
const submitDeviceDir = () => {
let obj = {
nDid: nDid.value,
path: activePath.value == '/' ? activePath.value + form.value.path : activePath.value + '/' + form.value.path
}
loading.value=true
addDeviceDir(obj).then((res: any) => {
if (res.code == 'A0000') {
ElMessage.success(res.message)
getFileServiceFileOrDir({ nDid: nDid.value, name: activePath.value, type: 'dir' }).then((resp:any) => {
if (resp.code == 'A0000') {
dirList.value = resp.data
currentDirList.value = resp.data
activePathList.value.map((item: any, index: any) => {
if (item.path.includes(activePath.value) && item.path.length > activePath.value.length) {
activePathList.value.splice(index, 1)
}
})
loading.value = false
const formRef = ref()
//重新加载当前页面菜单
const reloadCurrentMenu = (msg: string) => {
getFileServiceFileOrDir({ nDid: nDid.value, name: activePath.value, type: 'dir' }).then((resp: any) => {
if (resp.code == 'A0000') {
dirList.value = resp.data
currentDirList.value = resp.data
activePathList.value.map((item: any, index: any) => {
if (item.path.includes(activePath.value) && item.path.length > activePath.value.length) {
activePathList.value.splice(index, 1)
}
})
loading.value = false
if (!msg) return
ElMessage.success(msg)
}
})
}
//新建文件夹
const submitDeviceDir = () => {
formRef.value.validate((valid: any) => {
if (valid) {
let obj = {
nDid: nDid.value,
path:
activePath.value == '/'
? activePath.value + form.value.path
: activePath.value + '/' + form.value.path
}
loading.value = true
addDeviceDir(obj).then((res: any) => {
if (res.code == 'A0000') {
reloadCurrentMenu(res.message)
// ElMessage.success(res.message)
addDeviceDirOpen.value = false
}
})
addDeviceDirOpen.value = false
}
})
}
@@ -341,19 +346,8 @@ const handleDelDirOrFile = (row: any) => {
loading.value = true
delDeviceDir({ nDid: nDid.value, path: row.prjDataPath }).then((res: any) => {
if (res.code == 'A0000') {
getFileServiceFileOrDir({ nDid: nDid.value, name: activePath.value, type: 'dir' }).then((resp:any) => {
if (resp.code == 'A0000') {
dirList.value = resp.data
currentDirList.value = resp.data
activePathList.value.map((item: any, index: any) => {
if (item.path.includes(activePath.value) && item.path.length > activePath.value.length) {
activePathList.value.splice(index, 1)
}
})
loading.value = false
ElMessage.success(res.message)
}
})
reloadCurrentMenu(res.message)
// ElMessage.success(res.message)
}
})
}
@@ -367,6 +361,7 @@ const handleDownLoad = async (row: any) => {
const progressVisibile = ref<boolean>(false)
const fileName = ref<string>('')
const handleUpload = (e: any, fileList: any, row: any) => {
// loading.value=true
fileName.value = e.name
const obj = {
id: nDid.value,
@@ -374,9 +369,9 @@ const handleUpload = (e: any, fileList: any, row: any) => {
filePath: row || row.prjDataPath
}
progressVisibile.value = true
uploadDeviceFile(obj).then(res => {
uploadDeviceFile(obj).then((res: any) => {
if (res.code == 'A0000') {
ElMessage.success(res.message)
reloadCurrentMenu(res.message)
progressVisibile.value = false
}
})
@@ -521,4 +516,8 @@ watch(
}
}
}
.el-form {
padding: 20px 10px;
box-sizing: border-box;
}
</style>