<template>
  <div class="container normal-panel normal-margin">
    <!-- <el-button type="success" size="small">导 入</el-button> -->
    <importFile accept=".xlsx" :folderid="folderid" :bindData="{ownertable:'sat_orderclueuploadbill',ownerid:'',usetype:'default'}" @onSuccess="uploadOrderclueuploadbillByExcel">
      <a class="error-link" v-if="errorurl" :href="errorurl" slot="errorFile">下载错误数据</a>
    </importFile>
  </div>
</template>

<script>
import importFile from '@/components/import/importFile.vue'
export default {
  components:{
    importFile
  },
  data () {
    return {
      folderid:JSON.parse(sessionStorage.getItem('folderid')).appfolderid,
      errorurl:null
    }
  },
  methods:{
    async uploadOrderclueuploadbillByExcel (data,type) {
      const res = await this.$api.requested({
        "classname": "webmanage.saletool.orderclue.orderclue",
        "method": "uploadOrderclueuploadbillByExcel",
        "content": {
            "cluetype":type,
            "attachmentid":data.data.attachmentids[0]
        }
      })
      if (res.msg !== '成功') {
        this.errorurl = res.msg
      } else {
        this.errorurl = null
      }
      this.tool.showMessage(res,()=>{
        this.$emit('onSuccess')
      })
    },
  }
}

</script>
<style>
</style>
<style scoped>
.error-link{
  display: block;
  line-height: 30px;
}
</style>