<template>
  <div>
    <el-upload
      action = "https://jsonplaceholder.typicode.com/posts/"
      :on-preview="handlePictureCardPreview"
      :on-remove="handleRemove"
      list-type="picture-card"
      :on-success="uploadSuccess">
      <img src="/images/messageBoard/msg_uploadPic.png" alt="">
    </el-upload>
    <el-dialog v-model="dialogVisible" size="tiny">
      <img :src="dialogImageUrl" width="100%" alt="">
    </el-dialog>
  </div>
</template>
<script>
  export default {
    data () {
      return {
        dialogImageUrl: '',
        dialogVisible: false
      }
    },
    methods: {
      handleRemove (file, fileList) {
        console.log(file)
      },
      handlePictureCardPreview (file) {
        this.dialogImageUrl = file.url
        this.dialogVisible = true
      },
      uploadSuccess (response, file, fileList) {
        this.$emit('fileAction', file.url)
      }
    }
  }
</script>
<style>
  input[type="file"] {
    display: none;
  }
  .el-upload--picture-card {
    position: relative;
    width: 82px;
    height: 70px;
    line-height: 70px;
    background: transparent;
    cursor: pointer;
    border-radius: 0;
    box-sizing: border-box;
    border: none;
  }
  .el-upload--picture-card:hover {
    border-color: transparent;
    color: transparent;
  }
  .el-upload-list--picture-card .el-upload-list__item {
    margin: 0;
    width: 82px;
    height: 70px;
    border: 1px solid #999;
    border-radius: 0;
  }
  .el-upload-list--picture-card .el-upload-list__item-thumbnail {
    max-width: 82px;
    max-height: 70px;
  }
  .el-upload-list__item.is-success .el-upload-list__item-status-label {
    display: none;
  }
  [class*=" el-icon-"], [class^=el-icon-] {
    font-size: 14px;
  }
  .el-icon-delete2 {
    position: absolute;
    top: 3px;
    right: 3px;
  }
  .el-upload-list__item-preview .el-icon-view {
    margin-right: 7px;
  }
  .el-upload-list__item-preview:after{
    content: '查看';
    font-size: 14px;
  }
  .el-upload-list--picture-card .el-upload-list__item-actions{
    position: absolute;
    left: 0;
    top: 0;
    text-align: right;
  }
</style>
