<template>
  <a-button class="derive" type="dashed" shape="round" icon="download" @click="downLoad" />
</template>
<script>
import storage from 'store'
import { getStorageDownUrl } from '@/api/storage'
export default {
  name: 'DeriveButton',
  data () {
    return {}
  },
  props: {
    queryParam: {
      type: Object,
      default: null
    },
    listCount: {
      type: Number,
      default: 0
    }
  },
  methods: {
    downLoad () {
        if (this.listCount > 0) {
          const queryParam = this.queryParam
          let downUrl = getStorageDownUrl() + '?user_id=' + storage.get('userid')
          for (const key in queryParam) {
            downUrl = downUrl + '&' + key + '=' + queryParam[key]
          }
          window.open(downUrl)
        } else {
          this.$notification.error({
            message: '温馨提醒',
            description: '数据为空不能下载！'
          })
        }
    }
  }
}
</script>
<style lang="less" scoped>
.derive {
  margin-left: 8px;
}
</style>
