/* * 编辑橘色操作者 * * @Author: 黎永顺 * @Date: 2024/8/20 * @Wechat: * @Email: 971387674@qq.com * @description: */ import React, { Component } from "react"; import { inject, observer } from "mobx-react"; 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 class EditRoleDialog extends Component { constructor(props) { super(props); this.state = { conditions: [], loading: false }; } componentWillReceiveProps(nextProps, nextContext) { if (nextProps.visible !== this.props.visible && nextProps.visible) { this.setState({ conditions: _.map(roleOperatorConditions, item => ({ ...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 } = this.state; const { taxAgentStore: { roleOperatorForm }, linkOptions, loading } = this.props; return ( {getLabel(111, "保存")} ]} >
{getSearchs(roleOperatorForm, conditions, 1, false)}
); } } export default EditRoleDialog;