Commit 25129bd7 by zhaochengxiang

模型字段编辑增加非空

parent 144855cd
import React, { useState, useCallback, useRef, useEffect } from 'react';
import { Table, Input, Form, Typography, Radio, Divider, Button, Popconfirm, Select, Row, Col, Popover } from 'antd';
import { Table, Input, Form, Typography, Radio, Divider, Button, Popconfirm, Select, Row, Col, Popover, Checkbox } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
import { DndProvider, useDrag, useDrop } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
......@@ -117,21 +117,24 @@ const EditableCell = ({
let editingComponent = null;
if (editing) {
if (dataIndex !== 'datatype') {
const inputNode = inputType === 'check' ? <Checkbox /> : <Input />
editingComponent = (
<Form.Item
name={dataIndex}
style={{
margin: 0,
}}
valuePropName={'value'}
valuePropName={(inputType==='check')? 'checked': 'value'}
rules={[
{
required: true,
required: (inputType === 'text'),
message: `请输入${title}!`,
},
]}
>
<Input />
{ inputNode }
</Form.Item>
);
} else {
......@@ -364,7 +367,6 @@ const ImportActionTable = (props) => {
{
title: '类型',
width: 200,
dataIndex: 'datatype',
editable: true,
render: (datatype, record, index) => {
......@@ -381,6 +383,21 @@ const ImportActionTable = (props) => {
}
},
{
title: '非空',
width: 50,
dataIndex: 'nullable',
editable: true,
render: (nullable, record, index) => {
if (nullable === false) {
return '否';
} else if (nullable === true) {
return '是';
}
return '';
}
},
{
title: '描述',
dataIndex: 'remark',
editable: true,
......@@ -499,8 +516,8 @@ const ImportActionTable = (props) => {
...col,
onCell: (record) => ({
record,
inputType: 'text',
dataIndex: col.dataIndex,
inputType: col.dataIndex==='nullable' ? 'check' : 'text',
title: col.title,
editing: isEditing(record),
datatypes: supportedDatatypes,
......
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