|
|
@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react' |
|
|
|
import { connect } from 'react-redux'; |
|
|
|
import moment from 'moment'; |
|
|
|
import { RouteRequest } from '@peace/utils'; |
|
|
|
import { RouteTable } from '$utils' |
|
|
|
import { Func } from '$utils' |
|
|
|
|
|
|
|
import { Tabs, Form, Input, Space, Button, Table, Popconfirm, message } from 'antd'; |
|
|
|
const { Search } = Input; |
|
|
@ -10,7 +10,7 @@ const { Search } = Input; |
|
|
|
import EditModal from '../components/editModal'; |
|
|
|
|
|
|
|
|
|
|
|
function ServiceManagement ({ loading, clientHeight, actions, dispatch, }) { |
|
|
|
function ServiceManagement({ loading, clientHeight, actions, dispatch, }) { |
|
|
|
|
|
|
|
const { dataService } = actions |
|
|
|
const [query, setQuery] = useState({ page: 0, limit: 10 }); |
|
|
@ -53,63 +53,66 @@ function ServiceManagement ({ loading, clientHeight, actions, dispatch, }) { |
|
|
|
dataIndex: 'handle', |
|
|
|
width: '250px', |
|
|
|
// ellipsis: true,
|
|
|
|
render: (text, record) => <div style={{ width: 200, display: 'flex', justifyContent: 'space-evenly' }}> |
|
|
|
<a onClick={() => { |
|
|
|
setEditData(record) |
|
|
|
setEditModal(true) |
|
|
|
setViewDetails(true) |
|
|
|
}}>查看详情</a> |
|
|
|
<a onClick={() => { |
|
|
|
setEditData(record) |
|
|
|
setEditModal(true) |
|
|
|
}}>编辑</a> |
|
|
|
|
|
|
|
{/* {record?.enabled ? */} |
|
|
|
{record?.resourceConsumptions?.length > 0 ? <a onClick={() => { |
|
|
|
message.warning('已有关联数据,无法删除') |
|
|
|
}}>删除</a> |
|
|
|
: <Popconfirm |
|
|
|
title="是否确认删除该服务?" |
|
|
|
onConfirm={() => { |
|
|
|
dispatch(dataService.delServiceManagement(record.id)).then(res => { |
|
|
|
if (res.success) { |
|
|
|
setQuery({ limit: 10, page: 0 }); |
|
|
|
resourceData({ limit: 10, page: 0, keyword }) |
|
|
|
} |
|
|
|
}) |
|
|
|
}} |
|
|
|
> |
|
|
|
<a >删除</a> |
|
|
|
</Popconfirm>} |
|
|
|
|
|
|
|
{/* // } */} |
|
|
|
{record?.enabled ? |
|
|
|
<Popconfirm |
|
|
|
title="禁用后该服务将不可用" |
|
|
|
onConfirm={() => { |
|
|
|
render: (text, record) => { |
|
|
|
const isCurrentOrg = Func?.isOrgOrSuperAdmin(record?.resourceCatalog?.organization?.id) |
|
|
|
return <div style={{ width: 200, display: 'flex', justifyContent: 'space-evenly' }}> |
|
|
|
<a onClick={() => { |
|
|
|
setEditData(record) |
|
|
|
setEditModal(true) |
|
|
|
setViewDetails(true) |
|
|
|
}}>查看详情</a> |
|
|
|
{isCurrentOrg && <a onClick={() => { |
|
|
|
setEditData(record) |
|
|
|
setEditModal(true) |
|
|
|
}}>编辑</a> |
|
|
|
} |
|
|
|
{/* {record?.enabled ? */} |
|
|
|
{!isCurrentOrg ? '' : record?.resourceConsumptions?.length > 0 ? <a onClick={() => { |
|
|
|
message.warning('已有关联数据,无法删除') |
|
|
|
}}>删除</a> |
|
|
|
: <Popconfirm |
|
|
|
title="是否确认删除该服务?" |
|
|
|
onConfirm={() => { |
|
|
|
dispatch(dataService.delServiceManagement(record.id)).then(res => { |
|
|
|
if (res.success) { |
|
|
|
setQuery({ limit: 10, page: 0 }); |
|
|
|
resourceData({ limit: 10, page: 0, keyword }) |
|
|
|
} |
|
|
|
}) |
|
|
|
}} |
|
|
|
> |
|
|
|
<a >删除</a> |
|
|
|
</Popconfirm>} |
|
|
|
|
|
|
|
{/* // } */} |
|
|
|
{!isCurrentOrg ? '' : record?.enabled ? |
|
|
|
<Popconfirm |
|
|
|
title="禁用后该服务将不可用" |
|
|
|
onConfirm={() => { |
|
|
|
dispatch(dataService.postServiceManagement({ |
|
|
|
id: record.id, name: record?.name, enabled: false |
|
|
|
}, true)).then(res => { |
|
|
|
if (res.success) { |
|
|
|
resourceData({ keyword }) |
|
|
|
} |
|
|
|
}) |
|
|
|
}} |
|
|
|
> |
|
|
|
<a>禁用</a> |
|
|
|
</Popconfirm> |
|
|
|
: <a onClick={() => { |
|
|
|
dispatch(dataService.postServiceManagement({ |
|
|
|
id: record.id, name: record?.name, enabled: false |
|
|
|
id: record.id, name: record?.name, enabled: true |
|
|
|
}, true)).then(res => { |
|
|
|
if (res.success) { |
|
|
|
resourceData({ keyword }) |
|
|
|
} |
|
|
|
}) |
|
|
|
}} |
|
|
|
> |
|
|
|
<a>禁用</a> |
|
|
|
</Popconfirm> |
|
|
|
: <a onClick={() => { |
|
|
|
dispatch(dataService.postServiceManagement({ |
|
|
|
id: record.id, name: record?.name, enabled: true |
|
|
|
}, true)).then(res => { |
|
|
|
if (res.success) { |
|
|
|
resourceData({ keyword }) |
|
|
|
} |
|
|
|
}) |
|
|
|
}}>启用</a> |
|
|
|
} |
|
|
|
}}>启用</a> |
|
|
|
} |
|
|
|
|
|
|
|
</div > |
|
|
|
</div > |
|
|
|
} |
|
|
|
}, |
|
|
|
]; |
|
|
|
|
|
|
@ -174,7 +177,7 @@ function ServiceManagement ({ loading, clientHeight, actions, dispatch, }) { |
|
|
|
|
|
|
|
</> |
|
|
|
} |
|
|
|
function mapStateToProps (state) { |
|
|
|
function mapStateToProps(state) { |
|
|
|
const { global, auth, resourceCatalog } = state; |
|
|
|
return { |
|
|
|
user: auth.user, |
|
|
|