模版下载
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
draggable
|
||||
class="cn-operate-dialog"
|
||||
v-model="eventDataUploadVisible"
|
||||
:title="title"
|
||||
style="width: 415px"
|
||||
top="25vh"
|
||||
>
|
||||
<el-scrollbar>
|
||||
<el-form :inline="false" :model="form" label-width="120px" ref="formRef">
|
||||
<el-form-item label="用户数据文件">
|
||||
<el-upload
|
||||
v-model:file-list="fileList"
|
||||
ref="uploadEventData"
|
||||
action=""
|
||||
:limit="1"
|
||||
:on-exceed="handleExceed"
|
||||
:auto-upload="false"
|
||||
:on-change="choose"
|
||||
>
|
||||
<template #trigger>
|
||||
<el-button type="primary">选择数据文件</el-button>
|
||||
</template>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-scrollbar>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="eventDataUploadVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="submit">评估</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, inject } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { UploadInstance, UploadProps, UploadRawFile, UploadUserFile } from 'element-plus'
|
||||
import { genFileId } from 'element-plus'
|
||||
import { deVReportImportSensitive } from '@/api/supervision-boot/userReport/form'
|
||||
import {evaluation} from '@/api/advance-boot/assess'
|
||||
|
||||
const fileList = ref<UploadUserFile[]>([])
|
||||
|
||||
const formRef = ref()
|
||||
const tableStore = inject('tableStore') as TableStore
|
||||
const eventDataUploadVisible = ref(false)
|
||||
const title = ref('')
|
||||
const uploadEventData = ref<UploadInstance>()
|
||||
const currentNodeId = ref('')
|
||||
// 注意不要和表单ref的命名冲突
|
||||
const form = reactive({
|
||||
file: null
|
||||
})
|
||||
|
||||
//弹出界面,默认选择用户的第一个生产线的第一条进线进行数据导入
|
||||
const open = async (text: string , treeId:string) => {
|
||||
currentNodeId.value = treeId
|
||||
title.value = text
|
||||
resetForm()
|
||||
form.file = null
|
||||
fileList.value = []
|
||||
eventDataUploadVisible.value = true
|
||||
}
|
||||
|
||||
//重置表单内容
|
||||
const resetForm = () => {
|
||||
if (formRef.value) {
|
||||
formRef.value.resetFields()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择待上传文件
|
||||
*/
|
||||
const choose = (e: any) => {
|
||||
form.file = e.raw
|
||||
}
|
||||
const handleExceed: UploadProps['onExceed'] = files => {
|
||||
uploadEventData.value!.clearFiles()
|
||||
const file = files[0] as UploadRawFile
|
||||
file.uid = genFileId()
|
||||
uploadEventData.value!.handleStart(file)
|
||||
fileList.value = [{ name: file.name, url: '' }]
|
||||
}
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'data-success'): void
|
||||
}>()
|
||||
|
||||
/**
|
||||
* 提交用户表单数据
|
||||
*/
|
||||
const submit = async () => {
|
||||
if (form.file) {
|
||||
formRef.value.validate(async (valid: any) => {
|
||||
if (valid) {
|
||||
try {
|
||||
ElMessage.info('评估中...')
|
||||
// 调用后端评估接口
|
||||
const formData = new FormData()
|
||||
formData.append('assessId',currentNodeId.value)
|
||||
formData.append('file', form.file)
|
||||
|
||||
// 假设你有一个调用评估接口的方法,如 evaluation
|
||||
// 你需要在 API 文件中实现这个方法
|
||||
const response = await evaluation(currentNodeId.value, form.file)
|
||||
|
||||
if (response.data) {
|
||||
ElMessage.success('评估成功!')
|
||||
emit('data-success')
|
||||
} else {
|
||||
ElMessage.error('评估失败!')
|
||||
}
|
||||
eventDataUploadVisible.value = false
|
||||
} catch (error) {
|
||||
ElMessage.error('评估失败,请重试!')
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
ElMessage.error('请选择数据文件')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.el-form-item__content div {
|
||||
width: 100% !important;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user