From b8d8ae6dba20f63de88e38cd36bd3b41330d3235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98lijianhao=E2=80=99?= Date: Thu, 28 Jul 2022 14:25:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7=E5=A7=93?= =?UTF-8?q?=E5=90=8D=E9=99=90=E5=88=B6=E8=BE=93=E5=85=A5=E4=B8=AD=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organization/components/userModal.js | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/web/client/src/sections/organization/components/userModal.js b/web/client/src/sections/organization/components/userModal.js index 29a91f9f..d229bc7a 100644 --- a/web/client/src/sections/organization/components/userModal.js +++ b/web/client/src/sections/organization/components/userModal.js @@ -1,22 +1,25 @@ import React from 'react'; import { connect } from 'react-redux'; -import { Spin, Card, Modal, TreeSelect, message } from 'antd'; +import { Spin } from 'antd'; import ProForm, { ProFormText, ModalForm, ProFormSwitch, ProFormTreeSelect } from '@ant-design/pro-form'; const UserModal = (props) => { const { visible, modalType, depData, onVisibleChange, onConfirm, editData } = props - const reg_tel = /^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/; const onFinish = (values) => { if (onConfirm) { onConfirm(values); } } - const mobile = (value) => { - if (reg_tel.test(value)) { - return + + const checkName = (rule, value, callback) => { + if (value && value.replace(/[^\u4E00-\u9FA5]/g).includes('undefined')) { + callback(new Error('请输入中文!')); + } else { + callback() } - return message('请输入姓名') } + + return ( { label="姓名" required placeholder="请输入姓名" - rules={[{ required: true, message: '请输入姓名' },{ max: 5, message: '请输入5个字以内的名称' }]} + rules={[{ required: true, message: '请输入姓名' }, + { max: 5, message: '请输入5个字以内的名称' }, + { validator: checkName } + ]} /> < ProFormText name={['contract', 'phone']}