Commit 7a7c2741 by zhaochengxiang

资产目录编码限制

parent 957f033f
...@@ -11,6 +11,25 @@ const resourceTypes = [ ...@@ -11,6 +11,25 @@ const resourceTypes = [
{ key: 'custom', name: '自定义' }, { key: 'custom', name: '自定义' },
] ]
const CodeInput = ({ value = '', onChange, restrict = false, action }) => {
const onCodeChange = (e) => {
if (!restrict || (
restrict&&/^[a-zA-Z]+$/.test(e.target.value)
)) {
onChange?.(e.target.value);
}
}
return <Input
placeholder="请输入编号"
disabled={action!=='add'}
maxLength={restrict?3:null}
value={value}
onChange={onCodeChange}
/>
}
const UpdateDirectoryModal = (props) => { const UpdateDirectoryModal = (props) => {
const { visible, onCancel, dirId, action } = props; const { visible, onCancel, dirId, action } = props;
...@@ -154,7 +173,7 @@ const UpdateDirectoryModal = (props) => { ...@@ -154,7 +173,7 @@ const UpdateDirectoryModal = (props) => {
if (action==='add') { if (action==='add') {
if (changedValues.type === 'theme') { if (changedValues.type === 'theme') {
setIsThemeAdd(true); setIsThemeAdd(true);
if (allValues.code?.length > 3) { if (allValues.code?.length > 3 || !(/^[a-zA-Z]+$/.test(allValues.code))) {
form.setFieldsValue({ code: '' }); form.setFieldsValue({ code: '' });
} }
} else if (changedValues.type === 'directory') { } else if (changedValues.type === 'directory') {
...@@ -231,7 +250,7 @@ const UpdateDirectoryModal = (props) => { ...@@ -231,7 +250,7 @@ const UpdateDirectoryModal = (props) => {
name="code" name="code"
rules={[{ required: true, message: '必填项' }]} rules={[{ required: true, message: '必填项' }]}
> >
<Input placeholder="请输入编号" disabled={action!=='add'} maxLength={codeRestrict?3:null} /> <CodeInput restrict={codeRestrict} action={action} />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label="名称" label="名称"
......
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