12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- import { convertEnumArr } from "@/utils";
- import { ProFormColumnsType } from "@ant-design/pro-components";
- function formConfig(props: { paragraphList?: any[], enumList?: { [key: string]: any }, paymentType: any[] }): ProFormColumnsType<{
- name: string;
- state: string;
- }>[] {
- let { paragraphList, enumList, paymentType } = props
- // console.log("paragraphList",paragraphList)
- return [
- {
- title: '开始付费段落',
- dataIndex: 'beginPayChapterNo',
- valueType: 'select',
- fieldProps: {
- showSearch: true, placeholder: '请选择开始收费段落'
- },
- formItemProps: {
- style: { marginBottom: 15 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- valueEnum: () => {
- return new Map(paragraphList?.map(item => [item.chapterNo, item.chapterName]))
- }
- },
- {
- title: 'VIP阅读',
- dataIndex: 'vipFree',
- valueType: 'segmented',
- formItemProps: {
- style: { marginBottom: 15 },
- },
- valueEnum: () => {
- let arr = enumList?.VIP_FREE?.values
- return new Map(arr?.map(({ value, description }: any) => [value, description]))
- }
- },
- {
- title: '付费方式',
- dataIndex: 'paymentType',
- valueType: 'checkbox',
- fieldProps: {
- onChange: (value) => {
- paymentType[1](value)
- }
- },
- formItemProps: {
- style: { marginBottom: 15 },
- },
- valueEnum: () => {
- let arr = enumList?.PAYMENT_TYPE?.values
- let obj = {}
- if (paymentType?.[0]?.includes('0')) {
- obj = { "1": { disabled: true }, '2': { disabled: true }, '3': { disabled: true } }
- }
- if (paymentType?.[0]?.join().match(/[123]/g)) {
- obj = { "0": { disabled: true } }
- }
- let enumObj = convertEnumArr(arr, obj)
- return enumObj
- }
- },
- {
- title: '收费金额',
- dataIndex: 'paymentAmount',
- valueType: 'money',
- hideInForm: !paymentType?.[0]?.includes('2'),
- formItemProps: {
- style: { marginBottom: 15 },
- },
- },
- {
- title: '收费书币',
- dataIndex: 'paymentCoin',
- valueType: 'digit',
- hideInForm: !paymentType?.[0]?.join().match(/[13]/g),
- formItemProps: {
- style: { marginBottom: 15 },
- },
- },
- {
- title: '备注',
- dataIndex: 'remark',
- valueType: 'textarea',
- formItemProps: {
- style: { marginBottom: 15 },
- },
- }
- ]
- }
- export default formConfig
|