Files
fe_supplier_frontend/src/components/CompanyInfo/component/PeBaseInfoFormModal.tsx

110 lines
2.6 KiB
TypeScript
Raw Normal View History

2025-07-09 14:01:45 +08:00
import React, { useEffect, useState } from 'react';
import { Modal, Form, message, Input, Upload, Button } from 'antd';
import Person from './Person';
import { updateSupplierBase } from '../services'
interface Props {
visible: boolean;
onOk: () => void;
onCancel: () => void;
initialValues?: coscoSupplierBases;
}
// 基础信息
interface coscoSupplierBases {
id?: string;
supplierType?: string;
name?: string;
nameEn?: string;
range?: string;
workAddress?: string;
parentCompanyInvestor?: string;
legalPerson?: string;
capital?: string;
contactsName?: string;
contactsPhone?: string;
contactsEmail?: string;
nation?: string;
vat?: string;
currency?: string;
licenceAccessory?: string;
licenceDate?: string;
enterpriseType?: string;
socialCreditCode?: string;
regAddress?: string;
idCard?: string;
contactsType?: string;
telephone?: string;
coscoSupplierSurveyAttachments?: coscoSupplierSurveyAttachments[];
}
interface coscoSupplierSurveyAttachments {
attachmentsType: string;
fileName: string;
fileType: string;
fileSize: string;
filePath: string;
fileUrl: string;
}
const BaseInfoFormModal: React.FC<Props> = ({
visible,
onOk,
onCancel,
initialValues,
}) => {
const [form] = Form.useForm();
//数据初始化
useEffect(() => {
if (visible && initialValues) {
form.setFieldsValue({
coscoSupplierBase: {
...initialValues,
},
});
} else {
form.resetFields();
}
}, [visible, initialValues]);
//确认提交
const handleFinish = async () => {
const values = await form.validateFields();
const payload = {
...values,
};
payload.coscoSupplierBase.name = payload.coscoSupplierBase.personName;
payload.coscoSupplierBase.contactPhone = payload.coscoSupplierBase.personPhone;
payload.coscoSupplierBase.id = initialValues?.id;
const res = await updateSupplierBase(payload);
if (res.code === 200) {
message.success('修改成功');
onOk();
}
};
return (
<Modal
title="企业基本信息"
visible={visible}
onCancel={onCancel}
onOk={handleFinish}
destroyOnClose
width={800}
>
<Form form={form} labelCol={{ flex: '140px' }} wrapperCol={{ flex: 1 }} >
<Person form={form} />
</Form>
</Modal >
);
};
export default BaseInfoFormModal;