<template>
  <div class="bottom">
    <div class="file-box">
      <file-item :isDownLoad="false" :isDelete="true" :itemStyle="itemDrawerStyle" :fileData="fileType.fileList(data.attinfos)"
        @deleteSuccess="deleteSuccess"></file-item>
    </div>
    <upload :folderid="folderid"
      :bindData="{ ownertable: idname.slice(0, idname.length - 2), ownerid: data[idname], usetype: '' }"
      @onSuccess="queryAttments"></upload>
  </div>
</template>

<script>
import FileItem from '@/components/file-block/index'
import upload from '@/components/upload/hw_obs_upload.vue'
import { log } from '@antv/g2plot/lib/utils';
export default {
  props:['data'],
  name: '',
  data() {
    return {
      idname:'sa_project_stageworkid',
      folderid:JSON.parse(sessionStorage.getItem('folderid')).appfolderid,
      itemDrawerStyle: {
        img: {
          width: 53,
          height: 64
        },
        title: 16,
        descript: 12
      },
    };
  },
  components: {
    FileItem,
    upload
  },
  computed:{
  },
  watch:{
  },
  methods: {
    deleteSuccess (data) {
      console.log(data);
      this.$emit('deleteSuccess',data)
    },
    async queryAttments (data) {
      let param = {
        "classname": "system.attachment.Attachment",
        "method": "createFileLink",
        "content": {
          "ownertable": "sa_project_stagework",
          "ownerid": this.data.sa_project_stageworkid,
          "usetype": "default",
          "attachmentids" : data.data.attachmentids
        }
      }
      let res = await this.$api.requested(param)   
      this.$emit('onSuccess',res.data[0])   
    }
  },
};
</script>

<style scoped>
  .bottom {
    margin-top: 15px;
  }
</style>
