<template>
  <div class="withinLine">
    <el-button @click="abnormal" :disabled="disabled" type="primary" size="mini">取消工单</el-button>
  </div>
</template>

<script>
import buttonMixin from './button_mixin.js'
import { MessageBox } from '@zjlib/element-ui2'
import { orderBaseCancel } from "@/api/workOrderPool.js"
export default {
  mixins: [buttonMixin],
  methods: {
    abnormal() {
      this.lockBtn()
      MessageBox.confirm('是否确定取消此单，请谨慎操作', '取消工单', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        orderBaseCancel({
          orderBaseId: this.orderInfo.id
        }).then(res => {
          // 编辑保存后不跳转列表，刷新数据
          this.acquireVerify(this, 'getorderDetail')()
          // 刷新操作记录
          this.acquireVerify(this, 'getOrderBaseLogList')()
          this.$message({
            type: 'success',
            message: '取消成功！'
          })
        }).catch(() => {
          this.unlockBtn()
        })
      }).catch(() => {
        this.unlockBtn()
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.withinLine {
  display: inline-block;

  ::v-deep .el-button {
    margin-left: 0;
    margin-right: 10px;
    margin-bottom: 10px;
  }
}
</style>
