Commit d36788ca by zhaochengxiang

模型主页面调整

parent b8627b42
...@@ -21,7 +21,7 @@ const ExportOtherModal = (props) => { ...@@ -21,7 +21,7 @@ const ExportOtherModal = (props) => {
const onOk = async() => { const onOk = async() => {
try { try {
const row = await form.validateFields(); await form.validateFields();
reset(); reset();
onCancel && onCancel(modeKey); onCancel && onCancel(modeKey);
......
...@@ -18,7 +18,6 @@ const ImportModal = (props) => { ...@@ -18,7 +18,6 @@ const ImportModal = (props) => {
const { view, catalogId, visible, onCancel } = props; const { view, catalogId, visible, onCancel } = props;
const [ modeKey, setModeKey ] = useState(''); const [ modeKey, setModeKey ] = useState('');
const [ files, setFiles ] = useState([]);
const [ hints, setHints ] = useState([]); const [ hints, setHints ] = useState([]);
const [ confirmLoading, setConfirmLoading ] = useState(false); const [ confirmLoading, setConfirmLoading ] = useState(false);
...@@ -95,7 +94,6 @@ const ImportModal = (props) => { ...@@ -95,7 +94,6 @@ const ImportModal = (props) => {
const reset = () => { const reset = () => {
form.resetFields(); form.resetFields();
setModeKey(''); setModeKey('');
setFiles([]);
setHints([]); setHints([]);
setConfirmLoading(false); setConfirmLoading(false);
} }
......
import React, { useState, useEffect, useRef } from "react"; import React, { useState, useEffect, useRef } from "react";
import { Space, Button, Tooltip, Modal, Divider, Pagination, Table } from 'antd'; import { Button, Tooltip, Modal, Pagination, Table, Dropdown, Menu, Divider } from 'antd';
import { EditOutlined, DeleteOutlined, DownOutlined, UpOutlined, HistoryOutlined } from '@ant-design/icons'; import { DownOutlined, UpOutlined } from '@ant-design/icons';
import SmoothScroll from 'smooth-scroll'; import SmoothScroll from 'smooth-scroll';
import classnames from 'classnames'; import classnames from 'classnames';
import { dispatchLatest, dispatch } from '../../../../model'; import { dispatchLatest, dispatch } from '../../../../model';
import { showMessage, getQueryParam, paginate } from '../../../../util'; import { showMessage, getQueryParam, paginate } from '../../../../util';
import { AnchorId, AnchorTimestamp } from '../../../../util/constant'; import { AnchorId, AnchorTimestamp, Action, CatalogId, ModelerId } from '../../../../util/constant';
import './ModelTable.less'; import './ModelTable.less';
const ModelTable = (props) => { const ModelTable = (props) => {
const { data, onChange, onItemAction, onSelect, onHistory, catalogId, keyword, onAutoCreateTable, offset = null, modelId = null } = props; const { data, onChange, onItemAction, onSelect, onHistory, catalogId, keyword, onAutoCreateTable, offset = null, modelId = null, view } = props;
const [ selectedRowKeys, setSelectedRowKeys ] = useState([]); const [ selectedRowKeys, setSelectedRowKeys ] = useState([]);
const [ subData, setSubData ] = useState([]); const [ subData, setSubData ] = useState([]);
const moreMenu = (record) => {
return <Menu onClick={(e) => { onMoreMenuClick(e, record); }}>
<Menu.Item key='history'>
历史版本
</Menu.Item>
<Menu.Item key='copy'>
复制模型
</Menu.Item>
{
(record?.state?.supportedActions||[]).length>0 && record?.state?.supportedActions.map((item, index) => {
return (
<Menu.Item key={`action-${index}`}>
{item.cnName||''}
</Menu.Item>
);
})
}
{
record?.deployable && <Menu.Item key='createTable'>
建表
</Menu.Item>
}
</Menu>
}
const columns = [ const columns = [
{ {
title: '序号', title: '序号',
...@@ -69,51 +94,68 @@ const ModelTable = (props) => { ...@@ -69,51 +94,68 @@ const ModelTable = (props) => {
{ {
title: '状态', title: '状态',
dataIndex: 'state', dataIndex: 'state',
width: 100, width: 120,
ellipsis: true, ellipsis: true,
render: (_, record) => { render: (_, record) => {
return record?.state?.cnName||'';
let color = '';
if (record?.state?.id === '1') {
color = '#DE7777';
} else if (record?.state?.id === '2') {
color = '#779BDE';
} else if (record?.state?.id === '4') {
color = '#77DEBF';
}
return (
<span>
<span style={{ display: 'inline-block', width: 10, height: 10, borderRadius: 5, marginRight: 5, backgroundColor: color }}></span>
<span>{record?.state?.cnName||''}</span>
</span>
);
} }
}, },
{ {
title: '操作', title: '操作',
key: 'action', key: 'action',
width: 230, width: 200,
render: (_,record) => { render: (_,record) => {
return ( return (
<Space size='small'> <div style={{ display: 'flex', alignItems: 'center' }}>
{ <Button
<React.Fragment> type='link'
<Tooltip placement='bottom' title={'修改'}> size='small'
<Button icon={<EditOutlined />} size='small' disabled={!record?.editable&&!record?.permitCheckOut} onClick={() => { editItem(record); }} /> disabled={!record?.editable&&!record?.permitCheckOut}
</Tooltip> onClick={() => { editItem(record); }}
<Tooltip placement='bottom' title={'删除'}> style={{ padding: 0 }}
<Button icon={<DeleteOutlined />} size='small' disabled={!record?.deletable} onClick={() => { deleteItem(record); }} /> >
</Tooltip> 编辑
<Tooltip placement='bottom' title={'版本历史'}> </Button>
<Button icon={<HistoryOutlined />} size='small' onClick={() => { historyItem(record); }} /> <div style={{ margin: '0 5px' }}>
</Tooltip> <Divider type='vertical' />
</React.Fragment> </div>
} <Button
{ type='link'
(record?.state?.supportedActions||[]).length>0 && record?.state?.supportedActions.map((item, index) => { size='small'
return ( disabled={!record?.deletable}
<React.Fragment> onClick={() => { deleteItem(record); }}
{ style={{ padding: 0 }}
(record.editable||record.permitCheckOut||record.deletable) && index===0 && <Divider type='vertical' /> >
} 删除
<Button key={index} size='small' onClick={() => { stateAction(record, item); }} >{item.cnName||''}</Button> </Button>
</React.Fragment> <div style={{ margin: '0 5px' }}>
); <Divider type='vertical' />
}) </div>
} <Dropdown overlay={moreMenu(record)} placement="bottomLeft">
{ <Button
record?.deployable && <React.Fragment> type='link'
{ record.editable && <Divider type='vertical' /> } size='small'
<Button size='small' onClick={() => { deployAction(record); }} >建表</Button> style={{ padding: 0 }}
</React.Fragment> >
} 更多<DownOutlined />
</Space> </Button>
</Dropdown>
</div>
) )
} }
} }
...@@ -206,6 +248,21 @@ const ModelTable = (props) => { ...@@ -206,6 +248,21 @@ const ModelTable = (props) => {
onItemAction && onItemAction(record, 'detail'); onItemAction && onItemAction(record, 'detail');
} }
const onMoreMenuClick = (e, record) => {
const { key } = e;
if (key === 'history') {
historyItem(record);
} else if (key === 'copy') {
window.open(`/data-govern/data-model-action?${Action}=add&${CatalogId}=${(view==='dir')?(catalogId||''):''}&${ModelerId}=${record.id}`);
} else if (key === 'createTable') {
deployAction(record);
} else if (key.indexOf('action') !== -1) {
const index = (key.split('-'))[1];
const action = record.state?.supportedActions[index];
stateAction(record, action);
}
}
const deployAction = (record) => { const deployAction = (record) => {
onAutoCreateTable && onAutoCreateTable(record); onAutoCreateTable && onAutoCreateTable(record);
} }
...@@ -334,7 +391,7 @@ const ModelTable = (props) => { ...@@ -334,7 +391,7 @@ const ModelTable = (props) => {
sticky={!modelId} sticky={!modelId}
/> />
{ {
!modelId && <Pagination !modelId && (data||[]).length>0 && <Pagination
className="text-center mt-3" className="text-center mt-3"
showSizeChanger showSizeChanger
showQuickJumper showQuickJumper
......
...@@ -6,6 +6,22 @@ ...@@ -6,6 +6,22 @@
} }
.yy-table-thead > tr > th { .yy-table-thead > tr > th {
padding: 8px 16px !important;
}
.yy-table-tbody > tr > td {
padding: 12px 16px !important;
}
.yy-table-tbody > .yy-table-measure-row > td {
padding: 0px !important;
}
tr.yy-table-expanded-row > td {
background: #fff !important;
}
.yy-table-thead > tr > th {
background-color: #F2F5FC !important; background-color: #F2F5FC !important;
} }
...@@ -24,4 +40,12 @@ ...@@ -24,4 +40,12 @@
.yy-table { .yy-table {
height: auto !important; height: auto !important;
} }
.yy-table-placeholder {
display: none;
}
.yy-table-tbody > tr > td {
padding: 8px 16px !important;
}
} }
\ No newline at end of file
...@@ -203,22 +203,6 @@ class Model extends React.Component { ...@@ -203,22 +203,6 @@ class Model extends React.Component {
window.open(`/data-govern/data-model-action?${Action}=add&${CatalogId}=${(currentView==='dir')?(catalogId||''):''}`); window.open(`/data-govern/data-model-action?${Action}=add&${CatalogId}=${(currentView==='dir')?(catalogId||''):''}`);
} }
onImportModelBtnClick = () => {
const { catalogId, selectModelerIds, currentView } = this.state;
if ((selectModelerIds||[]).length === 0) {
showMessage('info', '请先选择一个模型');
return;
}
if ((selectModelerIds||[]).length > 1) {
showMessage('info', '只能选择一个模型');
return;
}
window.open(`/data-govern/data-model-action?${Action}=add&${CatalogId}=${(currentView==='dir')?(catalogId||''):''}&${ModelerId}=${selectModelerIds[0]}`);
}
onExportDDLBtnClick = () => { onExportDDLBtnClick = () => {
const { selectModelerIds, tableData } = this.state; const { selectModelerIds, tableData } = this.state;
if ((selectModelerIds||[]).length === 0) { if ((selectModelerIds||[]).length === 0) {
...@@ -410,6 +394,7 @@ class Model extends React.Component { ...@@ -410,6 +394,7 @@ class Model extends React.Component {
<ModelTable <ModelTable
loading={loadingTableData} loading={loadingTableData}
catalogId={catalogId} catalogId={catalogId}
view={currentView}
data={filterTableData} data={filterTableData}
offset={offset} offset={offset}
onChange={this.onTableChange} onChange={this.onTableChange}
......
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