地市组件
This commit is contained in:
@ -1,18 +1,10 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Modal, Form, Input, message, Row, Col, Descriptions, Cascader, Select } from 'antd';
|
||||
import { Modal, Form, Input, message, Row, Col, Descriptions, Select } from 'antd';
|
||||
import { getDictList } from '@/servers/api/dicts';
|
||||
import { bankView, bankAdd, bankEdit } from '../services';
|
||||
import { getRegionTree } from '@/servers/api/register';
|
||||
import type { DictItem } from '@/servers/api/dicts';
|
||||
import DictRegionSelect from '@/components/CommonSelect/DictRegionSelect'
|
||||
|
||||
// 地区字段转换
|
||||
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;
|
||||
@ -54,8 +46,6 @@ const InvoiceFormModal: React.FC<props> = ({
|
||||
const [form] = Form.useForm();
|
||||
//查看
|
||||
const [viewData, setViewData] = useState<viewDataData>({});
|
||||
// 地区
|
||||
const [addressOptions, setAddressOptions] = useState<API.RegionOption[]>([]);
|
||||
//提交防抖
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const [currency, setCurrency] = useState<DictItem[]>([]);
|
||||
@ -82,14 +72,8 @@ const InvoiceFormModal: React.FC<props> = ({
|
||||
}
|
||||
});
|
||||
} else {
|
||||
form.resetFields(); // ✅ 只有无 initialValues 才重置
|
||||
form.resetFields();
|
||||
}
|
||||
getRegionTree().then(res => {
|
||||
if (res.code === 200) {
|
||||
setAddressOptions(convertToCascaderOptions(res.data));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
getDictList('currency').then((res) => {
|
||||
if (res.code === 200) {
|
||||
@ -190,22 +174,7 @@ const InvoiceFormModal: React.FC<props> = ({
|
||||
|
||||
<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;
|
||||
});
|
||||
},
|
||||
}}
|
||||
/>
|
||||
<DictRegionSelect />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
{/* <Col span={24}>
|
||||
|
Reference in New Issue
Block a user