<template>
  <div class="image-panel">
    <i v-if="deletebtn" class="el-icon-error close-btn" @click="deleteFileLink"></i>
    <el-image 
      style="width: 100%;"
      :src="image.url" 
      :preview-src-list="srcList">
    </el-image>
  </div>
</template>

<script>
export default {
  props:['image','deletebtn'],
  data () {
    return {
      srcList:[]
    }
  },
  methods:{
    async deleteFileLink () {
      const res = await this.$api.requested({
        "classname": "system.attachment.Attachment",
        "method": "deleteFileLink",
        "content": {
          "linksids":[this.image.linksid]
        }
      })
      res.code === 1?this.$emit('onSuccess'):''
    },
  },
  watch: {
    image: {
      deep: true,
      immediate: true,
      handler(newValue, oldValue) {
        this.srcList.push(this.image.url)
      },
    }
  }
}

</script>
<style scoped>
.demo-image__preview{
  position: relative;
}
</style>