修改loading与上传文件逻辑
This commit is contained in:
@@ -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,17 +301,10 @@ 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) => {
|
||||
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
|
||||
@@ -330,30 +314,40 @@ const submitDeviceDir = () => {
|
||||
}
|
||||
})
|
||||
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
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
//删除文件夹或文件
|
||||
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>
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user