Browse Source

(*)模型管理增加属性名称 代码判重

master
peng.peng 2 years ago
parent
commit
3dc3891f5f
  1. 38
      web/client/src/sections/metadataManagement/components/modelModal.js
  2. 7
      web/client/src/sections/metadataManagement/containers/metaModelManagement.js

38
web/client/src/sections/metadataManagement/components/modelModal.js

@ -1,24 +1,36 @@
import React, { useState, useRef } from 'react';
import { Button, Form, Row, Col, Table, Popconfirm, Input, message } from 'antd';
import React from 'react';
import { Button } from 'antd';
import {
ModalForm,
ProFormRadio,
ProFormSelect,
ProFormTextArea,
ProFormDigit,
ProFormDependency,
ProFormText
} from '@ant-design/pro-form';
import moment from 'moment';
export default (props) => {
const { title, triggerRender, editData = null, onFinish, readOnly, } = props;
const { title, triggerRender, editData = null, onFinish, readOnly, models } = props;
const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 16 } };
const initialValues = editData ? {
...editData,
} : {};
const checkName = async (rule, value) => {
let filter = models?.find(s => s?.attributeName == value)
if (filter) {
return Promise.reject(new Error('已存该属性名称!'));
}
return Promise.resolve();
}
const checkCode = async (rule, value) => {
let filter = models?.find(s => s?.attributeCode == value)
if (filter) {
return Promise.reject(new Error('已存该属性代码!'));
}
return Promise.resolve();
}
return (
<ModalForm
title={title || ''}
@ -34,19 +46,17 @@ export default (props) => {
modalProps={{
destroyOnClose: true,
onCancel: () => { },
// bodyStyle: { height: 800, overflowY: 'auto' }
}}
onFinish={async (values) => {
onFinish && await onFinish(values, editData)
return true;
}}
// submitter={!readOnly}
width={500}
>
<ProFormText
rules={[{ required: true, message: '请输入属性名称' },
{ max: 255, message: '属性名称长度不能大于255个字符' }
{ max: 255, message: '属性名称长度不能大于255个字符' },
{ validator: checkName }
]}
name="attributeName"
label="属性名称"
@ -54,7 +64,8 @@ export default (props) => {
<ProFormText
rules={[{ required: true, message: '请输入属性代码' },
{ max: 255, message: '属性代码长度不能大于255个字符' }
{ max: 255, message: '属性代码长度不能大于255个字符' },
{ validator: checkCode }
]}
name="attributeCode"
label="属性代码"
@ -76,7 +87,8 @@ export default (props) => {
<ProFormDigit
name="length"
label="长度"
fieldProps={{ precision: 0 }}
fieldProps={{ precision: 0, max: 99999999, }}
// rules={[{ max: 99999999, message: '长度最大值不能超过99999999' }]}
/>
<ProFormSelect

7
web/client/src/sections/metadataManagement/containers/metaModelManagement.js

@ -112,6 +112,7 @@ function MetaModelManagement(props) {
editData={record}
title="编辑模型"
onFinish={onFinish}
models={metaModel?.rows || []}
key="editModel"
/>)
@ -172,9 +173,10 @@ function MetaModelManagement(props) {
}
}
pagination={{
size: 'large',
total: metaModel?.count,
showSizeChanger: true,
showQuickJumper: true,
// showQuickJumper: true,
current: currentPage,
pageSize: pageSize || 10,
pageSizeOptions: [10, 20, 50],
@ -199,6 +201,7 @@ function MetaModelManagement(props) {
title="新建模型"
onFinish={onFinish}
key="addModel"
models={metaModel?.rows || []}
/>
]}
options={false}
@ -214,7 +217,7 @@ function mapStateToProps(state) {
auth, global, metaModel
} = state;
return {
loading: auth.isRequesting,
loading: metaModel.isRequesting,
clientHeight: global.clientHeight,
actions: global.actions,
metaModel: metaModel?.data || {}

Loading…
Cancel
Save