修改测试bug

This commit is contained in:
GGJ
2024-12-09 16:30:40 +08:00
parent 2ed728ee71
commit 22d85dfca1
30 changed files with 499 additions and 221 deletions

View File

@@ -1,66 +1,93 @@
<!-- 离线数据导入 -->
<template>
<el-dialog v-model="dialogVisible" title="文件列表" width="70%" :destroy-on-close="true" draggable @closed="close">
<!-- 上传文件列表 -->
<div class="offline_data">
<div class="offline_data_btn">
<!-- <el-dialog v-model="dialogVisible" title="文件列表" width="70%" :destroy-on-close="true" draggable @closed="close"> -->
<!-- 上传文件列表 -->
<div class=" ">
<!-- <div class="offline_data_btn">
<el-button :loading="loading" style="margin-left: 10px" type="primary" @click="submitUpload">
上传离线数据
</el-button>
<el-button type="primary" @click="removeAllFile" :loading="loading"
:disabled="offLineFileList.length == 0">
重置上传文件
</el-button>
</div>
<div :style="tableHeight">
<vxe-table border auto-resize height="auto" :data="offLineFileList" v-bind="defaultAttribute"
:key="updateKey">
<vxe-column field="name" align="center" title="文件名"></vxe-column>
<vxe-column field="webkitRelativePath" align="center" title="文件地址"></vxe-column>
<vxe-column field="status" align="center" title="状态" width="250">
<template v-slot:default="scoped">
<el-progress v-if="scoped.row.status == 0" :percentage="0">
<el-button text>等待上传</el-button>
</el-progress>
<el-progress v-if="scoped.row.status == -1" :percentage="30" :indeterminate="true">
<el-button text>上传中...</el-button>
</el-progress>
<el-progress v-if="scoped.row.status == 1" status="success" :percentage="100">
<el-button text>上传成功</el-button>
</el-progress>
</template>
</vxe-column>
<vxe-column title="操作" width="200px">
<template v-slot:default="scoped">
<el-button link type="danger" @click="removeFile(scoped.row)">移除</el-button>
</template>
</vxe-column>
</vxe-table>
</div>
<el-button type="primary" @click="handleUpload" :loading="loading"
:disabled="offLineFileList.length == 0 || disableHandleUpload">
开始上传
</el-button>
</div> -->
<TableHeader ref="refheader" :showSearch="false">
<template #operation>
<el-button :loading="loading" style="margin-left: 10px" type="primary" @click="submitUpload">
上传离线数据
</el-button>
<el-button type="primary" @click="removeAllFile" :loading="loading"
:disabled="offLineFileList.length == 0">
重置上传文件
</el-button>
<el-button type="primary" @click="handleUpload" :loading="loading"
:disabled="offLineFileList.length == 0 || disableHandleUpload">
开始上传
</el-button>
<el-button :icon="Back" @click="go(-1)">返回</el-button>
</template>
</TableHeader>
<div :style="tableHeight">
<vxe-table border auto-resize height="auto" :data="offLineFileList" v-bind="defaultAttribute"
:key="updateKey">
<vxe-column field="name" align="center" title="文件名"></vxe-column>
<vxe-column field="webkitRelativePath" align="center" title="文件地址"></vxe-column>
<vxe-column field="status" align="center" title="状态" width="300">
<template v-slot:default="scoped">
<el-progress v-if="scoped.row.status == 0" :percentage="0">
<el-button text>等待上传</el-button>
</el-progress>
<el-progress v-if="scoped.row.status == -1" :percentage="30" :indeterminate="true">
<el-button text>上传中...</el-button>
</el-progress>
<el-progress v-if="scoped.row.status == 1" status="success" :percentage="100">
<el-button text>上传成功</el-button>
</el-progress>
</template>
</vxe-column>
<vxe-column title="操作" width="200px">
<template v-slot:default="scoped">
<el-button link type="danger" @click="removeFile(scoped.row)">移除</el-button>
</template>
</vxe-column>
</vxe-table>
</div>
<template #footer>
</div>
<!-- <template #footer>
<div class="dialog-footer">
<!-- <el-button @click="close">取消</el-button> -->
<!-- <el-button type="primary" @click="close">确定</el-button> -->
<el-button type="primary" @click="handleUpload" :loading="loading"
:disabled="offLineFileList.length == 0 || disableHandleUpload">
开始上传
</el-button>
</div>
</template>
</el-dialog>
</template> -->
<!-- </el-dialog> -->
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import TableHeader from '@/components/table/header/index.vue'
import { uploadOffLineDataFile } from '@/api/cs-device-boot/EquipmentDelivery.ts'
import { defaultAttribute } from '@/components/table/defaultAttribute'
import {Back} from '@element-plus/icons-vue'
import { mainHeight } from '@/utils/layout'
import { useRouter, useRoute } from 'vue-router'
const { go } = useRouter() // 路由
const routes = useRoute()
const dialogVisible = ref(false)
const loading = ref(false)
const offLineFileList: any = ref([])
const disableHandleUpload = ref(true)
const tableHeight = mainHeight(550)
const tableHeight = mainHeight(85)
//上传离线数据
const submitUpload = (e: any) => {
const input = document.createElement('input')
@@ -102,8 +129,8 @@ const updateKey = ref(0)
const handleUpload = () => {
loading.value = true
const subForm = new FormData()
subForm.append('devId', deviceId.value)
subForm.append('lineId', lineId.value)
subForm.append('devId', routes.query.deviceId)
subForm.append('lineId', routes.query.lineId)
let webkitRelativePathList: any = []
offLineFileList.value.map((item: any, index: any) => {
subForm.append(`files[${index}]`, item)
@@ -126,22 +153,22 @@ const handleUpload = () => {
loading.value = false
disableHandleUpload.value = true
}
}).catch(()=>{
}).catch(() => {
loading.value = false
disableHandleUpload.value = false
offLineFileList.value.map((item: any) => {
item.status = 0
item.status = 0
})
updateKey.value += 1
})
}
const deviceId: any = ref()
const lineId: any = ref()
const open = (devId: any, lineIds: any) => {
deviceId.value = devId
lineId.value = lineIds
dialogVisible.value = true
}
// 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 = () => {
offLineFileList.value = []
dialogVisible.value = false
@@ -160,4 +187,7 @@ defineExpose({ open })
justify-content: flex-end;
}
}
</style>
// .device {
// height: calc(100vh - 130px);
// }</style>