添加日志功能
This commit is contained in:
@@ -6,15 +6,19 @@
|
||||
v-model:file-list="reportPath"
|
||||
ref="uploadRef"
|
||||
action=""
|
||||
accept=""
|
||||
:limit="1"
|
||||
accept=".xml"
|
||||
:on-exceed="handleExceed"
|
||||
:auto-upload="false"
|
||||
:on-remove="removeFile"
|
||||
:on-change="choose"
|
||||
>
|
||||
<template #trigger>
|
||||
<el-button type="primary">上传文件</el-button>
|
||||
</template>
|
||||
<template #tip>
|
||||
<div>请上传xml文件</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -64,9 +68,37 @@ const open = (text: string, data?: any) => {
|
||||
form.id = data?.id
|
||||
form.filePath = data?.path
|
||||
}
|
||||
// 上传报告
|
||||
const uploadRef = ref()
|
||||
/**
|
||||
* 选择待上传文件
|
||||
*/
|
||||
const choose = (e: any) => {
|
||||
const file = e.raw
|
||||
if (!isValidFile(file)) {
|
||||
uploadRef.value!.clearFiles()
|
||||
form.filePath = []
|
||||
return
|
||||
}
|
||||
form.filePath.file = file
|
||||
}
|
||||
/**
|
||||
* 文件校验函数
|
||||
*/
|
||||
const isValidFile = (file: UploadRawFile) => {
|
||||
const validExtensions = ['.xml']
|
||||
const fileExtension = file.name.slice(((file.name.lastIndexOf('.') - 1) >>> 0) + 2)
|
||||
if (!validExtensions.includes(`.${fileExtension}`)) {
|
||||
ElMessage.error('文件类型不支持,请选择 .xml')
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
// 上传报告
|
||||
|
||||
const handleExceed: UploadProps['onExceed'] = files => {
|
||||
console.log('🚀 ~ files:', files)
|
||||
|
||||
uploadRef.value!.clearFiles()
|
||||
const file = files[0] as UploadRawFile
|
||||
file.uid = genFileId()
|
||||
@@ -89,8 +121,8 @@ const submit = async () => {
|
||||
form.fileName = res.data.fileName.split('.')[0]
|
||||
form.filePath = res.data.name
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (title.value == '新增icd文件') {
|
||||
await addIcdPath(form).then(res => {
|
||||
ElMessage.success('新增成功!')
|
||||
|
||||
@@ -42,7 +42,7 @@ import TableStore from '@/utils/tableStore'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import taskForm from './form.vue'
|
||||
import { getFileNameAndFilePath } from '@/api/system-boot/file'
|
||||
import { downloadFile } from '@/api/system-boot/file'
|
||||
import { ElMessage, ElMessageBox, ElDatePicker } from 'element-plus'
|
||||
import { timerRun, runTimer, deleteTimer, stop, start } from '@/api/system-boot/csDictData'
|
||||
import { delIcdPath } from '@/api/device-boot/icd'
|
||||
@@ -59,7 +59,7 @@ const taskFormFlag = ref(false)
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/device-boot/icd/pageIcdList',
|
||||
method: 'POST',
|
||||
isWebPaging: true,
|
||||
// isWebPaging: true,
|
||||
column: [
|
||||
{
|
||||
title: '序号',
|
||||
@@ -100,13 +100,17 @@ const tableStore: any = new TableStore({
|
||||
icon: 'el-icon-EditPen',
|
||||
render: 'basicButton',
|
||||
click: async row => {
|
||||
getFileNameAndFilePath({ filePath: row.path }).then(res => {
|
||||
downloadFile({ filePath: row.path }).then(res => {
|
||||
let blob = new Blob([res], {
|
||||
type: 'application/xml'
|
||||
})
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = res.data.url
|
||||
link.download = res.data.name
|
||||
link.href = url
|
||||
link.download = row.name
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
link.remove()
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
@@ -60,7 +60,7 @@ const dialogVisible = ref(false)
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/device-boot/devType/pageDevTypeList',
|
||||
method: 'POST',
|
||||
isWebPaging: true,
|
||||
// isWebPaging: true,
|
||||
column: [
|
||||
{
|
||||
title: '序号',
|
||||
|
||||
Reference in New Issue
Block a user