设备监控二级页面
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<!-- 上传文件列表 -->
|
||||
<div class="offline_data">
|
||||
<div class="offline_data_btn">
|
||||
<el-button type="primary" @click="handleUpload" ize="small" :disabled="offLineFileList.length == 0">
|
||||
<el-button type="primary" @click="handleUpload" size="small" :disabled="offLineFileList.length == 0">
|
||||
开始上传
|
||||
</el-button>
|
||||
<el-button type="primary" @click="removeAllFile" size="small" :disabled="offLineFileList.length == 0">
|
||||
@@ -63,6 +63,7 @@ import JSZip from 'jszip'
|
||||
import { saveAs } from 'file-saver'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import { uploadOffLineDataFile } from '@/api/cs-device-boot/EquipmentDelivery.ts'
|
||||
import { off } from 'process'
|
||||
const dialogVisible = ref(false)
|
||||
const selectedFile = ref(null)
|
||||
|
||||
@@ -148,32 +149,11 @@ const submitUpload = e => {
|
||||
input.multiple = true
|
||||
document.querySelector('body').appendChild(input)
|
||||
// todo 这里增加了input标签,可以给它删掉
|
||||
|
||||
input.click()
|
||||
|
||||
// 覆盖原生的 alert 函数
|
||||
// window.alert = function (message) {
|
||||
// console.log(message) // 可以在这里处理消息或者什么都不做
|
||||
// }
|
||||
|
||||
// // 覆盖原生的 confirm 函数
|
||||
// window.confirm = function (message) {
|
||||
// console.log(message) // 可以在这里处理消息或者返回 true 或 false
|
||||
// return false // 始终返回 false 来模拟用户点击“取消”
|
||||
// }
|
||||
|
||||
// // 覆盖原生的 prompt 函数
|
||||
// window.prompt = function (message, defaultValue) {
|
||||
// console.log(message, defaultValue) // 可以在这里处理消息和默认值
|
||||
// return null // 始终返回 null 来模拟用户点击“取消”
|
||||
// }
|
||||
input.onclick = function (e) {
|
||||
console.log(e)
|
||||
e.preventDefault()
|
||||
}
|
||||
input.onchange = async function (e) {
|
||||
input.onchange = function (e) {
|
||||
const formData = new FormData()
|
||||
e.preventDefault()
|
||||
|
||||
// e.preventDefault()
|
||||
const file = e.target['files']
|
||||
for (let i = 0; i < file.length; i++) {
|
||||
formData.append('files', file[i])
|
||||
@@ -187,11 +167,6 @@ const submitUpload = e => {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const previewFile = (file: any) => {
|
||||
// 这里可以实现文件预览逻辑,例如图片预览等
|
||||
console.log('预览文件:', file.name)
|
||||
}
|
||||
//清空文件
|
||||
const removeAllFile = () => {
|
||||
offLineFileList.value = []
|
||||
@@ -224,20 +199,41 @@ const removeFile = async (file: any) => {
|
||||
saveAs(newZipContent, '5555.zip')
|
||||
}
|
||||
//开始上传
|
||||
const handleUpload = () => {
|
||||
return
|
||||
const obj={
|
||||
devId:'',//设备id
|
||||
lineId:'',//监测点id
|
||||
files:'',//上传文件集
|
||||
paths:''//上传文件路径集
|
||||
const handleUpload = async () => {
|
||||
// return
|
||||
console.log(offLineFileList.value, '000000000')
|
||||
const subForm = new FormData()
|
||||
let obj = {
|
||||
devId: deviceId.value, //设备id
|
||||
lineId: lineId.value, //监测点id
|
||||
files: offLineFileList.value, //上传文件集
|
||||
paths: offLineFileList.value //上传文件路径集
|
||||
}
|
||||
uploadOffLineDataFile(obj).then(res => {
|
||||
if (res.code == 'A0009') {
|
||||
subForm.append('devId', deviceId.value)
|
||||
subForm.append('lineId', lineId.value)
|
||||
// subForm.append('files', offLineFileList.value)
|
||||
let webkitRelativePathList: any = []
|
||||
offLineFileList.value.map((item: any, index: any) => {
|
||||
console.log(item)
|
||||
// obj.paths.push(item.webkitRelativePath)
|
||||
subForm.append(`files[${index}]`, item)
|
||||
// subForm.append(`paths[${index}]`, item.webkitRelativePath)
|
||||
webkitRelativePathList.push(item.webkitRelativePath)
|
||||
})
|
||||
console.log(subForm.getAll('files'), subForm)
|
||||
subForm.append('paths', webkitRelativePathList.join(','))
|
||||
// return;
|
||||
await uploadOffLineDataFile(subForm).then(res => {
|
||||
if (res.code == 'A0000') {
|
||||
console.log(res, '0999999999状态吗')
|
||||
}
|
||||
})
|
||||
}
|
||||
const open = () => {
|
||||
const deviceId: any = ref()
|
||||
const lineId: any = ref()
|
||||
const open = (devId: any, lineIds: any) => {
|
||||
deviceId.value = devId
|
||||
lineId.value = lineIds
|
||||
dialogVisible.value = true
|
||||
}
|
||||
const close = () => {
|
||||
@@ -252,7 +248,6 @@ defineExpose({ open })
|
||||
.offline_data {
|
||||
width: 100%;
|
||||
height: 400px;
|
||||
border: 2px solid red;
|
||||
.offline_data_btn {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
|
||||
Reference in New Issue
Block a user