import React from 'react'; import classnames from 'classnames'; import { decorator } from 'grey-react-box'; import { Form } from 'kts-components-antd-x3'; import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form'; import { FormComponentProps } from 'kts-components-antd-x3/lib/form'; import Invoice from '../../..'; import TableVirtual from './ui/TableVirtual'; import AddRowButton from './ui/AddRowButton'; import TableRow from './ui/TableRow'; import useColumns from './hook/useColumns'; import useOnRow from './hook/useOnRow'; import useWindowClick from './hook/useWindowClick'; import useRowSelection from './hook/useRowSelection'; import useDelRowButton from './ui/BulkMenu/hooks/useDelRowButton'; import './index.less'; export interface IGoodsListProps { /** 产品最大数 */ goodMax?: number; addressOptions: any[]; vehicleTypeList:any[]; /** * 地址数据字段名 */ fieldNames?: any; } export default class FreightList extends React.Component { render() { return
} } const Main = decorator(Form.create())((props) => { const { form } = props; /** 控制器 */ const controller = Invoice.useInvoiceController(); const goodsList = controller.useMemo(s => s.freightListState.goodsList, []); /** 货物列表 */ const dataSource = controller.useMemo(s => s.freightListState.goodsList, []) /** 表格行事件 */ const onRow = useOnRow(); /** 批量删除 */ const delRowButton = useDelRowButton(); useWindowClick(controller); // 点击组件外部 保存正在编辑的货物 /** 注册 from 对象 */ React.useEffect(() => { controller.pipeline(async (s, form) => { s.freightListState = { ...s.freightListState, form } })(props.form); }, [controller, props.form]); React.useEffect(() => { controller.run(async (s) => { s.freightListState.addressFieldNames = props.fieldNames }); }, [props.fieldNames]) React.useEffect(() => { controller.run(async (s) => { s.freightListState.vehicleTypeList = props.vehicleTypeList }); }, [props.vehicleTypeList]) React.useEffect(() => { controller.run(async (s) => { s.freightListState.area = props.addressOptions }); }, [props.addressOptions]) // 跟新 货物 React.useEffect(() => { controller.run(async (s) => { s.freightListState.goodsMap = new Map(); goodsList.forEach((e) => { s.freightListState.goodsMap.set(e.$index, e); }); }); }, [controller, goodsList]); /** props 产品最大数 更新 */ React.useEffect(() => { controller.pipeline(async s => { s.freightListState.goodMax = props.goodMax })() }, [controller, props.goodMax]) // 注册 form // controller.useForm('freightInfo', form); return (
特殊信息-货物运输
{ e.stopPropagation() }} >
{/* 添加行 */} {/* 批量删除 */} {delRowButton.button}
({ onClick: () => { onRow.onClick(record); }, })} />
); });