|
|
@@ -309,11 +309,27 @@
|
|
|
placeholder="请输入应用场景和优势"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="专利附件" prop="attachments">
|
|
|
+ <el-form-item label="专利文件">
|
|
|
<UploadFile
|
|
|
:file-type="['doc', 'docx', 'pdf', 'jpg', 'png', 'jpeg']"
|
|
|
:return-object="true"
|
|
|
- v-model="formData.attachments"
|
|
|
+ v-model="patentAttachments"
|
|
|
+ :limit="10"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="论文文件">
|
|
|
+ <UploadFile
|
|
|
+ :file-type="['doc', 'docx', 'pdf', 'jpg', 'png', 'jpeg']"
|
|
|
+ :return-object="true"
|
|
|
+ v-model="paperAttachments"
|
|
|
+ :limit="10"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="其他资料">
|
|
|
+ <UploadFile
|
|
|
+ :file-type="['doc', 'docx', 'pdf', 'jpg', 'png', 'jpeg']"
|
|
|
+ :return-object="true"
|
|
|
+ v-model="otherMaterialAttachments"
|
|
|
:limit="10"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
@@ -396,6 +412,9 @@ const deptList2 = ref<Tree[]>([])
|
|
|
const formType = ref<'create' | 'update'>('create')
|
|
|
const formRef = ref()
|
|
|
const queryFormRef = ref()
|
|
|
+const patentAttachments = ref<any[]>([])
|
|
|
+const paperAttachments = ref<any[]>([])
|
|
|
+const otherMaterialAttachments = ref<any[]>([])
|
|
|
|
|
|
const queryParams = reactive({
|
|
|
pageNo: 1,
|
|
|
@@ -418,7 +437,6 @@ const createDefaultForm = () => ({
|
|
|
summary: '',
|
|
|
principles: '',
|
|
|
advantages: '',
|
|
|
- attachments: [],
|
|
|
details: [] as Array<{ progressDate: string | number; overview: string }>
|
|
|
})
|
|
|
|
|
|
@@ -445,16 +463,22 @@ const getDeptName = (departmentId?: number) => {
|
|
|
return findDept(deptList2.value) || String(departmentId)
|
|
|
}
|
|
|
|
|
|
-const normalizeAttachments = (attachments: unknown): any[] => {
|
|
|
+const normalizeAttachments = (attachments: unknown, type?: string): any[] => {
|
|
|
if (!attachments) return []
|
|
|
const values = Array.isArray(attachments) ? attachments : [attachments]
|
|
|
return values
|
|
|
.flatMap((attachment: any) => {
|
|
|
- if (typeof attachment === 'string') return attachment.split(',')
|
|
|
+ if (typeof attachment === 'string') {
|
|
|
+ return attachment
|
|
|
+ .split(',')
|
|
|
+ .map((filePath) => filePath.trim())
|
|
|
+ .filter(Boolean)
|
|
|
+ .map((filePath) => (type ? { filePath, type } : filePath))
|
|
|
+ }
|
|
|
if (attachment && typeof attachment === 'object') {
|
|
|
const filePath =
|
|
|
attachment.filePath || attachment.path || attachment.url || attachment.fileUrl
|
|
|
- return filePath ? [{ ...attachment, filePath }] : []
|
|
|
+ return filePath ? [{ ...attachment, filePath, ...(type ? { type } : {}) }] : []
|
|
|
}
|
|
|
return []
|
|
|
})
|
|
|
@@ -463,6 +487,23 @@ const normalizeAttachments = (attachments: unknown): any[] => {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
+const splitAttachments = (attachments: unknown) => {
|
|
|
+ const values = normalizeAttachments(attachments)
|
|
|
+ patentAttachments.value = values.filter(
|
|
|
+ (attachment) => !attachment.type || attachment.type === 'PATENT'
|
|
|
+ )
|
|
|
+ paperAttachments.value = values.filter((attachment) => attachment.type === 'PAPER')
|
|
|
+ otherMaterialAttachments.value = values.filter(
|
|
|
+ (attachment) => attachment.type === 'OTHER_MATERIAL'
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+const getAttachments = () => [
|
|
|
+ ...normalizeAttachments(patentAttachments.value, 'PATENT'),
|
|
|
+ ...normalizeAttachments(paperAttachments.value, 'PAPER'),
|
|
|
+ ...normalizeAttachments(otherMaterialAttachments.value, 'OTHER_MATERIAL')
|
|
|
+]
|
|
|
+
|
|
|
const getList = async () => {
|
|
|
loading.value = true
|
|
|
try {
|
|
|
@@ -501,6 +542,9 @@ const openForm = async (type: 'create' | 'update', id?: number) => {
|
|
|
dialogTitle.value = type === 'create' ? '新增核心技术' : '编辑核心技术'
|
|
|
if (type === 'create') {
|
|
|
formData.value = createDefaultForm()
|
|
|
+ patentAttachments.value = []
|
|
|
+ paperAttachments.value = []
|
|
|
+ otherMaterialAttachments.value = []
|
|
|
dialogVisible.value = true
|
|
|
return
|
|
|
}
|
|
|
@@ -511,9 +555,9 @@ const openForm = async (type: 'create' | 'update', id?: number) => {
|
|
|
formData.value = {
|
|
|
...createDefaultForm(),
|
|
|
...data,
|
|
|
- attachments: normalizeAttachments(data.attachments),
|
|
|
details: Array.isArray(data.details) ? data.details : []
|
|
|
}
|
|
|
+ splitAttachments(data.attachments)
|
|
|
dialogVisible.value = true
|
|
|
} finally {
|
|
|
loading.value = false
|
|
|
@@ -537,11 +581,12 @@ const submitForm = () => {
|
|
|
if (!valid) return
|
|
|
formLoading.value = true
|
|
|
try {
|
|
|
+ const payload = { ...formData.value, attachments: getAttachments() }
|
|
|
if (formType.value === 'create') {
|
|
|
- await createTechnology(formData.value)
|
|
|
+ await createTechnology(payload)
|
|
|
message.success('新增成功')
|
|
|
} else {
|
|
|
- await updateTechnology(formData.value)
|
|
|
+ await updateTechnology(payload)
|
|
|
message.success('更新成功')
|
|
|
}
|
|
|
dialogVisible.value = false
|