formConfig.tsx 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. import { ProFormColumnsType } from "@ant-design/pro-components";
  2. import { useModel } from "@umijs/max";
  3. function formConfig(props: { paragraphList?: any[], enumList?: { [key: string]: any }, paymentType: any, paymentCategory: any, isGlobalConfig: boolean }): ProFormColumnsType<{
  4. name: string;
  5. state: string;
  6. }>[] {
  7. let { paragraphList, enumList, paymentType, paymentCategory, isGlobalConfig } = props
  8. let {getEnum} = useModel('global')
  9. return [
  10. {
  11. title: '付费方式',
  12. dataIndex: 'paymentType',
  13. valueType: 'radio',
  14. fieldProps: {
  15. onChange: (e) => {
  16. let value = e.target.value
  17. paymentType[1](value)
  18. }
  19. },
  20. formItemProps: {
  21. style: { marginBottom: 10 },
  22. rules: [
  23. {
  24. required: true,
  25. message: '此项为必填项',
  26. },
  27. ],
  28. },
  29. valueEnum: () => {
  30. return getEnum("PAYMENT_TYPE","map")
  31. }
  32. },
  33. {
  34. title: '收费类型',
  35. dataIndex: 'paymentOption',
  36. valueType: 'radio',
  37. formItemProps: {
  38. style: { marginBottom: 10 },
  39. rules: [
  40. {
  41. required: true,
  42. message: '此项为必填项',
  43. },
  44. ],
  45. },
  46. hideInForm: paymentType[0] != 2,
  47. valueEnum: () => {
  48. return getEnum("PAYMENT_OPTION","map")
  49. }
  50. },
  51. {
  52. title: '收费货币',
  53. dataIndex: 'paymentCategory',
  54. valueType: 'radio',
  55. fieldProps: {
  56. onChange: (e) => {
  57. let value = e.target.value
  58. paymentCategory[1](value)
  59. }
  60. },
  61. formItemProps: {
  62. style: { marginBottom: 10 },
  63. rules: [
  64. {
  65. required: true,
  66. message: '此项为必填项',
  67. },
  68. ],
  69. },
  70. hideInForm: paymentType[0] == 0,
  71. valueEnum: () => {
  72. return getEnum("PAYMENT_CATEGORY","map")
  73. }
  74. },
  75. {//单本
  76. title: '付费起始段落',
  77. dataIndex: 'beginPayParagraphNo',
  78. valueType: 'select',
  79. fieldProps: {
  80. showSearch: true, placeholder: '请选择开始收费段落'
  81. },
  82. formItemProps: {
  83. style: { marginBottom: 15 },
  84. rules: [
  85. {
  86. required: true,
  87. message: '此项为必填项',
  88. },
  89. ],
  90. },
  91. hideInForm: paymentType[0] != 2 || isGlobalConfig,//单本书
  92. valueEnum: () => {
  93. return new Map(paragraphList?.map(item => [item.paragraphNo, item.content]))
  94. }
  95. },
  96. {//全局
  97. title: '付费起始段落',
  98. dataIndex: 'beginPayNo',
  99. valueType: 'digit',
  100. fieldProps: {
  101. placeholder: '请输入收费段落'
  102. },
  103. width: 200,
  104. formItemProps: {
  105. style: { marginBottom: 15 },
  106. rules: [
  107. {
  108. required: true,
  109. message: '此项为必填项',
  110. },
  111. ],
  112. },
  113. hideInForm: paymentType[0] != 2 || !isGlobalConfig,//单本书
  114. },
  115. {
  116. title: 'VIP阅读',
  117. dataIndex: 'vipFree',
  118. valueType: 'segmented',
  119. formItemProps: {
  120. style: { marginBottom: 15 },
  121. rules: [
  122. {
  123. required: true,
  124. message: '此项为必填项',
  125. },
  126. ],
  127. },
  128. hideInForm: paymentType[0] == 0 || isGlobalConfig,
  129. valueEnum: () => {
  130. return getEnum("VIP_FREE","map")
  131. }
  132. },
  133. {
  134. title: '收费金额',
  135. dataIndex: 'paymentAmount',
  136. valueType: 'money',
  137. hideInForm: paymentCategory[0] == 1,
  138. fieldProps: {
  139. addonAfter: "元"
  140. },
  141. formItemProps: {
  142. style: { marginBottom: 15 },
  143. rules: [
  144. {
  145. required: true,
  146. message: '此项为必填项',
  147. },
  148. ],
  149. },
  150. },
  151. {
  152. title: '收费书币',
  153. dataIndex: 'paymentCoin',
  154. valueType: 'digit',
  155. hideInForm: paymentCategory[0] == 0,
  156. fieldProps: {
  157. addonAfter: "书币"
  158. },
  159. formItemProps: {
  160. style: { marginBottom: 15 },
  161. rules: [
  162. {
  163. required: true,
  164. message: '此项为必填项',
  165. },
  166. ],
  167. },
  168. },
  169. {
  170. title: '备注',
  171. dataIndex: 'remark',
  172. valueType: 'textarea',
  173. hideInForm: isGlobalConfig,
  174. formItemProps: {
  175. style: { marginBottom: 15 },
  176. },
  177. }
  178. ]
  179. }
  180. export default formConfig