Commit 25129bd7 by zhaochengxiang

模型字段编辑增加非空

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