新增正则判断
This commit is contained in:
parent
82d446ffe2
commit
4c06fdc2f5
@ -1,12 +1,15 @@
|
|||||||
import './ai-helper-mod.css'
|
import './ai-helper-mod.css'
|
||||||
import { Button,
|
import {
|
||||||
|
Button,
|
||||||
// Divider, Dropdown, Space,
|
// Divider, Dropdown, Space,
|
||||||
Table, TableProps, Modal } from "antd";
|
Table, TableProps, Modal
|
||||||
|
} from "antd";
|
||||||
import {
|
import {
|
||||||
// CheckOutlined,
|
// CheckOutlined,
|
||||||
LoadingOutlined,
|
LoadingOutlined,
|
||||||
// ReloadOutlined,
|
// ReloadOutlined,
|
||||||
RedoOutlined } from "@ant-design/icons";
|
RedoOutlined
|
||||||
|
} from "@ant-design/icons";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { IProjMod } from "../../../interfaces/proj/IProj.ts";
|
import { IProjMod } from "../../../interfaces/proj/IProj.ts";
|
||||||
import EditModal from '../../EditModal/EditModal.tsx'
|
import EditModal from '../../EditModal/EditModal.tsx'
|
||||||
@ -71,6 +74,11 @@ export default function AiHelperMod(props: PropsType) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
}, [])
|
}, [])
|
||||||
|
const returnValue = (value:string) => {
|
||||||
|
// 如果value包含. / \ ` ! @ # $ % ^ & * ( ) 等特殊符号 去掉
|
||||||
|
// return value.replace(/[\\/:*?"<>|]/g, '');
|
||||||
|
return value.replace(/[./\\`!@#$%^&*()]/g, '');
|
||||||
|
}
|
||||||
const modColumnArray: TableProps<IProjMod>['columns'] = [
|
const modColumnArray: TableProps<IProjMod>['columns'] = [
|
||||||
{
|
{
|
||||||
title: '序号',
|
title: '序号',
|
||||||
@ -82,7 +90,15 @@ export default function AiHelperMod(props: PropsType) {
|
|||||||
return index + 1
|
return index + 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ title: '模块名称', dataIndex: 'modName', key: 'name', width: 200, align: 'center' },
|
{ title: '模块名称', dataIndex: 'modName', key: 'name', width: 200, align: 'center',
|
||||||
|
render: (value) => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{returnValue(value)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
{ title: '模块描述', dataIndex: 'modDesc', key: 'desc', align: 'center' },
|
{ title: '模块描述', dataIndex: 'modDesc', key: 'desc', align: 'center' },
|
||||||
{
|
{
|
||||||
title: 'AI状态',
|
title: 'AI状态',
|
||||||
@ -260,7 +276,16 @@ export default function AiHelperMod(props: PropsType) {
|
|||||||
return index + 1
|
return index + 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ title: '模块名称', dataIndex: 'name', key: 'name', width: 200, align: 'center' },
|
{
|
||||||
|
title: '模块名称', dataIndex: 'name', key: 'name', width: 200, align: 'center',
|
||||||
|
render: (value) => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{returnValue(value)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
{ title: '模块描述', dataIndex: 'desc', key: 'desc', align: 'center' },
|
{ title: '模块描述', dataIndex: 'desc', key: 'desc', align: 'center' },
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
|
@ -43,6 +43,14 @@ export default function ModField(props: PropsType) {
|
|||||||
setTableDataArray(props.modFiledArray)
|
setTableDataArray(props.modFiledArray)
|
||||||
}
|
}
|
||||||
}, [props.modFiledArray])
|
}, [props.modFiledArray])
|
||||||
|
const returnValue = (value:string) => {
|
||||||
|
if (value && value[0].match(/[0-9]/)) {
|
||||||
|
// 生成一个随机的小写字母
|
||||||
|
const randomChar = String.fromCharCode(97 + Math.floor(Math.random() * 26));
|
||||||
|
value = randomChar + value;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
const columns: TableProps<IModField>['columns'] = [
|
const columns: TableProps<IModField>['columns'] = [
|
||||||
{
|
{
|
||||||
@ -51,7 +59,7 @@ export default function ModField(props: PropsType) {
|
|||||||
render: (text, _record, index) => {
|
render: (text, _record, index) => {
|
||||||
if (props.isEdit) {
|
if (props.isEdit) {
|
||||||
return (
|
return (
|
||||||
<Input defaultValue={text} onChange={(e) => {
|
<Input defaultValue={returnValue(text)} onChange={(e) => {
|
||||||
const item = tableDataArray[index];
|
const item = tableDataArray[index];
|
||||||
const value = e.target.value;
|
const value = e.target.value;
|
||||||
const fieldName = pinyin(value, {
|
const fieldName = pinyin(value, {
|
||||||
@ -72,9 +80,10 @@ export default function ModField(props: PropsType) {
|
|||||||
setTableDataArray([...tableDataArray]);
|
setTableDataArray([...tableDataArray]);
|
||||||
handleChange();
|
handleChange();
|
||||||
}}/>
|
}}/>
|
||||||
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
return text;
|
return returnValue(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user