新增正则判断
This commit is contained in:
parent
82d446ffe2
commit
4c06fdc2f5
@ -1,12 +1,15 @@
|
||||
import './ai-helper-mod.css'
|
||||
import { Button,
|
||||
import {
|
||||
Button,
|
||||
// Divider, Dropdown, Space,
|
||||
Table, TableProps, Modal } from "antd";
|
||||
Table, TableProps, Modal
|
||||
} from "antd";
|
||||
import {
|
||||
// CheckOutlined,
|
||||
LoadingOutlined,
|
||||
LoadingOutlined,
|
||||
// ReloadOutlined,
|
||||
RedoOutlined } from "@ant-design/icons";
|
||||
RedoOutlined
|
||||
} from "@ant-design/icons";
|
||||
import { useEffect, useState } from "react";
|
||||
import { IProjMod } from "../../../interfaces/proj/IProj.ts";
|
||||
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'] = [
|
||||
{
|
||||
title: '序号',
|
||||
@ -82,7 +90,15 @@ export default function AiHelperMod(props: PropsType) {
|
||||
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: 'AI状态',
|
||||
@ -260,7 +276,16 @@ export default function AiHelperMod(props: PropsType) {
|
||||
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: '操作',
|
||||
@ -333,7 +358,7 @@ export default function AiHelperMod(props: PropsType) {
|
||||
// </Modal>
|
||||
// </>
|
||||
|
||||
<div style={{ height: `${height}px`, border: '1px solid #D5D5D5',overflow:'auto' }}>
|
||||
<div style={{ height: `${height}px`, border: '1px solid #D5D5D5', overflow: 'auto' }}>
|
||||
<div className="aiMod-top">
|
||||
{modArray.length > 0 ?
|
||||
<>
|
||||
@ -392,7 +417,7 @@ export default function AiHelperMod(props: PropsType) {
|
||||
<>
|
||||
<span style={{
|
||||
color: '#ABABAB',
|
||||
fontSize:16
|
||||
fontSize: 16
|
||||
}}> 点击AI自动生成后可自动生成模块管理...</span>
|
||||
</>}
|
||||
</div>
|
||||
|
@ -43,6 +43,14 @@ export default function ModField(props: PropsType) {
|
||||
setTableDataArray(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'] = [
|
||||
{
|
||||
@ -51,7 +59,7 @@ export default function ModField(props: PropsType) {
|
||||
render: (text, _record, index) => {
|
||||
if (props.isEdit) {
|
||||
return (
|
||||
<Input defaultValue={text} onChange={(e) => {
|
||||
<Input defaultValue={returnValue(text)} onChange={(e) => {
|
||||
const item = tableDataArray[index];
|
||||
const value = e.target.value;
|
||||
const fieldName = pinyin(value, {
|
||||
@ -72,9 +80,10 @@ export default function ModField(props: PropsType) {
|
||||
setTableDataArray([...tableDataArray]);
|
||||
handleChange();
|
||||
}}/>
|
||||
|
||||
)
|
||||
} else {
|
||||
return text;
|
||||
return returnValue(text);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user