import React, { Component } from 'react'; import {Link} from 'react-router-dom'; import axios from "axios"; import {Popconfirm} from "antd"; class Attachment extends Component{ constructor(props){ super(props); this.state={ attachments:undefined, canDelete: false, Deleted:[] } } componentDidMount=()=>{ this.getDetail(); } getDetail=()=>{ this.setState({ attachments: this.props.attachments, canDelete: this.props.canDelete }) } deleteAttachment = (id) => { const url = `/attachments/${id}.json` axios.delete(url, { }).then((response) => { if (response.data) { if (response.data.status === 0) { this.setState({ Deleted: this.state.Deleted.concat(id) }); this.props.showNotification("附件删除成功") }else{ this.props.showNotification(response.data.message) } } }).catch(function (error) { console.log(error); }); } render(){ const { Deleted, attachments, canDelete } = this.state; return(