<template>
  <div class="app-container">
    <el-form>
      <el-form-item label="明细文件">
        <el-upload
          class="upload-demo"
          action="http://wms.xingyunyi.cn/api/Finance/updateLoadFile"
          :on-success="changeFileUrl"
        >
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传zip文件</div>
        </el-upload>
      </el-form-item>

      <el-button @click="start">
        开始任务
      </el-button>
    </el-form>
  </div>
</template>
<script>
export default {
  name: 'BatchInput',

  data() {
    return {
      fileUrl: ''
    }
  },
  mounted() {
    // this.openConnection()
  },
  methods: {
    changeFileUrl(r) {
      this.fileUrl = r.Data.url
    },
    start() {
      debugger
      if (this.$store.getters.isConnection) {
        this.$store.getters.connection.invoke('Start', this.fileUrl).then(() => {
          console.info('开始任务成功')
        }).catch(r => {
          this.$alert('开始任务失败' + r)
        })
      } else {
        this.$alert('当前webSocket未连接')
      }
    }
  }
}
</script>
