import { Button, Modal,message,Row,Col, Spin} from 'antd'; import { WeaErrorPage, WeaTools,WeaSearchBrowserBox,WeaTableEdit, WeaDialog,WeaSearchGroup, WeaRightMenu,WeaFormItem , WeaQrcode} from 'ecCom' import isEmpty from 'lodash/isEmpty' import debounce from 'lodash/debounce' import isArray from 'lodash/isArray' import '../../style/cardInfo.less'; import {InfoGroup4Formal} from '../../coms/infoGroup4Formal'; import * as PublicFunc from '../../util/pulic-func'; import {createQRCode} from '../../util'; import UploadAvatar from '../../../../pc4public/hrm/uploadAvatar' import TopButton from '../../coms/topButton'; import {WeaSwitch} from 'comsMobx'; import * as mobx from 'mobx'; import { inject, observer} from 'mobx-react'; import {i18n} from '../../public/i18n'; import {AttachToNumberField} from '../../../../pc4backstage/hrmengine/util/index.js' import {addContentPath} from '../../util/index.js' const getKey = WeaTools.getKey; const toJS = mobx.toJS; @inject('hrmCardInfo') @inject('hrmCard') @observer class Main extends React.Component { constructor(props) { super(props); const funcs = ['showSQR','editCard','backCard','saveEditCard']; funcs.forEach(f=> this[f] = this[f].bind(this)); } componentWillReceiveProps(nextProps) { const keyOld = this.props.location.key; const keyNew = nextProps.location.key; if(keyOld !== keyNew) { const {hrmCardInfo, hrmCard} = this.props; hrmCardInfo.updateIsEditor(); const hrmId = nextProps.params.hrmId ||''; hrmCardInfo.getData(hrmId); hrmCardInfo.getRightMenu(hrmId); hrmCard.setTopButtons(this.getTopButtons.bind(this)); hrmCard.setTopRightMenus(this.getRightMenu.bind(this)); hrmCard.setTopShowDropIcon(true); } } componentDidMount(){ const {hrmCardInfo, hrmCard} = this.props; const hrmId = this.props.params.hrmId ||''; hrmCardInfo.updateIsEditor(); hrmCardInfo.getData(hrmId); hrmCardInfo.getRightMenu(hrmId); hrmCard.setTopButtons(this.getTopButtons.bind(this)); hrmCard.setTopRightMenus(this.getRightMenu.bind(this)); hrmCard.setTopShowDropIcon(true); } showSQR(bool,e){ const {hrmCardInfo} = this.props; e.stopPropagation && e.stopPropagation(); e.preventDefault && e.preventDefault(); e.nativeEvent && e.nativeEvent.preventDefault(); hrmCardInfo.updateShowSQR(bool); } getIcon(str) { switch(str){ case 'sendEmessage': return 'icon-coms-Send-message'; case 'openmessage': return 'icon-coms-message-o'; case 'openemail': return 'icon-coms-Send-emails'; case 'doAddWorkPlan': return 'icon-coms-New-schedule-o'; } } getRightMenu(){ const {hrmCardInfo, hrmCard} = this.props; let {isEditor, buttons, rightMenus} = hrmCardInfo; buttons = toJS(buttons); rightMenus = toJS(rightMenus); let arr = []; if (isEditor){ arr = [{ icon: , content:i18n.button.save(), key: 'save', onClick: key =>{ this.saveEditCard(); } }, { icon: , content: i18n.button.back(), key: 'back', onClick: key =>{ this.backCard(); } }] } else { !isEmpty(rightMenus) && rightMenus.forEach((c) => { let item = { icon: , content: c.menuName, key: c.menuFun, onClick: key =>{ const menuFun = c.menuFun; if(menuFun === 'showPortraitSetting'){ hrmCard[menuFun] && hrmCard[menuFun](); } this[menuFun] && this[menuFun](c.params); } } if((c.type === 'BTN_SetUserIcon' && hrmCard.uploadPortrailAuth) || c.type != 'BTN_SetUserIcon') arr.push(item); }) } return arr; } showLog(params){ window.setLogViewProps(params); } sendEmessage = () =>{ const {params} = this.props; let id = params.hrmId; if (id) PublicFunc.sendEmessage(id); } sendSmsMessage(){ const {params} = this.props; let id = params.hrmId; if (id) PublicFunc.sendSmsMessage(id); } sendMail(){ const {params} = this.props; let id = params.hrmId; if (id) PublicFunc.sendMail(id); } doAddWorkPlanByHrm(){ const {params} = this.props; let id = params.hrmId; if (id) PublicFunc.doAddWorkPlanByHrm(id); } addCoWork(){ const {params} = this.props; let id = params.hrmId; if (id) PublicFunc.addCoWork(id); } getTopButtons() { const {hrmCardInfo} = this.props; let {isEditor, buttons} = hrmCardInfo; buttons = toJS(buttons); const save = {i18n.button.save()}; const back = {i18n.button.back()}; const edit = {i18n.button.modify()}; const btns = []; if (isEditor) { if (!isEmpty(buttons) && buttons.hasSave) { btns.push(save); btns.push(back); } } else { if (!isEmpty(buttons) && buttons.hasEdit) { btns.push(edit); } } return btns; } editCard(){ const hrmId = this.props.params.hrmId ||''; const {hrmCardInfo} = this.props; hrmCardInfo.edit(hrmId); } saveEditCard(){ const hrmId = this.props.params.hrmId ||''; const {hrmCardInfo,hrmCard} = this.props; hrmCardInfo.saveEditCard(()=>{ hrmCard.getTabBaseInfo({id:hrmId}); hrmCard.setupdateStatus(); }); } backCard(){ const hrmId = this.props.params.hrmId ||''; const {hrmCardInfo} = this.props; hrmCardInfo.updateIsEditor(); hrmCardInfo.qrcode(hrmId); hrmCardInfo.updateShowSQR(false); } getSearchs(){ const {hrmCardInfo} = this.props; let {conditioninfo,hideBelongto,isEditor,form, validate,hrmId} = hrmCardInfo; let group = []; const {isFormInit} = form; let idx = 0; window.e9HideFormFieldKeys = []; isFormInit && conditioninfo.forEach((c, i) =>{ let items = []; idx++; if(c.hasResourceImage){ let resourceimg; let baseGroup = { c.items.forEach( (field, j) => { let dom = { if (v.accounttype) { hrmCardInfo.updateHideBelongto(v.accounttype.value == '0'); } }}/> if (field.conditionType == 'RESOURCEIMG' || (field.domkey && field.domkey[0] == 'belongto' && hideBelongto)) { } else { 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 }); } } }) } { c.items.forEach( (field, j) => { if (field.conditionType == 'RESOURCEIMG') { if(!isEmpty(validate)&&validate[36] && validate[36].isValidate){ const key = getKey(field); const bindObj = form.$(key); resourceimg = } } }) } {resourceimg} group.push(baseGroup); }else{ c.items.forEach( (field, j) => { if(c.hide || (!isEmpty(field.otherParams) && field.otherParams.hide)){ window.e9HideFormFieldKeys.push(field.domkey[0]); }else{ let dom = { if (v.accounttype) { hrmCardInfo.updateHideBelongto(v.accounttype.value == '0'); } }}/> if (field.conditionType == 'RESOURCEIMG' || (field.domkey && field.domkey[0] == 'belongto' && hideBelongto)) { } else { items.push({ com:( {dom} {field.domkey[0] == 'workcode' && } ), colSpan: 2 }); } } }); group.push() } }); return group } getPortraitButtons(){ const colArr = []; const {hrmCardInfo} = this.props; let {sendButtons, validate} = hrmCardInfo; sendButtons = toJS(sendButtons); const emJoinStatus = window.emJoinStatus; isArray(sendButtons) && sendButtons.forEach((item, i) => { let status = true; if(item.name == 'sendEmessage'){ status = emJoinStatus ? (!emJoinStatus.joinStatus || (emJoinStatus.status && emJoinStatus.joinStatus && emJoinStatus.emSwitch !== "0")) : false; } if(status && !isEmpty(validate)&&validate[item.validateId] && validate[item.validateId].isValidate){ colArr.push( { PublicFunc[item.funname](item.id); }} title={item.title} > ) } }) return colArr; } render() { const {hrmCardInfo} = this.props; let {isEditor, infoGroup,imgSrc,modelItems,showSQR, showBigImg,sendButtons,accountInfo,showAccountInfo,QRCodeOptions,validate,jobtitleVisible,closeJobtitleDialog,form} = hrmCardInfo; sendButtons = toJS(sendButtons); infoGroup = toJS(infoGroup); modelItems = toJS(modelItems); // infoGroup.map(info => { // info.items.map(item => { // if (item.type === "email" && !item.value.includes("@")) { // item.value = ""; // } // }) // }); const sendBtns = this.getPortraitButtons(); const hasQRCode = !isEmpty(validate) && validate[37] && validate[37].isValidate; const getPortrait =()=>{ const loadingImg = '/images/messageimages/temp/loading_wev8.gif'; const hasNoImg = ['/images/messageimages/temp/man_wev8.png', '/images/messageimages/temp/women_wev8.png', ''].indexOf(imgSrc || '') > -1; return ( {!showBigImg && {this.setState({imgSrc: addContentPath('/images/messageimages/temp/man_wev8.png')})}} onClick={()=>imgSrc && hrmCardInfo.updateShowBigImg(true)} /> } {showBigImg && {this.setState({imgSrc: addContentPath('/images/messageimages/temp/man_wev8.png')})}} onClick={()=>imgSrc && hrmCardInfo.updateShowBigImg(false)} src={`${window.ecologyContentPath || ''}${imgSrc ? imgSrc : loadingImg}`} /> } { !isEmpty(QRCodeOptions) && } {i18n.button.scanAddContacts()} ) } const getAccountinfo=()=>{ let colArr = []; let idx = 0; accountInfo && accountInfo.forEach((a,i)=>{ let showValue; if(a.showName && a.showName!=''){ showValue = window.pointerXY(event)}>{a.showName} }else{ showValue = a.value ? : ; } if(a.name=='weixin'){ colArr.push( {showWeaDialog()}}>{a.label} ); }else{ colArr.push( {a.label}: ); colArr.push( {showValue} ); } if(a.name=='lastlogindate'){ idx = i; } a.name=='lastlogindate' && colArr.push(); }); if(!showAccountInfo){ colArr.splice((idx+1)*2+1,colArr.length); } colArr.push( hrmCardInfo.updateShowAccountInfo(!showAccountInfo)}> ); return colArr; } const viewCard = ( {getPortrait()} {!isEmpty(sendBtns) && {sendBtns}} {getAccountinfo()} { modelItems && modelItems.map(c => { const fontColor = c['font-color']; return ( {window.open(c.url)}}> {c.label} {c.num} ) }) } { infoGroup && infoGroup.map((info, i) => { return ( ) }) } ) const editCard = ( {this.getSearchs()} { jobtitleVisible && ( { const { id, jobtitlemark } = datas; form.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}} /> ) } ) return ( {!isEditor ? viewCard : editCard} ) } } export default Main;
{i18n.button.scanAddContacts()}