Browse Source

(*)各模块增加机构相关配置

master
peng.peng 1 year ago
parent
commit
3badb3cee0
  1. 1
      api/app/lib/controllers/member/index.js
  2. 32
      api/app/lib/controllers/resourceConsumption/index.js
  3. 8
      api/app/lib/index.js
  4. 9
      api/app/lib/models/restful_api.js
  5. 16
      scripts/0.0.14/01_add_organization.sql
  6. 8
      scripts/0.0.14/02_alter_organization.sql
  7. 7
      web/client/src/sections/memberManagement/containers/member.js
  8. 3
      web/client/src/sections/metadataManagement/components/releaseModal.js
  9. 5
      web/client/src/sections/metadataManagement/components/resourceCatalogModal.js
  10. 23
      web/client/src/sections/resourceConsumption/containers/approve.js
  11. 13
      web/client/src/sections/resourceConsumption/containers/myApplication.js
  12. 28
      web/client/src/utils/func.js

1
api/app/lib/controllers/member/index.js

@ -18,6 +18,7 @@ function getUserList(opts) {
where: searchWhere,
order: [["id", "desc"]],
attributes: { exclude: ['password'] },
include: [{ model: models.Organization }]
}
if (name) {

32
api/app/lib/controllers/resourceConsumption/index.js

@ -5,7 +5,7 @@ function getApproveList(opts) {
return async function (ctx, next) {
const models = ctx.fs.dc.models;
const { page, limit, applyAt, approveState, resourceName, applyBy, applyById, state ,} = ctx.query;
const { page, limit, applyAt, approveState, resourceName, applyBy, applyById, state, } = ctx.query;
let errMsg = { message: '获取消费审批列表失败' }
try {
@ -17,12 +17,38 @@ function getApproveList(opts) {
include: [{
model: models.User,
as: 'applyUser',
attributes: ['id', 'name']
attributes: ['id', 'name'],
include: [{ model: models.Organization }]
}, {
model: models.User,
as: 'approveUser',
attributes: ['id', 'name']
},]
},
{
model: models.MetadataDatabase,
attributes: ['id', 'name'],
include: [{
model: models.ResourceCatalog,
attributes: ['id', 'name'],
include: [{
model: models.Organization,
attributes: ['id', 'name'],
}]
}]
},
{
model: models.RestfulApi,
attributes: ['id', 'name'],
include: [{
model: models.ResourceCatalog,
attributes: ['id', 'name'],
include: [{
model: models.Organization,
attributes: ['id', 'name'],
}]
}]
}
]
}
if (resourceName) {
option.where.resourceName = { $iLike: `%${resourceName}%` }

8
api/app/lib/index.js

@ -104,4 +104,12 @@ module.exports.models = function (dc) {
RestfulApiRecord.belongsTo(RestfulApi, { foreignKey: 'restServiceId', targetKey: 'id' });
User.belongsTo(Organization, { foreignKey: 'orgId', targetKey: 'id' });
ResourceConsumption.belongsTo(MetadataDatabase, { foreignKey: 'resourceId', targetKey: 'id' });
ResourceConsumption.belongsTo(RestfulApi, { foreignKey: 'restServiceId', targetKey: 'id' });
MetadataDatabase.belongsTo(ResourceCatalog, { foreignKey: 'catalog', targetKey: 'id' });
RestfulApi.belongsTo(ResourceCatalog, { foreignKey: 'catalog', targetKey: 'id' });
ResourceCatalog.belongsTo(Organization, { foreignKey: 'orgId', targetKey: 'id' });
};

9
api/app/lib/models/restful_api.js

@ -78,6 +78,15 @@ module.exports = dc => {
primaryKey: false,
field: "fields",
autoIncrement: false
},
catalog: {
type: DataTypes.INTEGER,
allowNull: true,
defaultValue: null,
comment: null,
primaryKey: false,
field: "catalog",
autoIncrement: false
}
}, {
tableName: "t_restful_api",

16
scripts/0.0.14/01_add_organization.sql

@ -0,0 +1,16 @@
create table organization
(
id serial
constraint organization_pk
primary key,
name varchar,
code varchar,
ability varchar
);
comment on table organization is '用户机构';
comment on column organization.ability is '职能';
create unique index organization_id_uindex
on organization (id);

8
scripts/0.0.14/02_alter_organization.sql

@ -0,0 +1,8 @@
alter table t_user
add "orgId" int;
alter table t_resource_catalog
add "orgId" int;
alter table t_restful_api
add catalog int;

7
web/client/src/sections/memberManagement/containers/member.js

@ -50,6 +50,13 @@ function Member(props) {
title: '角色',
dataIndex: 'role',
},
{
title: '机构',
dataIndex: 'org',
render: (text, record) => {
return record?.organization?.name
}
},
{
title: '状态',
dataIndex: 'enabled',

3
web/client/src/sections/metadataManagement/components/releaseModal.js

@ -249,6 +249,7 @@ const ReleaseModal = ({ actions, dispatch, onConfirm, onCancel, editData = {} })
});
} else {
dispatch(metadataManagement.publishingServices({
catalog: database?.catalog,
table: database?.code,
fields: editData?.code,
conditions: sql,
@ -269,7 +270,7 @@ const ReleaseModal = ({ actions, dispatch, onConfirm, onCancel, editData = {} })
</Modal >
)
}
function mapStateToProps (state) {
function mapStateToProps(state) {
const { global, auth, } = state;
return {
user: auth.user,

5
web/client/src/sections/metadataManagement/components/resourceCatalogModal.js

@ -77,10 +77,9 @@ const ResourceCatalogModal = (props) => {
<Form.Item
label='机构'
name='orgId'
disabled={editData?.orgId}
rules={[{ required: true, message: '' }]}
rules={[{ required: true, message: '请选择机构' }]}
>
<Select style={{ width: '90%' }} placeholder={`输入代码`} >
<Select disabled={editData?.record?.orgId} style={{ width: '90%' }} placeholder={`选择`} >
{
organization?.map(s => (<Select.Option value={s.id}>{s.name}</Select.Option>))
}

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

@ -2,13 +2,11 @@ import React, { useEffect, useState } from 'react'
import { connect } from 'react-redux';
import moment from 'moment';
import ApproveModal from '../components/approveModal';
import { Tabs, Form, Input, DatePicker, Button, Table } from 'antd';
import { v1 } from 'uuid';
import { Func } from '$utils'
function Approve ({ loading, clientHeight, actions, dispatch, }) {
function Approve({ loading, clientHeight, actions, dispatch, }) {
const { resourceConsumption } = actions
const [tabsKey, setTabsKey] = useState("stay")
@ -41,6 +39,10 @@ function Approve ({ loading, clientHeight, actions, dispatch, }) {
title: '申请人',
dataIndex: 'applyBy',
render: (text, record) => record?.applyUser?.name
}, {
title: '申请人机构',
dataIndex: 'approveOrg',
render: (text, record) => record?.applyUser?.organization?.name
}, {
title: '需求描述',
dataIndex: 'requirements',
@ -83,10 +85,13 @@ function Approve ({ loading, clientHeight, actions, dispatch, }) {
title: '操作',
dataIndex: 'handle',
// ellipsis: true,
render: (text, record) => <Button type="link" onClick={() => {
setEditData(record)
setApproveModal(true);
}}>审批</Button>
render: (text, record) => {
let enable = Func?.isOrgOrSuperAdmin(record?.applyUser?.organization?.id)
return enable ? <Button type="link" onClick={() => {
setEditData(record)
setApproveModal(true);
}}>审批</Button> : <Button disabled type="link"></Button>
}
},
];
@ -175,7 +180,7 @@ function Approve ({ loading, clientHeight, actions, dispatch, }) {
</>
}
function mapStateToProps (state) {
function mapStateToProps(state) {
const { global, auth, resourceCatalog } = state;
return {
user: auth.user,

13
web/client/src/sections/resourceConsumption/containers/myApplication.js

@ -8,7 +8,7 @@ import { Tabs, Form, Input, DatePicker, Button, Table, Select } from 'antd';
import { v1 } from 'uuid';
function MyApplication ({ loading, clientHeight, actions, dispatch, user }) {
function MyApplication({ loading, clientHeight, actions, dispatch, user }) {
const { resourceConsumption } = actions
@ -34,7 +34,14 @@ function MyApplication ({ loading, clientHeight, actions, dispatch, user }) {
const columns = [{
title: '资源名称',
dataIndex: 'resourceName',
}, {
},
{
title: '数据资源机构',
dataIndex: 'org',
render: (text, record) => record?.metadataDatabase?.resourceCatalog?.organization?.name ||
record?.restfulApi?.resourceCatalog?.organization?.name
},
{
title: '审批人',
dataIndex: 'approveBy',
render: (text, record) => record?.approveUser?.name
@ -136,7 +143,7 @@ function MyApplication ({ loading, clientHeight, actions, dispatch, user }) {
</>
}
function mapStateToProps (state) {
function mapStateToProps(state) {
const { global, auth, resourceCatalog } = state;
return {
user: auth.user,

28
web/client/src/utils/func.js

@ -1,13 +1,21 @@
'use strict';
export default class Func {
static isAuthorized(authcode) {
if (JSON.parse(sessionStorage.getItem('user'))) {
const { resources } = JSON.parse(sessionStorage.getItem('user'));
return resources.includes(authcode);
}else{
return false;
}
}
}
export default class Func {
static isAuthorized(authcode) {
if (JSON.parse(sessionStorage.getItem('user'))) {
const { resources } = JSON.parse(sessionStorage.getItem('user'));
return resources.includes(authcode);
} else {
return false;
}
}
static isOrgOrSuperAdmin(id) {
if (JSON.parse(sessionStorage.getItem('user'))) {
const { username, orgId } = JSON.parse(sessionStorage.getItem('user'));
return username == 'SuperAdmin' || orgId == id;
} else {
return false;
}
}
}

Loading…
Cancel
Save