import React from 'react'; import { inject, observer} from 'mobx-react'; import {WeaAlertPage,WeaTools,WeaTab,WeaTop,WeaSearchGroup,WeaFormItem,WeaRightMenu} from 'ecCom'; import { Tabs,Button,Table,Form, Modal,message,Row,Col, Spin} from 'antd'; import {WeaSwitch} from 'comsMobx'; import * as mobx from 'mobx'; import isEmpty from 'lodash/isEmpty'; const toJS = mobx.toJS; import * as PublicFunc from '../util/pulic-func'; window.openFullWindowForXtable = PublicFunc.openFullWindowForXtable; import moment from 'moment'; import {WeaTableNew} from 'comsMobx'; const WeaTable = WeaTableNew.WeaTable; import cloneDeep from 'lodash/cloneDeep' import {i18n} from '../public/i18n'; import '../style/financeExpand.less'; import AlertPage from '../public/components/AlertPage.js'; import VerifyResourceID from './financeExpand/VerifyResourceID.js'; @inject('hrmFinance') @inject('hrmCard') @observer class HrmFinance extends React.Component { componentWillReceiveProps(nextProps) { if (this.props.location.key !== nextProps.location.key) { this.showDialog(); } } componentDidMount() { this.showDialog((token) => { const {hrmCard} = this.props; hrmCard.setTopButtons(this.getTopButtons.bind(this)); hrmCard.setTopRightMenus(this.getRightMenu.bind(this)); hrmCard.setTopShowDropIcon(true); this.init(token); }); } showDialog = (cb)=>{ const { hrmFinance } = this.props, { financeExpand } = hrmFinance; if (window.doCheckSecondaryVerify4ec) { window.doCheckSecondaryVerify4ec({mouldCode: 'HRM', itemCode: 'SALARY'}, res => { if (res.status == "1") { cb && cb(res.token); } financeExpand.loading = false; financeExpand.isNeedSecondPwdVerify = false; }) } else { financeExpand.fetchSecondPwdVerifyInfo().then(isNeedSecondPwdVerify => { isNeedSecondPwdVerify && financeExpand.openDialog(); cb && cb(); }); } } init(token) { const {hrmFinance} = this.props; const hrmId = this.props.params.hrmId || ''; hrmFinance.hrmId = hrmId; hrmFinance.init(token); hrmFinance.getTabInfo(); } componentWillUnmount() { const { financeExpand } = this.props.hrmFinance, { resetParams } = financeExpand; resetParams(); } render(){ const { hrmFinance } = this.props; let {title,form,tabDatas,table,formFields,tabkey,isEditor} = hrmFinance; let qname = ''; const {query} = this.props.location; const formParams = form.getFormParams(); const { financeExpand } = hrmFinance, { isNeedSecondPwdVerify, dialogStore, loading, } = financeExpand, { visible } = dialogStore; if (isNeedSecondPwdVerify) { return (
{ visible && }
) } try{ return (
} iconBgcolor='#217346' buttons={this.getTopButtons()} buttonSpace={10} showDropIcon={true} dropMenuDatas={this.getRightMenu()} />
{this.getFormField()}
{this.getTable()}
); }catch(e){ return (
{i18n.message.authFailed()}
) } } editCard = () => { const {hrmFinance} = this.props; hrmFinance.edit(); } saveEditCard = () => { const {hrmFinance} = this.props; hrmFinance.save(); } backCard = () => { this.init(); } getTable = () => { const { hrmFinance } = this.props; let {table} = hrmFinance; table = toJS(table); if(!isEmpty(table)){ return (
) } } reRenderColumns = (columns) => { columns.forEach(c=>{ if(c.dataIndex.indexOf('column_')!=-1){ c.render = function(text, record){ return {typeof(record[c.dataIndex]) == 'object' ? record[c.dataIndex].value : record[c.dataIndex]} } } }) return columns; } getFormField = () => { const {hrmFinance} = this.props; let {form, formFields, isEditor} = hrmFinance; const {isFormInit} = form; let group = []; isFormInit && formFields.forEach((c, i) =>{ let items = []; c.items.forEach( (field, j) => { items.push({ com:( ), colSpan: 1 }); }); group.push() }); return group; } onTabChange = (key) => { const {hrmFinance} = this.props; hrmFinance.changeTab(key); } getRightMenu = () => { const {hrmFinance, hrmCard} = this.props; const {isEditor, buttons, hrmId} = hrmFinance; let arr = []; try{ if(buttons && buttons.hasEdit){ 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 { arr = [{ icon: , content:i18n.button.modify(), key: 'editCard', onClick: key =>{ this.editCard(); } } ] arr.push( { icon: , content:i18n.button.log(), key: 'showLog', onClick: key =>{ window.setLogViewProps({logSmallType:i18n.smallType.HRM_RSOURCE_CARD_FINANCE,targetId:hrmId}); } } ) } } }catch(e){} return arr; } getTopButtons = () => { const {hrmFinance} = this.props; const {isEditor, buttons} = hrmFinance; const save = ; const back = ; const edit = ; const btns = []; try{ if (isEditor) { if (buttons && buttons.hasSave) { btns.push(save); btns.push(back); } } else { if (buttons && buttons.hasEdit) { btns.push(edit); } } }catch(e){} return btns; } } export default HrmFinance