formConfig.tsx 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. import { ProFormColumnsType } from '@ant-design/pro-components';
  2. function formConfig(
  3. enumList?: { [key: string]: any },
  4. getWechatMchAll?: any[],
  5. pageList?: any[]
  6. ): ProFormColumnsType<{
  7. name: string;
  8. state: string;
  9. }>[] {
  10. return [
  11. {
  12. title: '小程序appId',
  13. dataIndex: 'wechatAppId',
  14. formItemProps: {
  15. style: { marginBottom: 10 },
  16. rules: [
  17. {
  18. required: true,
  19. message: '此项为必填项',
  20. },
  21. ],
  22. },
  23. },
  24. {
  25. title: 'appSecret',
  26. dataIndex: 'appSecret',
  27. formItemProps: {
  28. style: { marginBottom: 10 },
  29. rules: [
  30. {
  31. required: true,
  32. message: '此项为必填项',
  33. },
  34. ],
  35. },
  36. fieldProps: {
  37. placeholder: '请输入小程序秘钥'
  38. },
  39. },
  40. {
  41. title: 'appToken',
  42. dataIndex: 'appToken',
  43. formItemProps: {
  44. style: { marginBottom: 10 },
  45. rules: [
  46. {
  47. required: true,
  48. message: '此项为必填项',
  49. },
  50. ],
  51. },
  52. fieldProps: {
  53. placeholder: '微信小程序消息服务器配置的token'
  54. },
  55. },
  56. {
  57. title: 'appAesKey',
  58. dataIndex: 'appAesKey',
  59. formItemProps: {
  60. style: { marginBottom: 10 },
  61. rules: [
  62. {
  63. required: true,
  64. message: '此项为必填项',
  65. },
  66. ],
  67. },
  68. fieldProps: {
  69. placeholder: '微信小程序消息服务器配置的EncodingAESKey'
  70. },
  71. },
  72. {
  73. title: '商户',
  74. dataIndex: 'mchId',
  75. valueType: 'select',
  76. fieldProps: { showSearch: true, placeholder: '请选择商户' },
  77. formItemProps: {
  78. style: { marginBottom: 10 },
  79. rules: [
  80. {
  81. required: true,
  82. message: '此项为必填项',
  83. },
  84. ],
  85. },
  86. valueEnum: () => {
  87. let arr = getWechatMchAll;
  88. return arr ? new Map([...arr]?.map(({ id, mchName }: any) => [id, mchName])) : {};
  89. },
  90. },
  91. {
  92. title: '小程序名称',
  93. dataIndex: 'appName',
  94. formItemProps: {
  95. style: { marginBottom: 10 },
  96. rules: [
  97. {
  98. required: true,
  99. message: '此项为必填项',
  100. },
  101. ],
  102. },
  103. },
  104. {
  105. title: '小程序类型',
  106. dataIndex: 'appCategory',
  107. valueType: 'radio',
  108. formItemProps: {
  109. initialValue: 2,
  110. style: { marginBottom: 10 },
  111. rules: [
  112. {
  113. required: true,
  114. message: '此项为必填项',
  115. },
  116. ],
  117. },
  118. valueEnum: () => {
  119. let arr = enumList?.APP_CATEGORY?.values;
  120. return arr
  121. ? new Map([...arr]?.map(({ value, description }: any) => [value, description]))
  122. : {};
  123. },
  124. },
  125. {
  126. title: '小程序页面模板',
  127. dataIndex: 'templateName',
  128. fieldProps: { showSearch: true, placeholder: '请选择小程序页面模板' },
  129. valueType: 'select',
  130. formItemProps: {
  131. style: { marginBottom: 10 },
  132. rules: [
  133. {
  134. required: true,
  135. message: '此项为必填项',
  136. },
  137. ],
  138. },
  139. valueEnum: () => {
  140. let arr = pageList || [];
  141. return arr ? new Map([...arr]?.map(({ templateName }: any) => [templateName, templateName])) : {};
  142. }
  143. },
  144. {
  145. valueType: 'dependency',
  146. name: ['templateName'],
  147. columns: ({ templateName }) => {
  148. return [
  149. {
  150. title: '小程序首页链接',
  151. dataIndex: 'homePage',
  152. hideInForm: !templateName,
  153. formItemProps: {
  154. style: { marginBottom: 10 },
  155. rules: [
  156. {
  157. required: true,
  158. message: '此项为必填项',
  159. },
  160. ],
  161. },
  162. valueEnum: () => {
  163. let arr = pageList?.find(item => item.templateName === templateName)?.appPageVOList || [];
  164. return arr ? new Map([...arr]?.map(({ pagePath, pageName }: any) => [pagePath, pageName])) : {};
  165. }
  166. },
  167. ]
  168. },
  169. },
  170. {
  171. title: '小程序版本号',
  172. tooltip: "线上版本号",
  173. dataIndex: 'appVersion',
  174. formItemProps: {
  175. style: { marginBottom: 10 },
  176. },
  177. },
  178. {
  179. valueType: 'dependency',
  180. name: ['appVersion'],
  181. columns: ({ appVersion }) => {
  182. return [
  183. {
  184. title: 'ios支付版本号',
  185. tooltip: "ios的特殊性,此版本号与IOS支付模块关联,小程序版本号<=此版本号IOS才会出现支付功能,(微信)小程序发布线上后必须设置",
  186. dataIndex: 'iosPayment',
  187. formItemProps: {
  188. style: { marginBottom: 10 },
  189. rules: [
  190. {
  191. validator: (_, value) => {
  192. if (!value || !appVersion) {
  193. return Promise.resolve();
  194. }
  195. if (value > appVersion) {
  196. return Promise.reject(new Error('支付版本号不能大于小程序版本号'));
  197. }
  198. return Promise.resolve();
  199. },
  200. },
  201. ],
  202. },
  203. },
  204. ]
  205. }
  206. },
  207. {
  208. dataIndex: 'configParamList',
  209. valueType: 'formList',
  210. colProps: {
  211. offset: 6,
  212. },
  213. fieldProps: {
  214. creatorButtonProps: {
  215. creatorButtonText: '新增小程序配置',
  216. },
  217. },
  218. formItemProps: {
  219. style: { marginBottom: 10 },
  220. },
  221. columns: [
  222. {
  223. valueType: 'dependency',
  224. name: ['configParamList'],
  225. formItemProps: {
  226. style: { marginBottom: 10 },
  227. },
  228. columns: ({ configParamList }) => {
  229. return [
  230. {
  231. valueType: 'group',
  232. columns: [
  233. {
  234. formItemProps: {
  235. style: { marginBottom: 10 },
  236. },
  237. },
  238. {
  239. formItemProps: {
  240. style: { marginBottom: 10 },
  241. },
  242. },
  243. ],
  244. },
  245. ];
  246. },
  247. },
  248. ],
  249. },
  250. {
  251. title: '备注',
  252. dataIndex: 'remark',
  253. },
  254. ];
  255. }
  256. export default formConfig;