import { inject, observer } from 'mobx-react'; import { WeaUpload, WeaDialog, WeaSelect, WeaNewScroll, WeaMoreButton, WeaSearchGroup, } from 'ecCom' import { WeaSwitch } from 'comsMobx'; import { Row, Col, Spin, Button, } from 'antd' import { IEVersion } from '../../public/pulic-func' import { i18n } from '../../public/i18nbk'; import ImportResult from './ImportResult' import ImportHistory from './ImportHistory' @inject('hrmImportCommon') @observer export default class Import extends React.Component { constructor(props) { super(props); this.state = { width: 870, height: 510, list: [], upStatus: '', } } getForm = () => { const { hrmImportCommon } = this.props, { importDialog } = hrmImportCommon, { condition, form, } = importDialog, { isFormInit } = form; let _arr = []; isFormInit && condition.map((c, i) => { let arr = []; if (i == 0) { //基本信息 c.items.map((field, index) => { let key = field.domkey[0]; let url = field.value ? field.value : ''; arr.push({ com: (
{index + 1}
{field.label.length > 14 ? `${field.label.slice(0, 14)}...` : field.label}: {this.getElements(key, url, field)}
), colSpan: 1, }) }) } if (i == 1) { //导入说明 c.items.map((field, index) => { let p = field.value; let url = field.link ? field.link : ''; arr.push({ com: (
8) ? 3 : 6}}>
{index + 1}
{this.getImportInstructions(p, url, index)}
), colSpan: 1 }) }) } _arr.push(
) }); return _arr; } getElements = (key, url, field) => { const { hrmImportCommon } = this.props, { setExcelFileNo, importDialog, setSelectedValue } = hrmImportCommon, { templetName, selectedValue, form, } = importDialog, { upStatus, list } = this.state; let dom; if (key == 'templet') { dom = this.getTempletElement(url, selectedValue, templetName); } else if (key == 'excelfile') { dom = (
{this.setState({list:list}); setExcelFileNo(id)}} onUploading={status => this.handleUploading(status)} >
{ list.length == 0 ?

{i18n.label.noFileSelected()}

: list.map(file =>

{file.filename}

) }
) } else { dom = } return dom; } getImportInstructions = (val, url, index) => { const { hrmImportCommon } = this.props, { importDialog } = hrmImportCommon, { templetName, selectedValue, } = importDialog; let p; if (index == 0) { let dom = this.getTempletElement(url, selectedValue, templetName); p = (

{i18n.label.downloadTemplateFirst()}:{dom}

); } else { p = (

{val}

); } return p; } getTempletElement = (url, selectedValue, templetName) => { let dom; let urlArr = url.split(';'); if (urlArr.length > 1) { if (selectedValue == 'workcode') { dom = {templetName}; } else { dom = {templetName}; } } else { dom = {templetName}; } return dom } handleUploading = (status) => { this.setState({ upStatus: status }); if (status == 'uploading') { this.setState({ list: [] }); } } getButtons = () => { const { hrmImportCommon } = this.props, { submitExcel, queryRecord, importDialog, } = hrmImportCommon, { upStatus } = this.state; return [ (), (), () ]; } render() { const { hrmImportCommon } = this.props, { importDialog, resultDialog, recordDialog, setImportDialogVisible } = hrmImportCommon, { visible, title, loading } = importDialog, { width, height, } = this.state; return (
setImportDialogVisible(false) } buttons={this.getButtons()} style={{width: width, height: height}} onChangeHeight={(h) => this.setState({height: h})} > {this.getForm()} {resultDialog.visible && } {recordDialog.visible && }
) } }