Commit 51684410 authored by wuting's avatar wuting

Merge branch 'v2-220618' of…

Merge branch 'v2-220618' of https://gitlab.shushangyun.com/linkseeks-design/pro-admin into jinfa-0618
parents f0102b20 b0af6ab1
...@@ -74,4 +74,4 @@ const mountRouter = [ ...@@ -74,4 +74,4 @@ const mountRouter = [
const router = isDev ? localRouter : mountRouter const router = isDev ? localRouter : mountRouter
export { router ,isDev}; export { router, isDev};
...@@ -10,7 +10,7 @@ import { ...@@ -10,7 +10,7 @@ import {
import OuterSider from './OuterSide' import OuterSider from './OuterSide'
import styles from '../styles/MenuSlider.less' import styles from '../styles/MenuSlider.less'
import { getRouters } from '@/utils/auth'; import { getRouters } from '@/utils/auth';
import { isDev } from '@/constants'; // import { isDev } from '../../../config/routes'
import menuIcon from '../../asserts/menuIcon/logo.png' import menuIcon from '../../asserts/menuIcon/logo.png'
const { Sider } = Layout const { Sider } = Layout
const { SubMenu } = Menu; const { SubMenu } = Menu;
...@@ -29,7 +29,6 @@ const MenuSlider: React.FC<MenuSliderProps> = (props) => { ...@@ -29,7 +29,6 @@ const MenuSlider: React.FC<MenuSliderProps> = (props) => {
const { menuData, pathname, currentSelectKey = [], openKeys = [], changeOpenKeys } = props const { menuData, pathname, currentSelectKey = [], openKeys = [], changeOpenKeys } = props
const [innerCollapsed, setInnerCollapsed] = useState(false) const [innerCollapsed, setInnerCollapsed] = useState(false)
let menuItemsCache = null let menuItemsCache = null
const getMenuRouter = (routes: any, pathname: any) => { const getMenuRouter = (routes: any, pathname: any) => {
const list = routes.filter((item: any) => pathname.indexOf(item.key) > -1) const list = routes.filter((item: any) => pathname.indexOf(item.key) > -1)
return list[0] return list[0]
...@@ -39,7 +38,7 @@ const MenuSlider: React.FC<MenuSliderProps> = (props) => { ...@@ -39,7 +38,7 @@ const MenuSlider: React.FC<MenuSliderProps> = (props) => {
if (!!menuArray && menuArray.length > 0) { if (!!menuArray && menuArray.length > 0) {
return menuArray.map((item: any) => { return menuArray.map((item: any) => {
// 不存在路由表内或者 需要隐藏 // 不存在路由表内或者 需要隐藏
if (item.hideInMenu || (!getRouters().includes(item.path) && !isDev)) { if (item.hideInMenu) {
return null return null
} }
......
...@@ -3,7 +3,7 @@ import { Layout, Menu, Avatar, Image } from 'antd' ...@@ -3,7 +3,7 @@ import { Layout, Menu, Avatar, Image } from 'antd'
import { Link } from 'umi' import { Link } from 'umi'
import styles from '../styles/MenuSlider.less' import styles from '../styles/MenuSlider.less'
import { getRouters } from '@/utils/auth' import { getRouters } from '@/utils/auth'
import { isDev } from '@/constants' // import { isDev } from '../../../config/routes'
import { observer, inject } from 'mobx-react'; import { observer, inject } from 'mobx-react';
import CustomIcon from './CustomIcon'; import CustomIcon from './CustomIcon';
import Icon from '@ant-design/icons'; import Icon from '@ant-design/icons';
...@@ -22,25 +22,23 @@ const OuterSider: React.FC<OuterSiderProps> = observer((props) => { ...@@ -22,25 +22,23 @@ const OuterSider: React.FC<OuterSiderProps> = observer((props) => {
const { menuData, pathname = "/", currentRouter } = props const { menuData, pathname = "/", currentRouter } = props
const authRouters = getRouters() const authRouters = getRouters()
let defaultSelectedKeys = "" let defaultSelectedKeys = ""
const isAuthPath = (path) => { const isAuthPath = (path) => {
if (isDev) { // if (isDev) {
return true return true
} else { // } else {
return authRouters.includes(path) // return authRouters.includes(path)
} // }
} }
const getSubMenu = () => { const getSubMenu = () => {
const subHeadMenus: Array<any> = [] const subHeadMenus: Array<any> = []
menuData.forEach(item => { menuData.forEach(item => {
// 为适配pass菜单自由组合变更, 使用code进行高亮显示 // 为适配pass菜单自由组合变更, 使用code进行高亮显示
const code = currentRouter.relationParentCode const code = currentRouter?.relationParentCode
// console.log(code, item.relationParentCode) // console.log(code, item.relationParentCode)
if (code && code === item.relationParentCode) { if (code && code === item.relationParentCode) {
defaultSelectedKeys = item.relationParentCode defaultSelectedKeys = item.relationParentCode
} }
!item.hideInMenu && isAuthPath(item.path) && subHeadMenus.push({ !item.hideInMenu && isAuthPath(item.path) && subHeadMenus.push({
path: item.path, path: item.path,
title: item.name, title: item.name,
......
...@@ -143,7 +143,7 @@ const BasicLayout: React.FC<any> = (props) => { ...@@ -143,7 +143,7 @@ const BasicLayout: React.FC<any> = (props) => {
minWidth: '1280px', minWidth: '1280px',
} }
: {} : {}
return currentRouter.noLayout ? props.children : ( return currentRouter?.noLayout ? props.children : (
<ProLayout <ProLayout
pageTitleRender={() => currentRouter ? currentRouter.name : window.location.href} pageTitleRender={() => currentRouter ? currentRouter.name : window.location.href}
// contentStyle={{minWidth: '1280px'}} // contentStyle={{minWidth: '1280px'}}
......
...@@ -61,7 +61,8 @@ const ListWrap: React.FC<ListType> = (props) => { ...@@ -61,7 +61,8 @@ const ListWrap: React.FC<ListType> = (props) => {
currentListData.length && currentListData.forEach(item => { currentListData.length && currentListData.forEach(item => {
let obj = {} let obj = {}
item.map(val => { item.map(val => {
return obj[val.fieldName] = val.fieldValue obj[val.fieldName] = val.fieldValue
obj.key = val.fieldOrder
}) })
sumData.push(obj) sumData.push(obj)
}) })
...@@ -71,7 +72,7 @@ const ListWrap: React.FC<ListType> = (props) => { ...@@ -71,7 +72,7 @@ const ListWrap: React.FC<ListType> = (props) => {
}, [currentListData]) }, [currentListData])
return ( return (
<Table columns={tableCoumns} pagination={false} dataSource={tableData} style={{width: '95%'}} /> <Table rowKey='key' columns={tableCoumns} pagination={false} dataSource={tableData} style={{width: '95%'}} />
) )
} }
......
...@@ -10,7 +10,7 @@ import { history, Prompt } from 'umi'; ...@@ -10,7 +10,7 @@ import { history, Prompt } from 'umi';
import { Button, Card, Spin, message } from 'antd'; import { Button, Card, Spin, message } from 'antd';
import { PageHeaderWrapper } from '@ant-design/pro-layout'; import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined } from '@ant-design/icons'; import { SaveOutlined } from '@ant-design/icons';
import { createFormActions, FormEffectHooks, FormPath } from '@formily/antd'; import { createFormActions, FormEffectHooks, FormPath, IFormExtendsEffectSelector, ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd';
import { Radio, Checkbox, ArrayTable } from '@formily/antd-components'; import { Radio, Checkbox, ArrayTable } from '@formily/antd-components';
import ReutrnEle from '@/components/ReturnEle'; import ReutrnEle from '@/components/ReturnEle';
import NiceForm from '@/components/NiceForm'; import NiceForm from '@/components/NiceForm';
...@@ -85,9 +85,10 @@ const MemberForm: React.FC<MemberFormProps> = ({ ...@@ -85,9 +85,10 @@ const MemberForm: React.FC<MemberFormProps> = ({
...rest ...rest
}: any = infoRes.data; }: any = infoRes.data;
// 注册资料处理 // 注册资料处理
const detail = {}, list = [] const detail = {}
for (let i = 0; i < groups.length; i++) { for (let i = 0; i < groups.length; i++) {
const item = groups[i]; const item = groups[i]
if (item.elements) { if (item.elements) {
for (let j = 0; j < item.elements.length; j++) { for (let j = 0; j < item.elements.length; j++) {
const ele = item.elements[j]; const ele = item.elements[j];
...@@ -95,14 +96,13 @@ const MemberForm: React.FC<MemberFormProps> = ({ ...@@ -95,14 +96,13 @@ const MemberForm: React.FC<MemberFormProps> = ({
detail[ele.fieldName] = ele.fieldValue; detail[ele.fieldName] = ele.fieldValue;
} }
if (ele.fieldType === 'list') { if (ele.fieldType === 'list') {
ele.registers && ele.registers.forEach(element => { detail[ele.fieldName] = ele.registers?.map(element => {
let obj = {} let obj = {};
element.map(val => { element.forEach(val => {
obj[val.fieldName] = val.fieldValue; obj[val.fieldName] = val.fieldValue;
}) });
list.push(obj) return obj;
}) });
detail[ele.fieldName] = list
} }
} }
} }
...@@ -211,21 +211,21 @@ const MemberForm: React.FC<MemberFormProps> = ({ ...@@ -211,21 +211,21 @@ const MemberForm: React.FC<MemberFormProps> = ({
const res = await getMemberMaintenanceAddpageitems(); const res = await getMemberMaintenanceAddpageitems();
if (res.code === 1000) { if (res.code === 1000) {
const { data = {} }: any = res; const { data } = res;
const { const {
memberTypes = [], memberTypes,
countryCodes = [], countryCodes,
} = data; } = data;
return { return {
memberTypeId: memberTypes.map(item => ({ label: item.memberTypeName, value: item.memberTypeId })), memberTypeId: memberTypes?.map(item => ({ label: item.memberTypeName, value: item.memberTypeId })),
countryCodeId: countryCodes.map(item => ({ label: item.text, value: item.id })), countryCodeId: countryCodes?.map(item => ({ label: item.text, value: item.id, phoneLength: item.phoneLength })),
}; };
} }
return {}; return {};
}; };
const useBusinessEffects = () => { const useBusinessEffects = ($: IFormExtendsEffectSelector<any, ISchemaFormActions | ISchemaFormAsyncActions>) => {
const linkage = useLinkageUtils(); const linkage = useLinkageUtils();
// 间接触发根据会员类型 // 间接触发根据会员类型
...@@ -316,6 +316,47 @@ const MemberForm: React.FC<MemberFormProps> = ({ ...@@ -316,6 +316,47 @@ const MemberForm: React.FC<MemberFormProps> = ({
}, 0); }, 0);
}); });
// 国家区号改变,触发电话号码校验
onFieldInputChange$('countryCodeId').subscribe(() => {
const phoneValue = formActions.getFieldValue('phone');
if (phoneValue) {
formActions.setFieldState('phone', (state) => {
state.value = '';
});
}
});
// 国家区号改变,触发电话号码校验
onFieldValueChange$('countryCodeId').subscribe((fieldState) => {
const current = fieldState.props.enum?.find((item) => item.value === fieldState.value);
if (current && current.phoneLength) {
formActions.setFieldState('phone', (state) => {
state.rules = [
{
required: true,
message: '请输入你的手机号码',
},
{
validator: (value) => {
return value?.length > current.phoneLength ? `注册手机号超出${current.phoneLength}位数` : '';
},
},
];
});
}
});
// 订阅 countryCodeId 选项初始化
$('requestAsyncSelect').subscribe(({ name: names, payload }) => {
const countryCodeIdValue = formActions.getFieldValue('countryCodeId');
if (
names.includes('countryCodeId')
&& payload.countryCodeId?.length
&& countryCodeIdValue
) {
formActions.setFieldValue('countryCodeId', countryCodeIdValue);
}
});
} }
return ( return (
...@@ -353,7 +394,7 @@ const MemberForm: React.FC<MemberFormProps> = ({ ...@@ -353,7 +394,7 @@ const MemberForm: React.FC<MemberFormProps> = ({
getPageitemsBasic, getPageitemsBasic,
); );
useBusinessEffects(); useBusinessEffects($);
onFormInputChange$().subscribe(() => { onFormInputChange$().subscribe(() => {
if (!unsaved) { if (!unsaved) {
......
...@@ -82,18 +82,16 @@ export const initDetailSchema = (props: GroupItem[]) => { ...@@ -82,18 +82,16 @@ export const initDetailSchema = (props: GroupItem[]) => {
}, },
phone: { phone: {
type: 'string', type: 'string',
required: true,
'x-mega-props': { 'x-mega-props': {
span: 2, span: 2,
}, },
'x-component-props': { 'x-component-props': {
placeholder: '请输入你的手机号码', placeholder: '请输入你的手机号码',
maxLength: 11,
}, },
'x-rules': [ 'x-rules': [
{ {
pattern: PATTERN_MAPS.phone, required: true,
message: '请输入正确格式的手机号', message: '请输入你的手机号码',
}, },
], ],
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment