import React from "react"; import { Drawer, Input, Tree, Form, Button, Card, FormReadOnly } from "kts-xui"; import { Icon, message } from "kts-components-antd-x3"; import './index.less'; export interface TaxClassificationProps { /** 是否开启 */ open?: boolean; /** 数据 */ list?: any[]; /** 点击了取消 */ onCancel?: () => void; /** 点击了选择 */ onSelect?: (key: any, info: any) => void; /** 点击了提交 */ onSubmit?: (key: any, info: any) => void; /** 点击了加载 */ onLoad: (value: any) => Promise; /** 点击了搜索 */ onSearch?: (value?: any) => void; info?: any; } export default function TaxClassificationModal(props: TaxClassificationProps) { const [form] = Form.useForm(); const searchTax = React.useCallback(async (value?: any) => { if(!value?.target?.value) { form.resetFields(); } props.onSearch && props.onSearch(value); }, [props.onSearch, form]); React.useEffect(() => { if (!props.open) { setTimeout(()=> { form.resetFields(); }, 500) } }, [form, props.open]); // const [childrenDrawer, setChildrenDrawer] = React.useState(false); const showChildrenDrawer = (key: any, info: any) => { if(props.onSelect){ props.onSelect(key, info); } // setChildrenDrawer(true); }; const onChildrenDrawerClose = () => { // setChildrenDrawer(false); if(props.onCancel){ props.onCancel(); } }; const layout = { labelCol: { span: 8 }, wrapperCol: { span: 16 }, }; const sureTaxCodeSubmit = () => { form.validateFields().then(values => { // if(!values.taxCategoryCode){ // message.warn('请选择税收分类编码'); // return; // } onChildrenDrawerClose(); props.onSubmit && props.onSubmit(props.info?.key, {...props.info,...values}); }).catch(errorInfo => { console.log('errorInfo', errorInfo); }); } React.useEffect(() => { form.setFieldsValue({ ...form.getFieldsValue(), taxCategoryCode: props?.info?.taxCategoryCode, productName: props?.info?.productName, shorthand: props?.info?.shorthand, taxDesc: props?.info?.taxDesc, }) },[props?.info?.key]) return ( } >
{showChildrenDrawer(key, info)}} loadData={props.onLoad} treeData={props.list} switcherIcon={} />
) }