- 在 CostList 组件中增加物流类型和司机类型的枚举支持 - 更新表单和列配置以支持新的费用类型(LOGISTICS_TYPE, DRIVER_TYPE) - 隐藏物流类型的费用项显示 - 修改费用项依赖逻辑以适配新的人工类型 - 添加 OrderCostList 组件用于展示订单相关的成本费用信息 - 实现费用名称下拉选择及分组展示 - 支持通过是否付款状态筛选数据 - 展示关联采购单、车辆路线及公司信息 - 提供已付款/未付款标签页切换 - 引入 orderCost 相关接口和服务 - 更新权限标识为 operation-order-cost - 增加国际化文案支持新增的字段和选项 - 调整角色ID和标签ID类型为字符串数组 - 替换 PaymentCost 页面组件引用为 OrderCostList
275 lines
6.0 KiB
TypeScript
275 lines
6.0 KiB
TypeScript
import {
|
|
BizContainer,
|
|
BizValueType,
|
|
CompanyList,
|
|
ModeType,
|
|
PurchaseOrderList,
|
|
} from '@/components';
|
|
import { business } from '@/services';
|
|
import { useIntl } from '@@/exports';
|
|
import { ProColumns } from '@ant-design/pro-components';
|
|
import { ProDescriptionsItemProps } from '@ant-design/pro-descriptions';
|
|
import React, { useState } from 'react';
|
|
import groupby from '@/utils/groupby';
|
|
|
|
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 [activeKey, setActiveKey] = useState<string>('ALL');
|
|
|
|
const columns: ProColumns<BusinessAPI.OrderCostVO, BizValueType>[] = [
|
|
{
|
|
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: {
|
|
WORKER_TYPE: {
|
|
text: intl.formatMessage({
|
|
id: intlPrefix + '.column.belong.workerType',
|
|
}),
|
|
},
|
|
PRODUCTION_TYPE: {
|
|
text: intl.formatMessage({
|
|
id: intlPrefix + '.column.belong.productionType',
|
|
}),
|
|
},
|
|
DRIVER_TYPE: {
|
|
text: intl.formatMessage({
|
|
id: intlPrefix + '.column.belong.driverType',
|
|
}),
|
|
},
|
|
},
|
|
},
|
|
{
|
|
title: intl.formatMessage({ id: intlPrefix + '.column.price' }),
|
|
dataIndex: 'price',
|
|
key: 'price',
|
|
valueType: 'money',
|
|
search: false,
|
|
},
|
|
{
|
|
title: intl.formatMessage({ id: intlPrefix + '.column.purchaseOrder' }),
|
|
dataIndex: 'purchaseOrderVO',
|
|
key: 'poOrderSn',
|
|
render: (_, record) => {
|
|
return (
|
|
<PurchaseOrderList
|
|
ghost={true}
|
|
mode={'detail'}
|
|
orderId={record.purchaseOrderVO.orderId}
|
|
trigger={() => <a href={'#'}>{record.purchaseOrderVO.orderSn}</a>}
|
|
/>
|
|
);
|
|
},
|
|
},
|
|
{
|
|
title: intl.formatMessage({ id: intlPrefix + '.column.orderVehicle' }),
|
|
dataIndex: 'orderVehicle',
|
|
key: 'ovVehicleNo',
|
|
render: (_, record) => {
|
|
return (
|
|
<span>
|
|
{record.orderVehicle.origin} 至 {record.orderVehicle.destination}
|
|
</span>
|
|
);
|
|
},
|
|
},
|
|
{
|
|
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 (
|
|
<CompanyList
|
|
ghost={true}
|
|
mode={'detail'}
|
|
companyId={record.orderCompany.companyId}
|
|
trigger={() => <a href={'#'}>{record.orderCompany.fullName}</a>}
|
|
/>
|
|
);
|
|
},
|
|
},
|
|
{
|
|
title: intl.formatMessage({ id: intlPrefix + '.column.isPaid' }),
|
|
dataIndex: 'isPaid',
|
|
key: 'isPaid',
|
|
valueType: 'select',
|
|
valueEnum: {
|
|
true: {
|
|
text: intl.formatMessage({
|
|
id: intlPrefix + '.column.isPaid.paid',
|
|
}),
|
|
status: 'success',
|
|
},
|
|
false: {
|
|
text: intl.formatMessage({
|
|
id: intlPrefix + '.column.isPaid.unpaid',
|
|
}),
|
|
status: 'processing',
|
|
},
|
|
},
|
|
},
|
|
];
|
|
|
|
const detailColumns: ProDescriptionsItemProps<
|
|
BusinessAPI.OrderCostVO,
|
|
BizValueType
|
|
>[] = columns as ProDescriptionsItemProps<
|
|
BusinessAPI.OrderCostVO,
|
|
BizValueType
|
|
>[];
|
|
|
|
return (
|
|
<BizContainer<
|
|
typeof business.orderCost,
|
|
BusinessAPI.OrderCostVO,
|
|
BusinessAPI.OrderCostPageQry
|
|
>
|
|
rowKey={'orderCostId'}
|
|
permission={'operation-order-cost'}
|
|
func={business.orderCost}
|
|
method={'orderCost'}
|
|
methodUpper={'OrderCost'}
|
|
intlPrefix={intlPrefix}
|
|
modeType={mode}
|
|
onValueChange={onValueChange}
|
|
container={{
|
|
ghost,
|
|
}}
|
|
status={false}
|
|
page={{
|
|
fieldProps: {
|
|
bordered: true,
|
|
ghost,
|
|
//@ts-ignore
|
|
search,
|
|
params: {
|
|
...(activeKey !== 'ALL' && {
|
|
isPaid: activeKey! as any,
|
|
}),
|
|
poStates: ['COMPLETED'],
|
|
belongs: ['WORKER_TYPE', 'PRODUCTION_TYPE', 'DRIVER_TYPE'],
|
|
},
|
|
toolbar: {
|
|
menu: {
|
|
type: 'tab',
|
|
activeKey: activeKey,
|
|
items: [
|
|
// 全部
|
|
{
|
|
key: 'ALL',
|
|
label: intl.formatMessage({
|
|
id: intlPrefix + '.tab.all',
|
|
}),
|
|
},
|
|
// 已支付
|
|
{
|
|
key: 'true',
|
|
label: intl.formatMessage({
|
|
id: intlPrefix + '.tab.paid',
|
|
}),
|
|
},
|
|
// 未支付
|
|
{
|
|
key: 'false',
|
|
label: intl.formatMessage({
|
|
id: intlPrefix + '.tab.unpaid',
|
|
}),
|
|
},
|
|
],
|
|
onChange: (key) => {
|
|
setActiveKey(key as string);
|
|
},
|
|
},
|
|
},
|
|
},
|
|
columns,
|
|
}}
|
|
create={false}
|
|
update={false}
|
|
destroy={false}
|
|
detail={{
|
|
rowId: orderCostId,
|
|
formType: 'drawer',
|
|
columns: detailColumns,
|
|
trigger,
|
|
}}
|
|
/>
|
|
);
|
|
}
|