From 8a44f31d647e825b636e4032f8b2cea969264fd5 Mon Sep 17 00:00:00 2001 From: 18652063575 Date: Tue, 6 Sep 2022 10:08:08 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90ID1000165=E3=80=91=20=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E6=9C=BA=E6=9E=84=EF=BC=9A=E5=88=86=E9=83=A8/?= =?UTF-8?q?=E9=83=A8=E9=97=A8/=E5=B2=97=E4=BD=8D=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=20=E5=A2=9E=E5=8A=A0=20=E9=A2=84=E7=95=99?= =?UTF-8?q?=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/NewAndEditDialog.js | 6 +- .../organization/components/NewNumberField.js | 140 ++++++++++++++++++ .../organization/components/office/index.less | 4 +- .../components/office/officeManage.js | 1 - 4 files changed, 148 insertions(+), 3 deletions(-) create mode 100644 pc4mobx/organization/components/NewNumberField.js diff --git a/pc4mobx/organization/components/NewAndEditDialog.js b/pc4mobx/organization/components/NewAndEditDialog.js index be503bb..535f8a3 100644 --- a/pc4mobx/organization/components/NewAndEditDialog.js +++ b/pc4mobx/organization/components/NewAndEditDialog.js @@ -19,6 +19,7 @@ import { import { i18n } from '../public/i18n'; +import AttachToNumberField from './NewNumberField'; export default class NewAndEditDialog extends React.Component { constructor(props) { @@ -103,6 +104,9 @@ export default class NewAndEditDialog extends React.Component { > + {field.domkey[0] == 'comp_no' && field.viewAttr != '1' && } + {field.domkey[0] == 'dept_no' && field.viewAttr != '1' && } + {field.domkey[0] == 'job_no' && field.viewAttr != '1' && } ), colSpan: 1 @@ -159,4 +163,4 @@ export default class NewAndEditDialog extends React.Component { ) } -} \ No newline at end of file +} diff --git a/pc4mobx/organization/components/NewNumberField.js b/pc4mobx/organization/components/NewNumberField.js new file mode 100644 index 0000000..91724ff --- /dev/null +++ b/pc4mobx/organization/components/NewNumberField.js @@ -0,0 +1,140 @@ +import React, { PureComponent } from "react"; +import { i18n } from "../public/i18n"; +import { WeaTools } from "ecCom"; + +/** + * 添加多级路径 + * + * @param {*} url + */ +export const addContentPath = (url) => { + const ecologyContentPath = window.ecologyContentPath || ""; + if (url && ecologyContentPath) { + //避免重复添加ecologyContentPath + //避免传入的参数不是链接 + if (url.startsWith("/") && !url.startsWith(ecologyContentPath)) { + url = ecologyContentPath + url; + } + } + return url; +}; + +export default class AttachToNumberField extends PureComponent { + constructor(props) { + super(props); + + this.state = { + canRe: false, + canCheck: false, + canNew: false + }; + this.typeMap = { + comp_no: "SUBCOMPANY", + dept_no: "DEPARTMENT", + job_no: "JOBTITLES", + workcode: "USER" + }; + + } + + componentWillMount() { + const { field: { domkey: [targetKey] } } = this.props; + this.targetKey = targetKey; + this.type = this.typeMap[this.targetKey]; + } + + componentDidMount() { + this.init(this.props.isEdit); + } + + componentWillReceiveProps(nextProps) { + if (nextProps.form != this.props.form) { + this.init(nextProps.isEdit); + } + } + + init = (isEdit) => { + WeaTools.callApi("/api/hrm/codeSetting/getHasSelect", "GET", {}).then(res => { + if (res) { + //后台设置页面开关关闭,接口不会返回对应的权限,所以这里做下兼容 + const target = res[this.type] || { hasSelect: false, hasRight: false }; + const { hasSelect, hasRight } = target; + this.setState({ + canRe: hasSelect && isEdit, + canCheck: hasSelect, + canNew: hasRight + }); + } + }); + }; + + handleClick = (e) => { + const urlMap = { + select: { + title: i18n.label.selectReserveNumber(), + url: addContentPath(`/spa/hrm/engine.html#/hrmengine/reservedNumber?type=${this.type}&isSimple=1`) + }, + add: { + title: i18n.label.newReserveNumber(), + url: addContentPath(`/spa/hrm/engine.html#/hrmengine/newReservedNumberContent?type=${this.type}`) + } + }; + + const { title, url } = urlMap[e.target.id]; + + ecCom.WeaTools.createDialog({ + title, + url, + moduleName: "hrm", + style: { width: 800, height: 600 }, + callback: this.updateFormField, + onCancel: () => { // 关闭通信 + } + }).show(); + }; + updateFormField = (value) => { + const { form } = this.props; + form.updateFields({ + [this.targetKey]: value + }); + }; + //重新生成编号 + reNumber = () => { + const { form, useId } = this.props; + const fieldMap = { + subcompanycode: "subshowid", + departmentcode: "showid", + jobtitlecode: "jobactivityid", + workcode: "useid" + }, + fieldname = fieldMap[this.targetKey]; + + WeaTools.callApi("/api/hrm/codeSetting/regenerateCode", "POST", { + serialtype: this.type, + [`${this.type.toLocaleLowerCase()}id`]: form.getFormParams()[fieldname] || useId + }).then(res => { + const { api_status, code } = res; + if (api_status) { + if (code) { + this.updateFormField(code); + } else { + message.error(res.api_errormsg); + } + } + }); + }; + + + render() { + const { canRe, canCheck, canNew } = this.state; + return ( +
+ {canRe && {i18n.label.reNumber()}} + {canCheck && {i18n.label.selectReserveNumber()}} + {canCheck && canNew && + {i18n.label.newReserveNumber()}} +
+ ); + } +} diff --git a/pc4mobx/organization/components/office/index.less b/pc4mobx/organization/components/office/index.less index d39a49d..ba6f3eb 100644 --- a/pc4mobx/organization/components/office/index.less +++ b/pc4mobx/organization/components/office/index.less @@ -1,6 +1,8 @@ // office-wapper .office-wapper { height: 100%; + display: flex; + flex-direction: column; .rightmenu { border-right: none; @@ -17,4 +19,4 @@ } } -} \ No newline at end of file +} diff --git a/pc4mobx/organization/components/office/officeManage.js b/pc4mobx/organization/components/office/officeManage.js index 4d25114..6ead8fb 100644 --- a/pc4mobx/organization/components/office/officeManage.js +++ b/pc4mobx/organization/components/office/officeManage.js @@ -437,7 +437,6 @@ export default class OfficeManage extends Component { }>