<template>
  <div>
    <el-button size="mini" :type="disabled || data.status === '已无效'?'':'primary'" @click="dialog=true" :disabled="disabled || data.status === '已无效'">作 废</el-button>
    <el-dialog append-to-body width="30%" title="作废" :visible.sync="dialog">
      <el-input type="textarea" v-model="deletereason" size="small" :autosize="{minRows:6}" placeholder="作废原因"></el-input>
      <div class="dialog-footer">
        <el-button size="small" @click="dialog = false" class="normal-btn-width">取 消</el-button>
        <el-button size="small" type="warning" @click="onSubmit" class="normal-btn-width btn-warning">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: '',
  data() {
    return {
      dialog:false,
      deletereason:'',
    };
  },
  props:['idName','idKey','id','data','disabled'],
  computed:{
  },
  methods: {
    async onSubmit () {
      let res = await this.$api.requested({
        "id": this.idName,
        "content": {
            [this.idKey]: [this.id],
            "deletereason":this.deletereason
        },
      })
      this.tool.showMessage(res,() => {
        this.dialog = false
        this.$store.dispatch('changeDetailDrawer',false)
        this.$emit('onSuccess')
      })
    }
  },
};
</script>

<style scoped>

</style>
