parent
ac8f61cc15
commit
8a44f31d64
|
|
@ -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 {
|
|||
>
|
||||
<WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@5r6c5a@${index}`} fieldConfig={field} form={form} formParams={form.getFormParams()} onChange={this.onChange}
|
||||
onBlur={this.onBlur} />
|
||||
{field.domkey[0] == 'comp_no' && field.viewAttr != '1' && <AttachToNumberField field={field} form={form} isEdit={true}/>}
|
||||
{field.domkey[0] == 'dept_no' && field.viewAttr != '1' && <AttachToNumberField field={field} form={form} isEdit={true}/>}
|
||||
{field.domkey[0] == 'job_no' && field.viewAttr != '1' && <AttachToNumberField field={field} form={form} isEdit={true}/>}
|
||||
</WeaFormItem>
|
||||
),
|
||||
colSpan: 1
|
||||
|
|
@ -159,4 +163,4 @@ export default class NewAndEditDialog extends React.Component {
|
|||
</WeaDialog>
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<div>
|
||||
{canRe && <a onClick={this.reNumber}>{i18n.label.reNumber()}</a>}
|
||||
{canCheck && <a onClick={this.handleClick} style={{ marginLeft: canRe && 10 }}
|
||||
id="select">{i18n.label.selectReserveNumber()}</a>}
|
||||
{canCheck && canNew &&
|
||||
<a style={{ marginLeft: 10 }} onClick={this.handleClick} id="add">{i18n.label.newReserveNumber()}</a>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// office-wapper
|
||||
.office-wapper {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.rightmenu {
|
||||
border-right: none;
|
||||
|
|
@ -17,4 +19,4 @@
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -437,7 +437,6 @@ export default class OfficeManage extends Component {
|
|||
</WeaTop>
|
||||
<WeaLeftRightLayout
|
||||
isNew={true}
|
||||
leftWidth={260}
|
||||
leftCom={
|
||||
<LeftTree deleteOfficeClassifyFlag={deleteOfficeClassifyFlag}/>
|
||||
}>
|
||||
|
|
|
|||
Loading…
Reference in New Issue