<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 { orderBaseFlag } from '@/api/workOrderPool.js'
export default {
  mixins: [buttonMixin],
  methods: {
    urgent() {
      this.lockBtn()
      MessageBox.confirm('加急操作，会消息通知所有订单相关人员，请谨慎操作', '加急确认', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          orderBaseFlag({ flag: true, orderBaseId: this.orderInfo.id, orderFlagEnum: 'JIA_JI' })
            .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>
