<template>
  <div class="app-container">
    <div class="itemGroup">
      <el-divider content-position="left">FBA下单</el-divider>
      <el-form>
        <el-form-item label="IB-FBA批量下单">
          <el-upload
            :action="url"
            :headers="header"
            :multiple="false"
            :on-success="importSuccess"
            :loading="loading"
            :on-error="importError"
            :before-upload="onImporting"
          >
            <el-button size="small" type="primary">点击上传</el-button>
          </el-upload>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import { getToken } from '@/utils/auth'

export default {
  name: 'ImportIbFba',

  data() {
    return {
      url: 'http://120.24.149.148:9518/api/order/ImportIBFba',
      header: { Authorization: 'token ' + getToken() },
      loading: false
    }
  },

  mounted() {},

  methods: {
    importSuccess(response, file, fileList) {
      this.$message('上传成功')
      this.loading = false
    },
    importError() {
      this.$message('上传失败')
      this.updateTHOrderLoading = false
    },
    onImporting() {
      if (this.updateTHOrderLoading) {
        this.$message('上传中，请勿重复上传')
        return false
      } else {
        this.updateTHOrderLoading = true
      }
    }
  }
}
</script>

<style lang="scss" scoped></style>
