Commit 2f638bc9 by zhaochengxiang

我的空间服务

parent 299abef3
import React, { useEffect, useState, useContext } from 'react'; import React, { useEffect, useState, useContext, useMemo } from 'react';
import { Spin } from 'antd'; import { Spin, Tooltip, Typography, Pagination, Table } from 'antd';
import { AppContext } from '../../../../App'; import { AppContext } from '../../../../App';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
import ModelTable from "./ModelTable"; import { paginate } from '../../../../util';
import HistoryAndVersionDrawer from './HistoryAndVersionDrawer';
const FC = (props) => { const FC = (props) => {
const app = useContext(AppContext); const app = useContext(AppContext);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [data, setData] = useState([]); const [data, setData] = useState([]);
const [historyParams, setHistoryParams] = useState({visible: false, id: undefined }) const [pagination, setPagination] = useState({pageNum: 1, pageSize: 20});
const {pageNum, pageSize} = pagination;
const cols = [
{
title: '序号',
dataIndex: 'key',
render: (text, record, index) => {
return (index+1).toString();
},
width: 60,
ellipsis: true,
},
{
title: '数据服务资产编码',
dataIndex: 'code',
ellipsis: true,
},
{
title: '数据服务名称',
dataIndex: 'name',
ellipsis: true,
},
{
title: 'URI',
dataIndex: 'odata',
ellipsis: true,
render: (text, _, __) => {
return (
<React.Fragment>
{
text ? <div className='flex'>
<Tooltip title={text||''} overlayClassName='tooltip-common'>
<Typography.Text ellipsis={true}>
{text||''}
</Typography.Text>
</Tooltip>
<Typography.Text copyable={{ text }}></Typography.Text>
</div> : ''
}
</React.Fragment>
);
}
},
{
title: '操作',
dataIndex: 'action',
width: 60,
fixed: 'right',
render: (_, record) => {
return (
<a onClick={() => {
app.openDetail?.({ service: record })
}}>详情</a>
)
}
}
];
useEffect(() => { useEffect(() => {
getServices(); getServices();
}, []) }, [])
const tableData = useMemo(() => {
if (data) {
return paginate(data, pagination.pageNum, pagination.pageSize);
}
return [];
}, [data, pagination])
const getServices = () => { const getServices = () => {
setLoading(true); setLoading(true);
dispatch({ dispatch({
...@@ -33,28 +97,32 @@ const FC = (props) => { ...@@ -33,28 +97,32 @@ const FC = (props) => {
}); });
} }
const onHistory = (id) => {
setHistoryParams({visible: true, id});
}
const onHistoryCancel = () => {
setHistoryParams({visible: false, id: undefined});
}
return ( return (
<div> <div>
<Spin spinning={loading}> <Table
<ModelTable extraColWidth={10}
user={app?.user} loading={loading}
view='grant' columns={cols||[]}
data={data} dataSource={tableData}
onHistory={onHistory} pagination={false}
{...props} /> scroll={{y: (tableData||[]).length===0?null:'calc(100vh - 121px - 57px - 24px - 38px - 44px)'}}
</Spin> />
<HistoryAndVersionDrawer <Pagination
id={historyParams?.id} className="text-center mt-3"
visible={historyParams?.visible} showSizeChanger
onCancel={onHistoryCancel} showQuickJumper
onChange={(_pageNum, _pageSize) => {
setPagination({ pageNum: _pageNum, pageSize: _pageSize || 20 });
}}
onShowSizeChange={(_pageNum, _pageSize) => {
setPagination({ pageNum: 1, pageSize: _pageSize });
}}
current={pageNum}
pageSize={pageSize}
defaultCurrent={1}
total={(data||[]).length}
pageSizeOptions={[10,20,50,100]}
showTotal={total => ` ${total} `}
/> />
</div> </div>
) )
......
...@@ -510,7 +510,7 @@ const ModelTable = (props) => { ...@@ -510,7 +510,7 @@ const ModelTable = (props) => {
}; };
} }
if (item.key === 'itStaff' || item.key === 'keyUsers' || item.key === 'owner') { if (item.userSelected === true) {
col.render = (_, record) => { col.render = (_, record) => {
const user = users?.filter((user)=>(user.pernr===record.basicInfo?.[item.key])); const user = users?.filter((user)=>(user.pernr===record.basicInfo?.[item.key]));
if (user && user.length > 0) { if (user && user.length > 0) {
......
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