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"]],
include: [{
model: models.ResourceConsumption,
}],
},
{
model: models.ResourceCatalog,
attributes: ['id', 'name'],
include: [{
model: models.Organization,
attributes: ['id', 'name'],
}]
}
],
distinct: true
}
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 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;
@ -53,19 +53,21 @@ function ServiceManagement ({ loading, clientHeight, actions, dispatch, }) {
dataIndex: 'handle',
width: '250px',
// 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={() => {
setEditData(record)
setEditModal(true)
setViewDetails(true)
}}>查看详情</a>
<a onClick={() => {
{isCurrentOrg && <a onClick={() => {
setEditData(record)
setEditModal(true)
}}>编辑</a>
}
{/* {record?.enabled ? */}
{record?.resourceConsumptions?.length > 0 ? <a onClick={() => {
{!isCurrentOrg ? '' : record?.resourceConsumptions?.length > 0 ? <a onClick={() => {
message.warning('已有关联数据,无法删除')
}}>删除</a>
: <Popconfirm
@ -83,7 +85,7 @@ function ServiceManagement ({ loading, clientHeight, actions, dispatch, }) {
</Popconfirm>}
{/* // } */}
{record?.enabled ?
{!isCurrentOrg ? '' : record?.enabled ?
<Popconfirm
title="禁用后该服务将不可用"
onConfirm={() => {
@ -110,6 +112,7 @@ function ServiceManagement ({ loading, clientHeight, actions, dispatch, }) {
}
</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 moment from 'moment';
import { RouteRequest } from '@peace/utils';
import { RouteTable } from '$utils'
import { Func } from '$utils'
import { Tabs, Form, Input, Space, Button, Table, message } from 'antd';
const { Search } = Input;
@ -14,7 +14,7 @@ import ResourceModal from '../components/resourceModal';
import { If } from 'react-if';
function ServiceView ({ loading, clientHeight, actions, dispatch, }) {
function ServiceView({ loading, clientHeight, actions, dispatch, user }) {
const { dataService, metadataManagement } = actions
const [query, setQuery] = useState({ page: 0, limit: 10 });
@ -54,15 +54,19 @@ function ServiceView ({ loading, clientHeight, actions, dispatch, }) {
dataIndex: 'handle',
width: '250px',
// 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={() => {
setEditData(record)
setEditModal(true)
setViewDetails(true)
}}>查看详情</a>
<a onClick={() => {
{!isCurrentOrg && <a onClick={() => {
let result
record?.resourceConsumptions?.map(v => {
record?.resourceConsumptions
?.filter(v => v.applyBy == user?.id)
?.map(v => {
if (result != '已有申请成功的资源' && result != '资源审批中') {
if (v.token) {
result = '已有申请成功的资源'
@ -82,10 +86,11 @@ function ServiceView ({ loading, clientHeight, actions, dispatch, }) {
setResourceModal(true)
}
}}>申请资源</a>
}
</div >
}
},
];

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

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

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

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

Loading…
Cancel
Save