提交 48681e5e authored 作者: 钟是志's avatar 钟是志

一站式app应用权限.可以在学工里面进行配置

上级 fa77557e
......@@ -99,6 +99,23 @@ export const getHistoryFormDetail = ({ id, code }) => {
return uaaRequest('/UnifiedAppFormApi/getFormDetail', { id, code });
};
/**
* 获取一站式应用列表
* 用于授权
*/
export const getAppList = (params = {} ) => {
return uaaRequest('/UnifiedAppApi/getListByTree', params);
};
/**
*
* 用于一站式 应用分类列表 tree
*/
export const getAppTypeList = () => {
return uaaRequest('/UnifiedAppGroupApi/getList', {
});
};
export function getOnestopKey(key = '', formKey = 'key_list', formValue = 'value_list') {
return fetchTableData({
......
/**
* 钟是志
* 2019年3月29日
* 一个年份加上校区-学院-专业的树
* */
import { Tree } from 'antd';
import React, { Component, Fragment } from 'react';
import Shell from '@/baseComponent/Shell';
import { getAppTypeList } from '@/webPublic/Services';
import { getPermInfo } from '@/highOrderComponent/Service';
import { connect } from 'dva';
const { TreeNode } = Tree;
@connect(({ global }) => ({
sysCode: global.system.sysCode,
}))
export default class AppTypeTree extends Component {
constructor() {
super();
this.state = {
treeListData: [],
initYear: 0,
};
}
handleChange = (newSearch) => {
this.props.changeSearch(newSearch);
};
getList = () => {
getPermInfo({
sysCode: this.props.sysCode,
},'/PermApi/getRoleList').then((treeListData) => {
if (!treeListData || !treeListData.length) {
this.setState({
treeListData: [],
loading: false,
});
this.handleChange({
selectKey: '',
});
} else {
this.handleChange({
selectKey: treeListData[0].id + '',
});
this.handleChange({
selectKey: treeListData[0].id + '',
});
this.setState({
treeListData,
loading: false,
});
}
});
};
componentDidMount() {
this.getList();
setTimeout(() => {
if (document.getElementById('list-table-dom')) {
let tableDom = document.getElementById('list-table-dom');
this.setState({
heightSet:
document.body.clientHeight - 150 > tableDom.offsetHeight + 164
? document.body.clientHeight - 150
: tableDom.offsetHeight + 164,
});
}
}, 1000);
}
onSelect = (selectedKeys, info) => {
this.handleChange({
year: this.props.year,
selectKey: selectedKeys[0],
});
};
treeNodeList = (data) => {
let dom = data.map((item) => {
return (
<TreeNode title={item.title}
key={item.id}>
</TreeNode>
);
});
return dom;
};
render() {
const { treeListData, loading, heightSet } = this.state;
const { selectKey } = this.props;
return (
<Fragment>
<Shell
styleShell={{
borderRight: '1px solid rgba(210,210,210,1)',
minHeight: heightSet || document.body.clientHeight - 150,
backgroundColor: '#fff',
overflowX: 'auto',
marginTop: 0,
}}>
<Tree
onSelect={this.onSelect}
selectedKeys={[selectKey]}
style={{ minHeight: '400px,' }}
disabled={loading}>
{this.treeNodeList(treeListData)}
</Tree>
</Shell>
</Fragment>
);
}
}
/**
* 钟是志
* 2020年5月13日 17:38:51
* 一站式应用 学工角色授权
* */
import pageSetting from './pageSetting';
import pageSearch from './pageSearch';
import pageButton from './pageButton';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import { Row, Col } from 'antd';
import React from 'react';
import List from '@/highOrderComponent/List';
import AppTypeTree from './AppTypeTree';
import { getAppTypeList } from '@/webPublic/Services';
import { getInfo } from '@/highOrderComponent/Service';
const Index = (WrappedComponent) =>
class extends WrappedComponent {
constructor(props) {
super(props);
this.state = {
search: {
selectKey: '',
},
typeList: [],
authorizedApp: [],
};
}
getAuthorizedApp = () => {
const { selectKey } = this.state.search;
if (selectKey) {
getInfo(
{
roleId: selectKey,
cacheKey: Math.random(),
},
'/CommonApi/queryRoleApply',
).then((x) => {
if (x) {
this.setState({
authorizedApp: x,
});
}
});
this.instanceComponent.getPage();
}
};
changeSearch = (search) => {
this.setState(
{
search,
},
() => {
this.getAuthorizedApp();
},
);
};
componentDidMount() {
getAppTypeList().then((treeListData) => {
if (!treeListData) {
return false;
}
this.setState({
typeList: treeListData.map((x) => {
return {
key: x.id,
name: x.name + `(${x.appNum})`,
};
}),
});
});
return true;
}
render() {
const { search, typeList, authorizedApp } = this.state;
if (!typeList.length) {
return null;
}
const pageS = pageSearch({ typeList, authorizedApp });
const pageB = pageButton({
roleId: search.selectKey,
authorizedApp,
getAuthorizedApp: this.getAuthorizedApp,
});
return (
<PageHeaderWrapper title="">
<Row>
<Col xl={5} xxl={4}>
<AppTypeTree
changeSearch={this.changeSearch}
selectKey={search.selectKey}
year={search.year}
/>
</Col>
<Col xl={19} xxl={20}>
<WrappedComponent
listConfig={pageSetting.listConfig}
pageButton={pageB}
ref={(instanceComponent) => (this.instanceComponent = instanceComponent)}
pageSearch={pageS}
/>
</Col>
</Row>
</PageHeaderWrapper>
);
}
};
export default Index(List); // 高阶组件
import React from 'react';
import { message } from 'antd';
import { getInfo } from '@/highOrderComponent/Service';
const submitData = (selectRows, roleId) => {
if (!selectRows.length) {
message.warning('请先选择一个应用');
return false;
} else {
let content = selectRows.map((x) => {
return {
appId: x.id,
roleId,
};
});
content = JSON.stringify(content);
const data = {
roleId,
op: 'add',
content,
};
return getInfo(data, '/CommonApi/configRoleApply');
}
};
const deleteData = (ids, roleId) => {
const data = {
ids,
roleId,
op: 'delete',
};
return getInfo(data, '/CommonApi/configRoleApply');
};
const handleButton = (props) => {
const buttonConfig = [
{
name: '批量授权',
type: 'Normal',
component: 'Normal',
handleClick: (selectRows, formValues, getPage, search) => {
submitData(selectRows, props.roleId).then((x) => {
props.getAuthorizedApp();
});
},
},
{
name: '批量取消授权',
type: 'Normal222',
component: 'Normal',
handleClick: (selectRows, formValues, getPage, search) => {
if (!selectRows.length) {
message.warning('请先选择一个应用');
return false;
}
const deleteIds = [];
for (let item of selectRows) {
for(let x of props.authorizedApp){
if(x.appId === item.id){
deleteIds.push(x.id);
}
}
}
deleteData(deleteIds, props.roleId).then((x) => {
props.getAuthorizedApp();
});
},
},
];
return buttonConfig;
};
export default handleButton;
import moment from 'moment';
import { Link } from 'react-router-dom';
import React, { Fragment } from 'react';
import { getAppList } from '@/webPublic/Services';
import { redText } from '@/pages/zydxg/CheckManage/PiciSetting/publicFunc';
const width = 110;
const handlePageSearch = (props) => {
const pageSearch = {
search: {
url: '/asdasd/asdgggki',
field: {
groupId: { //
required: true,
defaultValue: props.typeList[0].key,
},
},
getInfo: (data, url) => {
return getAppList(data);
},
giveFieldsToFormValues: true,
afterFormValuesChange: (key, oldValue, getPage) => {
getPage();
},
responseCallBack: (response) => {
return response;
},
condition: [
{
key: 'groupId',
name: '类别',
type: 'radioGroup',
options: props.typeList,
},
],
nameSpan: { big: 2, small: 4 },
fileSpan: { big: 2, small: 2 },
},
tableRowKey: 'id',
columns: [
{
dataIndex: 'groupName',
title: '类别',
width,
},
{
dataIndex: 'name',
title: '应用名',
width: width + 150,
},
{
dataIndex: 'isAuthorized',
title: '是否已授权',
render: (text, record) => {
// return '未授权';
const includesIds = props.authorizedApp.map((x) => {
return x.appId;
});
if (record && record.id && includesIds.includes(record.id)) {
return redText('已授权');
} else {
return '未授权';
}
},
},
],
};
return pageSearch;
};
export default handlePageSearch;
const pageSetting = {
type: 'list', // 页面类型 list列表 可能包含有其他类型的 比如 detail 详情 add 新增 update 更新 等等 ....
listConfig:{
selectRows: true, // 是否可以行选择,
paging: false, // 是否可以分页,
searchArea: true, // 是否拥有 搜索区dom,
buttonArea: true, // 是否拥有 按钮区,
},
};
export default pageSetting;
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论