diff --git a/src/views/govern/device/fileService/index.vue b/src/views/govern/device/fileService/index.vue index 5ebabaa..a2b2625 100644 --- a/src/views/govern/device/fileService/index.vue +++ b/src/views/govern/device/fileService/index.vue @@ -7,11 +7,13 @@
- + 搜索 重置 - + " + > 文件上传 @@ -51,8 +64,13 @@
- + @@ -62,32 +80,21 @@ - -
- + 暂无数据

{{ item && - item?.prjDataPath && - item?.prjDataPath.includes(activePath) && - item?.prjDataPath.length > activePath.length + item?.prjDataPath && + item?.prjDataPath.includes(activePath) && + item?.prjDataPath.length > activePath.length ? item?.prjDataPath.replace(activePath, ' ').replace('/', ' ') : item?.prjDataPath.replace('/', ' ') }} @@ -97,9 +104,18 @@

- - + + @@ -159,9 +175,7 @@ const activePath = ref('') //判断是否是根目录 const isRoot = ref(true) //储存所有点击过的目录 -const activePathList: any = ref([ - -]) +const activePathList: any = ref([]) const nodeClick = (e: any) => { if (e.level == 2) { loading.value = true @@ -184,51 +198,48 @@ const nodeClick = (e: any) => { } } //搜索文件或文件夹 -const filterFileName = ref('') +const filterText = ref('') const handleSearch = () => { let filterList: any = [] dirList.value = currentDirList.value dirList.value.map(item => { - if (filterFileName.value && item.prjDataPath.includes(filterFileName.value)) { + if (filterText.value && item.prjDataPath.includes(filterText.value)) { filterList.push(item) } }) if (filterList.length != 0) { dirList.value = filterList } - if (!filterFileName) { + if (filterList.length == 0) { + dirList.value = [] + } + if (!filterText.value) { dirList.value = currentDirList.value } } //重置搜索 const handleRefresh = () => { loading.value = true - filterFileName.value = '' + filterText.value = '' dirList.value = currentDirList.value reloadCurrentMenu('') } - const reboot: any = ref('') const vNode = () => { return h('div', {}, [ - - h(ElInput, { modelValue: reboot.value, 'onUpdate:modelValue': ($event: any) => { - reboot.value = $event; + reboot.value = $event }, placeholder: '请输入姓名', type: 'password', - autocomplete: "off", + autocomplete: 'off', class: 'displayPass' - }), - - ]); -}; - - + }) + ]) +} //装置重启 const deviceRestartLoading = ref(false) @@ -238,10 +249,7 @@ const handleRestartDevice = () => { confirmButtonText: '确认', cancelButtonText: '取消', customClass: 'customInput', - inputType: 'text', - - - + inputType: 'text' }) .then(({ value }) => { if (!value) { @@ -256,6 +264,8 @@ const handleRestartDevice = () => { if (res.code == 'A0000') { deviceRestartLoading.value = false ElMessage({ message: res.message, type: 'success', duration: 5000 }) + }else{ + deviceRestartLoading.value = false } }) } @@ -287,20 +297,21 @@ const handleIntoDir = (row: any) => { if (activePathList.value.indexOf(obj.name) == -1) { activePathList.value.push({ path: obj.name }) } - 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) - } + 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) + } + }) + isRoot.value = false + }) + .catch(e => { + loading.value = false }) - isRoot.value = false - }).catch(e => { - loading.value = false - }) - } //处理导航栏路径 @@ -318,7 +329,6 @@ const outPutPath = (row: any, key: any) => { } if (row.path.split('/').length !== 0) { path = '/' + row.path.split('/')[row.path.split('/').length - 1] - } } return path.split('/')[1] @@ -333,18 +343,19 @@ const handleIntoByPath = async (val: any) => { } activePath.value = val.path loading.value = true - getFileServiceFileOrDir(obj).then(res => { - dirList.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) - } + getFileServiceFileOrDir(obj) + .then(res => { + dirList.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) + } + }) + loading.value = false + }) + .catch(e => { + loading.value = false }) - loading.value = false - }).catch(e => { - loading.value = false - }) - } const form = ref({ path: '' @@ -363,28 +374,25 @@ const formRef = ref() //重新加载当前页面菜单 const reloadCurrentMenu = (msg: string) => { loading.value = true - getFileServiceFileOrDir({ nDid: nDid.value, name: activePath.value, type: 'dir' }).then((resp: any) => { - if (resp.code == 'A0000') { + getFileServiceFileOrDir({ nDid: nDid.value, name: activePath.value, type: 'dir' }) + .then((resp: any) => { + if (resp.code == 'A0000') { + loading.value = false + 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({ message: msg, type: 'success', duration: 5000 }) + } + }) + .catch(e => { loading.value = false - 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({ message: msg, type: 'success', duration: 5000 }) - - - } - }).catch(e => { - loading.value = false - }) - // setTimeout(() => { - // loading.value = false - // },0) + }) } //新建文件夹 const submitDeviceDir = () => { @@ -410,7 +418,6 @@ const submitDeviceDir = () => { } //删除文件夹或文件 const handleDelDirOrFile = (row: any) => { - // delDeviceDir({ nDid: nDid.value, path: row.prjDataPath }).then((res: any) => { // if (res.code == 'A0000') { // reloadCurrentMenu(res.message) @@ -423,40 +430,36 @@ const handleDelDirOrFile = (row: any) => { cancelButtonText: '取消', customClass: 'customInput', inputType: 'text' + }).then(({ value }) => { + if (!value) { + ElMessage.warning('请输入密码') + } else { + loading.value = true + passwordConfirm(value) + .then((resp: any) => { + if (resp.code == 'A0000') { + delDeviceDir({ nDid: nDid.value, path: row.prjDataPath }).then((res: any) => { + if (res.code == 'A0000') { + reloadCurrentMenu(res.message) + + // ElMessage({ message: res.message, type: 'success', duration: 5000 }) + } + }) + } + }) + .catch(e => { + loading.value = false + }) + } }) - .then(({ value }) => { - if (!value) { - ElMessage.warning('请输入密码') - - } else { - loading.value = true - passwordConfirm(value) - .then((resp: any) => { - if (resp.code == 'A0000') { - delDeviceDir({ nDid: nDid.value, path: row.prjDataPath }).then((res: any) => { - if (res.code == 'A0000') { - - reloadCurrentMenu(res.message) - - // ElMessage({ message: res.message, type: 'success', duration: 5000 }) - } - }) - } - }) - .catch(e => { - loading.value = false - }) - } - }) - } const changeType = ref('') //下载文件 const fileRef = ref() const handleDownLoad = async (row: any) => { - ; (await nDid.value) && fileRef.value && fileRef.value.open(row, nDid.value) - fileName.value = row?.prjDataPath.split('/')[row?.prjDataPath.split('/').length - 1] - localStorage.setItem('fileName', fileName.value) + ;(await nDid.value) && fileRef.value && fileRef.value.open(row, nDid.value) + // fileName.value = row?.prjDataPath.split('/')[row?.prjDataPath.split('/').length - 1] + // localStorage.setItem('fileName', fileName.value) changeType.value = 'download' localStorage.setItem('changeType', changeType.value) } @@ -513,6 +516,7 @@ const connectMqtt = () => { username: 't_user', password: 'njcnpqs' } + // 线上 // const url = 'wss://pqmcn.com:8087/mqtt' const url = 'ws://192.168.1.24:8085/mqtt' mqttRef.value = mqtt.connect(url, options) @@ -525,15 +529,28 @@ mqttRef.value.on('connect', (e: any) => { mqttRef.value.subscribe('/Web/Progress/+') }) const mqttMessage = ref({}) -const status = ref() +const status: any = ref() + mqttRef.value.on('message', (topic: any, message: any) => { // console.log('🚀 ~ mqttRef.value.on ~ message:', JSON.parse(message)) + // console.log('mqtt接收到消息', message,topic) console.log('mqtt接收到消息', JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))) // "{allStep:\""+times+"\",nowStep:"+i+"}" let str = JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message)))) - mqttMessage.value = eval('(' + str + ')') + // eval('(' + str + ')').includes('fileName') + let regex = /fileName:(.*?),allStep/ + let regex1 = /allStep:(.*?),nowStep/ + let regex2 = /nowStep:(.*?)}/ + mqttMessage.value = { + fileName: str.match(regex)[1], + allStep: str.match(regex1)[1], + nowStep: str.match(regex2)[1] + } + console.log(mqttMessage.value, '?????????') status.value = parseInt(Number((mqttMessage.value.nowStep / mqttMessage.value.allStep) * 100)) - fileRef.value.setStatus(status.value) + fileRef.value.setStatus(mqttMessage.value) + fileName.value = mqttMessage.value.fileName + localStorage.setItem('fileName', fileName.value) if (status.value == 100) { status.value = 99 } @@ -711,7 +728,6 @@ onBeforeUnmount(() => { :deep(.el-breadcrumb__separator) { margin: 0px -10px 0px 0px; } - \ No newline at end of file + diff --git a/src/views/govern/device/fileService/popup.vue b/src/views/govern/device/fileService/popup.vue index 50e0891..ab03a42 100644 --- a/src/views/govern/device/fileService/popup.vue +++ b/src/views/govern/device/fileService/popup.vue @@ -6,9 +6,10 @@
正在下载: {{ - fileData?.prjDataPath - ? fileData?.prjDataPath.split('/')[fileData?.prjDataPath.split('/').length - 1] - : '/' + // fileData?.prjDataPath + // ? fileData?.prjDataPath.split('/')[fileData?.prjDataPath.split('/').length - 1] + // : '/' + fileName }}
@@ -125,8 +126,10 @@ const handleDownLoad = () => { onMounted(() => {}) onUnmounted(() => {}) const status = ref(0) +const fileName=ref('') const setStatus = (val: any) => { - status.value = val + status.value = parseInt(Number((val.nowStep / val.allStep) * 100)) + fileName.value = val.fileName } defineExpose({ open, setStatus })