diff --git a/pc4mobx/hrmSalary/apis/taxAgent.js b/pc4mobx/hrmSalary/apis/taxAgent.js
index c8317a45..1f297904 100644
--- a/pc4mobx/hrmSalary/apis/taxAgent.js
+++ b/pc4mobx/hrmSalary/apis/taxAgent.js
@@ -140,6 +140,10 @@ export const syncAuthData = (params) => {
export const syncAuthMember = (params) => {
return postFetch("/api/bs/hrmsalary/auth/member/sync", params);
};
+//保存权限
+export const saveAuthOpt = (params) => {
+ return postFetch("/api/bs/hrmsalary/auth/opt/save", params);
+};
//权限项
export const getAuthOptTree = (params) => {
return WeaTools.callApi("/api/bs/hrmsalary/auth/opt/tree", "GET", params);
diff --git a/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/authTree.js b/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/authTree.js
index ccd825a4..d9d972ac 100644
--- a/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/authTree.js
+++ b/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/authTree.js
@@ -10,28 +10,79 @@
import React, { Component } from "react";
import * as API from "../../../../apis/taxAgent";
import { Row } from "antd";
-import { WeaLocaleProvider } from "ecCom";
+import { WeaLocaleProvider, WeaTree } from "ecCom";
const getLabel = WeaLocaleProvider.getLabel;
class AuthTree extends Component {
constructor(props) {
super(props);
- this.state = {};
+ this.state = {
+ checkedKeys: [], expandedKeys: [], datas: {}
+ };
}
componentDidMount() {
const { roleId } = this.props;
API.getAuthOptTree({ roleId }).then(({ status, data }) => {
if (status) {
- console.log(data);
+ this.setState({
+ datas: {
+ canClick: true, id: data.key, nodeid: data.key, isParent: true, name: data.name,
+ subs: _.map(data.modules, item => ({
+ ...item, canClick: true, id: item.key, nodeid: item.key, pid: data.key, isParent: !_.isEmpty(item.pages),
+ subs: _.map(item.pages, o => ({
+ ...o, canClick: true, id: `${item.key}-${o.key}`, nodeid: `${item.key}-${o.key}`,
+ pid: item.key, isParent: !_.isEmpty(o.opts),
+ subs: _.map(o.opts, k => ({
+ canClick: true, id: `${o.key}-${k.key}`, name: k.name, nodeid: `${o.key}-${k.key}`,
+ pid: `${item.key}-${o.key}`, isParent: false, able: k.able
+ }))
+ }))
+ }))
+ }
+ }, () => this.setState({ expandedKeys: this.initExpandKeys(), checkedKeys: this.initCheckedKeys() }));
}
});
}
+ initExpandKeys = () => {
+ const { datas } = this.state;
+ const parentIds = [];
+ const findParent = (node) => {
+ if (node.subs && node.subs.length > 0) {
+ parentIds.push(node.id);
+ node.subs.forEach(child => findParent(child));
+ }
+ };
+ findParent(datas);
+ return parentIds;
+ };
+ initCheckedKeys = () => {
+ const { datas } = this.state;
+ const checkedIds = [];
+ const findCheckedId = (node) => {
+ if (node.subs && node.subs.length > 0) {
+ node.subs.forEach(child => {
+ if (!!child.able) checkedIds.push(child.id);
+ findCheckedId(child);
+ });
+ }
+ };
+ findCheckedId(datas);
+ return checkedIds;
+ };
+
render() {
+ const { checkedKeys, expandedKeys, datas } = this.state;
return (
- 权限
+
+ this.setState({ checkedKeys })} checkedKeys={checkedKeys}
+ expandedKeys={expandedKeys} onExpand={expandedKeys => this.setState({ expandedKeys })}
+ datas={datas}
+ />
+
);
}
}
diff --git a/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/index.js b/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/index.js
index de3b1223..0ec684c4 100644
--- a/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/index.js
+++ b/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/index.js
@@ -146,6 +146,28 @@ class Index extends Component {
}
});
};
+ saveAuthOpt = () => {
+ const { roleId } = this.props;
+ const { state: { checkedKeys } } = this.authTreeRef;
+ const payload = {
+ roleId, opts: _.reduce(checkedKeys, (pre, cur) => {
+ if (cur.indexOf("query") !== -1 || cur.indexOf("admin") !== -1) {
+ const [page, opt] = cur.split("-");
+ return [...pre, { page, opt }];
+ }
+ return pre;
+ }, [])
+ };
+ this.setState({ loading: { ...this.state.loading, set: true } });
+ API.saveAuthOpt(payload).then(({ status, errormsg }) => {
+ this.setState({ loading: { ...this.state.loading, set: false } });
+ if (status) {
+ message.success(getLabel(111, "操作成功!"));
+ } else {
+ message.error(errormsg);
+ }
+ });
+ };
syncAuthData = () => {
const { roleId } = this.props, { selectedKey } = this.state;
this.setState({ async: true });
@@ -199,7 +221,7 @@ class Index extends Component {
onChange={(__, ___, replaceDatas) => this.setState({ replaceDatas })}/>
);
} else {
- return ();
+ return ( this.authTreeRef = dom}/>);
}
};
@@ -233,16 +255,19 @@ class Index extends Component {
const rowSelection = {
selectedRowKeys, onChange: (selectedRowKeys) => this.setState({ selectedRowKeys })
};
+ const buttons = [
+ ,
+
+ ];
+ selectedKey === "auth.AuthTargetTypeEnum" && buttons.shift();
+ selectedKey !== "auth.AuthTargetTypeEnum" && buttons.pop();
return (
{getLabel(111, "同步")}
- ]}
- style={{
- width: 960, height: 606.6, minHeight: 200, minWidth: 380,
- maxHeight: "90%", maxWidth: "90%", overflow: "hidden", transform: "translate(0px, 0px)"
- }}
+ buttons={buttons} style={{
+ width: 960, height: 606.6, minHeight: 200, minWidth: 380,
+ maxHeight: "90%", maxWidth: "90%", overflow: "hidden", transform: "translate(0px, 0px)"
+ }}
>