<template>
  <div class="inline-16">
    <el-popconfirm :title="message ? message : '确定删除当前产品吗？'" @confirm="deleteRow()">
      <el-button slot="reference" size="mini" v-if="type=='detail'" :disabled="disabled">删 除</el-button>
      <el-button slot="reference" size="mini" type="text" :disabled="disabled" v-else>删 除</el-button>
    </el-popconfirm>
  </div>
</template>

<script>
/* 
id:数据id
nameId:接口id
nameKey:接口字段
 */
export default {
  props: ['id','nameId','nameKey','type','disabled','data','message'],
  data () {
    return {
      param: {
        "id":this.nameId,
        "content":{
          "sa_contractid": this.$route.query.id,
          [this.nameKey]:[this.id]
        }
      }
    }
  },
  methods: {
    async deleteRow() {
      this.param.content[this.nameKey] = [this.id]
      let res = await this.$api.requested(this.param)
      this.tool.showMessage(res,() => {
        this.$emit('deleteSuccess',this.data ? this.data : '')
      })
    },
  },
  created () {
    this.$emit('deleteCreate',this.param)
  }
}

</script>
