<template>
  <div class="withinLine">
    <el-button @click="urgent" :disabled="disabled" type="primary" size="mini">工单驳回</el-button>
  </div>
</template>

<script>
import buttonMixin from './button_mixin.js'
import { MessageBox } from '@zjlib/element-ui2'
import { orderBaseReject } from '@/api/workOrderPool.js'
export default {
  mixins: [buttonMixin],
  methods: {
    urgent() {
      this.lockBtn()
      MessageBox.confirm('是否确定工单驳回？', '工单驳回', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          orderBaseReject({
            orderBaseId: this.orderInfo.id
          })
            .then(res => {
              this.unlockBtn()
              // 编辑保存后不跳转列表，刷新数据
              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>
