<template>
  <div class="inline-16">
    <el-popconfirm
        title="确定要删除该联系人吗？"
        @confirm="onSubmit()">
      <el-button slot="reference" size="small" type="text">删 除</el-button>
    </el-popconfirm>
    <el-dialog
        :visible.sync="dialogToVoidVisible"
        width="900px"
        @close="dialogToVoidVisible = false"
    >
      <div slot="title" style="font-size: 15px">
        作废联系人
      </div>
      <div>
        <el-row :gutter="20">
          <el-form :model="form" :rules="rules"  ref="form"  size="mini" label-position="right" label-width="90px">
            <el-col :span="20">
              <el-form-item  label="作废原因:" prop="deletereason">
                <el-input type="textarea"  autosize v-model="form.deletereason" placeholder="请输入作废原因"></el-input>
              </el-form-item>
            </el-col>
          </el-form>
        </el-row>
      </div>
      <div class="dialog-footer">
        <el-button size="small" @click="dialogToVoidVisible = false" class="normal-btn-width">取 消</el-button>
        <el-button size="small" type="primary" @click="onSubmit"   class="normal-btn-width btn-primary">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "toVoid",
  props:["data"],
  data(){
    return {
      dialogToVoidVisible:false,
      form:{
        "contactsid": '',
        "sys_enterpriseid": '',
        "deletereason":"",
        "ownerid": this.$route.query.id,
        "ownertable": "sa_competitor"
      },
      rules:{
        deletereason:[
          { required: true, message: '作废原因不能为空', trigger: 'blur' },
        ]
      }
    }
  },
  methods:{
    toVoidRow(){
      this.dialogToVoidVisible = true
      this.form.sys_enterpriseid = this.data.sys_enterpriseid
      this.form.contactsid = this.data.contactsid
    },
    async onSubmit(){
      this.form.sys_enterpriseid = this.data.sys_enterpriseid
      this.form.contactsid = this.data.contactsid
      const res = await this.$api.requested({
        "id": "20221018145502",
        "content": this.form,

      })
      this.tool.showMessage(res,()=>{
        this.$emit("toVoidSuccess")
      })

    }
  }
}
</script>

<style scoped>

</style>