From 40c909ea61e38f368722227b44c2cbea04b68201 Mon Sep 17 00:00:00 2001 From: zhujiyan <17812234322@163.com> Date: Mon, 2 Sep 2024 18:19:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/govern/device/fileService/index.vue | 127 +++++++++++++++--- src/views/govern/device/fileService/popup.vue | 28 ++-- 2 files changed, 122 insertions(+), 33 deletions(-) diff --git a/src/views/govern/device/fileService/index.vue b/src/views/govern/device/fileService/index.vue index efc223c..da13c1c 100644 --- a/src/views/govern/device/fileService/index.vue +++ b/src/views/govern/device/fileService/index.vue @@ -17,15 +17,49 @@ +
+ + 搜索 + 重置 +
-
+
- - + +
- - +
+ + + + + +
+ + 暂无内容

{{ @@ -49,8 +83,13 @@ import DeviceTree from '@/components/tree/govern/deviceTree.vue' import { mainHeight } from '@/utils/layout' import { ref, reactive, watch } from 'vue' import { ElMessage } from 'element-plus' -import { ArrowLeft, ArrowRight, Download } from '@element-plus/icons-vue' -import { getDeviceRootPath, getFileServiceFileOrDir, downLoadDeviceFile,uploadDeviceFile } from '@/api/cs-device-boot/fileService.ts' +import { ArrowLeft, ArrowRight, Download, Upload } from '@element-plus/icons-vue' +import { + getDeviceRootPath, + getFileServiceFileOrDir, + downLoadDeviceFile, + uploadDeviceFile +} from '@/api/cs-device-boot/fileService.ts' import popup from './popup.vue' defineOptions({ name: 'govern/device/fileService' @@ -81,11 +120,34 @@ const nodeClick = (e: any) => { }) } } - +//搜索文件或文件夹 +const filterFileName = ref('') +const handleSearch = () => { + let filterList = [] + dirList.value = currentDirList.value + dirList.value.map(item => { + if (filterFileName.value && item.prjDataPath.includes(filterFileName.value)) { + filterList.push(item) + } + }) + if (filterList.length != 0) { + dirList.value = filterList + } + if (!filterFileName) { + dirList.value = currentDirList.value + } +} +//重置搜索 +const handleRefresh = () => { + filterFileName.value = '' + dirList.value = currentDirList.value +} // 进入文件夹 const dirList = ref([]) +// 村村当前目录数据 +const currentDirList = ref([]) const handleIntoDir = (row: any) => { - if (!row.type||row.type == 'file') return + if (!row.type || row.type == 'file') return loading.value = true const obj = { nDid: nDid.value, @@ -100,6 +162,7 @@ const handleIntoDir = (row: any) => { getFileServiceFileOrDir(obj).then(res => { dirList.value = res.data loading.value = false + currentDirList.value = res.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) @@ -109,15 +172,13 @@ const handleIntoDir = (row: any) => { } //上传文件 -const uploadFile=(file:any)=>{ - const obj={ - id:nDid.value, - file:file, - filePath:'/' +const uploadFile = (file: any) => { + const obj = { + id: nDid.value, + file: file, + filePath: '/' } - uploadDeviceFile().then((res)=>{ - - }) + uploadDeviceFile().then(res => {}) } //根据面包屑导航切换 @@ -141,7 +202,22 @@ const handleIntoByPath = async (val: any) => { //下载文件 const fileRef = ref() const handleDownLoad = async (row: any) => { - await fileRef.value && fileRef.value.open(row, nDid.value) + ;(await nDid.value) && fileRef.value && fileRef.value.open(row, nDid.value) +} +//上传文件 +const handleUpload = (e: any, fileList: any, row: any) => { + console.log(e, fileList, row) + const obj = { + id: nDid.value, + file: e.raw, + filePath: row.prjDataPath + } + uploadDeviceFile(obj).then(res => { + console.log(res, '上传文件毁掉') + if (res.code == 'A0000') { + ElMessage.success(res.message) + } + }) } watch( () => activePathList.value, @@ -191,12 +267,22 @@ watch( cursor: pointer; } } + .filter { + width: 100%; + height: 30px; + display: flex; + margin-top: 10px; + justify-content: flex-start; + .el-button { + margin-left: 10px; + } + } .list { display: flex; flex-wrap: wrap; align-items: flex-start; overflow-y: auto; - margin-top: 20px; + margin-top: 10px; height: 100%; padding-bottom: 200px; z-index: 100; @@ -214,7 +300,8 @@ watch( cursor: pointer; position: relative; z-index: 1001 !important; - .item_download { + .item_download, + .item_upload { position: absolute; top: 10px; right: 10px; diff --git a/src/views/govern/device/fileService/popup.vue b/src/views/govern/device/fileService/popup.vue index 7c7d2b8..1d2c77d 100644 --- a/src/views/govern/device/fileService/popup.vue +++ b/src/views/govern/device/fileService/popup.vue @@ -39,15 +39,15 @@ const handleClose = () => { } //文件信息 const fileData: any = ref({}) -const open = (row: any, id: any) => { +const open = async (row: any, id: any) => { dialogVisible.value = true + loading.value = true const obj = { nDid: id, name: row.prjDataPath, type: row.type } - loading.value = true - getFileServiceFileOrDir(obj).then(res => { + await getFileServiceFileOrDir(obj).then(res => { if (res.code == 'A0000') { fileData.value = res.data[0] fileData.value.nDid = id @@ -63,16 +63,18 @@ const handleDownLoad = () => { fileCheck: fileData.value.fileCheck } downLoading.value = true - downLoadDeviceFile(obj).then(res => { - if (res.code == 'A0000') { - window.open(res.data, '_blank') - downLoading.value = false - } - }).catch((e)=>{ - if(e){ - downLoading.value=false; - } - }) + downLoadDeviceFile(obj) + .then(res => { + if (res.code == 'A0000') { + window.open(res.data, '_blank') + downLoading.value = false + } + }) + .catch(e => { + if (e) { + downLoading.value = false + } + }) } onMounted(() => {}) onUnmounted(() => {})