diff --git a/src/app.ts b/src/app.ts index 471fc84..b2f304e 100644 --- a/src/app.ts +++ b/src/app.ts @@ -2,7 +2,7 @@ import { history } from 'umi'; export function onRouteChange({ location }: any) { const token = sessionStorage.getItem('token'); - const whiteList = ['/login', '/forgot', '/403', '/404']; + const whiteList = ['/login', '/forgot', '/register/supplier', '/register/expert', '/403', '/404']; if (!token && !whiteList.includes(location.pathname)) { history.replace('/login'); } diff --git a/src/components/AccessDepartmentSelect/index.tsx b/src/components/AccessDepartmentSelect/index.tsx index 49276dc..ec3b0ce 100644 --- a/src/components/AccessDepartmentSelect/index.tsx +++ b/src/components/AccessDepartmentSelect/index.tsx @@ -4,7 +4,7 @@ import { treeData } from './services'; // 你的接口 export interface AccessDepartmentSelectProps { value?: string | number; - onChange?: (value: string | number) => void; + onChange?: (value: string | number, label: any, extra: any) => void; placeholder?: string; disabled?: boolean; orgCategory?: string; diff --git a/src/pages/register/supplier.tsx b/src/pages/register/supplier.tsx index f1c4891..6b11da9 100644 --- a/src/pages/register/supplier.tsx +++ b/src/pages/register/supplier.tsx @@ -100,7 +100,7 @@ const SupplierRegister: React.FC = (props) => { fileType: values.attachments.file.response.fileType, fileSize: values.attachments.file.response.fileSize, filePath: values.attachments.file.response.filePath, - fileUrl: values.attachments.file.response.filePath, + fileUrl: values.attachments.file.response.url, }, ]; } diff --git a/src/pages/register/supplier/CommonFormSections.tsx b/src/pages/register/supplier/CommonFormSections.tsx index f57ffcf..0229568 100644 --- a/src/pages/register/supplier/CommonFormSections.tsx +++ b/src/pages/register/supplier/CommonFormSections.tsx @@ -16,6 +16,7 @@ import { Radio, Cascader, Empty, + Descriptions } from 'antd'; import { UploadOutlined, PlusOutlined, DeleteOutlined } from '@ant-design/icons'; import { message } from 'antd'; @@ -257,9 +258,8 @@ export const QualificationSection: React.FC = ({ form } ), @@ -379,9 +379,8 @@ export const InvoiceSection: React.FC = ({ form }) => { @@ -474,40 +473,40 @@ export const BankAccountSection: React.FC = ({ form, su const domesticColumns: ColumnType[] = supplierType === 'dvs' ? [ - { - title: '银联号', - dataIndex: 'interbankNumber', - render: (text, record) => ( - - - - ), - }, - ] + { + title: '银联号', + dataIndex: 'interbankNumber', + render: (text, record) => ( + + + + ), + }, + ] : []; // 境外企业特有列 const foreignColumns: ColumnType[] = supplierType === 'ovs' ? [ - { - title: 'SWIFT CODE', - dataIndex: 'swiftCode', - render: (text, record) => ( - - - - ), - }, - ] + { + title: 'SWIFT CODE', + dataIndex: 'swiftCode', + render: (text, record) => ( + + + + ), + }, + ] : []; // 通用列 @@ -818,19 +817,24 @@ export const AttachmentSection: React.FC = ({ form }) = return ( <>
供应商反商业贿赂承诺书
- - -
- 请加盖公司公章后上传 - -
+ + + + + {(fields, { add, remove }) => { // 确保至少有一项用于反商业贿赂承诺书 @@ -863,6 +867,7 @@ export const AttachmentSection: React.FC = ({ form }) = { if (value && value.length > 0) { const file = value[0]; @@ -891,7 +896,6 @@ export const AttachmentSection: React.FC = ({ form }) = maxCount={1} allowedTypes={['pdf', 'doc', 'docx', 'jpg', 'jpeg', 'png']} maxSize={10} - tip="pdf,doc,docx,jpg,jpeg,png类型的文件,大小不超过10MB" /> @@ -900,16 +904,23 @@ export const AttachmentSection: React.FC = ({ form }) = ); }} - -
+ + + +
其他附件
- - - + + + {(fields, { add, remove }) => ( <> -
其他附件(非必须上传)
{fields.map((field, index) => (
= ({ form }) = > {index > 0 && ( <> - - - - + + + + )} @@ -987,8 +998,8 @@ export const AttachmentSection: React.FC = ({ form }) = )} - - + + ); }; diff --git a/src/pages/register/supplier/ForeignForm.tsx b/src/pages/register/supplier/ForeignForm.tsx index fc83855..d812699 100644 --- a/src/pages/register/supplier/ForeignForm.tsx +++ b/src/pages/register/supplier/ForeignForm.tsx @@ -337,7 +337,7 @@ const ForeignForm: React.FC = ({ {/* 使用通用表单组件 */} - + {/* */} diff --git a/src/pages/supplier/admission/SupplierCategoryEntry/components/CreateModal.tsx b/src/pages/supplier/admission/SupplierCategoryEntry/components/CreateModal.tsx index c99143b..12a3376 100644 --- a/src/pages/supplier/admission/SupplierCategoryEntry/components/CreateModal.tsx +++ b/src/pages/supplier/admission/SupplierCategoryEntry/components/CreateModal.tsx @@ -10,7 +10,7 @@ import { categoryTree, add } from '../services'; const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ visible, onCancel }) => { const [form] = Form.useForm(); - //名称输入 + //名称输入 const [accessWorkNameEdited, setAccessWorkNameEdited] = useState(false); //品类选择 @@ -20,6 +20,8 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi const [supplierModalVisible, setSupplierModalVisible] = useState(false); //品类选择渲染数据 const [categoriesTreeData, setCategoriesTreeData] = useState([]); + //提交防抖 + const [submitting, setSubmitting] = useState(false); //品类选择数据中字段转换 const convertTreeData = (data: any) => { return data.map((item: any) => ({ @@ -54,69 +56,69 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi ? checkedKeysValue : checkedKeysValue.checked; - // 只取叶子节点 key + // 只取叶子节点 key const leafKeys = findLeafKeys(convertTreeData(categoriesTreeData)); const onlyLeafChecked = keys.filter(key => leafKeys.includes(String(key))); - console.log(onlyLeafChecked,'onlyLeafChecked', leafKeys ,keys); + console.log(onlyLeafChecked, 'onlyLeafChecked', leafKeys, keys); setCheckedKeys(keys); // UI 显示用,还是全量 form.setFieldsValue({ categoryIds: onlyLeafChecked }); // 只存叶子到表单 - // ============================== - // 增加自动拼标题的逻辑 - // ============================== - if (!accessWorkNameEdited) { - // 1. 获取供应商名 - const supplier = (form.getFieldValue('supplier') || [])[0]; - let supplierName = ''; - if (supplier) { - supplierName = supplier.supplierType === 'ovs' ? supplier.nameEn : supplier.name; - } - // 2. 获取已选品类名称 - const findNamesByIds = (treeData: any[], ids: any[]) => { - let names: string[] = []; - const dfs = (list: any[]) => { - list.forEach(item => { - if (ids.includes(item.id)) { - names.push(item.categoryName); - } - if (item.children) dfs(item.children); - }); + // ============================== + // 增加自动拼标题的逻辑 + // ============================== + if (!accessWorkNameEdited) { + // 1. 获取供应商名 + const supplier = (form.getFieldValue('supplier') || [])[0]; + let supplierName = ''; + if (supplier) { + supplierName = supplier.supplierType === 'ovs' ? supplier.nameEn : supplier.name; } - dfs(treeData); - return names; - }; - const categoryNames = findNamesByIds(categoriesTreeData, onlyLeafChecked); + // 2. 获取已选品类名称 + const findNamesByIds = (treeData: any[], ids: any[]) => { + let names: string[] = []; + const dfs = (list: any[]) => { + list.forEach(item => { + if (ids.includes(item.id)) { + names.push(item.categoryName); + } + if (item.children) dfs(item.children); + }); + } + dfs(treeData); + return names; + }; + const categoryNames = findNamesByIds(categoriesTreeData, onlyLeafChecked); - let autoTitle = supplierName; -if (supplierName && categoryNames.length) { - if (categoryNames.length === 1) { - autoTitle = `${supplierName}-${categoryNames[0]}-品类准入工作`; - } else { - autoTitle = `${supplierName}-${categoryNames[0]}等-品类准入工作`; - } -} else if (!supplierName && categoryNames.length) { - if (categoryNames.length === 1) { - autoTitle = categoryNames[0]; - } else { - autoTitle = `${categoryNames[0]}等-品类准入工作`; - } -} -form.setFieldsValue({ accessWorkName: autoTitle }); - } + let autoTitle = supplierName; + if (supplierName && categoryNames.length) { + if (categoryNames.length === 1) { + autoTitle = `${supplierName}-${categoryNames[0]}-品类准入工作`; + } else { + autoTitle = `${supplierName}-${categoryNames[0]}等-品类准入工作`; + } + } else if (!supplierName && categoryNames.length) { + if (categoryNames.length === 1) { + autoTitle = categoryNames[0]; + } else { + autoTitle = `${categoryNames[0]}等-品类准入工作`; + } + } + form.setFieldsValue({ accessWorkName: autoTitle }); + } }; - + // 提交 const onFinish = async (values: any) => { const finalPayload: { coscoAccessWork: { accessWorkName: string; deptId: string; - }; - categoryIds: string[]; - supplierIds: string[]; + }; + categoryIds: string[]; + supplierIds: string[]; } = { coscoAccessWork: { accessWorkName: '', @@ -132,25 +134,33 @@ form.setFieldsValue({ accessWorkName: autoTitle }); //品类选择 finalPayload.categoryIds = values.categoryIds; //选择供应商 - if(values.supplier.length != 0) { + if (values.supplier.length != 0) { values.supplier.forEach((item: { id: string }) => { finalPayload.supplierIds.push(item.id) }) } - console.log( finalPayload, values); - const res = await add(finalPayload); - if (res?.success) { - message.success('创建成功'); - form.resetFields(); - setCheckedKeys([]); - onCancel(); - } else { - message.error('创建失败'); + console.log(finalPayload, values); + if (submitting) return; // 防重复提交 + setSubmitting(true); + + try { + const res = await add(finalPayload); + if (res?.success) { + message.success('创建成功'); + form.resetFields(); + setCheckedKeys([]); + onCancel(); + } else { + message.error('创建失败'); + } + } + finally { + setSubmitting(false); // 无论成功失败都解锁 } }; //初始化 useEffect(() => { - if(visible) { + if (visible) { categoryTree().then((res) => { const { code, data } = res; if (code == 200) { @@ -183,21 +193,21 @@ form.setFieldsValue({ accessWorkName: autoTitle }); name="accessWorkName" rules={[{ required: true, message: '请输入标题名称' }]} > - { - if (e.target.value) { - setAccessWorkNameEdited(true); - } else { - setAccessWorkNameEdited(false); - } - }}/> + { + if (e.target.value) { + setAccessWorkNameEdited(true); + } else { + setAccessWorkNameEdited(false); + } + }} /> - + @@ -209,7 +219,7 @@ form.setFieldsValue({ accessWorkName: autoTitle }); - {`${form.getFieldValue('supplier')? form.getFieldValue('supplier')[0].supplierType === 'ovs' ? form.getFieldValue('supplier')[0].nameEn : form.getFieldValue('supplier')[0].name : ''}`} + {`${form.getFieldValue('supplier') ? form.getFieldValue('supplier')[0].supplierType === 'ovs' ? form.getFieldValue('supplier')[0].nameEn : form.getFieldValue('supplier')[0].name : ''}`} - diff --git a/src/pages/supplier/category/SupplierEntryManage/components/SupplierAddModal.tsx b/src/pages/supplier/category/SupplierEntryManage/components/SupplierAddModal.tsx index 4b33922..e99d3c1 100644 --- a/src/pages/supplier/category/SupplierEntryManage/components/SupplierAddModal.tsx +++ b/src/pages/supplier/category/SupplierEntryManage/components/SupplierAddModal.tsx @@ -51,7 +51,8 @@ const SupplierAddModal: React.FC<{ const [categoryInfo, setCategoryInfo] = useState({}); // loading const [loading, setLoading] = useState(false); - + //提交防抖 + const [submitting, setSubmitting] = useState(false); const supplierDetailModal = useSupplierDetailModal(); //供应商符合性审查 const [fileList, setFileList] = useState[]>([]); @@ -145,15 +146,19 @@ const SupplierAddModal: React.FC<{ attachmentsType: 'accessory' } } - - apply({ categoryLibraryId: storeId, supplierIds: selectedIds, ...values }).then((res) => { - if(res.code == 200) { - message.success('操作成功'); - setSelectedIds([]); - onSuccess && onSuccess(); - } - }) - + if (submitting) return; // 防重复提交 + setSubmitting(true); + try { + apply({ categoryLibraryId: storeId, supplierIds: selectedIds, ...values }).then((res) => { + if(res.code == 200) { + message.success('操作成功'); + setSelectedIds([]); + onSuccess && onSuccess(); + } + }) + } finally { + setSubmitting(false); // 无论成功失败都解锁 + } }; // 自定义上传 @@ -233,7 +238,7 @@ const SupplierAddModal: React.FC<{ visible={visible} onCancel={onCancel} footer={[ - , + , , ]} width={820} diff --git a/src/pages/supplier/category/SupplierEntryReview/components/CategoryAddModal.tsx b/src/pages/supplier/category/SupplierEntryReview/components/CategoryAddModal.tsx index 712e90f..ed62622 100644 --- a/src/pages/supplier/category/SupplierEntryReview/components/CategoryAddModal.tsx +++ b/src/pages/supplier/category/SupplierEntryReview/components/CategoryAddModal.tsx @@ -60,6 +60,8 @@ const CategoryAddModal: React.FC = ({ visible, onCancel, onSuccess }) => const [expandedKeys, setExpandedKeys] = useState([]); //供应商符合性审查 const [fileList, setFileList] = useState[]>([]); + //提交防抖 + const [submitting, setSubmitting] = useState(false); const [deptOptions, setDeptOptions] = useState([]); // 自定义上传 @@ -142,6 +144,8 @@ const CategoryAddModal: React.FC = ({ visible, onCancel, onSuccess }) => // 提交校验 const handleOk = async () => { + if (submitting) return; // 防重复提交 + setSubmitting(true); try { const values = await form.validateFields(); const submitData = { @@ -172,7 +176,9 @@ const CategoryAddModal: React.FC = ({ visible, onCancel, onSuccess }) => onSuccess && onSuccess(); } }) - } catch { } + } finally { + setSubmitting(false); // 无论成功失败都解锁 + } }; return ( = ({ visible, onCancel, onSuccess }) => -
- +
diff --git a/src/pages/supplier/supplierExit/supplierExitAudit/components/CreateBlacklistModal.tsx b/src/pages/supplier/supplierExit/supplierExitAudit/components/CreateBlacklistModal.tsx index a765123..a7bfd1b 100644 --- a/src/pages/supplier/supplierExit/supplierExitAudit/components/CreateBlacklistModal.tsx +++ b/src/pages/supplier/supplierExit/supplierExitAudit/components/CreateBlacklistModal.tsx @@ -35,7 +35,8 @@ const CreateBlacklistModal: React.FC = ({ const [selectVisible, setSelectVisible] = useState(false); const [suppliers, setSuppliers] = useState([]); const [form] = Form.useForm(); - + //提交防抖 + const [submitting, setSubmitting] = useState(false); const removeSupplier = (id: number) => { setSuppliers(suppliers.filter((s) => s.id !== id)); }; @@ -46,6 +47,8 @@ const CreateBlacklistModal: React.FC = ({ }; const handleSubmit = async () => { + if (submitting) return; // 防重复提交 + setSubmitting(true); try { const values = await form.validateFields(); if (suppliers.length === 0) { @@ -76,6 +79,8 @@ const CreateBlacklistModal: React.FC = ({ } } catch (err) { // 校验失败 + } finally { + setSubmitting(false); // 无论成功失败都解锁 } }; useEffect(() => { @@ -162,7 +167,7 @@ const CreateBlacklistModal: React.FC = ({
- +
diff --git a/src/pages/supplier/supplierExit/supplierExitManage/components/CreateBlacklistModal.tsx b/src/pages/supplier/supplierExit/supplierExitManage/components/CreateBlacklistModal.tsx index 45cdcb5..e1eb88b 100644 --- a/src/pages/supplier/supplierExit/supplierExitManage/components/CreateBlacklistModal.tsx +++ b/src/pages/supplier/supplierExit/supplierExitManage/components/CreateBlacklistModal.tsx @@ -39,7 +39,8 @@ const CreateBlacklistModal: React.FC = ({ const [userDeptId, setUserDeptId] = useState(''); const currentUserStr = sessionStorage.getItem('currentUser'); const currentUser = currentUserStr ? JSON.parse(currentUserStr) : null; - + //提交防抖 + const [submitting, setSubmitting] = useState(false); //移除已选供应商 const removeSupplier = (id: number) => { setSuppliers(suppliers.filter((s) => s.id !== id)); @@ -51,6 +52,8 @@ const CreateBlacklistModal: React.FC = ({ }; //提交 const handleSubmit = async () => { + if (submitting) return; // 防重复提交 + setSubmitting(true); try { const values = await form.validateFields(); if (suppliers.length === 0) { @@ -80,6 +83,8 @@ const CreateBlacklistModal: React.FC = ({ message.error("提交失败"); } } catch (err) { + } finally { + setSubmitting(false); // 无论成功失败都解锁 } }; useEffect(() => { @@ -165,7 +170,7 @@ const CreateBlacklistModal: React.FC = ({
- +