feature/2.15.1.2407.01-权限

This commit is contained in:
黎永顺 2024-08-07 09:02:12 +08:00
parent 531e975820
commit 2dc1061fa2
6 changed files with 283 additions and 25 deletions

View File

@ -98,3 +98,14 @@ export const getTaxAgentSelectListAsAdmin = (params) => {
export const hasIconInTax = (params) => {
return WeaTools.callApi("/api/bs/hrmsalary/sys/conf/code?code=hideIconInTax", "GET", params);
};
/**权限-角色相关*/
//保存角色
export const saveAuthRole = (params) => {
return postFetch("/api/bs/hrmsalary/auth/role/save", params);
};
//删除角色
export const deleteAuthRole = (params) => {
return postFetch("/api/bs/hrmsalary/auth/role/delete", params);
};

View File

@ -10,9 +10,10 @@
import React, { Component } from "react";
import { inject, observer } from "mobx-react";
import { WeaDialog, WeaLocaleProvider } from "ecCom";
import { Button, message } from "antd";
import { getSearchs } from "../../../../util";
import { roleConditions } from "../conditions";
import { Button } from "antd";
import * as API from "../../../../apis/taxAgent";
import "../index.less";
const getLabel = WeaLocaleProvider.getLabel;
@ -33,20 +34,43 @@ class Index extends Component {
conditions: _.map(roleConditions, item => ({
...item, items: _.map(item.items, o => ({ ...o, label: getLabel(o.lanId, o.label) }))
}))
}, () => this.props.taxAgentStore.roleForm(this.state.conditions));
}, () => nextProps.taxAgentStore.roleForm.initFormFields(this.state.conditions));
}
if (nextProps.visible !== this.props.visible && !nextProps.visible) this.props.taxAgentStore.initRoleForm();
if (nextProps.visible !== this.props.visible && !nextProps.visible) nextProps.taxAgentStore.initRoleForm();
}
save = (isSetting) => {
const { taxAgentStore: { roleForm }, taxAgentId } = this.props;
roleForm.validateForm().then(f => {
if (f.isValid) {
const payload = roleForm.getFormParams();
this.setState({ loading: true });
API.saveAuthRole({ ...payload, taxAgentId }).then(({ status, data, errormsg }) => {
this.setState({ loading: false });
if (status) {
message.success(getLabel(111, "操作成功!"));
this.props.onCancel(() => this.props.onSearch());
isSetting && this.props.showRoleSetDialog({ id: data, name: payload.name });
} else {
message.error(errormsg);
}
});
} else {
f.showErrors();
}
});
};
render() {
const { conditions } = this.state;
const { conditions, loading, roleSetDialog } = this.state;
const { taxAgentStore: { roleForm } } = this.props;
return (
<WeaDialog
{...this.props} style={{ width: 480, height: 174 }} initLoadCss title={getLabel(111, "添加角色")}
{...this.props} style={{ width: 480, height: 147 }} initLoadCss title={getLabel(111, "添加角色")}
buttons={[
<Button type="primary">{getLabel(111, "保存")}</Button>,
<Button type="primary">{getLabel(111, "保存并进入详细设置")}</Button>
<Button type="primary" loading={loading} onClick={() => this.save()}>{getLabel(111, "保存")}</Button>,
<Button type="primary" loading={loading}
onClick={() => this.save(true)}>{getLabel(111, "保存并进入详细设置")}</Button>
]}
>
<div className="form-dialog-layout">{getSearchs(roleForm, conditions, 1, false)}</div>

View File

@ -6,9 +6,77 @@
cursor: default !important;
}
.wea-field-readonly.border .child-item {
margin-bottom: 4px;
}
.only-operate {
white-space: normal !important;
display: inline !important;
color: #2db7f5;
position: relative;
& > a {
white-space: normal !important;
display: inline !important;
color: #2db7f5;
}
}
.only-operate:hover {
.ant-select-selection__choice__remove {
visibility: visible;
}
}
.ant-select-selection__choice__remove:before {
content: "\E62D";
font-family: anticon !important;
}
.ant-select-selection__choice__remove {
visibility: hidden;
right: -3px;
font-size: 12px !important;
top: 50%;
margin-top: -6px;
text-decoration: none;
position: static;
padding: 0;
cursor: pointer;
transform: scale(.66666667) rotate(0deg);
}
}
.tax_role_set_dialog {
.tax_role_set_container {
padding: 10px 25px;
.tax_role_row_groupname {
padding: 10px 0;
}
.tax_role_form_item {
min-height: 190px;
border: 1px solid rgb(217, 217, 217);
& > .wea-select {
margin: 10px 10px 0 20px;
line-height: 25px;
}
.tax_role_operator_setting {
border-top: 1px solid rgb(217, 217, 217);
padding: 8px;
display: table;
width: 100%;
& > div {
text-align: right;
}
}
.tax_role_browser_form_item {
margin: 12px 14px;
}
}
}
}

