From d6a1b78b091763ab01b5d338d501ab545f2c73df Mon Sep 17 00:00:00 2001 From: zhujiyan <17812234322@163.com> Date: Wed, 11 Sep 2024 20:17:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9loading=E4=B8=8E=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E6=96=87=E4=BB=B6=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/govern/device/fileService/index.vue | 113 +++++++++--------- src/views/govern/device/fileService/popup.vue | 2 + 2 files changed, 58 insertions(+), 57 deletions(-) diff --git a/src/views/govern/device/fileService/index.vue b/src/views/govern/device/fileService/index.vue index ace08c6..0f79e47 100644 --- a/src/views/govern/device/fileService/index.vue +++ b/src/views/govern/device/fileService/index.vue @@ -32,9 +32,8 @@ > 搜索 重置 - 新建文件夹 + + 新建文件夹 +
{{ fileName }} @@ -62,28 +64,16 @@ - +
- { const handleRefresh = () => { filterFileName.value = '' dirList.value = currentDirList.value + reloadCurrentMenu('') } //装置重启 const deviceRestartLoading = ref(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(false) const fileName = ref('') 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; +} diff --git a/src/views/govern/device/fileService/popup.vue b/src/views/govern/device/fileService/popup.vue index ab5a998..bedd9bd 100644 --- a/src/views/govern/device/fileService/popup.vue +++ b/src/views/govern/device/fileService/popup.vue @@ -87,7 +87,9 @@ const handleDownLoad = () => { ? fileData.value?.prjDataPath.split('/')[fileData.value?.prjDataPath.split('/').length - 1] : '/' document.body.appendChild(link) + downLoading.value = false link.click() + ElMessage.success('文件下载成功') link.remove() } else { console.log(6666)