picturesWall.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import React, { Component } from "react";
  2. import { Modal, Icon, Upload } from "antd";
  3. import { timingSafeEqual } from "crypto";
  4. import ImgList from "../../../../common/imgList";
  5. class PicturesWall extends Component {
  6. constructor(props) {
  7. super(props);
  8. this.state = {
  9. previewVisible: false,
  10. previewImage: "",
  11. fileList: this.props.pictureUrl
  12. };
  13. this.handleCancel = this.handleCancel.bind(this);
  14. this.handleChange = this.handleChange.bind(this);
  15. this.handlePreview = this.handlePreview.bind(this);
  16. }
  17. handleCancel() {
  18. this.setState({
  19. previewVisible: false
  20. });
  21. }
  22. handlePreview(file) {
  23. this.setState({
  24. previewImage: file.url || file.thumbUrl,
  25. previewVisible: true
  26. });
  27. }
  28. handleChange(info) {
  29. let fileList = info.fileList;
  30. this.setState({
  31. fileList
  32. });
  33. this.props.fileList(fileList);
  34. }
  35. componentWillReceiveProps(nextProps) {
  36. this.state.fileList = nextProps.pictureUrl;
  37. this.state.pojectApplicationUrl = undefined;
  38. }
  39. render() {
  40. const { previewVisible, previewImage, fileList } = this.state;
  41. const uploadButton = (
  42. <div>
  43. <Icon type="plus" />
  44. <div className="ant-upload-text">点击上传</div>
  45. </div>
  46. );
  47. return (
  48. <div style={{ display: "inline-block" }}>
  49. <ImgList
  50. domId={this.props.domId}
  51. uploadConfig={{
  52. action:globalConfig.context + this.props.url,
  53. data:{ sign: this.props.sign },
  54. multiple:true,
  55. listType:"picture-card",
  56. }}
  57. onChange={(infor)=>{
  58. this.handleChange(infor)
  59. }}
  60. fileList={fileList}
  61. />
  62. </div>
  63. );
  64. }
  65. }
  66. export default PicturesWall;