<template>
  <el-button 
    v-if="isShow"
    :type="type" 
    :size="size"
    @click.native="retrieve"
  >
    {{ title }}
  </el-button>
</template>

<script>
// import {rollback} from "@/api/business/purchase/purchase-order.js"
import {rollback} from "./api/index";
export default {
  name:'Retrieve',
  props:{
    data:{
      type:[Object],
      require:true,
    },
    type:{
      type:String,
      default:'text',
    },
    size:{
      type:String,
      default:'mini',
    },

  },
  computed:{
    isShow:{
      get(){
        if(this.data.status === '1'){

          return true;
        }
        return false;
      },
      set(){

      }
    }
  },
  data(){
    return {
      title:'收 回',
    }
  },
  methods:{
    retrieve(){

      // if(this.data.status === '1'){

        this.$confirm('是否继续此操作?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(async() => {
  
            try {
              this.$modal.loading("请稍候...");
              console.log(this.data,'this.data');
              let {code,msg} = await rollback({...this.data});
              if(code == 200){
                this.$emit('success');
              }
              
            } catch (error) {
              
            }finally{
              this.$modal.closeLoading();
            }
  
          }).catch(() => {        
          });
      
      // }else{
      //   this.$notify.warning({
      //     title: '警告',
      //     message: '！',
      //   });
      // }

    },

  },
  created(){},
  mounted(){},

}
</script>