绘制并联调icd文件管理页面
绘制并联调终端型号管理页面
This commit is contained in:
@@ -1,27 +1,9 @@
|
||||
<template>
|
||||
<el-dialog draggable width="600px" v-model="dialogVisible" :title="title">
|
||||
<el-dialog draggable width="400px" v-model="dialogVisible" :title="title">
|
||||
<el-form :inline="false" :model="form" label-width="auto" class="form-one" :rules="rules" ref="formRef">
|
||||
<el-form-item label="文件名称" prop="name">
|
||||
<el-input
|
||||
v-model.trim="form.name"
|
||||
clearable
|
||||
maxlength="32"
|
||||
show-word-limit
|
||||
placeholder="请输入icd文件名称"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="存储的地址" prop="path">
|
||||
<el-input
|
||||
v-model.trim="form.path"
|
||||
clearable
|
||||
maxlength="32"
|
||||
show-word-limit
|
||||
placeholder="请输入icd文件名称"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="文件" prop="path">
|
||||
<el-form-item label="icd文件">
|
||||
<el-upload
|
||||
v-model:file-list="form.reportPath"
|
||||
v-model:file-list="reportPath"
|
||||
ref="uploadRef"
|
||||
action=""
|
||||
accept=""
|
||||
@@ -46,42 +28,44 @@
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref, inject, onMounted } from 'vue'
|
||||
import { uploadFile } from '@/api/system-boot/file'
|
||||
import { reactive } from 'vue'
|
||||
import { getActionClasses, addTimer, updateTimer } from '@/api/system-boot/csDictData'
|
||||
import { UploadInstance, UploadProps, UploadRawFile, ElMessage, genFileId } from 'element-plus'
|
||||
import { addIcdPath, updateIcdPath } from '@/api/device-boot/icd'
|
||||
|
||||
const emit = defineEmits(['submit'])
|
||||
const dialogVisible = ref(false)
|
||||
const title = ref('')
|
||||
// 注意不要和表单ref的命名冲突
|
||||
const form = reactive<anyObj>({
|
||||
cron: '',
|
||||
path: '',
|
||||
reportPath: []
|
||||
fileName: '',
|
||||
filePath: '',
|
||||
id: ''
|
||||
})
|
||||
const reportPath: any = ref([])
|
||||
const formRef = ref()
|
||||
const rules = {
|
||||
path: [{ required: true, message: '请选择任务执行器', trigger: 'change' }],
|
||||
name: [{ required: true, message: '请输入任务名称', trigger: 'blur' }]
|
||||
fileName: [{ required: true, message: '请输入任务名称', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const open = (text: string, data?: anyObj) => {
|
||||
const open = (text: string, data?: any) => {
|
||||
reportPath.value = []
|
||||
title.value = text
|
||||
dialogVisible.value = true
|
||||
if (data) {
|
||||
// 表单赋值
|
||||
for (let key in form) {
|
||||
form[key] = data[key]
|
||||
}
|
||||
} else {
|
||||
// 在此处恢复默认表单
|
||||
for (let key in form) {
|
||||
key == 'sort' ? (form[key] = 100) : (form[key] = '')
|
||||
}
|
||||
if (data?.path) {
|
||||
reportPath.value = [
|
||||
{
|
||||
name: data?.path.split('/icd/')[1]
|
||||
}
|
||||
]
|
||||
}
|
||||
form.fileName = data?.name
|
||||
form.id = data?.id
|
||||
form.filePath = data?.path
|
||||
}
|
||||
// 上传报告
|
||||
const uploadRef = ref()
|
||||
|
||||
const handleExceed: UploadProps['onExceed'] = files => {
|
||||
uploadRef.value!.clearFiles()
|
||||
const file = files[0] as UploadRawFile
|
||||
@@ -91,30 +75,41 @@ const handleExceed: UploadProps['onExceed'] = files => {
|
||||
|
||||
//移除文件上传
|
||||
const removeFile = (file: any, uploadFiles: any) => {
|
||||
console.log(file, uploadFiles)
|
||||
form.filePath = ''
|
||||
}
|
||||
onMounted(() => {})
|
||||
const submit = () => {
|
||||
console.log('🚀 ~ form:', form)
|
||||
|
||||
formRef.value.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
if (title.value == '新增定时任务') {
|
||||
// addTimer(form).then(res => {
|
||||
// ElMessage.success('新增成功')
|
||||
// dialogVisible.value = false
|
||||
// emit('submit')
|
||||
// })
|
||||
} else {
|
||||
// updateTimer(form).then(res => {
|
||||
// ElMessage.success('新增成功')
|
||||
// dialogVisible.value = false
|
||||
// emit('submit')
|
||||
// })
|
||||
}
|
||||
}
|
||||
})
|
||||
const submit = async () => {
|
||||
console.log(123, reportPath.value[0]?.raw)
|
||||
if (reportPath.value.length == 0) {
|
||||
return ElMessage.warning('请上传icd文件')
|
||||
}
|
||||
if (reportPath.value[0]?.raw != undefined) {
|
||||
await uploadFile(reportPath.value[0].raw, '/icd/').then(res => {
|
||||
//治理工程验收报告
|
||||
form.fileName = res.data.fileName.split('.')[0]
|
||||
form.filePath = res.data.name
|
||||
})
|
||||
}
|
||||
|
||||
if (title.value == '新增icd文件') {
|
||||
await addIcdPath(form).then(res => {
|
||||
ElMessage.success('新增成功!')
|
||||
dialogVisible.value = false
|
||||
emit('submit')
|
||||
})
|
||||
} else {
|
||||
await updateIcdPath(form).then(res => {
|
||||
ElMessage.success('编辑成功!')
|
||||
dialogVisible.value = false
|
||||
emit('submit')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
:deep(.el-upload-list__item) {
|
||||
width: 300px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user