Commit e182d528 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix:交易规则查看异常处理

parent f3ded9af
......@@ -7,6 +7,7 @@ import {ColumnType} from 'antd/lib/table/interface';
import ReutrnEle from '@/components/ReturnEle';
import { PublicApi } from '@/services/api';
import { usePageStatus } from '@/hooks/usePageStatus';
import { validatorByte } from '@/utils/regExp';
const { Option } = Select;
......@@ -173,6 +174,9 @@ const AddAtttribute: React.FC<{}> = () => {
required: true,
message: '输入属性组名!',
},
{
validator: (r, v, c) => validatorByte(r, v, c, 20)
}
]}
>
<Input placeholder="输入属性组名" disabled={pageStatus === 2} />
......@@ -195,6 +199,9 @@ const AddAtttribute: React.FC<{}> = () => {
required: true,
message: '输入属性名称!',
},
{
validator: (r, v, c) => validatorByte(r, v, c, 20)
}
]}
>
<Input placeholder="输入属性名称" disabled={pageStatus === 2} />
......
......@@ -28,7 +28,13 @@ export const classSchema: ISchema = {
required: true,
"x-component-props": {
placeholder: '请输入品类名称'
}
},
"x-rules": [
{
limitByte: true,
maxByte: 16
}
]
},
type: {
type: 'number',
......
......@@ -7,6 +7,7 @@ import { history } from 'umi';
import ReutrnEle from '@/components/ReturnEle';
import { PublicApi } from '@/services/api';
import { GetManageAreaAllResponse } from '@/services/PassApi';
import { validatorByte } from '@/utils/regExp';
const layout = {
labelCol: {
......@@ -158,6 +159,9 @@ const AddPropertyValue: React.FC<{}> = () => {
required: true,
message: '输入属性值名称!',
},
{
validator: (r, v, c) => validatorByte(r, v, c, 12)
}
]}
>
<Input placeholder="输入属性值名称" disabled={isSee} />
......
......@@ -42,3 +42,28 @@ export const checkRegExp = (str:string, type:string) => {
return true;
}
}
/**
* 区别校验 汉字 和 字符 长度
* @param rule
* @param value 表单输入的值
* @param callback
* @param maxByte:number 最大字符数
*/
export const validatorByte = (rule, value, callback, maxByte: number) => {
try {
if(value){
let str = value
str = str.replace(/[\u4e00-\u9fa5]/g, 'OO')
if(str.length > maxByte)
throw new Error(`最多输入${maxByte}个字符,${Math.floor(maxByte / 2)}个汉字`);
else
callback()
} else {
callback()
}
} catch (err) {
callback(err)
}
}
\ No newline at end of file
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