<template>
  <div class="app-container" style="width:50%">
    <el-form v-loading="loading">
      <el-form-item label="XYY单号" label-width="100px">
        <el-input v-model="SysmteNos" type="textarea" :rows="25" placeholder="请输入XYY单号,每行一个" />
      </el-form-item>
    </el-form>
    <div class="text-center">
      <el-button type="success" @click="submit">确认取消</el-button>
    </div>
    <el-alert
    title="不可取消"
    type="warning"
    show-icon
    :description=this.errorTip
    v-if="this.errorTip!=''"
    >
  </el-alert>
  </div>
</template>
<script>
import { CancelOrders } from '@/api/channel/CancelOrder'
export default {
  name: 'ChannelOrderCancel',
  data: function() {
    return {
      loading: false,
      SysmteNos: '',
      submitLoading: false,
      errorTip:'',
    }
  },
  methods: {
    submit() {
      if (!this.SysmteNos) {
        this.$message({ message: '请填写XYY单号', type: 'error' })
        return
      }
      const SysmteNos = this.SysmteNos.split(/[\n,]/)
      const param={SysmteNos}
      this.loading = true
      if (this.submitLoading) { return false }
      this.submitLoading = true
      this.errorTip='';
      CancelOrders(param)
        .then((res) => {
          console.log(res);
          if(res.length>0){this.$message({ message: '可取消渠道单，已操作取消！', type: 'warning' });this.errorTip=res.join(',');}
          else{this.$message({ message: '已操作取消！', type: 'success' })}
          this.SysmteNos=''
        })
        .finally(() => {
          this.loading = false
          this.submitLoading = false
        })
    }
  }
}
</script>
