import { BizContainer, BizValueType, CompanyList, CostList, ModeType, OrderSelect, } from '@/components'; import { business } from '@/services'; import groupby from '@/utils/groupby'; import { useIntl } from '@@/exports'; import { ProColumns, ProFormDependency, ProFormMoney, ProFormText, } from '@ant-design/pro-components'; import { ProDescriptionsItemProps } from '@ant-design/pro-descriptions'; import { ProFormBizSelect } from '@chageable/components'; import { ProFormBizSelectHandles } from '@chageable/components/src'; import { Button, Space } from 'antd'; import React, { useRef, useState } from 'react'; interface IOrderCostListProps { ghost?: boolean; orderCostId?: BusinessAPI.OrderCostVO['orderCostId']; search?: boolean; onValueChange?: () => void; mode?: ModeType; trigger?: () => React.ReactNode; } export default function OrderCostList(props: IOrderCostListProps) { const { ghost = false, orderCostId, search = true, mode = 'page', trigger, onValueChange, } = props; const intl = useIntl(); const intlPrefix = 'orderCost'; const costRef = useRef(null); const [activeKey, setActiveKey] = useState('ALL'); const columns: ProColumns[] = [ { title: intl.formatMessage({ id: intlPrefix + '.column.order' }), dataIndex: 'orderVO', key: 'orderId', valueType: 'order', }, { title: intl.formatMessage({ id: intlPrefix + '.column.name' }), dataIndex: 'name', key: 'costId', valueType: 'select', fieldProps: { fetchDataOnSearch: false, showSearch: true, autoClearSearchValue: true, }, request: async () => { const { data } = await business.cost.listCost({ costListQry: {}, }); const costGroup = groupby(data || [], (item) => item.type); const options = Object.keys(costGroup).map((key) => ({ label: intl.formatMessage({ id: 'cost.column.type.enum.' + key .toLowerCase() .replace(/_([a-z])/g, (_, char) => char.toUpperCase()), }), title: key, options: costGroup[key].map((item) => ({ label: item.name, value: item.costId, })), })); return options || []; }, }, { title: intl.formatMessage({ id: intlPrefix + '.column.principal' }), dataIndex: 'principal', key: 'principal', }, { title: intl.formatMessage({ id: intlPrefix + '.column.belong' }), dataIndex: 'belong', key: 'belong', valueType: 'select', valueEnum: { NONE_TYPE: intl.formatMessage({ id: intlPrefix + '.column.belong.enum.noneType', }), WORKER_TYPE: { text: intl.formatMessage({ id: intlPrefix + '.column.belong.enum.workerType', }), }, PRODUCTION_TYPE: { text: intl.formatMessage({ id: intlPrefix + '.column.belong.enum.productionType', }), }, DRIVER_TYPE: { text: intl.formatMessage({ id: intlPrefix + '.column.belong.enum.driverType', }), }, }, }, { title: intl.formatMessage({ id: intlPrefix + '.column.price' }), dataIndex: 'price', key: 'price', valueType: 'money', search: false, }, { title: intl.formatMessage({ id: intlPrefix + '.column.orderCompany' }), dataIndex: 'orderCompany', valueType: 'select', request: async (params) => { const { data } = await business.company.listCompany({ companyListQry: { ...params, }, }); return ( data?.map((item) => { return { label: item.fullName, value: item.companyId, }; }) || [] ); }, render: (_, record) => { return ( {record.orderCompany.fullName}} /> ); }, }, { title: intl.formatMessage({ id: intlPrefix + '.column.isPaid' }), dataIndex: 'isPaid', key: 'isPaid', valueType: 'select', valueEnum: { true: { text: intl.formatMessage({ id: intlPrefix + '.column.isPaid.enum.paid', }), status: 'success', }, false: { text: intl.formatMessage({ id: intlPrefix + '.column.isPaid.enum.unpaid', }), status: 'processing', }, }, }, ]; const formContext = [ { const { data } = await business.cost.listCost({ costListQry: { type: 'LOGISTICS_TYPE', }, }); const costGroup = groupby( data?.filter( (item) => item.type === 'LOGISTICS_TYPE' && item.name !== '主运费' && item.name !== '短驳费' && item.name !== '草帘费', ) || [], (item) => item.type, ); const options = Object.keys(costGroup).map((key) => ({ label: intl.formatMessage({ id: 'cost.column.type.enum.' + key .toLowerCase() .replace(/_([a-z])/g, (_, char) => char.toUpperCase()), }), title: key, options: costGroup[key].map((item) => ({ label: item.name, value: item.costId, })), })); return options || []; }} fieldProps={{ fetchDataOnSearch: false, showSearch: true, autoClearSearchValue: true, }} addonAfter={ costRef.current?.reload()} /> } />, , {({ orderVO }, form) => { form.setFieldsValue({ principal: orderVO?.orderVehicle.driver, }); return ( <> {orderVO && ( )} {orderVO && ( )} ); }} ,