feature/2.15.1.2407.01-权限
This commit is contained in:
parent
6e7137b6b3
commit
71b4e766af
|
|
@ -112,8 +112,20 @@ export const deleteAuthRole = (params) => {
|
|||
export const authMemberList = (params) => {
|
||||
return postFetch("/api/bs/hrmsalary/auth/member/list", params);
|
||||
};
|
||||
//保存成员
|
||||
export const saveAuthMember = (params) => {
|
||||
return postFetch("/api/bs/hrmsalary/auth/member/save", params);
|
||||
};
|
||||
//数据列表
|
||||
export const authDataList = (params) => {
|
||||
return postFetch("/api/bs/hrmsalary/auth/data/list", params);
|
||||
};
|
||||
//保存数据
|
||||
export const saveAuthData = (params) => {
|
||||
return postFetch("/api/bs/hrmsalary/auth/data/save", params);
|
||||
};
|
||||
//同步数据
|
||||
export const syncAuthData = (params) => {
|
||||
return postFetch("/api/bs/hrmsalary/auth/data/sync", params);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,9 @@
|
|||
|
||||
.tax_role_operator_setting_table {
|
||||
.setting_table_title {
|
||||
//line-height: 45px;
|
||||
& > .operator {
|
||||
line-height: 45px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import {
|
|||
WeaFormItem,
|
||||
WeaInput,
|
||||
WeaLocaleProvider,
|
||||
WeaScope,
|
||||
WeaSelect,
|
||||
WeaTab,
|
||||
WeaTable,
|
||||
|
|
@ -21,13 +22,15 @@ import {
|
|||
} from "ecCom";
|
||||
import { commonEnumList } from "../../../../apis/archive";
|
||||
import * as API from "../../../../apis/taxAgent";
|
||||
import { Button, Col, Row } from "antd";
|
||||
import { Button, Col, message, Modal, Row } from "antd";
|
||||
import "../index.less";
|
||||
|
||||
const getLabel = WeaLocaleProvider.getLabel;
|
||||
const APIFOX = {
|
||||
"auth.MemberTargetTypeEnum": API.authMemberList,
|
||||
"auth.DataTargetTypeEnum": API.authDataList
|
||||
"save.auth.MemberTargetTypeEnum": API.saveAuthMember,
|
||||
"auth.DataTargetTypeEnum": API.authDataList,
|
||||
"save.auth.DataTargetTypeEnum": API.saveAuthData
|
||||
};
|
||||
|
||||
class Index extends Component {
|
||||
|
|
@ -35,6 +38,7 @@ class Index extends Component {
|
|||
super(props);
|
||||
this.state = {
|
||||
selectedKey: "auth.MemberTargetTypeEnum", name: "", options: [], enumType: "",
|
||||
replaceDatas: [], loading: { set: false, query: false, async: false },
|
||||
columns: [], dataSource: [], pageInfo: { current: 1, pageSize: 10, total: 0 }
|
||||
};
|
||||
}
|
||||
|
|
@ -45,6 +49,8 @@ class Index extends Component {
|
|||
this.getEnumList();
|
||||
this.getSettingRoler(nextProps.roleId);
|
||||
});
|
||||
} else {
|
||||
this.setState({ replaceDatas: [], pageInfo: { current: 1, pageSize: 10, total: 0 } });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -60,26 +66,56 @@ class Index extends Component {
|
|||
};
|
||||
getSettingRoler = (roleId) => {
|
||||
const { selectedKey, pageInfo } = this.state;
|
||||
this.setState({ loading: { ...this.state.loading, query: true } });
|
||||
APIFOX[selectedKey]({ roleId, ...pageInfo }).then(({ status, data }) => {
|
||||
this.setState({ loading: { ...this.state.loading, query: false } });
|
||||
if (status) {
|
||||
const { columns, list: dataSource, pageNum: current, pageSize, total } = data;
|
||||
this.setState({
|
||||
dataSource, pageInfo: { ...pageInfo, current, pageSize, total },
|
||||
columns: _.map(columns, o => {
|
||||
if (o.dataIndex === "targetType") {
|
||||
return {
|
||||
...o,
|
||||
render: (txt, record) => (<span>{txt}</span>)
|
||||
};
|
||||
}
|
||||
return { ...o };
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
addOperatorSettings = () => {
|
||||
const { roleId } = this.props;
|
||||
const { selectedKey, enumType: targetType, replaceDatas } = this.state;
|
||||
if (_.isEmpty(replaceDatas)) {
|
||||
Modal.warning({
|
||||
title: getLabel(111, "系统提示"),
|
||||
content: getLabel(111, "请先选择操作对象的值!")
|
||||
});
|
||||
return;
|
||||
}
|
||||
const payload = _.map(replaceDatas, o => ({ roleId, targetType, target: o.id || "", targetName: o.name || "" }));
|
||||
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);
|
||||
} else {
|
||||
message.error(errormsg);
|
||||
}
|
||||
});
|
||||
};
|
||||
syncAuthData = () => {
|
||||
const { roleId } = this.props;
|
||||
this.setState({ async: true });
|
||||
API.syncAuthData({ roleId }).then(({ status, errormsg }) => {
|
||||
this.setState({ async: false });
|
||||
if (status) {
|
||||
message.success(getLabel(111, "操作成功!"));
|
||||
} else {
|
||||
message.error(errormsg);
|
||||
}
|
||||
});
|
||||
};
|
||||
getOperatorSetting = () => {
|
||||
const { selectedKey, enumType } = this.state;
|
||||
const { selectedKey, enumType, replaceDatas } = this.state;
|
||||
if (selectedKey !== "auth.AuthTargetTypeEnum") {
|
||||
let browserType = {};
|
||||
switch (enumType) {
|
||||
|
|
@ -100,13 +136,21 @@ class Index extends Component {
|
|||
break;
|
||||
case "SQL":
|
||||
return (<Row className="tax_role_browser_form_item">
|
||||
<WeaTextarea style={{ width: "100%" }} minRows={3}/>
|
||||
<WeaTextarea style={{ width: "100%" }} minRows={3}
|
||||
value={_.head(replaceDatas) ? _.head(replaceDatas).name : ""}
|
||||
onChange={v => this.setState({ replaceDatas: [{ id: v, name: v }] })}/>
|
||||
</Row>);
|
||||
case "LEVEL":
|
||||
return (<WeaFormItem label={getLabel(111, "安全级别")} labelCol={{ span: 2 }} wrapperCol={{ span: 5 }}
|
||||
className="tax_role_browser_form_item">
|
||||
<WeaScope isMobx/>
|
||||
</WeaFormItem>);
|
||||
default:
|
||||
break;
|
||||
return (<Row className="tax_role_browser_form_item"></Row>);
|
||||
}
|
||||
return (<Row className="tax_role_browser_form_item">
|
||||
<WeaBrowser {...browserType} isSingle={false} inputStyle={{ width: 150 }}/>
|
||||
<WeaBrowser {...browserType} isSingle={false} inputStyle={{ width: 150 }} replaceDatas={replaceDatas}
|
||||
onChange={(__, ___, replaceDatas) => this.setState({ replaceDatas })}/>
|
||||
</Row>);
|
||||
} else {
|
||||
return (<Row>权限</Row>);
|
||||
|
|
@ -115,7 +159,7 @@ class Index extends Component {
|
|||
|
||||
render() {
|
||||
const { roleId } = this.props;
|
||||
const { selectedKey, name, options, enumType, pageInfo, columns, dataSource } = this.state;
|
||||
const { selectedKey, name, options, enumType, pageInfo, columns, dataSource, loading } = this.state;
|
||||
const tabs = [
|
||||
{ title: getLabel(111, "成员"), viewcondition: "auth.MemberTargetTypeEnum" },
|
||||
{ title: getLabel(111, "权限"), viewcondition: "auth.AuthTargetTypeEnum" },
|
||||
|
|
@ -141,6 +185,9 @@ class Index extends Component {
|
|||
return (
|
||||
<WeaDialog
|
||||
{...this.props} hasScroll className="tax_role_set_dialog" initLoadCss title={getLabel(111, "编辑角色")}
|
||||
buttons={[
|
||||
<Button type="primary" onClick={this.syncAuthData} loading={loading.async}>{getLabel(111, "同步")}</Button>
|
||||
]}
|
||||
style={{
|
||||
width: 960, height: 606.6, minHeight: 200, minWidth: 380,
|
||||
maxHeight: "90%", maxWidth: "90%", overflow: "hidden", transform: "translate(0px, 0px)"
|
||||
|
|
@ -160,25 +207,26 @@ class Index extends Component {
|
|||
<div className="tax_role_form_item">
|
||||
<WeaTab datas={tabs} keyParam="viewcondition" selectedKey={selectedKey}
|
||||
onChange={v => this.setState({
|
||||
selectedKey: v, name: !name ? null : name
|
||||
selectedKey: v, name: !name ? null : name, replaceDatas: []
|
||||
}, () => {
|
||||
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 })}/>
|
||||
onChange={v => this.setState({ enumType: v, replaceDatas: [] })}/>
|
||||
{this.getOperatorSetting()}
|
||||
<Row className="tax_role_operator_setting">
|
||||
<Col span={8} offset={16}><Button type="primary">{getLabel(111, "添加操作者设置")}</Button></Col>
|
||||
<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">{getLabel(111, "已设操作者")}</div>
|
||||
<WeaTable columns={columns} dataSource={dataSource} draggable={true} bordered
|
||||
pagination={pagination}/>
|
||||
<div className="wea-f12 text-elli operator">{getLabel(111, "已设操作者")}</div>
|
||||
<WeaTable columns={columns} dataSource={dataSource} bordered loading={loading.query}
|
||||
pagination={pagination} draggable={selectedKey === "auth.DataTargetTypeEnum"}/>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue