formConfig.tsx 17 KB

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