123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- import { ProFormColumnsType } from '@ant-design/pro-components';
- function formConfig(
- enumList?: { [key: string]: any },
- getWechatMchAll?: any[],
- pageList?: any[]
- ): ProFormColumnsType<{
- name: string;
- state: string;
- }>[] {
- return [
- {
- title: '小程序appId',
- dataIndex: 'wechatAppId',
- formItemProps: {
- style: { marginBottom: 10 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- },
- {
- title: 'appSecret',
- dataIndex: 'appSecret',
- formItemProps: {
- style: { marginBottom: 10 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- fieldProps: {
- placeholder: '请输入小程序秘钥'
- },
- },
- {
- title: 'appToken',
- dataIndex: 'appToken',
- formItemProps: {
- style: { marginBottom: 10 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- fieldProps: {
- placeholder: '微信小程序消息服务器配置的token'
- },
- },
- {
- title: 'appAesKey',
- dataIndex: 'appAesKey',
- formItemProps: {
- style: { marginBottom: 10 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- fieldProps: {
- placeholder: '微信小程序消息服务器配置的EncodingAESKey'
- },
- },
- {
- title: '商户',
- dataIndex: 'mchId',
- valueType: 'select',
- fieldProps: { showSearch: true, placeholder: '请选择商户' },
- formItemProps: {
- style: { marginBottom: 10 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- valueEnum: () => {
- let arr = getWechatMchAll;
- return arr ? new Map([...arr]?.map(({ id, mchName }: any) => [id, mchName])) : {};
- },
- },
- {
- title: '小程序名称',
- dataIndex: 'appName',
- formItemProps: {
- style: { marginBottom: 10 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- },
- {
- title: '小程序类型',
- dataIndex: 'appCategory',
- valueType: 'radio',
- formItemProps: {
- initialValue: 2,
- style: { marginBottom: 10 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- valueEnum: () => {
- let arr = enumList?.APP_CATEGORY?.values;
- return arr
- ? new Map([...arr]?.map(({ value, description }: any) => [value, description]))
- : {};
- },
- },
- {
- title: '小程序页面模板',
- dataIndex: 'templateName',
- fieldProps: { showSearch: true, placeholder: '请选择小程序页面模板' },
- valueType: 'select',
- formItemProps: {
- style: { marginBottom: 10 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- valueEnum: () => {
- let arr = pageList || [];
- return arr ? new Map([...arr]?.map(({ templateName }: any) => [templateName, templateName])) : {};
- }
- },
- {
- valueType: 'dependency',
- name: ['templateName'],
- columns: ({ templateName }) => {
- return [
- {
- title: '小程序首页链接',
- dataIndex: 'homePage',
- hideInForm: !templateName,
- formItemProps: {
- style: { marginBottom: 10 },
- rules: [
- {
- required: true,
- message: '此项为必填项',
- },
- ],
- },
- valueEnum: () => {
- let arr = pageList?.find(item => item.templateName === templateName)?.appPageVOList || [];
- return arr ? new Map([...arr]?.map(({ pagePath, pageName }: any) => [pagePath, pageName])) : {};
- }
- },
- ]
- },
- },
- {
- title: '小程序版本号',
- tooltip: "线上版本号",
- dataIndex: 'appVersion',
- formItemProps: {
- style: { marginBottom: 10 },
- },
- },
- {
- valueType: 'dependency',
- name: ['appVersion'],
- columns: ({ appVersion }) => {
- return [
- {
- title: 'ios支付版本号',
- tooltip: "ios的特殊性,此版本号与IOS支付模块关联,小程序版本号<=此版本号IOS才会出现支付功能,(微信)小程序发布线上后必须设置",
- dataIndex: 'iosPayment',
- formItemProps: {
- style: { marginBottom: 10 },
- rules: [
- {
- validator: (_, value) => {
- if (!value || !appVersion) {
- return Promise.resolve();
- }
- if (value > appVersion) {
- return Promise.reject(new Error('支付版本号不能大于小程序版本号'));
- }
- return Promise.resolve();
- },
- },
- ],
- },
- },
- ]
- }
- },
- {
- dataIndex: 'configParamList',
- valueType: 'formList',
- colProps: {
- offset: 6,
- },
- fieldProps: {
- creatorButtonProps: {
- creatorButtonText: '新增小程序配置',
- },
- },
- formItemProps: {
- style: { marginBottom: 10 },
- },
- columns: [
- {
- valueType: 'dependency',
- name: ['configParamList'],
- formItemProps: {
- style: { marginBottom: 10 },
- },
- columns: ({ configParamList }) => {
- return [
- {
- valueType: 'group',
- columns: [
- {
- formItemProps: {
- style: { marginBottom: 10 },
- },
- },
- {
- formItemProps: {
- style: { marginBottom: 10 },
- },
- },
- ],
- },
- ];
- },
- },
- ],
- },
- {
- title: '备注',
- dataIndex: 'remark',
- },
- ];
- }
- export default formConfig;
|