diff --git a/pc4mobx/hrmSalary/apis/taxAgent.js b/pc4mobx/hrmSalary/apis/taxAgent.js index 8fcce44a..c8317a45 100644 --- a/pc4mobx/hrmSalary/apis/taxAgent.js +++ b/pc4mobx/hrmSalary/apis/taxAgent.js @@ -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); +}; diff --git a/pc4mobx/hrmSalary/pages/taxAgent/components/conditions.js b/pc4mobx/hrmSalary/pages/taxAgent/components/conditions.js index abf5dd55..ebb21338 100644 --- a/pc4mobx/hrmSalary/pages/taxAgent/components/conditions.js +++ b/pc4mobx/hrmSalary/pages/taxAgent/components/conditions.js @@ -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, diff --git a/pc4mobx/hrmSalary/pages/taxAgent/components/index.less b/pc4mobx/hrmSalary/pages/taxAgent/components/index.less index 4cbd11ce..41ab0eb7 100644 --- a/pc4mobx/hrmSalary/pages/taxAgent/components/index.less +++ b/pc4mobx/hrmSalary/pages/taxAgent/components/index.less @@ -77,6 +77,10 @@ .tax_role_browser_form_item { margin: 12px 14px; } + + .tax_role_auth_tree { + padding: 10px 20px; + } } .tax_role_operator_setting_table { diff --git a/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/authTree.js b/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/authTree.js new file mode 100644 index 00000000..ccd825a4 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/authTree.js @@ -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 ( + 权限 + ); + } +} + +export default AuthTree; diff --git a/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/editRoleDialog.js b/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/editRoleDialog.js index 3e5d8492..359605e0 100644 --- a/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/editRoleDialog.js +++ b/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/editRoleDialog.js @@ -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 ( this.save()}>{getLabel(111, "保存")} + ]} >
{getSearchs(roleOperatorForm, conditions, 1, false)}
diff --git a/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/index.js b/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/index.js index cdf3d1c3..de3b1223 100644 --- a/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/index.js +++ b/pc4mobx/hrmSalary/pages/taxAgent/components/roleDetailSetDialog/index.js @@ -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 ( - + cur.id.split("-"), [])} + onChange={v => this.setState({ replaceDatas: [{ id: v.join("-"), name: v.join("-") }] })}/> ); default: return (); @@ -197,7 +199,7 @@ class Index extends Component { onChange={(__, ___, replaceDatas) => this.setState({ replaceDatas })}/> ); } else { - return (权限); + return (); } }; @@ -261,32 +263,44 @@ class Index extends Component { this.state.selectedKey !== "auth.AuthTargetTypeEnum" && this.getEnumList(); this.state.selectedKey !== "auth.AuthTargetTypeEnum" && this.getSettingRoler(roleId); })}/> - this.setState({ enumType: v, replaceDatas: [] })}/> + { + this.state.selectedKey !== "auth.AuthTargetTypeEnum" && + this.setState({ enumType: v, replaceDatas: [] })}/> + } {this.getOperatorSetting()} - - - + { + this.state.selectedKey !== "auth.AuthTargetTypeEnum" && + + + + + + } {/*表格*/} - - -
- {getLabel(111, "已设操作者")} - -
- - {/* 编辑操作者*/} - this.getSettingRoler(roleId)} - onCancel={callback => this.setState({ - editOperatorDialog: { ...editOperatorDialog, visible: false } - }, () => callback && callback())}/> - -
+ { + this.state.selectedKey !== "auth.AuthTargetTypeEnum" && + + +
+ {getLabel(111, "已设操作者")} + +
+ + {/* 编辑操作者*/} + this.setState({ replaceDatas }, () => this.addOperatorSettings())} + onCancel={callback => this.setState({ + editOperatorDialog: { ...editOperatorDialog, visible: false, record: {} } + }, () => callback && callback())}/> + +
+ }
);