Browse Source

(*)数据服务权限完善

master
peng.peng 1 year ago
parent
commit
1aefb64092
  1. 11
      api/app/lib/controllers/dataService/index.js
  2. 15
      web/client/src/sections/dataService/containers/serviceManagement.js
  3. 17
      web/client/src/sections/dataService/containers/serviceView.js
  4. 2
      web/client/src/sections/dataService/nav-item.js
  5. 25
      web/client/src/sections/resourceConsumption/containers/approve.js

11
api/app/lib/controllers/dataService/index.js

@ -15,7 +15,16 @@ function getServiceManagement(opts) {
order: [["id", "desc"]], order: [["id", "desc"]],
include: [{ include: [{
model: models.ResourceConsumption, model: models.ResourceConsumption,
}], },
{
model: models.ResourceCatalog,
attributes: ['id', 'name'],
include: [{
model: models.Organization,
attributes: ['id', 'name'],
}]
}
],
distinct: true distinct: true
} }
if (keyword) { if (keyword) {

15
web/client/src/sections/dataService/containers/serviceManagement.js

@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import moment from 'moment'; import moment from 'moment';
import { RouteRequest } from '@peace/utils'; import { RouteRequest } from '@peace/utils';
import { RouteTable } from '$utils' import { Func } from '$utils'
import { Tabs, Form, Input, Space, Button, Table, Popconfirm, message } from 'antd'; import { Tabs, Form, Input, Space, Button, Table, Popconfirm, message } from 'antd';
const { Search } = Input; const { Search } = Input;
@ -53,19 +53,21 @@ function ServiceManagement ({ loading, clientHeight, actions, dispatch, }) {
dataIndex: 'handle', dataIndex: 'handle',
width: '250px', width: '250px',
// ellipsis: true, // ellipsis: true,
render: (text, record) => <div style={{ width: 200, display: 'flex', justifyContent: 'space-evenly' }}> render: (text, record) => {
const isCurrentOrg = Func?.isOrgOrSuperAdmin(record?.resourceCatalog?.organization?.id)
return <div style={{ width: 200, display: 'flex', justifyContent: 'space-evenly' }}>
<a onClick={() => { <a onClick={() => {
setEditData(record) setEditData(record)
setEditModal(true) setEditModal(true)
setViewDetails(true) setViewDetails(true)
}}>查看详情</a> }}>查看详情</a>
<a onClick={() => { {isCurrentOrg && <a onClick={() => {
setEditData(record) setEditData(record)
setEditModal(true) setEditModal(true)
}}>编辑</a> }}>编辑</a>
}
{/* {record?.enabled ? */} {/* {record?.enabled ? */}
{record?.resourceConsumptions?.length > 0 ? <a onClick={() => { {!isCurrentOrg ? '' : record?.resourceConsumptions?.length > 0 ? <a onClick={() => {
message.warning('已有关联数据,无法删除') message.warning('已有关联数据,无法删除')
}}>删除</a> }}>删除</a>
: <Popconfirm : <Popconfirm
@ -83,7 +85,7 @@ function ServiceManagement ({ loading, clientHeight, actions, dispatch, }) {
</Popconfirm>} </Popconfirm>}
{/* // } */} {/* // } */}
{record?.enabled ? {!isCurrentOrg ? '' : record?.enabled ?
<Popconfirm <Popconfirm
title="禁用后该服务将不可用" title="禁用后该服务将不可用"
onConfirm={() => { onConfirm={() => {
@ -110,6 +112,7 @@ function ServiceManagement ({ loading, clientHeight, actions, dispatch, }) {
} }
</div > </div >
}
}, },
]; ];

17
web/client/src/sections/dataService/containers/serviceView.js

@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import moment from 'moment'; import moment from 'moment';
import { RouteRequest } from '@peace/utils'; import { RouteRequest } from '@peace/utils';
import { RouteTable } from '$utils' import { Func } from '$utils'
import { Tabs, Form, Input, Space, Button, Table, message } from 'antd'; import { Tabs, Form, Input, Space, Button, Table, message } from 'antd';
const { Search } = Input; const { Search } = Input;
@ -14,7 +14,7 @@ import ResourceModal from '../components/resourceModal';
import { If } from 'react-if'; import { If } from 'react-if';
function ServiceView ({ loading, clientHeight, actions, dispatch, }) { function ServiceView({ loading, clientHeight, actions, dispatch, user }) {
const { dataService, metadataManagement } = actions const { dataService, metadataManagement } = actions
const [query, setQuery] = useState({ page: 0, limit: 10 }); const [query, setQuery] = useState({ page: 0, limit: 10 });
@ -54,15 +54,19 @@ function ServiceView ({ loading, clientHeight, actions, dispatch, }) {
dataIndex: 'handle', dataIndex: 'handle',
width: '250px', width: '250px',
// ellipsis: true, // ellipsis: true,
render: (text, record) => <div style={{ width: 200, display: 'flex', justifyContent: 'space-evenly' }}> render: (text, record) => {
const isCurrentOrg = Func?.isOrgOrSuperAdmin(record?.resourceCatalog?.organization?.id)
return <div style={{ width: 200, display: 'flex', justifyContent: 'space-evenly' }}>
<a onClick={() => { <a onClick={() => {
setEditData(record) setEditData(record)
setEditModal(true) setEditModal(true)
setViewDetails(true) setViewDetails(true)
}}>查看详情</a> }}>查看详情</a>
<a onClick={() => { {!isCurrentOrg && <a onClick={() => {
let result let result
record?.resourceConsumptions?.map(v => { record?.resourceConsumptions
?.filter(v => v.applyBy == user?.id)
?.map(v => {
if (result != '已有申请成功的资源' && result != '资源审批中') { if (result != '已有申请成功的资源' && result != '资源审批中') {
if (v.token) { if (v.token) {
result = '已有申请成功的资源' result = '已有申请成功的资源'
@ -82,10 +86,11 @@ function ServiceView ({ loading, clientHeight, actions, dispatch, }) {
setResourceModal(true) setResourceModal(true)
} }
}}>申请资源</a> }}>申请资源</a>
}
</div > </div >
}
}, },
]; ];

2
web/client/src/sections/dataService/nav-item.js

@ -11,7 +11,7 @@ export function getNavItem (user) {
{user?.role == '系统管理员' && <Menu.Item key="serviceManagement"> {user?.role == '系统管理员' && <Menu.Item key="serviceManagement">
<Link to="/dataService/serviceManagement">服务管理</Link> <Link to="/dataService/serviceManagement">服务管理</Link>
</Menu.Item>} </Menu.Item>}
{user?.role != '系统管理员' && <Menu.Item key="serviceView"> {<Menu.Item key="serviceView">
<Link to="/dataService/serviceView">服务查看</Link> <Link to="/dataService/serviceView">服务查看</Link>
</Menu.Item>} </Menu.Item>}
</ SubMenu > </ SubMenu >

25
web/client/src/sections/resourceConsumption/containers/approve.js

@ -21,14 +21,24 @@ function Approve({ loading, clientHeight, actions, dispatch, user }) {
resourceData() resourceData()
}, []) }, [])
useEffect(() => {
resourceData()
}, [tabsKey, query])
let resourceData = (params) => { let resourceData = (params) => {
let data = params || query let data = params || query
dispatch(resourceConsumption.getApproveList({ const obj = {
approveState: tabsKey == 'stay' ? "审批中" : '已审批', ...formData, ...data, approveState: tabsKey == 'stay' ? "审批中" : '已审批',
orgId: user?.orgId, ...formData, ...data,
approveId: (params?.approveState == '已审批' && user?.username != 'SuperAdmin') ? user?.id : null approveId: (tabsKey == 'stay' && user?.username != 'SuperAdmin') ? user?.id : null,
})).then(res => { }
if (tabsKey == 'stay') {
obj.orgId = user?.orgId;
} else {
obj.applyById = user?.id;
}
dispatch(resourceConsumption.getApproveList(obj)).then(res => {
if (res.success) { if (res.success) {
setProTableList(res.payload.data) setProTableList(res.payload.data)
} }
@ -120,9 +130,10 @@ function Approve({ loading, clientHeight, actions, dispatch, user }) {
}, [tabsKey]) }, [tabsKey])
return <> return <>
<Tabs defaultActiveKey="stay" items={[{ key: 'stay', label: '待审批' }, { key: 'end', label: '已审批' }]} onTabClick={key => { <Tabs defaultActiveKey="stay" items={[{ key: 'stay', label: '待审批' }, { key: 'end', label: '已审批' }]}
onTabClick={key => {
setTabsKey(key) setTabsKey(key)
resourceData({ limit: 10, page: 0, approveState: key == 'stay' ? "审批中" : '已审批' }) // resourceData({ limit: 10, page: 0, approveState: key == 'stay' ? "审批中" : '已审批' })
setQuery({ limit: 10, page: 0 }); setQuery({ limit: 10, page: 0 });
}} /> }} />
<Form <Form

Loading…
Cancel
Save