新增组织账号,组织名称增加新的check条件

This commit is contained in:
caishi 2021-04-06 18:40:01 +08:00
parent 70ea6259ae
commit bcaec7a2db
5 changed files with 52 additions and 17 deletions

View File

@ -1,15 +1,15 @@
import React,{ forwardRef , useCallback , useEffect, useState } from 'react'; import React,{ forwardRef , useCallback , useEffect, useState } from 'react';
import './Index.scss'; import './Index.scss';
import { Form , Input , Radio , Checkbox , Button, InputNumber } from "antd"; import { Form , Input , Radio , Checkbox , Button } from "antd";
import UploadImage from './Component/UploadImage'; import UploadImage from './Component/UploadImage';
import axios from 'axios'; import axios from 'axios';
const port = window.location.port;
const hostname = window.location.hostname;
export default Form.create()( export default Form.create()(
forwardRef(({ form , showNotification , history })=>{ forwardRef(({ form , showNotification , history })=>{
const [ image , setImage ] = useState(undefined); const [ image , setImage ] = useState(undefined);
const [ imageFlag , setImageFlag] = useState(false); const [ imageFlag , setImageFlag] = useState(false);
const { getFieldDecorator, validateFields , setFieldsValue } = form; const { getFieldDecorator, validateFields , setFieldsValue } = form;
const radioStyle = { const radioStyle = {
display: 'block', display: 'block',
height: '30px', height: '30px',
@ -60,19 +60,44 @@ export default Form.create()(
}) })
},[]) },[])
function checkname(rule, value, callback){
if(!value){
callback();
}
if(value && !value.match(/^[a-zA-Z][a-zA-Z\d]{3,14}$/)){
callback("只能使用英文字母和数字以字母开头长度为4到15个字符");
}
callback();
}
return( return(
<div className="main"> <div className="main">
<div className="teamBox"> <div className="teamBox">
<p className="teamBox-title">新建组织</p> <p className="teamBox-title">新建组织</p>
<Form className="teamBox-form"> <Form className="teamBox-form">
{helper( {helper(
<span>组织名称<span className="color-grey-8">(组织名称应该简单明了)</span></span>, <span>组织账号</span>,
"name", "name",
[
{ required: true, message: "请输入组织账号" },
{
validator:checkname
}
],
<Input
addonBefore={`https://`+ port ? `${hostname}:${port}/organize`:`${hostname}/organize`}
placeholder="组织账号"
/>
)}
{helper(
<span>组织名称</span>,
"nickname",
[{ required: true, message: "请输入组织名称" }], [{ required: true, message: "请输入组织名称" }],
<Input <Input
placeholder="请输入组织名称" placeholder="请输入组织名称"
/> />
)} )}
{helper( {helper(
'组织描述', '组织描述',
"description", "description",

View File

@ -95,6 +95,15 @@ export default Form.create()(
}) })
setVisible(false); setVisible(false);
} }
function checkname(rule, value, callback){
if(!value){
callback();
}
if(value && !value.match(/^[a-zA-Z][a-zA-Z\d]{3,14}$/)){
callback("只能使用英文字母和数字以字母开头长度为4到15个字符");
}
callback();
}
return( return(
<div> <div>
<WhiteBack> <WhiteBack>
@ -102,8 +111,19 @@ export default Form.create()(
<Div> <Div>
<Form> <Form>
{helper( {helper(
"组织名称", "组织账号",
"name", "name",
[
{ required: true, message: "请输入组织账号" },
{
validator:checkname
}
],
<Input placeholder="请输入组织账号" />,true
)}
{helper(
"组织名称:",
"nickname",
[{ required: true, message: "请输入组织名称" }], [{ required: true, message: "请输入组织名称" }],
<Input placeholder="请输入组织名称" />,true <Input placeholder="请输入组织名称" />,true
)} )}

View File

@ -78,7 +78,7 @@ function Detail(props){
detail && detail &&
<Cards <Cards
src={`/organize/${detail.name}`} src={`/organize/${detail.name}`}
title={detail.name} title={detail.nickname}
desc={!buttonflag && detail.description} desc={!buttonflag && detail.description}
img={detail.avatar_url} img={detail.avatar_url}
rightBtn={ rightBtn={

View File

@ -56,7 +56,7 @@ export default ((props)=>{
detail && detail &&
<Cards <Cards
src={`/organize/${OIdentifier}/group/${groupId}`} src={`/organize/${OIdentifier}/group/${groupId}`}
title={detail.name} title={detail.nickname}
rightBtn={ rightBtn={
flag && <span className="subNavs"> flag && <span className="subNavs">
<Link to={`/organize/${OIdentifier}/member`} className={pathname ===`/organize/${OIdentifier}/member` ? "active":""}><span>组织成员</span>{detail.num_users && <lable>{detail.num_users}</lable>}</Link> <Link to={`/organize/${OIdentifier}/member`} className={pathname ===`/organize/${OIdentifier}/member` ? "active":""}><span>组织成员</span>{detail.num_users && <lable>{detail.num_users}</lable>}</Link>

View File

@ -1366,10 +1366,6 @@ samp {
line-height: 40px; line-height: 40px;
} }
.courseForm .ant-input-group>.ant-input:first-child,
.ant-input-group-addon:first-child {
height: 40px;
}
.courseForm .ant-select-selection, .courseForm .ant-select-selection,
.courseForm .ant-select-selection-selected-value { .courseForm .ant-select-selection-selected-value {
@ -1722,12 +1718,6 @@ samp {
background-color: #fff !important; background-color: #fff !important;
} }
.ant-input-group-addon {
color: #666 !important;
font-size: 12px;
border: 1px solid #d9d9d9 !important;
border-left: none !important;
}
.check_on { .check_on {
background: #4CACFF; background: #4CACFF;