<template>
  <div>
    <el-dropdown-item @click.native="dialogImageVisible = true">设置产品图</el-dropdown-item>
    <el-dialog title="设置产品图" append-to-body :visible.sync="dialogImageVisible">
      <div class="flex-align-center">
        <previewImage style="margin-right:10px;margin-top:0" v-for="item in data.attinfos" :key="item.index" :image="item" :deletebtn="true" @onSuccess="clearFile(item)"></previewImage>
        <uploadFile :folderid="folderid" accept=".JPG,.PNG,.jpg,.png" btntype="image" :bindData="{ownertable:'plm_item',ownerid:data.itemid,usetype:'default'}" @onSuccess="uploadSuccess"></uploadFile>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import previewImage from '@/components/previewImage/index'
import uploadFile from '@/components/upload/hw_obs_upload'

export default {
  props:['data'],
  components:{
    previewImage,
    uploadFile
  },
  data () {
    return {
      folderid:JSON.parse(sessionStorage.getItem('folderid')).appfolderid,
      dialogImageVisible:false
    }
  },
  methods:{
    uploadSuccess () {
      this.$emit('uploadSuccess')
    },
    clearFile (item) {
      this.data.attinfos = this.data.attinfos.filter(e=>{
        return e.attachmentid !== item.attachmentid
      })
    }
  }
}

</script>
<style>
</style>