pay-admin/src/pages/merchants/modals/CreateCounters.tsx

89 lines
2.5 KiB
TypeScript
Raw Normal View History

2025-06-27 16:42:11 +08:00
import {
MyBetaModalFormProps,
MyButtons,
MyFormItems,
MyModalFormProps,
rulesHelper,
} from '@/common';
import { Selects } from '@/components/Selects';
import { Apis } from '@/gen/Apis';
import { CommissionTypeEnum } from '@/gen/Enums';
import { BetaSchemaForm } from '@ant-design/pro-components';
import { message } from 'antd';
export default function CreateCounters(props: MyBetaModalFormProps) {
return (
<BetaSchemaForm<ApiTypes.MerchantCounters.Store>
{...MyModalFormProps.props}
title={`添加${props.title}`}
wrapperCol={{ span: 24 }}
width="800px"
trigger={<MyButtons.Create title={`添加${props.title}`} />}
onFinish={async (values) =>
Apis.MerchantCounters.Store({ ...props?.item, ...values })
.then(() => {
props.reload?.();
message.success(props.title + '成功');
return true;
})
.catch(() => false)
}
columns={[
Selects.Markets({ required: true }),
{
key: 'name',
title: '名称',
formItemProps: { ...rulesHelper.text },
},
{
key: 'up_merchant_no',
title: '上游商家编号',
formItemProps: { ...rulesHelper.text },
},
{
valueType: 'formList',
dataIndex: 'commissions',
title: '分佣配置',
formItemProps: { ...rulesHelper.array },
fieldProps: {
copyIconProps: false,
},
columns: [
{
valueType: 'group',
colProps: { span: 24 },
columns: [
{
key: 'seq',
colProps: { span: 3 },
title: '序号',
width: '100%',
formItemProps: { ...rulesHelper.text },
},
MyFormItems.EnumSelect({
key: 'type',
title: '类型',
colProps: { span: 4 },
valueEnum: CommissionTypeEnum,
required: true,
formItemProps: { ...rulesHelper.text },
}),
{
key: 'merchant_no',
colProps: { span: 9 },
title: '商户编号',
},
{
key: 'percent',
colProps: { span: 8 },
title: '分佣比例%(0为自动计算)',
},
],
},
],
},
]}
/>
);
}