2023-03-14 09:11:54 +08:00
|
|
|
|
import {
|
2024-12-11 15:32:14 +08:00
|
|
|
|
inject,
|
2023-03-14 09:11:54 +08:00
|
|
|
|
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
|
2024-12-11 15:32:14 +08:00
|
|
|
|
} from '../../public/pulic-func'
|
2023-03-14 09:11:54 +08:00
|
|
|
|
import {
|
2024-12-11 15:32:14 +08:00
|
|
|
|
i18n
|
|
|
|
|
|
} from '../../public/i18nbk';
|
|
|
|
|
|
|
2023-03-14 09:11:54 +08:00
|
|
|
|
import ImportResult from './ImportResult'
|
|
|
|
|
|
import ImportHistory from './ImportHistory'
|
|
|
|
|
|
|
2024-12-11 15:32:14 +08:00
|
|
|
|
@inject('hrmImportCommon')
|
2023-03-14 09:11:54 +08:00
|
|
|
|
@observer
|
|
|
|
|
|
export default class Import extends React.Component {
|
|
|
|
|
|
constructor(props) {
|
|
|
|
|
|
super(props);
|
|
|
|
|
|
this.state = {
|
|
|
|
|
|
width: 870,
|
|
|
|
|
|
height: 510,
|
|
|
|
|
|
list: [],
|
|
|
|
|
|
upStatus: '',
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getForm = () => {
|
|
|
|
|
|
const {
|
2024-12-11 15:32:14 +08:00
|
|
|
|
hrmImportCommon
|
2023-03-14 09:11:54 +08:00
|
|
|
|
} = this.props, {
|
|
|
|
|
|
importDialog
|
2024-12-11 15:32:14 +08:00
|
|
|
|
} = hrmImportCommon, {
|
2023-03-14 09:11:54 +08:00
|
|
|
|
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: (
|
2024-12-11 15:32:14 +08:00
|
|
|
|
<Row ecId={`${this && this.props && this.props.ecId || ''}_Row@u3pg88@${index}`}>
|
|
|
|
|
|
<Col ecId={`${this && this.props && this.props.ecId || ''}_Col@d34g4z@${index}`} span={1} offset={6}>
|
2023-03-14 09:11:54 +08:00
|
|
|
|
<div className='hrm-import-circle' style={{paddingLeft: IEVersion() == '-1' ? 6 : 7, marginTop: 15}}>
|
|
|
|
|
|
<div style={{paddingTop: (IEVersion() == '11' || IEVersion() == 'edge') ? 5 : 2}}>{index + 1}</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Col>
|
2024-12-11 15:32:14 +08:00
|
|
|
|
<Col ecId={`${this && this.props && this.props.ecId || ''}_Col@h1ko2g@${index}`} span={14}>
|
|
|
|
|
|
<Row ecId={`${this && this.props && this.props.ecId || ''}_Row@3swbr9@${index}`} style={{marginTop: 15}}>
|
|
|
|
|
|
<Col ecId={`${this && this.props && this.props.ecId || ''}_Col@55ag3k@${index}`} span={field.labelcol}>{field.label.length > 14 ? `${field.label.slice(0, 14)}...` : field.label}:</Col>
|
|
|
|
|
|
<Col ecId={`${this && this.props && this.props.ecId || ''}_Col@qyfneu@${index}`} span={field.fieldcol}>
|
2023-03-14 09:11:54 +08:00
|
|
|
|
{this.getElements(key, url, field)}
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
),
|
|
|
|
|
|
colSpan: 1,
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
if (i == 1) { //导入说明
|
|
|
|
|
|
c.items.map((field, index) => {
|
|
|
|
|
|
let p = field.value;
|
|
|
|
|
|
let url = field.link ? field.link : '';
|
|
|
|
|
|
arr.push({
|
|
|
|
|
|
com: (
|
2024-12-11 15:32:14 +08:00
|
|
|
|
<Row ecId={`${this && this.props && this.props.ecId || ''}_Row@r3k3h0@${index}`}>
|
|
|
|
|
|
<Col ecId={`${this && this.props && this.props.ecId || ''}_Col@2yfn9e@${index}`} span={1} offset={6} style={{marginTop: 15}}>
|
2023-03-14 09:11:54 +08:00
|
|
|
|
<div className='hrm-import-circle' style={{paddingLeft: IEVersion() == '-1' ? 6 : 7, paddingLeft: (index > 8) ? 3 : 6}}>
|
|
|
|
|
|
<div style={{paddingTop: (IEVersion() == '11' || IEVersion() == 'edge') ? 5 : 2}}>{index + 1}</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Col>
|
2024-12-11 15:32:14 +08:00
|
|
|
|
<Col ecId={`${this && this.props && this.props.ecId || ''}_Col@z6k87f@${index}`} span={14} style={{marginTop: 15}}>
|
2023-03-14 09:11:54 +08:00
|
|
|
|
{this.getImportInstructions(p, url, index)}
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
),
|
|
|
|
|
|
colSpan: 1
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2024-12-11 15:32:14 +08:00
|
|
|
|
_arr.push(<div style={{color: '#484848'}}><WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@a3rsv9@${i}`} needTigger={true} title={c.title} showGroup={c.defaultshow} items={arr} col={1} /></div>)
|
2023-03-14 09:11:54 +08:00
|
|
|
|
});
|
|
|
|
|
|
return _arr;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getElements = (key, url, field) => {
|
|
|
|
|
|
const {
|
2024-12-11 15:32:14 +08:00
|
|
|
|
hrmImportCommon
|
2023-03-14 09:11:54 +08:00
|
|
|
|
} = this.props, {
|
|
|
|
|
|
setExcelFileNo,
|
|
|
|
|
|
importDialog,
|
|
|
|
|
|
setSelectedValue
|
2024-12-11 15:32:14 +08:00
|
|
|
|
} = hrmImportCommon, {
|
2023-03-14 09:11:54 +08:00
|
|
|
|
templetName,
|
|
|
|
|
|
selectedValue,
|
|
|
|
|
|
form,
|
|
|
|
|
|
} = importDialog, {
|
|
|
|
|
|
upStatus,
|
|
|
|
|
|
list
|
|
|
|
|
|
} = this.state;
|
|
|
|
|
|
|
|
|
|
|
|
let dom;
|
|
|
|
|
|
if (key == 'templet') {
|
|
|
|
|
|
dom = this.getTempletElement(url, selectedValue, templetName);
|
|
|
|
|
|
} else if (key == 'excelfile') {
|
|
|
|
|
|
dom = (<div>
|
|
|
|
|
|
<div style={{float: 'left',marginTop: -10}}>
|
2024-12-11 15:32:14 +08:00
|
|
|
|
<WeaUpload ecId={`${this && this.props && this.props.ecId || ''}_WeaUpload@lcyams`}
|
2023-03-14 09:11:54 +08:00
|
|
|
|
uploadUrl='/api/doc/upload/uploadFile'
|
|
|
|
|
|
category='string'
|
2024-12-11 15:32:14 +08:00
|
|
|
|
limitType='xls'
|
2023-03-14 09:11:54 +08:00
|
|
|
|
datas={upStatus === 'uploaded' ? list : []}
|
|
|
|
|
|
onChange={(id, list) => {this.setState({list:list}); setExcelFileNo(id)}}
|
|
|
|
|
|
onUploading={status => this.handleUploading(status)}
|
|
|
|
|
|
>
|
2024-12-11 15:32:14 +08:00
|
|
|
|
<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@hmrzeo`}>{i18n.button.selectFile()}</Button>
|
2023-03-14 09:11:54 +08:00
|
|
|
|
</WeaUpload>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style={{float: 'left', paddingLeft: 10}}>
|
2024-12-11 15:32:14 +08:00
|
|
|
|
{ list.length == 0 ? <p>{i18n.label.noFileSelected()}</p> : list.map(file => <p>{file.filename}</p>) }
|
2023-03-14 09:11:54 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>)
|
|
|
|
|
|
} else {
|
2024-12-11 15:32:14 +08:00
|
|
|
|
dom = <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@tsac1c`} fieldConfig={field} form={form} formParams={form.getFormParams()} />
|
2023-03-14 09:11:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
return dom;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getImportInstructions = (val, url, index) => {
|
|
|
|
|
|
const {
|
2024-12-11 15:32:14 +08:00
|
|
|
|
hrmImportCommon
|
2023-03-14 09:11:54 +08:00
|
|
|
|
} = this.props, {
|
|
|
|
|
|
importDialog
|
2024-12-11 15:32:14 +08:00
|
|
|
|
} = hrmImportCommon, {
|
2023-03-14 09:11:54 +08:00
|
|
|
|
templetName,
|
|
|
|
|
|
selectedValue,
|
|
|
|
|
|
} = importDialog;
|
|
|
|
|
|
|
|
|
|
|
|
let p;
|
|
|
|
|
|
if (index == 0) {
|
|
|
|
|
|
let dom = this.getTempletElement(url, selectedValue, templetName);
|
2024-12-11 15:32:14 +08:00
|
|
|
|
p = (<p>{i18n.label.downloadTemplateFirst()}:{dom}</p>);
|
2023-03-14 09:11:54 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
p = (<p>{val}</p>);
|
|
|
|
|
|
}
|
|
|
|
|
|
return p;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getTempletElement = (url, selectedValue, templetName) => {
|
|
|
|
|
|
let dom;
|
|
|
|
|
|
let urlArr = url.split(';');
|
|
|
|
|
|
if (urlArr.length > 1) {
|
|
|
|
|
|
if (selectedValue == 'workcode') {
|
2024-12-11 15:32:14 +08:00
|
|
|
|
dom = <a href={urlArr[0]}>{templetName}</a>;
|
2023-03-14 09:11:54 +08:00
|
|
|
|
} else {
|
2024-12-11 15:32:14 +08:00
|
|
|
|
dom = <a href={urlArr[1]}>{templetName}</a>;
|
2023-03-14 09:11:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2024-12-11 15:32:14 +08:00
|
|
|
|
dom = <a href={url}>{templetName}</a>;
|
2023-03-14 09:11:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
return dom
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handleUploading = (status) => {
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
upStatus: status
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (status == 'uploading') {
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
list: []
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getButtons = () => {
|
|
|
|
|
|
const {
|
2024-12-11 15:32:14 +08:00
|
|
|
|
hrmImportCommon
|
2023-03-14 09:11:54 +08:00
|
|
|
|
} = this.props, {
|
|
|
|
|
|
submitExcel,
|
|
|
|
|
|
queryRecord,
|
|
|
|
|
|
importDialog,
|
2024-12-11 15:32:14 +08:00
|
|
|
|
} = hrmImportCommon, {
|
2023-03-14 09:11:54 +08:00
|
|
|
|
upStatus
|
|
|
|
|
|
} = this.state;
|
|
|
|
|
|
|
|
|
|
|
|
return [
|
2024-12-11 15:32:14 +08:00
|
|
|
|
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@2fiagn@1`} type="primary" disabled={upStatus === 'uploaded' ? false : true} onClick={() => submitExcel()}>{i18n.button.submit()}</Button>),
|
|
|
|
|
|
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@q04w9s@2`} type="primary" onClick={() => queryRecord()}>{i18n.button.importHistoryQuery()}</Button>),
|
|
|
|
|
|
(<WeaMoreButton ecId={`${this && this.props && this.props.ecId || ''}_WeaMoreButton@oizt3r@3`} />)
|
2023-03-14 09:11:54 +08:00
|
|
|
|
];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
|
const {
|
2024-12-11 15:32:14 +08:00
|
|
|
|
hrmImportCommon
|
2023-03-14 09:11:54 +08:00
|
|
|
|
} = this.props, {
|
|
|
|
|
|
importDialog,
|
|
|
|
|
|
resultDialog,
|
|
|
|
|
|
recordDialog,
|
|
|
|
|
|
setImportDialogVisible
|
2024-12-11 15:32:14 +08:00
|
|
|
|
} = hrmImportCommon, {
|
2023-03-14 09:11:54 +08:00
|
|
|
|
visible,
|
|
|
|
|
|
title,
|
|
|
|
|
|
loading
|
|
|
|
|
|
} = importDialog, {
|
|
|
|
|
|
width,
|
|
|
|
|
|
height,
|
|
|
|
|
|
} = this.state;
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div>
|
2024-12-11 15:32:14 +08:00
|
|
|
|
<WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@79hw9l`}
|
2023-03-14 09:11:54 +08:00
|
|
|
|
title={title}
|
|
|
|
|
|
icon="icon-coms-hrm"
|
|
|
|
|
|
iconBgcolor="#217346"
|
|
|
|
|
|
visible={visible}
|
|
|
|
|
|
closable={true}
|
|
|
|
|
|
onCancel={() => setImportDialogVisible(false) }
|
|
|
|
|
|
buttons={this.getButtons()}
|
|
|
|
|
|
style={{width: width, height: height}}
|
|
|
|
|
|
onChangeHeight={(h) => this.setState({height: h})}
|
|
|
|
|
|
>
|
2024-12-11 15:32:14 +08:00
|
|
|
|
<Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@qa42zo`} spinning={loading}>
|
|
|
|
|
|
<WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@vcz1bi`} height={height}>
|
2023-03-14 09:11:54 +08:00
|
|
|
|
{this.getForm()}
|
|
|
|
|
|
</WeaNewScroll>
|
|
|
|
|
|
</Spin>
|
|
|
|
|
|
</WeaDialog>
|
2024-12-11 15:32:14 +08:00
|
|
|
|
{resultDialog.visible && <ImportResult ecId={`${this && this.props && this.props.ecId || ''}_ImportResult@fd6jt3`} />}
|
|
|
|
|
|
{recordDialog.visible && <ImportHistory ecId={`${this && this.props && this.props.ecId || ''}_ImportHistory@weby4j`} />}
|
2023-03-14 09:11:54 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|