/** * 供应商注册表单通用部分 * 封装了国内企业和境外企业注册表单相同的部分 */ import React from 'react'; import { Form, Input, Button, Select, Upload, DatePicker, Row, Col, Table, Radio, Cascader, Empty, } from 'antd'; import { UploadOutlined, PlusOutlined, DeleteOutlined } from '@ant-design/icons'; import { message } from 'antd'; import { validateFileSize } from '@/utils/utils'; const { Option } = Select; // 中国省市区级联数据 export const addressOptions = [ { value: '330000', label: '浙江省', children: [ { value: '330100', label: '杭州市', children: [ { value: '330102', label: '上城区' }, { value: '330103', label: '下城区' }, { value: '330104', label: '江干区' }, { value: '330105', label: '拱墅区' }, { value: '330106', label: '西湖区' }, { value: '330108', label: '滨江区' }, ], }, ], }, { value: '310000', label: '上海市', children: [ { value: '310100', label: '上海市', children: [ { value: '310101', label: '黄浦区' }, { value: '310104', label: '徐汇区' }, { value: '310105', label: '长宁区' }, ], }, ], }, ]; interface CommonFormSectionsProps { form: any; } // 扩展问卷部分的属性接口 interface SurveySectionProps extends CommonFormSectionsProps { surveyQuestions?: API.SurveyQuestionResponse; } /** * 资质信息表单部分 * 包含资质证书类型、名称、编号、等级、发证机构、发证日期、有效期等 */ export const QualificationSection: React.FC = ({ form }) => { return ( <>
资质信息
{(fields, { add, remove }) => ( <> ({ ...field, key: field.key, fieldKey: field.name, }))} pagination={false} bordered size="middle" rowKey="key" columns={[ { title: '序号', dataIndex: 'name', width: 60, render: (_, __, index) => index + 1, }, { title: '资质证书类型', dataIndex: 'certType', render: (_, record) => ( ), }, { title: '资质名称', dataIndex: 'certName', render: (_, record) => ( ), }, { title: '资质证书编号', dataIndex: 'certNumber', render: (_, record) => ( ), }, { title: '资质类别和等级', dataIndex: 'certLevel', render: (_, record) => ( ), }, { title: '发证机构', dataIndex: 'issuingAuthority', render: (_, record) => ( ), }, { title: '发证日期', dataIndex: 'issueDate', render: (_, record) => ( ), }, { title: '资质有效期至', dataIndex: 'expiryDate', render: (_, record) => ( ), }, { title: '附件', dataIndex: 'certFile', render: (_, record) => ( ), }, { title: '操作', width: 70, render: (_, record) => ( ), }, ]} /> )} ); }; /** * 开票信息表单部分 * 包含纳税人类型、开票抬头、纳税人识别号、开票地址等 */ export const InvoiceSection: React.FC = ({ form }) => { return ( <>
开票信息
validateFileSize(file, 10, ['pdf', 'jpg', 'jpeg', 'png'])} > ); }; /** * 银行账户表单部分 * 包含开户银行、账户名称、账号、所在地区等 */ export const BankAccountSection: React.FC = ({ form }) => { return ( <>
银行账户
{(fields, { add, remove }) => ( <>
({ ...field, key: field.key, fieldKey: field.name, }))} pagination={false} bordered size="middle" rowKey="key" columns={[ { title: '序号', dataIndex: 'name', width: 60, render: (_, __, index) => index + 1, }, { title: '开户银行', dataIndex: 'bankName', render: (_, record) => ( ), }, { title: '账户名称', dataIndex: 'accountName', render: (_, record) => ( ), }, { title: '账号', dataIndex: 'accountNumber', render: (_, record) => ( ), }, { title: '国家、省、市', dataIndex: 'location', render: (_, record) => ( { return path.some((option) => { if (typeof option.label === 'string') { return ( option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1 ); } return false; }); }, }} /> ), }, { title: '操作', width: 70, render: (_, record) => ( ), }, ]} /> )} ); }; /** * 社会准则符合性自查问卷部分 * 包含填写人信息和问卷内容 */ export const SurveySection: React.FC = ({ form, surveyQuestions }) => { // 使用API获取的问卷数据,如果没有则显示无数据状态 const hasQuestions = surveyQuestions && surveyQuestions.length > 0; return ( <>
社会准则符合性自查问卷
填写人信息:
问卷:
{hasQuestions ? ( {(fields, { add, remove }) => { // 确保有足够的表单项对应每个问题 if (fields.length < surveyQuestions.length) { const diff = surveyQuestions.length - fields.length; for (let i = 0; i < diff; i++) { add(); } } return (
index + 1, }, { title: '问题', dataIndex: 'questionName', render: (text) =>
{text}
, }, { title: '回复', width: 650, render: (_, record, index) => ( <> {record.coscoSurveyQuestionOptionList?.map((option: any) => ( {option.optionName} ))} ), }, ]} /> ); }} ) : (
)} ); }; /** * 供应商反商业贿赂承诺书和其他附件部分 */ export const AttachmentSection: React.FC = ({ form }) => { return ( <>
供应商反商业贿赂承诺书
请加盖公司公章后上传
{(fields, { add, remove }) => { // 确保至少有一项用于反商业贿赂承诺书 if (fields.length === 0) { add({ attachmentsType: 'commitment' }); } return (
{fields.map((field, index) => (
validateFileSize(file, 10, ['pdf', 'doc', 'docx']) } onChange={(info) => { if (info.file.status === 'done') { const response = info.file.response; if (response && response.success) { // 填充文件信息 form.setFieldsValue({ coscoSupplierSurveyAttachments: [ { ...form.getFieldValue([ 'coscoSupplierSurveyAttachments', field.name, ]), fileName: info.file.name, fileType: info.file.type, fileSize: info.file.size.toString(), filePath: response.filePath || response.url, }, ], }); message.success(`${info.file.name} 上传成功`); } else { message.error(`${info.file.name} 上传失败`); } } }} >
))}
); }}
其他附件
{(fields, { add, remove }) => ( <>
其他附件(非必须上传)
{fields.map((field, index) => (
0 || fields.length === 1 ? 'block' : 'none', marginBottom: 8, }} > {index > 0 && ( )} {index > 0 && ( validateFileSize(file, 20, ['*'])} onChange={(info) => { if (info.file.status === 'done') { const response = info.file.response; if (response && response.success) { // 填充文件信息 const fieldValue = form.getFieldValue([ 'coscoSupplierSurveyAttachments', field.name, ]); form.setFieldsValue({ coscoSupplierSurveyAttachments: [ { ...fieldValue, fileName: info.file.name, fileType: info.file.type, fileSize: info.file.size.toString(), filePath: response.filePath || response.url, }, ], }); message.success(`${info.file.name} 上传成功`); } else { message.error(`${info.file.name} 上传失败`); } } }} > )}
))} )}
); };