feature/2.15.1.2407.01-权限
This commit is contained in:
parent
cc81d8c9bd
commit
b0d790f988
|
|
@ -140,4 +140,7 @@ export const syncAuthData = (params) => {
|
|||
export const syncAuthMember = (params) => {
|
||||
return postFetch("/api/bs/hrmsalary/auth/member/sync", params);
|
||||
};
|
||||
|
||||
//权限项
|
||||
export const getAuthOptTree = (params) => {
|
||||
return WeaTools.callApi("/api/bs/hrmsalary/auth/opt/tree", "GET", params);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ export const roleOperatorConditions = [
|
|||
items: [
|
||||
{
|
||||
conditionType: "INPUT",
|
||||
domkey: ["targetType"],
|
||||
fieldcol: 14,
|
||||
domkey: ["targetTypeName"],
|
||||
fieldcol: 18,
|
||||
label: "对象类型",
|
||||
lanId: 111,
|
||||
labelcol: 6,
|
||||
|
|
@ -43,7 +43,7 @@ export const roleOperatorConditions = [
|
|||
{
|
||||
conditionType: "BROWSER",
|
||||
domkey: ["targetName"],
|
||||
fieldcol: 14,
|
||||
fieldcol: 18,
|
||||
label: "对象",
|
||||
lanId: 111,
|
||||
labelcol: 6,
|
||||
|
|
@ -54,7 +54,7 @@ export const roleOperatorConditions = [
|
|||
{
|
||||
conditionType: "SELECT",
|
||||
domkey: ["link"],
|
||||
fieldcol: 14,
|
||||
fieldcol: 18,
|
||||
label: "连接符",
|
||||
lanId: 111,
|
||||
labelcol: 6,
|
||||
|
|
@ -65,7 +65,7 @@ export const roleOperatorConditions = [
|
|||
{
|
||||
conditionType: "INPUTNUMBER",
|
||||
domkey: ["sortedIndex"],
|
||||
fieldcol: 14,
|
||||
fieldcol: 18,
|
||||
label: "顺序",
|
||||
lanId: 111,
|
||||
labelcol: 6,
|
||||
|
|
|
|||
|
|
@ -77,6 +77,10 @@
|
|||
.tax_role_browser_form_item {
|
||||
margin: 12px 14px;
|
||||
}
|
||||
|
||||
.tax_role_auth_tree {
|
||||
padding: 10px 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.tax_role_operator_setting_table {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 角色权限设置
|
||||
*
|
||||
* @Author: 黎永顺
|
||||
* @Date: 2024/8/21
|
||||
* @Wechat:
|
||||
* @Email: 971387674@qq.com
|
||||
* @description:
|
||||
*/
|
||||
import React, { Component } from "react";
|
||||
import * as API from "../../../../apis/taxAgent";
|
||||
import { Row } from "antd";
|
||||
import { WeaLocaleProvider } from "ecCom";
|
||||
|
||||
const getLabel = WeaLocaleProvider.getLabel;
|
||||
|
||||
class AuthTree extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { roleId } = this.props;
|
||||
API.getAuthOptTree({ roleId }).then(({ status, data }) => {
|
||||
if (status) {
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Row className="tax_role_auth_tree">权限</Row>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default AuthTree;
|
||||
|
|
@ -9,12 +9,13 @@
|
|||
*/
|
||||
import React, { Component } from "react";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { WeaDialog, WeaLocaleProvider } from "ecCom";
|
||||
import { WeaDialog, WeaLocaleProvider, WeaTools } from "ecCom";
|
||||
import { Button } from "antd";
|
||||
import { roleOperatorConditions } from "../conditions";
|
||||
import { getSearchs } from "../../../../util";
|
||||
|
||||
const getLabel = WeaLocaleProvider.getLabel;
|
||||
const getKey = WeaTools.getKey;
|
||||
|
||||
@inject("taxAgentStore")
|
||||
@observer
|
||||
|
|
@ -30,21 +31,95 @@ class EditRoleDialog extends Component {
|
|||
if (nextProps.visible !== this.props.visible && nextProps.visible) {
|
||||
this.setState({
|
||||
conditions: _.map(roleOperatorConditions, item => ({
|
||||
...item, items: _.map(item.items, o => ({ ...o, label: getLabel(o.lanId, o.label) }))
|
||||
...item, items: _.map(item.items, o => {
|
||||
o = { ...o, label: getLabel(o.lanId, o.label), value: String(nextProps.record[getKey(o)]) };
|
||||
switch (getKey(o)) {
|
||||
case "link":
|
||||
o = { ...o, options: nextProps.linkOptions, hide: _.isEmpty(nextProps.linkOptions) };
|
||||
break;
|
||||
case "sortedIndex":
|
||||
o = { ...o, hide: _.isEmpty(nextProps.linkOptions) };
|
||||
break;
|
||||
case "targetName":
|
||||
o = ["EMP", "DEPARTMENT", "JOB", "SUB_COMPANY", "ROLE"].includes(nextProps.record.targetType) ?
|
||||
{
|
||||
...o, value: "", browserConditionParam: {
|
||||
...this.renderBrowserType(nextProps.record.targetType),
|
||||
replaceDatas: [{ id: nextProps.record["target"], name: nextProps.record[getKey(o)] }]
|
||||
}
|
||||
} :
|
||||
nextProps.record.targetType === "SQL" ? {
|
||||
...o, conditionType: "TEXTAREA", otherParams: { minRows: 3 }
|
||||
} : nextProps.record.targetType === "LEVEL" ?
|
||||
{
|
||||
...o, startValue: nextProps.record[getKey(o)].split("-")[0],
|
||||
endValue: nextProps.record[getKey(o)].split("-")[1],
|
||||
conditionType: "SCOPE", precision: 0
|
||||
} : { ...o };
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return o;
|
||||
})
|
||||
}))
|
||||
}, () => nextProps.taxAgentStore.roleOperatorForm.initFormFields(this.state.conditions));
|
||||
}
|
||||
if (nextProps.visible !== this.props.visible && !nextProps.visible) nextProps.taxAgentStore.initRoleOperatorForm();
|
||||
if (nextProps.loading !== this.props.loading && !nextProps.loading) this.props.onCancel();
|
||||
}
|
||||
|
||||
renderBrowserType = (enumType) => {
|
||||
let browserType = {};
|
||||
switch (enumType) {
|
||||
case "EMP":
|
||||
browserType = { ...browserType, type: 17, isSingle: true, title: getLabel(82246, "人员选择") };
|
||||
break;
|
||||
case "DEPARTMENT":
|
||||
browserType = { ...browserType, type: 57, isSingle: true, title: getLabel(111, "部门选择") };
|
||||
break;
|
||||
case "JOB":
|
||||
browserType = { ...browserType, type: 278, isSingle: true, title: getLabel(111, "岗位选择") };
|
||||
break;
|
||||
case "SUB_COMPANY":
|
||||
browserType = { ...browserType, type: 164, isSingle: true, title: getLabel(111, "分部选择") };
|
||||
break;
|
||||
case "ROLE":
|
||||
browserType = { ...browserType, type: 65, isSingle: true, title: getLabel(111, "角色选择") };
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return browserType;
|
||||
};
|
||||
save = () => {
|
||||
const { taxAgentStore: { roleOperatorForm }, record, onChange } = this.props;
|
||||
roleOperatorForm.validateForm().then(f => {
|
||||
if (f.isValid) {
|
||||
const { targetName: __, link, sortedIndex } = roleOperatorForm.getFormParams();
|
||||
const targetName = roleOperatorForm.getFormDatas().targetName;
|
||||
onChange([_.assign(record, {
|
||||
editId: record.id, sortedIndex,
|
||||
id: record.targetType === "LEVEL" ? targetName.value.join("-") : targetName.value,
|
||||
name: record.targetType === "SQL" ? __ :
|
||||
record.targetType === "LEVEL" ? __.join("-") : targetName.valueSpan,
|
||||
link: link === "undefined" ? "OR" : link
|
||||
})]);
|
||||
} else {
|
||||
f.showErrors();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
const { conditions, loading } = this.state;
|
||||
const { taxAgentStore: { roleOperatorForm } } = this.props;
|
||||
const { conditions } = this.state;
|
||||
const { taxAgentStore: { roleOperatorForm }, linkOptions, loading } = this.props;
|
||||
return (
|
||||
<WeaDialog
|
||||
{...this.props} style={{ width: 480, height: 187 }} initLoadCss title={getLabel(111, "编辑操作者")}
|
||||
{...this.props} style={{ width: 480, height: _.isEmpty(linkOptions) ? 129 : 223 }}
|
||||
initLoadCss title={getLabel(111, "编辑操作者")}
|
||||
buttons={[
|
||||
<Button type="primary" loading={loading} onClick={() => this.save()}>{getLabel(111, "保存")}</Button>
|
||||
<Button type="primary" loading={loading} onClick={this.save}>{getLabel(111, "保存")}</Button>
|
||||
]}
|
||||
>
|
||||
<div className="form-dialog-layout">{getSearchs(roleOperatorForm, conditions, 1, false)}</div>
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import {
|
|||
} from "ecCom";
|
||||
import { commonEnumList } from "../../../../apis/archive";
|
||||
import EditRoleDialog from "./editRoleDialog";
|
||||
import AuthTree from "./authTree";
|
||||
import * as API from "../../../../apis/taxAgent";
|
||||
import { Button, Col, message, Modal, Row } from "antd";
|
||||
import "../index.less";
|
||||
|
|
@ -110,16 +111,15 @@ class Index extends Component {
|
|||
return;
|
||||
}
|
||||
const payload = _.map(replaceDatas, o => ({
|
||||
roleId, targetType, target: o.id || "", targetName: o.name || "",
|
||||
link: selectedKey === "auth.DataTargetTypeEnum" ? "OR" : "",
|
||||
sortedIndex: o.sortedIndex || 0
|
||||
roleId, targetType: o.targetType || targetType, target: o.id || "", targetName: o.name || "",
|
||||
link: o.link || "OR", sortedIndex: o.sortedIndex || 0, id: o.editId || ""
|
||||
}));
|
||||
this.setState({ loading: { ...this.state.loading, set: true } });
|
||||
APIFOX[`save.${selectedKey}`](payload).then(({ status, errormsg }) => {
|
||||
this.setState({ loading: { ...this.state.loading, set: false } });
|
||||
if (status) {
|
||||
message.success(getLabel(111, "操作成功!"));
|
||||
this.getSettingRoler(roleId);
|
||||
this.setState({ replaceDatas: [] }, () => this.getSettingRoler(roleId));
|
||||
} else {
|
||||
message.error(errormsg);
|
||||
}
|
||||
|
|
@ -159,6 +159,7 @@ class Index extends Component {
|
|||
});
|
||||
};
|
||||
getOperatorSetting = () => {
|
||||
const { roleId } = this.props;
|
||||
const { selectedKey, enumType, replaceDatas } = this.state;
|
||||
if (selectedKey !== "auth.AuthTargetTypeEnum") {
|
||||
let browserType = {};
|
||||
|
|
@ -187,7 +188,8 @@ class Index extends Component {
|
|||
case "LEVEL":
|
||||
return (<WeaFormItem label={getLabel(111, "安全级别")} labelCol={{ span: 2 }} wrapperCol={{ span: 5 }}
|
||||
className="tax_role_browser_form_item">
|
||||
<WeaScope isMobx/>
|
||||
<WeaScope isMobx value={_.reduce(replaceDatas, (pre, cur) => cur.id.split("-"), [])}
|
||||
onChange={v => this.setState({ replaceDatas: [{ id: v.join("-"), name: v.join("-") }] })}/>
|
||||
</WeaFormItem>);
|
||||
default:
|
||||
return (<Row className="tax_role_browser_form_item"></Row>);
|
||||
|
|
@ -197,7 +199,7 @@ class Index extends Component {
|
|||
onChange={(__, ___, replaceDatas) => this.setState({ replaceDatas })}/>
|
||||
</Row>);
|
||||
} else {
|
||||
return (<Row>权限</Row>);
|
||||
return (<AuthTree roleId={roleId}/>);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -261,32 +263,44 @@ class Index extends Component {
|
|||
this.state.selectedKey !== "auth.AuthTargetTypeEnum" && this.getEnumList();
|
||||
this.state.selectedKey !== "auth.AuthTargetTypeEnum" && this.getSettingRoler(roleId);
|
||||
})}/>
|
||||
<WeaSelect options={options} detailtype={3} value={enumType}
|
||||
onChange={v => this.setState({ enumType: v, replaceDatas: [] })}/>
|
||||
{
|
||||
this.state.selectedKey !== "auth.AuthTargetTypeEnum" &&
|
||||
<WeaSelect options={options} detailtype={3} value={enumType}
|
||||
onChange={v => this.setState({ enumType: v, replaceDatas: [] })}/>
|
||||
}
|
||||
{this.getOperatorSetting()}
|
||||
<Row className="tax_role_operator_setting">
|
||||
<Col span={8} offset={16}><Button type="primary" loading={loading.set}
|
||||
onClick={this.addOperatorSettings}>{getLabel(111, "添加操作者设置")}</Button></Col>
|
||||
</Row>
|
||||
{
|
||||
this.state.selectedKey !== "auth.AuthTargetTypeEnum" &&
|
||||
<Row className="tax_role_operator_setting">
|
||||
<Col span={8} offset={16}>
|
||||
<Button type="primary" loading={loading.set}
|
||||
onClick={this.addOperatorSettings}>{getLabel(111, "添加操作者设置")}</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
}
|
||||
</div>
|
||||
</Row>
|
||||
{/*表格*/}
|
||||
<Row className="tax_role_operator_setting_table">
|
||||
<Col span={24} className="setting_table_title">
|
||||
<div className="wea-f12 text-elli operator">
|
||||
<span>{getLabel(111, "已设操作者")}</span>
|
||||
<Button type="ghost" disabled={_.isEmpty(selectedRowKeys)} loading={loading.delete}
|
||||
onClick={this.deleteOperatorSettings}>{getLabel(111, "批量删除")}</Button>
|
||||
</div>
|
||||
<WeaTable rowKey="id" columns={columns} dataSource={dataSource} bordered loading={loading.query}
|
||||
pagination={pagination} rowSelection={rowSelection}/>
|
||||
{/* 编辑操作者*/}
|
||||
<EditRoleDialog {...editOperatorDialog} onInitTable={() => this.getSettingRoler(roleId)}
|
||||
onCancel={callback => this.setState({
|
||||
editOperatorDialog: { ...editOperatorDialog, visible: false }
|
||||
}, () => callback && callback())}/>
|
||||
</Col>
|
||||
</Row>
|
||||
{
|
||||
this.state.selectedKey !== "auth.AuthTargetTypeEnum" &&
|
||||
<Row className="tax_role_operator_setting_table">
|
||||
<Col span={24} className="setting_table_title">
|
||||
<div className="wea-f12 text-elli operator">
|
||||
<span>{getLabel(111, "已设操作者")}</span>
|
||||
<Button type="ghost" disabled={_.isEmpty(selectedRowKeys)} loading={loading.delete}
|
||||
onClick={this.deleteOperatorSettings}>{getLabel(111, "批量删除")}</Button>
|
||||
</div>
|
||||
<WeaTable rowKey="id" columns={columns} dataSource={dataSource} bordered loading={loading.query}
|
||||
pagination={pagination} rowSelection={rowSelection}/>
|
||||
{/* 编辑操作者*/}
|
||||
<EditRoleDialog {...editOperatorDialog} loading={loading.set}
|
||||
onChange={replaceDatas => this.setState({ replaceDatas }, () => this.addOperatorSettings())}
|
||||
onCancel={callback => this.setState({
|
||||
editOperatorDialog: { ...editOperatorDialog, visible: false, record: {} }
|
||||
}, () => callback && callback())}/>
|
||||
</Col>
|
||||
</Row>
|
||||
}
|
||||
</div>
|
||||
</WeaDialog>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue