|
|
|
@ -1,14 +1,14 @@
|
|
|
|
|
<script setup lang="tsx">
|
|
|
|
|
import { Form, FormSchema } from '@/components/Form'
|
|
|
|
|
import { useForm } from '@/hooks/web/useForm'
|
|
|
|
|
import { PropType, reactive, watch } from 'vue'
|
|
|
|
|
import { useValidator } from '@/hooks/web/useValidator'
|
|
|
|
|
import { ElButton, ElMessage, ElMessageBox } from 'element-plus';
|
|
|
|
|
import { Form, FormSchema } from '@/components/Form'
|
|
|
|
|
import { useForm } from '@/hooks/web/useForm'
|
|
|
|
|
import { PropType, reactive, watch } from 'vue'
|
|
|
|
|
import { useValidator } from '@/hooks/web/useValidator'
|
|
|
|
|
import { ElButton, ElMessage, ElMessageBox } from 'element-plus';
|
|
|
|
|
|
|
|
|
|
let fileChoose = null;
|
|
|
|
|
const { required } = useValidator()
|
|
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
const { required } = useValidator()
|
|
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
currentRow: {
|
|
|
|
|
type: Object as PropType<any>,
|
|
|
|
|
default: () => null
|
|
|
|
@ -17,12 +17,12 @@
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'add'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const { formRegister, formMethods } = useForm()
|
|
|
|
|
const { setValues, getFormData, getElFormExpose } = formMethods
|
|
|
|
|
const { formRegister, formMethods } = useForm()
|
|
|
|
|
const { setValues, getFormData, getElFormExpose } = formMethods
|
|
|
|
|
|
|
|
|
|
const formSchema = reactive < FormSchema[] > ([
|
|
|
|
|
const formSchema = reactive<FormSchema[]>([
|
|
|
|
|
{
|
|
|
|
|
field: 'tId',
|
|
|
|
|
label: '编号',
|
|
|
|
@ -77,12 +77,10 @@
|
|
|
|
|
colProps: { span: 160 },
|
|
|
|
|
componentProps: {
|
|
|
|
|
limit: 1,
|
|
|
|
|
drag: true,
|
|
|
|
|
accept: ".doc,.docx",
|
|
|
|
|
action: null,
|
|
|
|
|
autoUpload:false,
|
|
|
|
|
multiple: false,
|
|
|
|
|
fileList: [],
|
|
|
|
|
drag:true,
|
|
|
|
|
accept:".doc,.docx",
|
|
|
|
|
action: 'https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15',
|
|
|
|
|
multiple: true,
|
|
|
|
|
onPreview: (uploadFile) => {
|
|
|
|
|
console.log(uploadFile)
|
|
|
|
|
},
|
|
|
|
@ -97,41 +95,36 @@
|
|
|
|
|
},
|
|
|
|
|
onExceed: (files, uploadFiles) => {
|
|
|
|
|
ElMessage.warning(
|
|
|
|
|
`The limit is 1, you selected ${files.length} files this time, add up to ${files.length + uploadFiles.length
|
|
|
|
|
`The limit is 1, you selected ${files.length} files this time, add up to ${
|
|
|
|
|
files.length + uploadFiles.length
|
|
|
|
|
} 总共`
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
slots: {
|
|
|
|
|
default: () => <div class="el-upload"><div class="el-upload__text">拖曳报告模版到这里或<em>上传报告模版</em></div></div>,
|
|
|
|
|
tip: () => <div class="el-upload__tip">doc,docx文件</div>,
|
|
|
|
|
file: (file) => {
|
|
|
|
|
fileChoose = file.file.raw;
|
|
|
|
|
console.log(file, "file信息");
|
|
|
|
|
}
|
|
|
|
|
default: () =><div class="el-upload"><div class="el-upload__text">拖曳报告模版到这里或<em>上传报告模版</em></div></div>,
|
|
|
|
|
tip: () => <div class="el-upload__tip">doc,docx文件</div>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
const rules = reactive({
|
|
|
|
|
const rules = reactive({
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const submit = async () => {
|
|
|
|
|
const submit = async () => {
|
|
|
|
|
const elForm = await getElFormExpose()
|
|
|
|
|
const valid = await elForm?.validate().catch((err) => {
|
|
|
|
|
console.log(err)
|
|
|
|
|
})
|
|
|
|
|
if (valid) {
|
|
|
|
|
const formData = await getFormData()
|
|
|
|
|
formData.file = fileChoose;
|
|
|
|
|
console.log(formData);
|
|
|
|
|
return formData
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
watch(
|
|
|
|
|
() => props.currentRow,
|
|
|
|
|
(currentRow) => {
|
|
|
|
|
if (!currentRow) return
|
|
|
|
@ -141,13 +134,14 @@
|
|
|
|
|
deep: true,
|
|
|
|
|
immediate: true
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
|
defineExpose({
|
|
|
|
|
submit
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<Form :rules="rules" @register="formRegister" :schema="formSchema" />
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|