View File

@ -0,0 +1,123 @@
/*
* 角色详情设置弹窗
*
* @Author: 黎永顺
* @Date: 2024/8/5
* @Wechat:
* @Email: 971387674@qq.com
* @description:
*/
import React, { Component } from "react";
import { WeaBrowser, WeaDialog, WeaFormItem, WeaInput, WeaLocaleProvider, WeaSelect, WeaTab, WeaTextarea } from "ecCom";
import { commonEnumList } from "../../../../apis/archive";
import { Button, Col, Row } from "antd";
import "../index.less";
const getLabel = WeaLocaleProvider.getLabel;
class Index extends Component {
constructor(props) {
super(props);
this.state = {
selectedKey: "auth.MemberTargetTypeEnum", name: "", options: [], enumType: ""
};
}
componentWillReceiveProps(nextProps, nextContext) {
if (nextProps.visible !== this.props.visible && nextProps.visible) {
this.setState({ name: nextProps.name, selectedKey: "auth.MemberTargetTypeEnum" }, () => this.getEnumList());
}
}
getEnumList = () => {
const payload = { enumClass: `com.engine.salary.enums.${this.state.selectedKey}` };
commonEnumList(payload).then(({ status, data }) => {
if (status) this.setState({
options: _.map(data, o => ({ key: o.enum, showname: o.defaultLabel })),
enumType: _.head(data).enum || ""
});
if (!status) this.setState({ options: [], enumType: "" });
});
};
getOperatorSetting = () => {
const { selectedKey, enumType } = this.state;
if (selectedKey !== "auth.AuthTargetTypeEnum") {
let browserType = {};
switch (enumType) {
case "EMP":
browserType = { ...browserType, type: 17, title: getLabel(82246, "人员选择") };
break;
case "DEPARTMENT":
browserType = { ...browserType, type: 57, title: getLabel(111, "部门选择") };
break;
case "JOB":
browserType = { ...browserType, type: 278, title: getLabel(111, "岗位选择") };
break;
case "SUB_COMPANY":
browserType = { ...browserType, type: 164, title: getLabel(111, "分部选择") };
break;
case "ROLE":
browserType = { ...browserType, type: 65, title: getLabel(111, "角色选择") };
break;
case "SQL":
return (<Row className="tax_role_browser_form_item">
<WeaTextarea style={{ width: "100%" }} minRows={3} />
</Row>);
default:
break;
}
return (<Row className="tax_role_browser_form_item">
<WeaBrowser {...browserType} isSingle={false} inputStyle={{ width: 150 }}/>
</Row>);
} else {
return (<Row>权限</Row>);
}
};
render() {
const { selectedKey, name, options, enumType } = this.state;
const tabs = [
{ title: getLabel(111, "成员"), viewcondition: "auth.MemberTargetTypeEnum" },
{ title: getLabel(111, "权限"), viewcondition: "auth.AuthTargetTypeEnum" },
{ title: getLabel(111, "数据"), viewcondition: "auth.DataTargetTypeEnum" }
];
return (
<WeaDialog
{...this.props} hasScroll className="tax_role_set_dialog" initLoadCss title={getLabel(111, "编辑角色")}
style={{
width: 960, height: 606.6, minHeight: 200, minWidth: 380,
maxHeight: "90%", maxWidth: "90%", overflow: "hidden", transform: "translate(0px, 0px)"
}}
>
<div className="tax_role_set_container">
<Row className="tax_role_row_groupname">
<Col span={18}>
<WeaFormItem
label={getLabel(111, "角色名称")} labelCol={{ span: 4 }} wrapperCol={{ span: 8 }}
error={name === "" ? getLabel(111, "角色名称不能为空") : ""} tipPosition="bottom">
<WeaInput viewAttr={3} value={name} onChange={val => this.setState({ name: val })}/>
</WeaFormItem>
</Col>
</Row>
<Row>
<div className="tax_role_form_item">
<WeaTab datas={tabs} keyParam="viewcondition" selectedKey={selectedKey}
onChange={v => this.setState({
selectedKey: v, name: !name ? null : name
}, () => this.state.selectedKey !== "auth.AuthTargetTypeEnum" && this.getEnumList())}/>
<WeaSelect options={options} detailtype={3} value={enumType}
onChange={v => this.setState({ enumType: v })}/>
{this.getOperatorSetting()}
<Row className="tax_role_operator_setting">
<Col span={8} offset={16}><Button type="primary">{getLabel(111, "添加操作者设置")}</Button></Col>
</Row>
</div>
</Row>
</div>
</WeaDialog>
);
}
}
export default Index;

