import React from 'react'; import { inject, observer } from 'mobx-react'; import { Button, Spin, Icon } from 'antd' import isEmpty from 'lodash/isEmpty' import { WeaDialog, WeaSearchGroup, WeaTools, WeaNewScroll, WeaFormItem,WeaDialogFooter } from 'ecCom'; import { WeaSwitch } from 'comsMobx' import UploadAvatar from '../../../../pc4public/hrm/uploadAvatar' const getKey = WeaTools.getKey; import * as mobx from 'mobx'; import { i18n } from '../../public/i18n'; import { AttachToNumberField } from '../../../../pc4backstage/hrmengine/util/index.js' import {addContentPath} from '../../util/index.js' const verificationCode = '/weaver/weaver.file.MakeValidateCode?isView=1&validatetype=0&validatenum=4&seriesnum_='; @inject('hrmAdd') @observer class Simple extends React.Component { constructor(props) { super(props); this.state = { time: new Date().getTime(), } this.deptInfo=null; } componentWillMount() { const {location,hrmAdd } = this.props; if (location && location.query && location.query.name) { hrmAdd.isUsedAsSingle = true; this.deptInfo = location.query; } } componentWillReceiveProps (nextProps) { const { hrmAdd } = this.props; const { conditionInfo } = hrmAdd; if ('visible' in nextProps && this.props.visible !== nextProps.visible) { if (nextProps.visible) { if (isEmpty(conditionInfo)) this.init(); hrmAdd.updateScroll = true; hrmAdd.canSave = true; } else { hrmAdd.conditionInfo = []; } } } componentDidUpdate () { const { hrmAdd } = this.props; const { updateScroll,formSimple } = hrmAdd; if (updateScroll) { if (this.refs.scrollBar) { setTimeout(() => { this.refs.scrollBar.scrollerToTop(); }, 0); } hrmAdd.updateScroll = false; } setTimeout(() => { $(".input-tip").attr("title", $(".input-tip").text()) }, 0) if (this.deptInfo) { const {id,name}= this.deptInfo; formSimple.updateFields({ departmentid:{ value: id, valueSpan: name, valueObj: [ { id, name } ] } }) } } componentDidMount () { this.init(); console.log(self.frameElement); } init = () => { const { hrmAdd } = this.props; hrmAdd.getHrmResourceAddForm({ 'type': 'simple' }); } save = () => { const { hrmAdd } = this.props; hrmAdd.save(this.refreshVerificationCode); } doSaveAndNew = () => { const { hrmAdd } = this.props; hrmAdd.doSaveAndNew(this.refreshVerificationCode); } more = () => { } openFullmode = () => { const { hrmAdd } = this.props; hrmAdd.openFullmode(); } refreshVerificationCode = () => this.setState({ time: new Date().getTime() }); getSearchs = () => { const { time } = this.state; const { hrmAdd } = this.props; const { formSimple, conditionInfo } = hrmAdd; const { isFormInit } = formSimple; const formParams = formSimple.getFormParams(); let group = []; window.e9HideFormFieldKeys = []; isFormInit && conditionInfo && conditionInfo.forEach((c, i) => { let items = []; c.items.forEach((field, j) => { let hide = false; if ((!formParams.accounttype || formParams.accounttype == '0') && field.domkey[0] == 'belongto') hide = true; if (formParams.accounttype == '1' && (field.domkey[0] == 'loginid' || field.domkey[0] == 'password' || field.domkey[0] == 'password1')) hide = true; let dom; if (field.conditionType == 'RESOURCEIMG') { const key = getKey(field); const bindObj = formSimple.$(key); dom = } else if (field.domkey[0] == 'validatecode') { dom = (
this.refreshVerificationCode()} title={i18n.label.preview()} />
) } else { dom = ; } if (c.hide || !isEmpty(field.otherParams) && field.otherParams.hide) { window.e9HideFormFieldKeys.push(field.domkey[0]); } else { items.push({ com: {dom} {field.domkey[0] == 'workcode' && } , colSpan: 1, hide: hide }); } }); group.push() }); return group; } render () { const { hrmAdd } = this.props; const { title, loading,isUsedAsSingle,jobtitleVisible,formSimple,closeJobtitleDialog} = hrmAdd; let dialogHeight = window.innerHeight - 250; if (dialogHeight > 660) dialogHeight = 660; let scrollProps = {}; if (!isUsedAsSingle) { scrollProps.height = dialogHeight } let com = this.getSearchs() if (!isUsedAsSingle) { return {com} }else{ return (
{com}
{ jobtitleVisible && ( { const { id, jobtitlemark } = datas; formSimple.updateFields({ jobtitle: { value: id, valueSpan: jobtitlemark, valueObj: [{ id, name: jobtitlemark }] } }); closeJobtitleDialog(); } } url={'/spa/hrm/engine.html#/hrmengine/posts?type=0'} visible={jobtitleVisible} style={{ width: 600, height: 500 }} /> ) }
) } } getBtns = () => { const { hrmAdd } = this.props; const { canSave,isUsedAsSingle } = hrmAdd; return [ (!isUsedAsSingle &&
{i18n.button.fullModle()}
), (), (!isUsedAsSingle && ), ] return btns; } } export default Simple