import React from 'react'; import { Form } from 'kts-components-antd-x3'; import { Select, Input, Spin, InputProps, Cascader } from 'kts-xui'; import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form'; import { IGood2 } from '../../../../../InvoiceController'; import Invoice from '../../../../..'; import TitleText from './ui/TitleText'; export default (form: WrappedFormUtils) => { const { getFieldDecorator } = form; const controller = Invoice.useInvoiceController(); const rootElement = controller.useMemo(s => s.rootElement, []); /** 组件模式 */ const model = controller.useMemo(e => e.model, []); /** 正在编辑的货物 */ const editGood = controller.useMemo((e) => e.freightListState.editGood, []); /** 禁用字段 */ const disableds = controller.useMemo((e) => e.stakeholder.disableds || [], []); /** 运输工具种类列表 */ const vehicleTypeList = controller.useMemo((e) => e.freightListState.vehicleTypeList, []); const area = controller.useMemo((e) => e.freightListState.area, []); const addressFieldNames = controller.useMemo((e) => e.freightListState.addressFieldNames, []); const getVehicle = React.useCallback((value?: string) => { if (vehicleTypeList && vehicleTypeList.length > 0) { return vehicleTypeList.find(e => e.value === value)?.label || ''; } }, [vehicleTypeList]) const splitArea = React.useCallback((value?: string) => { if (value) { const _array = value.split(','); return _array; } else { return []; } }, []); /** 表头 */ const columns = React.useMemo(() => { return [ { title: '序号', key: 'sortNumber', dataIndex: 'sortNumber', width: 50, render: (e: number) => {e}, }, { title: 运输工具种类, key: 'type', render: (_: string, record: IGood2) => { if (editGood?.$index === record.$index && !disableds.includes('type') && !(model === 'prefab')) { return ( {getFieldDecorator('type', { initialValue: editGood.type, rules: [ { required: true, message: '请输入' }, ], })( , )} ); } else { return {getVehicle(record.type)}; } }, }, { title: 运输工具牌号, key: 'licensePlate', width: 119, render: (_: string, record: IGood2) => { if (editGood?.$index === record.$index && !disableds.includes('licensePlate') && model !== 'prefab') { return ( {getFieldDecorator('licensePlate', { initialValue: editGood.licensePlate, rules: [ { required: true, message: '请输入' }, ], })( { await controller.wait() await controller.setEditFreight({ licensePlate: form.getFieldsValue().licensePlate }); }} />, )} ); } else { return {record.licensePlate}; } }, }, { title: 起运地, key: 'origin', width: 150, render: (_: string, record: IGood2) => { if (editGood?.$index === record.$index && !disableds.includes('origin') && model !== 'prefab') { return ( {getFieldDecorator('origin', { initialValue: editGood.origin, rules: [ { required: true, message: '请输入' }, ], })( { await controller.setEditFreight({ origin: value }); }} />)} ); } else { return {record.origin}; } }, }, { title: 到达地, dataIndex: 'destination', key: 'destination', width: 149, render: (_: string, record: IGood2) => { if (editGood?.$index === record.$index && !disableds.includes('destination') && model !== 'prefab') { return ( {getFieldDecorator('destination', { initialValue: editGood.destination, rules: [ { required: true, message: '请输入' }, ], })( { await controller.setEditFreight({ destination: value }); }} /> )} ); } else { return {record.destination}; } }, }, { title: 运输货物名称, dataIndex: 'itemName', key: 'itemName', width: 149, render: (_: string, record: IGood2) => { if (editGood?.$index === record.$index && !disableds.includes('itemName') && model !== 'prefab') { return ( {getFieldDecorator('itemName', { initialValue: editGood.itemName, rules: [ { required: true, message: '请输入货物名称' }, ], })( { await controller.wait() await controller.setEditFreight({ itemName: form.getFieldsValue().itemName }); }} />, )} ); } else { return {record.itemName}; } }, }, ] // 只读 .filter(e => { if (model === 'readOnly') { return e.key !== 'operating'; } else { return true; } }) .map((e) => { return { ...e, ellipsis: true, }; }) as any[]; }, [editGood, controller, model, getVehicle]); return columns; }; class MyInput extends React.Component { render() { if (this.props.loading) { return ( ) } else { return } } }