diff --git a/src/routes/System/User/DataPermModal.js b/src/routes/System/User/DataPermModal.js
index f960dfa54..75c582d4a 100644
--- a/src/routes/System/User/DataPermModal.js
+++ b/src/routes/System/User/DataPermModal.js
@@ -15,30 +15,45 @@
* limitations under the License.
*/
-import React, { Component } from 'react';
-import { Modal, Tree, Icon, Button, Checkbox, Table, Row, Col } from 'antd';
+import React, { Component } from "react";
+import {
+ Modal,
+ Tree,
+ Icon,
+ Button,
+ Checkbox,
+ Table,
+ Row,
+ Col,
+ Input,
+ Empty
+} from "antd";
import { connect } from "dva";
-import { getIntlContent } from '../../../utils/IntlUtils';
+import { getIntlContent } from "../../../utils/IntlUtils";
+import { titleCase } from "../../../utils/utils";
const { TreeNode } = Tree;
+const { Search } = Input;
@connect(({ dataPermission, resource, global, loading }) => ({
dataPermission,
resource,
global,
- selectorPermisionLoading: loading.effects["dataPermission/fetchDataPermisionSelectors"],
- rulePermisionLoading: loading.effects["dataPermission/fetchDataPermisionRules"]
+ selectorPermisionLoading:
+ loading.effects["dataPermission/fetchDataPermisionSelectors"],
+ rulePermisionLoading:
+ loading.effects["dataPermission/fetchDataPermisionRules"]
}))
export default class DataPermModal extends Component {
-
constructor(props) {
super(props);
this.state = {
- currentPlugin:null,
+ currentPlugin: null,
currentPermissionSelectorPage: 1,
selectorData: null,
pageSize: 12,
- ruleListMap:{}
+ ruleListMap: {},
+ searchValue: ""
};
}
@@ -57,7 +72,7 @@ export default class DataPermModal extends Component {
callback: () => {}
}
});
- }
+ };
getPermissionSelectorList = page => {
const { dispatch, userId } = this.props;
@@ -70,13 +85,13 @@ export default class DataPermModal extends Component {
userId,
pluginId: currentPlugin.pluginId
},
- callback: (res)=>{
+ callback: res => {
this.setState({
selectorData: res
- })
+ });
}
});
- }
+ };
getPermissionRuleList = (selectorId, page) => {
const { dispatch, userId } = this.props;
@@ -90,13 +105,16 @@ export default class DataPermModal extends Component {
pluginId: currentPlugin.pluginId,
selectorId
},
- callback: (res) =>{
- if(res.dataList && res.dataList.length > 0) {
- res.dataList.forEach(e=>{
+ callback: res => {
+ if (res.dataList && res.dataList.length > 0) {
+ res.dataList.forEach(e => {
e.selectorId = selectorId;
- })
+ });
}
- if(ruleListMap[selectorId] && ruleListMap[selectorId].currentRulePage) {
+ if (
+ ruleListMap[selectorId] &&
+ ruleListMap[selectorId].currentRulePage
+ ) {
res.currentRulePage = ruleListMap[selectorId].currentRulePage;
} else {
res.currentRulePage = 1;
@@ -104,26 +122,31 @@ export default class DataPermModal extends Component {
ruleListMap[selectorId] = res;
this.setState({
ruleListMap
- })
+ });
}
});
- }
+ };
onSelectPlugin = (selectedKeys, e) => {
const currentPlugin = e.node.props.dataRef;
- this.setState({
- currentPlugin,
- currentPermissionSelectorPage: 1,
- ruleListMap: {}
- }, () => {
- this.getPermissionSelectorList(1);
- })
- }
+ this.setState(
+ {
+ currentPlugin,
+ currentPermissionSelectorPage: 1,
+ ruleListMap: {}
+ },
+ () => {
+ this.getPermissionSelectorList(1);
+ }
+ );
+ };
- handleCheckSelector = (record) => {
+ handleCheckSelector = record => {
const { dispatch, userId } = this.props;
const { currentPermissionSelectorPage } = this.state;
- let type = record.isChecked ? "dataPermission/deletePermisionSelector" : "dataPermission/addPermisionSelector";
+ let type = record.isChecked
+ ? "dataPermission/deletePermisionSelector"
+ : "dataPermission/addPermisionSelector";
dispatch({
type,
payload: {
@@ -131,16 +154,18 @@ export default class DataPermModal extends Component {
userId
},
callback: () => {
- this.getPermissionSelectorList(currentPermissionSelectorPage)
- this.getPermissionRuleList(record.dataId,1)
+ this.getPermissionSelectorList(currentPermissionSelectorPage);
+ this.getPermissionRuleList(record.dataId, 1);
}
- })
- }
+ });
+ };
- handleCheckRule = (record) => {
+ handleCheckRule = record => {
const { dispatch, userId } = this.props;
const { currentPermissionSelectorPage, ruleListMap } = this.state;
- let type = record.isChecked ? "dataPermission/deletePermisionRule" : "dataPermission/addPermisionRule";
+ let type = record.isChecked
+ ? "dataPermission/deletePermisionRule"
+ : "dataPermission/addPermisionRule";
dispatch({
type,
payload: {
@@ -148,16 +173,16 @@ export default class DataPermModal extends Component {
userId
},
callback: () => {
- this.getPermissionSelectorList(currentPermissionSelectorPage)
+ this.getPermissionSelectorList(currentPermissionSelectorPage);
let page = ruleListMap[record.selectorId].currentRulePage || 1;
- this.getPermissionRuleList(record.selectorId,page)
+ this.getPermissionRuleList(record.selectorId, page);
}
- })
- }
+ });
+ };
handleExpandRuleTable = (expanded, record) => {
- this.getPermissionRuleList(record.dataId,1)
- }
+ this.getPermissionRuleList(record.dataId, 1);
+ };
selectorPageOnchange = page => {
this.setState({ currentPermissionSelectorPage: page });
@@ -167,89 +192,169 @@ export default class DataPermModal extends Component {
rulePageOnchange = (page, selectorId) => {
let { ruleListMap } = this.state;
ruleListMap[selectorId].currentRulePage = page;
- this.setState({
- ruleListMap
- },()=>{
- this.getPermissionRuleList(selectorId,page);
- })
-
- }
-
- renderPluginTree = ()=>{
- let { global: { plugins }, resource: { menuTree } } = this.props;
- let pluginMenuList = menuTree.filter(e=>e.url === "/plug");
+ this.setState(
+ {
+ ruleListMap
+ },
+ () => {
+ this.getPermissionRuleList(selectorId, page);
+ }
+ );
+ };
- if(pluginMenuList && pluginMenuList.length > 0){
- pluginMenuList[0].children.forEach(p => {
- if(plugins.some(e => e.name === p.name)) {
- p.pluginId = plugins.filter(e => e.name === p.name)[0].id;
+ filterPlugin = () => {
+ let {
+ global: { plugins },
+ resource: { menuTree }
+ } = this.props;
+ const { searchValue } = this.state;
+ let pluginMenuList = menuTree.filter(e => e.url === "/plug");
+ if (pluginMenuList && pluginMenuList.length > 0) {
+ pluginMenuList = pluginMenuList[0].children;
+ const treeData = [];
+ pluginMenuList.forEach(plugin => {
+ if (
+ typeof searchValue === "string" &&
+ searchValue.length &&
+ !plugin.name
+ .toLocaleLowerCase()
+ .includes(searchValue.toLocaleLowerCase())
+ ) {
+ return;
}
- })
- return (
-