import {
	observer
} from 'mobx-react';
import {
	Button,
} from 'antd';
import {
	WeaUpload
} from "ecCom";

@observer
export default class Upload extends React.Component{
	render() {
		const {
			name,
			type,
			store
		} = this.props, {
			uploadStatus,
			uploadList,
			handleUploadChange,
			handleUploadStatus,
		} = store;

		const datas = (uploadStatus === "uploaded") ? uploadList : [];
		const loading = ["true", "uploading"].includes(uploadStatus) ? true : false;

		return (
			<WeaUpload ecId={`${this && this.props && this.props.ecId || ''}_WeaUpload@abvsq8`}
				uploadUrl='/api/doc/upload/uploadFile'
				category='string'
          		limitType='jpg,gif,png'
          		datas={datas}
          		maxFilesNumber={10}
          		maxUploadSize={10}
          		onChange={(ids, list)=>handleUploadChange(ids, list,type)}
          		onUploading={handleUploadStatus}
			>
				<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@n7moqd`} type="primary" loading={loading}>{name}</Button>
			</WeaUpload>
		);
	}
}