<template>
  <div>
    <el-button :type="!disabled?'':'primary'" :disabled="!disabled" size="mini" @click="onToVoid" >作 废</el-button>
  </div>
</template>

<script>
export default {
  name: "toVoid",
  props:['data','disabled'],
  methods:{
    onToVoid(){
      this.$prompt('请输入作废原因', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputValidator: (value => {
          if (!value){
            return '请输入作废原因'
          }
        }),
      }).then(({ value }) => {
        this.toVoidOk(value)
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '取消作废操作'
        });
      });
    },
    async toVoidOk(val){
      console.log("执行作废",this.data)
      const res = await this.$api.requested({
        "id": 20221020165503,
        "content": {
          "sa_quotedpriceids":[this.data],
          "deletereason":val
        }
      })
      this.tool.showMessage(res,()=>{
        this.$emit('onSuccess')
        this.$store.dispatch('changeDetailDrawer',false)
      })
    }
  }
}
</script>

<style scoped>

</style>