|
|
@ -1,3 +1,11 @@ |
|
|
|
|
|
/* |
|
|
|
|
|
* @Author: AaronWu 2463371514@qq.com |
|
|
|
|
|
* @Date: 2025-04-02 13:45:06 |
|
|
|
|
|
* @LastEditors: AaronWu 2463371514@qq.com |
|
|
|
|
|
* @LastEditTime: 2025-07-28 14:09:09 |
|
|
|
|
|
* @FilePath: /IssueSupportManage/src/views/question/issue/formSchemas.tsx |
|
|
|
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
|
|
|
*/ |
|
|
import type { FormSchema } from '@/components/core/schema-form/'; |
|
|
import type { FormSchema } from '@/components/core/schema-form/'; |
|
|
import { TableListItem } from './columns'; |
|
|
import { TableListItem } from './columns'; |
|
|
import { commonUpload } from '@/api/upload'; |
|
|
import { commonUpload } from '@/api/upload'; |
|
|
@ -278,71 +286,87 @@ export const getEditFormSchema: ( |
|
|
}, |
|
|
}, |
|
|
rules: [{ required: true }], |
|
|
rules: [{ required: true }], |
|
|
}, |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
field: 'fileUploading', |
|
|
|
|
|
component: 'Input', |
|
|
|
|
|
defaultValue: false, |
|
|
|
|
|
label: '附件上传状态', |
|
|
|
|
|
vShow: false, |
|
|
|
|
|
}, |
|
|
{ |
|
|
{ |
|
|
label: '描述附件', |
|
|
label: '描述附件', |
|
|
field: 'files', |
|
|
field: 'files', |
|
|
component: 'Upload', |
|
|
component: 'Upload', |
|
|
componentProps: { |
|
|
|
|
|
disabled: isDetail, |
|
|
|
|
|
customRequest: async (data) => { |
|
|
|
|
|
console.log('data: ', data); |
|
|
|
|
|
const formData = new FormData(); |
|
|
|
|
|
formData.append('file', data.file); |
|
|
|
|
|
const res = await commonUpload(formData); |
|
|
|
|
|
console.log('res: ', res); |
|
|
|
|
|
data?.onSuccess && data?.onSuccess(res, data.file as any); |
|
|
|
|
|
}, |
|
|
|
|
|
beforeUpload: (file) => { |
|
|
|
|
|
console.log('file: ', file); |
|
|
|
|
|
|
|
|
componentProps: ({ formModel, formInstance }) => { |
|
|
|
|
|
return { |
|
|
|
|
|
disabled: isDetail, |
|
|
|
|
|
customRequest: async (data) => { |
|
|
|
|
|
// 添加附件上传状态
|
|
|
|
|
|
formInstance.setFieldsValue({ |
|
|
|
|
|
fileUploading: true, |
|
|
|
|
|
}); |
|
|
|
|
|
console.log('data: ', data); |
|
|
|
|
|
const formData = new FormData(); |
|
|
|
|
|
formData.append('file', data.file); |
|
|
|
|
|
const res = await commonUpload(formData); |
|
|
|
|
|
console.log('res: ', res); |
|
|
|
|
|
data?.onSuccess && data?.onSuccess(res, data.file as any); |
|
|
|
|
|
formInstance.setFieldsValue({ |
|
|
|
|
|
fileUploading: false, |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
beforeUpload: (file) => { |
|
|
|
|
|
console.log('file: ', file); |
|
|
|
|
|
|
|
|
// 限制允许上传的文件类型
|
|
|
|
|
|
// 添加视频和压缩包
|
|
|
|
|
|
const allowedTypes = [ |
|
|
|
|
|
// 文档
|
|
|
|
|
|
'xlsx', |
|
|
|
|
|
'xls', |
|
|
|
|
|
'doc', |
|
|
|
|
|
'docx', |
|
|
|
|
|
// 图片
|
|
|
|
|
|
'pdf', |
|
|
|
|
|
'jpg', |
|
|
|
|
|
'jpeg', |
|
|
|
|
|
'png', |
|
|
|
|
|
// 视频
|
|
|
|
|
|
'mp4', |
|
|
|
|
|
'avi', |
|
|
|
|
|
'mov', |
|
|
|
|
|
'wmv', |
|
|
|
|
|
'mkv', |
|
|
|
|
|
'flv', |
|
|
|
|
|
'webm', |
|
|
|
|
|
// 压缩包
|
|
|
|
|
|
'zip', |
|
|
|
|
|
'rar', |
|
|
|
|
|
'7z', |
|
|
|
|
|
'tar', |
|
|
|
|
|
'gz', |
|
|
|
|
|
'bz2', |
|
|
|
|
|
'tgz', |
|
|
|
|
|
'tbz2', |
|
|
|
|
|
// 其他
|
|
|
|
|
|
'htm', |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
// 限制允许上传的文件类型
|
|
|
|
|
|
// 添加视频和压缩包
|
|
|
|
|
|
const allowedTypes = [ |
|
|
|
|
|
// 文档
|
|
|
|
|
|
'xlsx', |
|
|
|
|
|
'xls', |
|
|
|
|
|
'doc', |
|
|
|
|
|
'docx', |
|
|
|
|
|
// 图片
|
|
|
|
|
|
'pdf', |
|
|
|
|
|
'jpg', |
|
|
|
|
|
'jpeg', |
|
|
|
|
|
'png', |
|
|
|
|
|
// 视频
|
|
|
|
|
|
'mp4', |
|
|
|
|
|
'avi', |
|
|
|
|
|
'mov', |
|
|
|
|
|
'wmv', |
|
|
|
|
|
'mkv', |
|
|
|
|
|
'flv', |
|
|
|
|
|
'webm', |
|
|
|
|
|
// 压缩包
|
|
|
|
|
|
'zip', |
|
|
|
|
|
'rar', |
|
|
|
|
|
'7z', |
|
|
|
|
|
'tar', |
|
|
|
|
|
'gz', |
|
|
|
|
|
'bz2', |
|
|
|
|
|
'tgz', |
|
|
|
|
|
'tbz2', |
|
|
|
|
|
// 其他
|
|
|
|
|
|
'htm', |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
// 检查文件类型
|
|
|
|
|
|
const fileType = getFileExtension(file.name) || 'unknown'; |
|
|
|
|
|
if (!allowedTypes.includes(fileType)) { |
|
|
|
|
|
// 文件类型不在允许列表中,拒绝上传
|
|
|
|
|
|
// 可以在这里展示错误信息
|
|
|
|
|
|
message.warning('文件类型不正确'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 检查文件类型
|
|
|
|
|
|
const fileType = getFileExtension(file.name) || 'unknown'; |
|
|
|
|
|
if (!allowedTypes.includes(fileType)) { |
|
|
|
|
|
// 文件类型不在允许列表中,拒绝上传
|
|
|
|
|
|
// 可以在这里展示错误信息
|
|
|
|
|
|
message.warning('文件类型不正确'); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 其他验证逻辑...
|
|
|
|
|
|
|
|
|
// 其他验证逻辑...
|
|
|
|
|
|
|
|
|
// 允许上传
|
|
|
|
|
|
return true; |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
// 允许上传
|
|
|
|
|
|
return true; |
|
|
|
|
|
}, |
|
|
|
|
|
}; |
|
|
}, |
|
|
}, |
|
|
componentSlots: { |
|
|
componentSlots: { |
|
|
default: () => ( |
|
|
default: () => ( |
|
|
|