formConfig.tsx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. import { convertEnumArr } from "@/utils";
  2. import { ProFormColumnsType } from "@ant-design/pro-components";
  3. function formConfig(enumList?: any): ProFormColumnsType<{
  4. name: string;
  5. state: string;
  6. }>[] {
  7. let templateTypeEnum = enumList?.TEMPLATE_TYPE?.values || []
  8. let ORDER_TYPEEnum = enumList?.ORDER_TYPE?.values || []
  9. let COLOREnum = enumList?.COLOR?.values || []
  10. let VIP_DAYSEnum = enumList?.VIP_DAYS?.values || []
  11. return [
  12. {
  13. title: '模板名称',
  14. dataIndex: 'templateName',
  15. colProps:{
  16. span:24
  17. },
  18. formItemProps: {
  19. rules: [
  20. {
  21. required: true,
  22. message: '此项为必填项',
  23. },
  24. ],
  25. }
  26. },
  27. {
  28. title: '充值模板描述',
  29. dataIndex: 'templateDescription',
  30. valueType: 'textarea',
  31. },
  32. {
  33. title: '备注',
  34. dataIndex: 'remark',
  35. valueType: 'textarea',
  36. },
  37. {
  38. title: '首充档位',
  39. dataIndex: 'rechargeConfigList',
  40. valueType: 'formList',
  41. fieldProps: {
  42. min: 4,
  43. max: 6,
  44. creatorButtonProps: {
  45. creatorButtonText: "添加一个首充档位配置",
  46. },
  47. },
  48. colProps: {
  49. span: 24
  50. },
  51. columns: [
  52. {
  53. valueType: 'group',
  54. colProps: {
  55. span: 24
  56. },
  57. columns: [
  58. {
  59. title: '类型',
  60. dataIndex: 'gearType',
  61. valueType: 'select',
  62. width: "100%",
  63. initialValue:1,
  64. fieldProps: { placeholder: "请选择档位类型" },
  65. colProps: {
  66. span: 4
  67. },
  68. formItemProps: {
  69. rules: [
  70. {
  71. required: true,
  72. message: '此项为必填项',
  73. },
  74. ],
  75. },
  76. valueEnum: new Map(ORDER_TYPEEnum?.map((item: { value: any; description: any; }) => [item.value, item.description]))
  77. },
  78. {
  79. valueType: 'dependency',
  80. name: ['gearType'],
  81. columns: ({ gearType }) => {
  82. return [
  83. {
  84. title: '价格',
  85. dataIndex: 'price',
  86. valueType: 'money',
  87. width: "100%",
  88. hideInForm: gearType === 3,
  89. fieldProps: { placeholder: "输入价格" },
  90. colProps: {
  91. span: 5
  92. },
  93. formItemProps: {
  94. rules: [
  95. {
  96. required: true,
  97. message: '此项为必填项',
  98. },
  99. ],
  100. }
  101. },
  102. {
  103. title: '赠送',
  104. dataIndex: 'gift',
  105. valueType: 'digit',
  106. width: "100%",
  107. hideInForm: gearType !== 1,
  108. fieldProps: { placeholder: "输入赠送书币数" },
  109. colProps: {
  110. span: 5
  111. },
  112. formItemProps: {
  113. rules: [
  114. {
  115. required: true,
  116. message: '此项为必填项',
  117. },
  118. ],
  119. }
  120. },
  121. {
  122. title: 'vip天数',
  123. dataIndex: 'vipDays',
  124. valueType: 'select',
  125. width: "100%",
  126. hideInForm: gearType !== 2,
  127. fieldProps: { placeholder: "选择VIP天数" },
  128. colProps: {
  129. span: 4
  130. },
  131. formItemProps: {
  132. rules: [
  133. {
  134. required: true,
  135. message: '此项为必填项',
  136. },
  137. ],
  138. },
  139. valueEnum: new Map(VIP_DAYSEnum?.map((item: { value: any; description: any; }) => [item.value, item.description]))
  140. },
  141. {
  142. title: '价格',
  143. width: "100%",
  144. fieldProps: { placeholder: "价格在小说管理设置", disabled: true },
  145. hideInForm: gearType !== 3,
  146. colProps: {
  147. span: 5
  148. }
  149. },
  150. {
  151. title: '文案',
  152. dataIndex: 'description',
  153. width: "100%",
  154. fieldProps: { placeholder: "输入展示文案" },
  155. hideInForm: gearType !== 3,
  156. colProps: {
  157. span: 5
  158. },
  159. formItemProps: {
  160. rules: [
  161. {
  162. required: true,
  163. message: '此项为必填项',
  164. },
  165. ],
  166. }
  167. },
  168. {
  169. title: '角标',
  170. dataIndex: 'subscript',
  171. width: "100%",
  172. fieldProps: { placeholder: "右上角角标文案" },
  173. colProps: {
  174. span: 5
  175. }
  176. },
  177. {
  178. title: '底色',
  179. dataIndex: "color",
  180. valueType: "radioButton",
  181. width: "100%",
  182. initialValue: false,
  183. colProps: {
  184. span: 4
  185. },
  186. valueEnum: new Map(COLOREnum?.map((item: { value: any; description: any; }) => [item.value, item.description]))
  187. }
  188. ]
  189. }
  190. },
  191. ]
  192. }
  193. ]
  194. },
  195. {
  196. title: '非首充档位',
  197. dataIndex: 'rechargeConfigList1',
  198. valueType: 'formList',
  199. fieldProps: {
  200. min: 4,
  201. max: 6,
  202. creatorButtonProps: {
  203. creatorButtonText: "添加一个非首充档位配置",
  204. },
  205. },
  206. colProps: {
  207. span: 24
  208. },
  209. columns: [
  210. {
  211. valueType: 'group',
  212. colProps: {
  213. span: 24
  214. },
  215. columns: [
  216. {
  217. title: '类型',
  218. dataIndex: 'gearType',
  219. valueType: 'select',
  220. width: "100%",
  221. initialValue:1,
  222. fieldProps: { placeholder: "请选择档位类型" },
  223. colProps: {
  224. span: 4
  225. },
  226. formItemProps: {
  227. rules: [
  228. {
  229. required: true,
  230. message: '此项为必填项',
  231. },
  232. ],
  233. },
  234. valueEnum: new Map(ORDER_TYPEEnum?.map((item: { value: any; description: any; }) => [item.value, item.description]))
  235. },
  236. {
  237. valueType: 'dependency',
  238. name: ['gearType'],
  239. columns: ({ gearType }) => {
  240. return [
  241. {
  242. title: '价格',
  243. dataIndex: 'price',
  244. valueType: 'money',
  245. width: "100%",
  246. hideInForm: gearType === 3,
  247. fieldProps: { placeholder: "输入价格" },
  248. colProps: {
  249. span: 5
  250. },
  251. formItemProps: {
  252. rules: [
  253. {
  254. required: true,
  255. message: '此项为必填项',
  256. },
  257. ],
  258. }
  259. },
  260. {
  261. title: '赠送',
  262. dataIndex: 'gift',
  263. valueType: 'digit',
  264. width: "100%",
  265. hideInForm: gearType !== 1,
  266. fieldProps: { placeholder: "输入赠送书币数" },
  267. colProps: {
  268. span: 5
  269. },
  270. formItemProps: {
  271. rules: [
  272. {
  273. required: true,
  274. message: '此项为必填项',
  275. },
  276. ],
  277. }
  278. },
  279. {
  280. title: 'vip天数',
  281. dataIndex: 'vipDays',
  282. valueType: 'select',
  283. width: "100%",
  284. hideInForm: gearType !== 2,
  285. fieldProps: { placeholder: "选择VIP天数" },
  286. colProps: {
  287. span: 4
  288. },
  289. formItemProps: {
  290. rules: [
  291. {
  292. required: true,
  293. message: '此项为必填项',
  294. },
  295. ],
  296. },
  297. valueEnum: new Map(VIP_DAYSEnum?.map((item: { value: any; description: any; }) => [item.value, item.description]))
  298. },
  299. {
  300. title: '价格',
  301. width: "100%",
  302. fieldProps: { placeholder: "价格在小说管理设置", disabled: true },
  303. hideInForm: gearType !== 3,
  304. colProps: {
  305. span: 5
  306. }
  307. },
  308. {
  309. title: '文案',
  310. dataIndex: 'description',
  311. width: "100%",
  312. fieldProps: { placeholder: "输入展示文案" },
  313. hideInForm: gearType !== 3,
  314. colProps: {
  315. span: 5
  316. },
  317. formItemProps: {
  318. rules: [
  319. {
  320. required: true,
  321. message: '此项为必填项',
  322. },
  323. ],
  324. }
  325. },
  326. {
  327. title: '角标',
  328. dataIndex: 'subscript',
  329. width: "100%",
  330. fieldProps: { placeholder: "右上角角标文案" },
  331. colProps: {
  332. span: 5
  333. }
  334. },
  335. {
  336. title: '底色',
  337. dataIndex: "color",
  338. valueType: "radioButton",
  339. width: "100%",
  340. initialValue: false,
  341. colProps: {
  342. span: 4
  343. },
  344. valueEnum: new Map(COLOREnum?.map((item: { value: any; description: any; }) => [item.value, item.description]))
  345. }
  346. ]
  347. }
  348. },
  349. ]
  350. }
  351. ]
  352. },
  353. {
  354. title: '激活当前模板',
  355. dataIndex: 'activateTemplate',
  356. valueType: 'switch',
  357. formItemProps: { layout: 'horizontal' },
  358. colProps: { offset: 19 }
  359. },
  360. ]
  361. }
  362. export default formConfig