123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- import { ProFormColumnsType } from "@ant-design/pro-components";
- import { useModel } from "@umijs/max";
- function formConfig(props: { paragraphList?: any[], enumList?: { [key: string]: any }, paymentType: any, paymentCategory: any, isGlobalConfig: boolean }): ProFormColumnsType<{
- name: string;
- state: string;
- }>[] {
- let { paragraphList, enumList, paymentType, paymentCategory, isGlobalConfig } = props
- let {getEnum} = useModel('global')
- return [
- {
- title: '付费方式',
- dataIndex: 'paymentType',
- valueType: 'radio',
- fieldProps: {
- onChange: (e) => {
- let value = e.target.value
- paymentType[1](value)
- }
- },
- formItemProps: {
- style: { marginBottom: 10 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- valueEnum: () => {
- return getEnum("PAYMENT_TYPE","map")
- }
- },
- {
- title: '收费类型',
- dataIndex: 'paymentOption',
- valueType: 'radio',
- formItemProps: {
- style: { marginBottom: 10 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- hideInForm: paymentType[0] != 2,
- valueEnum: () => {
- return getEnum("PAYMENT_OPTION","map")
- }
- },
- {
- title: '收费货币',
- dataIndex: 'paymentCategory',
- valueType: 'radio',
- fieldProps: {
- onChange: (e) => {
- let value = e.target.value
- paymentCategory[1](value)
- }
- },
- formItemProps: {
- style: { marginBottom: 10 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- hideInForm: paymentType[0] == 0,
- valueEnum: () => {
- return getEnum("PAYMENT_CATEGORY","map")
- }
- },
- {//单本
- title: '付费起始段落',
- dataIndex: 'beginPayParagraphNo',
- valueType: 'select',
- fieldProps: {
- showSearch: true, placeholder: '请选择开始收费段落'
- },
- formItemProps: {
- style: { marginBottom: 15 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- hideInForm: paymentType[0] != 2 || isGlobalConfig,//单本书
- valueEnum: () => {
- return new Map(paragraphList?.map(item => [item.paragraphNo, item.content]))
- }
- },
- {//全局
- title: '付费起始段落',
- dataIndex: 'beginPayNo',
- valueType: 'digit',
- fieldProps: {
- placeholder: '请输入收费段落'
- },
- width: 200,
- formItemProps: {
- style: { marginBottom: 15 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- hideInForm: paymentType[0] != 2 || !isGlobalConfig,//单本书
- },
- {
- title: 'VIP阅读',
- dataIndex: 'vipFree',
- valueType: 'segmented',
- formItemProps: {
- style: { marginBottom: 15 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- hideInForm: paymentType[0] == 0 || isGlobalConfig,
- valueEnum: () => {
- return getEnum("VIP_FREE","map")
- }
- },
- {
- title: '收费金额',
- dataIndex: 'paymentAmount',
- valueType: 'money',
- hideInForm: paymentCategory[0] == 1,
- fieldProps: {
- addonAfter: "元"
- },
- formItemProps: {
- style: { marginBottom: 15 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- },
- {
- title: '收费书币',
- dataIndex: 'paymentCoin',
- valueType: 'digit',
- hideInForm: paymentCategory[0] == 0,
- fieldProps: {
- addonAfter: "书币"
- },
- formItemProps: {
- style: { marginBottom: 15 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- },
- {
- title: '备注',
- dataIndex: 'remark',
- valueType: 'textarea',
- hideInForm: isGlobalConfig,
- formItemProps: {
- style: { marginBottom: 15 },
- },
- }
- ]
- }
- export default formConfig
|