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 =