离线数据上传关闭弹框清空上次上传的文件

This commit is contained in:
zhujiyan
2024-09-24 08:50:39 +08:00
parent d2e5743a2b
commit 34c38daf51

View File

@@ -1,6 +1,6 @@
<!-- 离线数据导入 --> <!-- 离线数据导入 -->
<template> <template>
<el-dialog v-model="dialogVisible" title="文件列表" width="70%" draggable> <el-dialog v-model="dialogVisible" title="文件列表" width="70%" :destroy-on-close="true" draggable @closed="close">
<!-- 上传文件列表 --> <!-- 上传文件列表 -->
<div class="offline_data"> <div class="offline_data">
<div class="offline_data_btn"> <div class="offline_data_btn">
@@ -34,7 +34,7 @@
上传离线数据 上传离线数据
</el-button> </el-button>
<div> <div>
<el-table :data="offLineFileList" style="width: 100%" height="280" border stripe :key="updateKey"> <el-table v-if="offLineFileList&&offLineFileList.length!=0" :data="offLineFileList" style="width: 100%" height="280" border stripe :key="updateKey">
<el-table-column prop="name" label="文件名" align="center"></el-table-column> <el-table-column prop="name" label="文件名" align="center"></el-table-column>
<el-table-column prop="webkitRelativePath" label="文件地址" align="center"></el-table-column> <el-table-column prop="webkitRelativePath" label="文件地址" align="center"></el-table-column>
<el-table-column prop="status" label="状态" align="center" width="250"> <el-table-column prop="status" label="状态" align="center" width="250">
@@ -87,7 +87,7 @@ const loading = ref(false)
const offLineFileList: any = ref([]) const offLineFileList: any = ref([])
const disableHandleUpload = ref(true) const disableHandleUpload = ref(true)
//上传离线数据 //上传离线数据
const submitUpload = e => { const submitUpload = (e:any) => {
const input = document.createElement('input') const input = document.createElement('input')
input.type = 'file' input.type = 'file'
input.setAttribute('allowdirs', 'true') input.setAttribute('allowdirs', 'true')
@@ -129,12 +129,9 @@ const handleUpload = () => {
const subForm = new FormData() const subForm = new FormData()
subForm.append('devId', deviceId.value) subForm.append('devId', deviceId.value)
subForm.append('lineId', lineId.value) subForm.append('lineId', lineId.value)
// subForm.append('files', offLineFileList.value)
let webkitRelativePathList: any = [] let webkitRelativePathList: any = []
offLineFileList.value.map((item: any, index: any) => { offLineFileList.value.map((item: any, index: any) => {
// obj.paths.push(item.webkitRelativePath)
subForm.append(`files[${index}]`, item) subForm.append(`files[${index}]`, item)
// subForm.append(`paths[${index}]`, item.webkitRelativePath)
webkitRelativePathList.push(item.webkitRelativePath) webkitRelativePathList.push(item.webkitRelativePath)
}) })
subForm.append('paths', webkitRelativePathList.join(',')) subForm.append('paths', webkitRelativePathList.join(','))
@@ -144,7 +141,6 @@ const handleUpload = () => {
// 操作数据后更新视图 // 操作数据后更新视图
updateKey.value += 1 updateKey.value += 1
disableHandleUpload.value = true disableHandleUpload.value = true
// return;
uploadOffLineDataFile(subForm).then(res => { uploadOffLineDataFile(subForm).then(res => {
if (res.code == 'A0000') { if (res.code == 'A0000') {
offLineFileList.value.map((item: any) => { offLineFileList.value.map((item: any) => {
@@ -165,6 +161,7 @@ const open = (devId: any, lineIds: any) => {
dialogVisible.value = true dialogVisible.value = true
} }
const close = () => { const close = () => {
offLineFileList.value=[]
dialogVisible.value = false dialogVisible.value = false
} }
defineExpose({ open }) defineExpose({ open })