<template>
  <div>
    <el-button slot="reference" size="mini" style="width:100%" @click="onShow" type="primary" >反审核</el-button>
  </div>
</template>

<script>
export default {
  name: "deApprove",
  props:["data","disabled"],
  methods:{
    onShow() {
      this.$confirm('此操作将修改报价单的审核状态, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.onCheck()
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消反审核(退回)'
        });
      });
    },
    async onCheck(){
      if (this.data.status === '审核'){
        const res = await this.$api.requested({
          "id": 20221020165403,
          "version":1,
          "content": {
            "sa_quotedpriceid":this.data.sa_quotedpriceid,
            "ischeck":false
          }
        })
        this.tool.showMessage(res,()=>{
          console.log(res)
          this.$emit("onDeApprove")
        })
      }else {
        const res = await this.$api.requested({
          "id": 20221125162803,
          "version":1,
          "content": {
            "sa_quotedpriceid":this.data.sa_quotedpriceid,
          }
        })
        this.tool.showMessage(res,()=>{
          console.log(res)
          this.$emit("onDeApprove")
        })
      }

    }
  }
}
</script>

<style scoped>

</style>