View File

@ -9,7 +9,10 @@
*/
import React, { Component } from "react";
import { WeaBrowser, WeaLocaleProvider } from "ecCom";
import { message, Modal } from "antd";
import AddRoleDialog from "../addRoleDialog";
import RoleDetailSetDialog from "../roleDetailSetDialog";
import * as API from "../../../../apis/taxAgent";
import "../index.less";
const getLabel = WeaLocaleProvider.getLabel;
@ -18,29 +21,58 @@ class Index extends Component {
constructor(props) {
super(props);
this.state = {
addRoleDialog: { visible: false, taxAgentId: "" }
addRoleDialog: { visible: false, taxAgentId: "" },
roleSetDialog: { visible: false, roleId: "", name: "" }
};
}
componentDidMount() {
console.log(this.props);
}
showRoleSetDialog = (role) => this.setState({ roleSetDialog: { visible: true, roleId: role.id, name: role.name } });
deleteAuthRole = (role) => {
Modal.confirm({
title: getLabel(111, "信息确认"),
content: getLabel(111, "确认要删除吗?"),
onOk: () => {
API.deleteAuthRole([role.id]).then(({ status, errormsg }) => {
if (status) {
message.success(getLabel(111, "操作成功!"));
this.props.onSearch();
} else {
message.error(errormsg);
}
});
}
});
};
render() {
const { addRoleDialog } = this.state;
const { taxAgent } = this.props;
const { addRoleDialog, roleSetDialog } = this.state;
const { taxAgent, onSearch } = this.props;
const { role } = taxAgent;
return (
<React.Fragment>
<WeaBrowser type={-99991} hasAddBtn hasBorder whiteBackground viewAttr={1} className="tax_role_setting_browser"
<WeaBrowser type={-99991} isSingle={false} hasAddBtn hasBorder whiteBackground viewAttr={1}
className="tax_role_setting_browser"
addOnClick={() => this.setState({ addRoleDialog: { taxAgentId: taxAgent.id, visible: true } })}
replaceDatas={[{ id: 1, name: <a href="javascript:void(0);" className="only-operate">操作者</a> }]}
onChange={(ids, names, datas) =>
console.log("单人力", ids, names, datas)
}/>
<AddRoleDialog {...addRoleDialog}
replaceDatas={_.map(role, o => ({
id: o.id,
name: <span className="only-operate">
<a href="javascript:void(0);" onClick={() => this.showRoleSetDialog(o)}>{o.name}</a>
<span className="ant-select-selection__choice__remove"
onClick={() => this.deleteAuthRole(o)}/>
</span>
}))}/>
{/*添加角色*/}
<AddRoleDialog {...addRoleDialog} onSearch={onSearch}
showRoleSetDialog={this.showRoleSetDialog}
onCancel={callback => this.setState({
addRoleDialog: { ...addRoleDialog, visible: false }
}, () => callback && callback())}/>
{/*角色详情设置*/}
<RoleDetailSetDialog {...roleSetDialog} onSearch={onSearch}
onCancel={callback => this.setState({
roleSetDialog: { ...roleSetDialog, visible: false }
}, () => callback && callback())}/>
</React.Fragment>
);
}

View File

@ -412,11 +412,11 @@ export default class TaxAgent extends React.Component {
);
}
};
}else if(item.dataIndex === "role"){
} else if (item.dataIndex === "role") {
return {
...item,
render: (text, record) => (<RoleSetting taxAgent={record} />)
}
render: (text, record) => (<RoleSetting taxAgent={record} onSearch={() => getTaxAgentList({})}/>)
};
} else {
return { ...item };
}