Commit 789ff5fd by zhaochengxiang

模型ji基本信息展开

parent 006f8d94
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Form, Input, Row, Col, Descriptions, Select, AutoComplete, Checkbox } from 'antd'; import { Form, Input, Row, Col, Descriptions, Select, AutoComplete, Checkbox, Button } from 'antd';
import { DownOutlined, UpOutlined } from '@ant-design/icons';
import { highlightSearchContentByTerms, generateUUID } from '../../../../util'; import { highlightSearchContentByTerms, generateUUID } from '../../../../util';
import { dispatchLatest } from '../../../../model'; import { dispatchLatest } from '../../../../model';
...@@ -423,8 +424,8 @@ const ImportActionHeader = (props) => { ...@@ -423,8 +424,8 @@ const ImportActionHeader = (props) => {
} }
} }
const onOnlyShowRequireChange = (e) => { const onOnlyShowRequireChange = () => {
setOnlyShowRequireChange(e.target.checked); setOnlyShowRequireChange(!onlyShowRequireChange);
} }
let distributionDescription = '', primaryDescription = '', partitionsDescription = '', semiPrimaryDescription = ''; let distributionDescription = '', primaryDescription = '', partitionsDescription = '', semiPrimaryDescription = '';
...@@ -488,7 +489,9 @@ const ImportActionHeader = (props) => { ...@@ -488,7 +489,9 @@ const ImportActionHeader = (props) => {
}} }}
> >
<h2>基本信息</h2> <h2>基本信息</h2>
<Checkbox onChange={onOnlyShowRequireChange} defaultChecked={onlyShowRequireChange} value={onlyShowRequireChange}>仅显示必填项</Checkbox> {
onlyShowRequireChange ? <Button type='text' style={{ padding: 0, color: '#0069AC' }} onClick={onOnlyShowRequireChange}>展开<DownOutlined /></Button> : <Button type='text' style={{ padding: 0, color: '#0069AC' }} onClick={onOnlyShowRequireChange}>收起<UpOutlined /></Button>
}
</div> </div>
{ {
editable ? ( editable ? (
......
.model-import-action-header { .model-import-action-header {
.yy-form-item { .yy-form-item:nth-last-col {
margin-bottom: 24px; margin-bottom: 24px;
} }
......
...@@ -118,6 +118,7 @@ const ModelTable = (props) => { ...@@ -118,6 +118,7 @@ const ModelTable = (props) => {
id: MENU_ID, id: MENU_ID,
}); });
const [ tableWidth, setTableWidth ] = useState(0);
const [ selectedRowKeys, setSelectedRowKeys ] = useState([]); const [ selectedRowKeys, setSelectedRowKeys ] = useState([]);
const [ subSelectedRowKeys, setSubSelectedRowKeys ] = useState([]); const [ subSelectedRowKeys, setSubSelectedRowKeys ] = useState([]);
// const [ mouseEnterKey, setMouseEnterKey ] = useState(null); // const [ mouseEnterKey, setMouseEnterKey ] = useState(null);
...@@ -620,31 +621,35 @@ const ModelTable = (props) => { ...@@ -620,31 +621,35 @@ const ModelTable = (props) => {
<div className={classes}> <div className={classes}>
<ResizeObserver <ResizeObserver
onResize={({ width }) => { onResize={({ width }) => {
let newColumns = [...cols]; if (tableWidth !== width) {
setTableWidth(width);
if ((modelId||'') !== '') {
newColumns = cols.filter(item => item.dataIndex!=='key');
} else if ((modelId||'')==='' && (view==='state'||(keyword||'')!=='')) { let newColumns = [...cols];
newColumns = cols.splice(3, 0, pathColumn);
}
newColumns.forEach((column, index) => { if ((modelId||'') !== '') {
if (!column.width) { newColumns = cols.filter(item => item.dataIndex!=='key');
const rowWidth = (columns.reduce((preVal, col) => (col.width?col.width:0) + preVal, 0)) + 50;
if (width > rowWidth) { } else if ((modelId||'')==='' && (view==='state'||(keyword||'')!=='')) {
column.width = (width-rowWidth)>200?(width-rowWidth):200; newColumns = cols.splice(3, 0, pathColumn);
} else {
column.width = 200;
}
} }
}); newColumns.forEach((column, index) => {
setColumns(newColumns); if (!column.width) {
const rowWidth = (columns.reduce((preVal, col) => (col.width?col.width:0) + preVal, 0)) + 50;
if (width > rowWidth) {
column.width = (width-rowWidth)>200?(width-rowWidth):200;
} else {
column.width = 200;
}
}
});
setColumns(newColumns);
}
}} }}
> >
<Table <Table
......
...@@ -41,6 +41,7 @@ const ResizeableHeaderCell = props => { ...@@ -41,6 +41,7 @@ const ResizeableHeaderCell = props => {
const SuggestTable = (props) => { const SuggestTable = (props) => {
const { suggests, onSelect } = props; const { suggests, onSelect } = props;
const [ tableWidth, setTableWidth ] = useState(0);
const cols = [ const cols = [
{ {
...@@ -174,23 +175,26 @@ const SuggestTable = (props) => { ...@@ -174,23 +175,26 @@ const SuggestTable = (props) => {
<ResizeObserver <ResizeObserver
onResize={({ width }) => { onResize={({ width }) => {
let newColumns = [...cols]; if (tableWidth !== width) {
setTableWidth(width);
let newColumns = [...cols];
newColumns.forEach((column, index) => { newColumns.forEach((column, index) => {
if (!column.width) { if (!column.width) {
const rowWidth = (columns.reduce((preVal, col) => (col.width?col.width:0) + preVal, 0)) + 50; const rowWidth = (columns.reduce((preVal, col) => (col.width?col.width:0) + preVal, 0)) + 50;
if (width > rowWidth) { if (width > rowWidth) {
column.width = (width-rowWidth)>200?(width-rowWidth):200; column.width = (width-rowWidth)>200?(width-rowWidth):200;
} else { } else {
column.width = 200; column.width = 200;
}
} }
}
}); });
setColumns(newColumns); setColumns(newColumns);
}
}} }}
> >
<Table <Table
......
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