import React from 'react';
import {
	inject,
	observer,
} from 'mobx-react';
import {
	WeaUpload,
	WeaFormItem,
	WeaLocaleProvider
} from 'ecCom';
import {
	Button
} from 'antd';
const getLabel = WeaLocaleProvider.getLabel;

@inject('hrmStaffCareReminder')
@observer
class Upload extends React.Component {
	constructor(props) {
		super(props);
	}

	render() {
		const {
			hrmStaffCareReminder,
			wrapperStyle
		} = this.props, {
			upload,
			onUploading,
			tab,
		} = hrmStaffCareReminder, {
			upStatus,
		} = upload, {
			selectedKey
		} = tab;

		return (
			<WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@n8zcgh`}
	            label={getLabel(22923, '图片设置')}
	            labelCol={{span: 6}}
	            wrapperCol={{span: 18}}
	            style={wrapperStyle}
          	>
          		<WeaUpload ecId={`${this && this.props && this.props.ecId || ''}_WeaUpload@vcn6um`}
			        uploadUrl='/api/doc/upload/uploadFile'
			        category='string'
          			limitType='jpg,gif,png'
          			datas={(upStatus === 'uploaded')  ? upload.list : []}
          			showClearAll={false}
          			maxFilesNumber={10}
          			maxUploadSize={10}
                    onChange={(id, list) =>  ['setList','setImageId'].map( (f,i) => this.props.hrmStaffCareReminder[f](i === 0 ? list : id) ) }
                    onUploading={onUploading}
      			>
      				<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@mv1a82`} type='primary'>{getLabel('125333','选择文件')}</Button>
      			</WeaUpload>
      			<span style={{position: 'absolute',top: 10,left: 90}}>
      				{selectedKey === '0' ? getLabel('502033', '最大 10M/个（建议尺寸：475*500）') : getLabel('504616', '最大 10M/个（建议尺寸：700*330）')}
      			</span>
          	</WeaFormItem>
		)
	}
}

export default Upload