ERPTurbo_Admin/packages/app-operation/src/components/Company/CompanyList.tsx
shenyifei 7260b089e9 refactor(material): 重构素材库组件实现
- 移除旧的 MaterialList 组件相关配置和引用
- 删除 formatParam 工具函数的不必要导入
- 新增 MaterialLibraryModal 和 CategoryTree 组件
- 将 UploadMaterial 组件重构为使用新的素材库选择方式
- 实现素材分类树的菜单展示和选择功能
- 添加素材库弹窗的图片和列表两种视图模式
- 集成素材选择、预览和确认功能
- 移除各组件中对旧 MaterialList 的依赖配置
2026-01-07 11:25:50 +08:00

301 lines
6.6 KiB
TypeScript

import {
BizContainer,
BizValueType,
CompanyPaymentAccountList,
ModeType,
ProFormUploadMaterial,
} from '@/components';
import { business } from '@/services';
import { useIntl } from '@@/exports';
import { ProColumns, ProFormText } from '@ant-design/pro-components';
import { ProDescriptionsItemProps } from '@ant-design/pro-descriptions';
import React from 'react';
interface ICompanyListProps {
ghost?: boolean;
companyId?: BusinessAPI.CompanyVO['companyId'];
search?: boolean;
onValueChange?: () => void;
mode?: ModeType;
trigger?: () => React.ReactNode;
}
export default function CompanyList(props: ICompanyListProps) {
const {
ghost = false,
companyId,
search = true,
mode = 'page',
trigger,
onValueChange,
} = props;
const intl = useIntl();
const intlPrefix = 'company';
const columns: ProColumns<BusinessAPI.CompanyVO, BizValueType>[] = [
{
title: intl.formatMessage({ id: intlPrefix + '.column.logo' }),
dataIndex: 'logo',
key: 'logo',
valueType: 'image',
search: false,
},
{
title: intl.formatMessage({ id: intlPrefix + '.column.shortName' }),
dataIndex: 'shortName',
key: 'shortName',
renderText: (text: string) => <span className="font-medium">{text}</span>,
},
{
title: intl.formatMessage({ id: intlPrefix + '.column.fullName' }),
dataIndex: 'fullName',
key: 'fullName',
renderText: (text: string) => <span className="font-medium">{text}</span>,
},
{
title: intl.formatMessage({ id: intlPrefix + '.column.taxNumber' }),
dataIndex: 'taxNumber',
key: 'taxNumber',
valueType: 'text',
},
{
title: intl.formatMessage({ id: intlPrefix + '.column.contactPerson' }),
dataIndex: 'contactPerson',
key: 'contactPerson',
valueType: 'text',
search: false,
},
{
title: intl.formatMessage({ id: intlPrefix + '.column.contactPhone' }),
dataIndex: 'contactPhone',
key: 'contactPhone',
valueType: 'text',
search: false,
},
{
title: intl.formatMessage({ id: intlPrefix + '.column.address' }),
dataIndex: 'address',
key: 'address',
valueType: 'text',
search: false,
},
];
const formContext = [
<ProFormUploadMaterial
key={'logo'}
name={'logoList'}
label={intl.formatMessage({ id: intlPrefix + '.form.logo.label' })}
placeholder={intl.formatMessage({
id: intlPrefix + '.form.logo.placeholder',
})}
transform={(value) => {
console.log('transform', value);
return {
logoList: value,
logo: value[0],
};
}}
fieldProps={{
maxCount: 1,
}}
/>,
<ProFormText
key={'shortName'}
name={'shortName'}
label={intl.formatMessage({ id: intlPrefix + '.form.shortName.label' })}
required={true}
placeholder={intl.formatMessage({
id: intlPrefix + '.form.shortName.placeholder',
})}
rules={[
{
required: true,
message: intl.formatMessage({
id: intlPrefix + '.form.shortName.required',
}),
},
]}
/>,
<ProFormText
key={'fullName'}
name={'fullName'}
label={intl.formatMessage({ id: intlPrefix + '.form.fullName.label' })}
required={true}
placeholder={intl.formatMessage({
id: intlPrefix + '.form.fullName.placeholder',
})}
rules={[
{
required: true,
message: intl.formatMessage({
id: intlPrefix + '.form.fullName.required',
}),
},
]}
/>,
<ProFormText
key={'taxNumber'}
name={'taxNumber'}
label={intl.formatMessage({ id: intlPrefix + '.form.taxNumber.label' })}
required={true}
placeholder={intl.formatMessage({
id: intlPrefix + '.form.taxNumber.placeholder',
})}
rules={[
{
required: true,
message: intl.formatMessage({
id: intlPrefix + '.form.taxNumber.required',
}),
},
]}
/>,
<ProFormText
key={'contactPerson'}
name={'contactPerson'}
label={intl.formatMessage({
id: intlPrefix + '.form.contactPerson.label',
})}
required={true}
placeholder={intl.formatMessage({
id: intlPrefix + '.form.contactPerson.placeholder',
})}
rules={[
{
required: true,
message: intl.formatMessage({
id: intlPrefix + '.form.contactPerson.required',
}),
},
]}
tooltip={intl.formatMessage({
id: intlPrefix + '.form.contactPerson.tooltip',
})}
/>,
<ProFormText
key={'contactPhone'}
name={'contactPhone'}
label={intl.formatMessage({
id: intlPrefix + '.form.contactPhone.label',
})}
required={true}
placeholder={intl.formatMessage({
id: intlPrefix + '.form.contactPhone.placeholder',
})}
rules={[
{
required: true,
message: intl.formatMessage({
id: intlPrefix + '.form.contactPhone.required',
}),
},
]}
tooltip={intl.formatMessage({
id: intlPrefix + '.form.contactPhone.tooltip',
})}
/>,
<ProFormText
key={'address'}
name={'address'}
label={intl.formatMessage({ id: intlPrefix + '.form.address.label' })}
required={true}
placeholder={intl.formatMessage({
id: intlPrefix + '.form.address.placeholder',
})}
rules={[
{
required: true,
message: intl.formatMessage({
id: intlPrefix + '.form.address.required',
}),
},
]}
tooltip={intl.formatMessage({
id: intlPrefix + '.form.address.tooltip',
})}
/>,
];
const detailColumns: ProDescriptionsItemProps<
BusinessAPI.CompanyVO,
BizValueType
>[] = columns as ProDescriptionsItemProps<
BusinessAPI.CompanyVO,
BizValueType
>[];
const detailContext = (
companyVO: BusinessAPI.CompanyVO,
onValueChange: () => void,
) => {
return [
{
label: `付款账户`,
key: 'companyPaymentAccountList',
children: (
<CompanyPaymentAccountList
companyVO={companyVO}
ghost={true}
search={false}
onValueChange={onValueChange}
/>
),
},
];
};
return (
<BizContainer<
typeof business.company,
BusinessAPI.CompanyVO,
BusinessAPI.CompanyPageQry,
BusinessAPI.CompanyCreateCmd,
BusinessAPI.CompanyUpdateCmd
>
rowKey={'companyId'}
permission={'operation-company'}
func={business.company}
method={'company'}
methodUpper={'Company'}
intlPrefix={intlPrefix}
modeType={mode}
onValueChange={onValueChange}
container={{
ghost,
}}
remark={{
mode: 'editor',
}}
status
page={{
fieldProps: {
bordered: true,
ghost,
//@ts-ignore
search,
},
columns,
}}
create={{
formType: 'drawer',
formContext,
initValues: {
status: true,
},
}}
update={{
formType: 'drawer',
formContext,
}}
destroy={{}}
detail={{
rowId: companyId,
formType: 'drawer',
columns: detailColumns,
formContext: detailContext,
trigger,
}}
/>
);
}