流程问题修改-准入与后台
This commit is contained in:
@ -1,10 +1,16 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Modal, Form, Input, Button, Upload, message, Row, Col, Descriptions } from 'antd';
|
||||
import { Modal, Form, Input, Button, Upload, message, Row, Col, Descriptions, Cascader } from 'antd';
|
||||
import type { UploadProps } from 'antd';
|
||||
import { UploadOutlined } from '@ant-design/icons';
|
||||
import { uploadFile, bankView, bankAdd, bankEdit, coscoSupplierBase } from '../services';
|
||||
import { getRegionTree, getregionInternational } from '@/servers/api/register';
|
||||
|
||||
function convertToCascaderOptions(data: any[]): any[] {
|
||||
return data.map(item => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
children: item.children && item.children.length > 0 ? convertToCascaderOptions(item.children) : undefined,
|
||||
}));
|
||||
}
|
||||
interface props {
|
||||
visible: boolean;
|
||||
onOk: () => void;
|
||||
@ -43,6 +49,9 @@ const InvoiceFormModal: React.FC<props> = ({
|
||||
const [form] = Form.useForm();
|
||||
//查看
|
||||
const [viewData, setViewData] = useState<viewDataData>({});
|
||||
// 地区
|
||||
const [addressOptions, setAddressOptions] = useState<API.RegionOption[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (visible) {
|
||||
if (initialValues) {
|
||||
@ -59,14 +68,14 @@ const InvoiceFormModal: React.FC<props> = ({
|
||||
setViewData(fields);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
form.resetFields(); // ✅ 只有无 initialValues 才重置
|
||||
}
|
||||
getRegionTree().then(res => {
|
||||
if (res.code === 200) {
|
||||
setAddressOptions(convertToCascaderOptions(res.data));
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [visible, initialValues]);
|
||||
|
||||
@ -78,6 +87,10 @@ const InvoiceFormModal: React.FC<props> = ({
|
||||
...values,
|
||||
supplierId: userId,
|
||||
};
|
||||
payload.province = payload.address[0];
|
||||
payload.city = payload.address[1];
|
||||
payload.nation = payload.address[2];
|
||||
|
||||
if (!values.id) {
|
||||
bankAdd(payload).then((res) => {
|
||||
if (res.code == 200) {
|
||||
@ -103,6 +116,13 @@ const InvoiceFormModal: React.FC<props> = ({
|
||||
const uploadProps: UploadProps = {
|
||||
name: 'file',
|
||||
showUploadList: true,
|
||||
beforeUpload: (file) => {
|
||||
if (file.size > 1048576) { // 1MB
|
||||
message.error('文件大小不能超过1MB');
|
||||
return Upload.LIST_IGNORE; // 阻止上传
|
||||
}
|
||||
return true;
|
||||
},
|
||||
customRequest: async ({ file, onSuccess, onError }) => {
|
||||
try {
|
||||
const realFile = file as File;
|
||||
@ -172,7 +192,28 @@ const InvoiceFormModal: React.FC<props> = ({
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
|
||||
<Col span={24}>
|
||||
<Form.Item name="address" label="地址" rules={[{ required: true }]}>
|
||||
<Cascader
|
||||
options={addressOptions}
|
||||
placeholder="请选择地址"
|
||||
showSearch={{
|
||||
filter: (inputValue, path) => {
|
||||
return path.some((option) => {
|
||||
if (typeof option.label === 'string') {
|
||||
return (
|
||||
option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1
|
||||
);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
{/* <Col span={24}>
|
||||
<Form.Item name="province" label="省份" rules={[{ required: true }]}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
@ -186,7 +227,7 @@ const InvoiceFormModal: React.FC<props> = ({
|
||||
<Form.Item name="nation" label="国家/地区" rules={[{ required: true }]}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Col> */}
|
||||
<Col span={24}>
|
||||
<Form.Item name="currency" label="币种" rules={[{ required: true }]}>
|
||||
<Input />
|
||||
|
Reference in New Issue
Block a user