- 在BizProvider中新增supplierInvoice类型支持 - 添加SupplierInvoiceList组件用于显示供应商发票信息 - 为经销商显示添加市场/超市标识区分 - 更新公司支付账户模态框类型定义以支持业务值类型 - 优化订单成本列表中的公司字段显示方式 - 在订单供应商列表中新增发票上传状态显示 - 为订单供应商模态框添加开票状态逻辑处理 - 更新多个模态框的列配置以支持业务值类型 - 调整选择模态框布局大小和分页配置 - 移除支付记录列表的编辑删除功能 - 优化订单供应商选择列表的发票相关字段显示
176 lines
3.9 KiB
TypeScript
176 lines
3.9 KiB
TypeScript
import { BizValueType, Remark, SelectModal } from '@/components';
|
|
import { business } from '@/services';
|
|
import { formatParam } from '@/utils/formatParam';
|
|
import {
|
|
ActionType,
|
|
LightFilter,
|
|
ProColumns,
|
|
ProFormTreeSelect,
|
|
} from '@ant-design/pro-components';
|
|
import { ModalProps, TreeSelect } from 'antd';
|
|
import { useEffect, useRef, useState } from 'react';
|
|
|
|
export interface IMaterialModalProps extends ModalProps {
|
|
maxCount: number;
|
|
onFinish: (materialList: BusinessAPI.MaterialVO[]) => void;
|
|
fileList?: any[];
|
|
type?: 'checkbox' | 'radio';
|
|
}
|
|
|
|
export default function MaterialModal(props: IMaterialModalProps) {
|
|
const {
|
|
maxCount,
|
|
onFinish,
|
|
fileList: initialFileList,
|
|
type = 'radio',
|
|
...rest
|
|
} = props;
|
|
const actionRef = useRef<ActionType>();
|
|
const [fileList, setFileList] = useState<any[]>([]);
|
|
const [params, setParams] = useState<BusinessAPI.MaterialPageQry>();
|
|
|
|
useEffect(() => {
|
|
setFileList(initialFileList || []);
|
|
}, [initialFileList]);
|
|
|
|
const columns: ProColumns<BusinessAPI.MaterialVO, BizValueType>[] = [
|
|
{
|
|
title: '素材名称',
|
|
dataIndex: 'name',
|
|
order: 3,
|
|
},
|
|
{
|
|
title: '素材内容',
|
|
dataIndex: 'url',
|
|
search: false,
|
|
render: (_, record) => {
|
|
return record.type === 'FILE_IMAGE' || record.type === 'FILE_VIDEO' ? (
|
|
// 可预览
|
|
<a
|
|
href={record.url}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
style={{
|
|
display: 'inline-block',
|
|
width: 22,
|
|
height: 22,
|
|
overflow: 'hidden',
|
|
}}
|
|
>
|
|
<img
|
|
src={record.url}
|
|
alt={record.name}
|
|
style={{ width: 22, height: 22 }}
|
|
/>
|
|
</a>
|
|
) : (
|
|
<Remark remark={record.path} />
|
|
);
|
|
},
|
|
},
|
|
{
|
|
title: '素材分类',
|
|
dataIndex: 'categoryId',
|
|
valueType: 'treeSelect',
|
|
request: async (params) => {
|
|
const { data } = await business.materialCategory.treeMaterialCategory({
|
|
categoryTreeQry: {
|
|
...params,
|
|
},
|
|
});
|
|
return data || [];
|
|
},
|
|
fieldProps: {
|
|
fieldNames: {
|
|
label: 'name',
|
|
children: 'children',
|
|
value: 'categoryId',
|
|
},
|
|
showSearch: true,
|
|
allowClear: true,
|
|
autoClearSearchValue: true,
|
|
filterTreeNode: true,
|
|
multiple: false,
|
|
treeNodeFilterProp: 'name',
|
|
},
|
|
},
|
|
];
|
|
|
|
return (
|
|
<SelectModal
|
|
rowKey={'materialId'}
|
|
modalProps={{
|
|
title: '选择素材',
|
|
...rest,
|
|
afterClose: () => {
|
|
setFileList([]);
|
|
},
|
|
}}
|
|
selectedList={fileList}
|
|
tableProps={{
|
|
actionRef: actionRef,
|
|
rowKey: 'materialId',
|
|
columns: columns,
|
|
params: params,
|
|
request: async (params, sorter, filter) => {
|
|
const { data, success, totalCount } =
|
|
await business.material.pageMaterial({
|
|
materialPageQry: formatParam<typeof params>(
|
|
params,
|
|
sorter,
|
|
filter,
|
|
),
|
|
});
|
|
|
|
return {
|
|
data: data || [],
|
|
total: totalCount,
|
|
success,
|
|
};
|
|
},
|
|
toolbar: {
|
|
filter: (
|
|
<LightFilter
|
|
onFinish={async (values) => {
|
|
setParams(values as any);
|
|
}}
|
|
>
|
|
<ProFormTreeSelect
|
|
label="素材分类"
|
|
required={false}
|
|
name="categoryId"
|
|
request={async () => {
|
|
const { data } =
|
|
await business.materialCategory.treeMaterialCategory({
|
|
categoryTreeQry: {},
|
|
});
|
|
|
|
return data || [];
|
|
}}
|
|
fieldProps={{
|
|
showSearch: true,
|
|
allowClear: true,
|
|
autoClearSearchValue: true,
|
|
filterTreeNode: true,
|
|
multiple: true,
|
|
treeNodeFilterProp: 'name',
|
|
showCheckedStrategy: TreeSelect.SHOW_ALL,
|
|
fieldNames: {
|
|
label: 'name',
|
|
children: 'children',
|
|
value: 'categoryId',
|
|
},
|
|
placeholder: '请选择素材分类',
|
|
}}
|
|
/>
|
|
</LightFilter>
|
|
),
|
|
},
|
|
}}
|
|
onFinish={onFinish}
|
|
num={(maxCount || 1) - fileList.length}
|
|
type={type}
|
|
/>
|
|
);
|
|
}
|