<template>
  <div style="display: inline-block">
    <p v-if="buttonData.type == '0'" class="button-p reset-button-one" style="width:100px;margin-right:20px;" @click="auditClick(1)">驳回</p>
    <p v-if="buttonData.type == '1'" class="inquire-button-one" style="width:100px;" @click="auditClick(2)">通过</p>
    <el-button v-if="buttonData.type == '2'" type="primary" @click="laboratoryApply(1)">确 定</el-button>
  </div>
</template>

<script>
  import { laboratoryApply } from "@/api/laboratory/approval";
  export default {
    name: 'addPageSubPageSZDX',
    props:{
      buttonData: {},
    },
    methods:{
      auditClick(type){
        let self = this;
        if(type == 1){
          self.$parent.open = true;
        }else if(type == 2){
          self.$confirm('是否确认审核?', "", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          }).then(function() {
            self.laboratoryApply(type);
          }).then(() => {}).catch(() => {});
        }
      },
      laboratoryApply(type){
        let self = this;
        let obj = {
          id:type==1?self.$parent.$parent.infoData.list.id:self.$parent.infoData.list.id,
          auditStatus:type,
          rejectCause:type==1?self.$parent.$parent.rejectCause:self.$parent.rejectCause
        };
        if(type == 1){
          obj.rejectCause = self.$parent.$parent.form.rejectCause;
          obj.rejectMaterial = self.$parent.$parent.checkList + '';
        }
        laboratoryApply(obj).then(response => {
          self.msgSuccess("操作成功");
          if(type == 1){
            self.$parent.$parent.$parent.tableClick(1);
          }else{
            self.$parent.$parent.tableClick(1);
          }
        })
      },
    }
  }
</script>

<style scoped>

</style>
