import React from 'react';
import { Icon, Upload, Modal } from 'antd';
import ImgList from "../../common/imgList";

const PicturesWall = React.createClass({
  getInitialState() {
    return {
      previewVisible: false,
      previewImage: '',
      fileList: [],
    }
  },
  handleCancel() {
    this.setState({ previewVisible: false })
  },
  handlePreview(file) {
    this.setState({
      previewImage: file.url || file.thumbUrl,
      previewVisible: true,
    });
  },
  handleChange(info) {
    let fileList = info.fileList;
    this.setState({ fileList });
    this.props.fileList(fileList);
  },
  componentWillReceiveProps(nextProps) {
    this.state.fileList = nextProps.pictureUrl;
  },
  render() {
    const { previewVisible, previewImage, fileList } = this.state;
    //      预览图标             删除图标
    const { showPreview = true, showRemove = true } = this.props
    const uploadButton = (
      <div>
        <Icon type="plus" />
        <div className="ant-upload-text">点击上传</div>
      </div>
    );
    return (
      <div className="clearfix">
        <ImgList
          domId={this.props.domId}
          uploadConfig={{
            action: globalConfig.context + this.props.data.url,
            data: { 'sign': this.props.data.sign },
            listType: "picture-card",
            multiple: true,
            showUploadList: { 'showPreviewIcon': showPreview, 'showRemoveIcon': showRemove }
          }}
          onChange={(infor) => {
            this.handleChange(infor)
          }}
          fileList={fileList}
        />
      </div>
    );
  }
});

export default PicturesWall;