<template>
  <div>
    <el-button size="mini" type="primary"  @click="onshow">删 除</el-button>
    <el-dialog
        :visible.sync="dialogToVoidVisible"
        width="25%"
        @close="dialogToVoidVisible = false"
        append-to-body
    >
      <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:["id"],
  data(){
    return {
      dialogVisible:false,
      dialogToVoidVisible:false,
      form:{
        sa_competitorid:"",
        deletereason:""
      },
      rules:{
        deletereason:[
          { required: true, message: '作废原因不能为空', trigger: 'blur' },
        ]
      }
    }
  },
  methods:{
    onshow() {
      this.$confirm('是否确认删除该竞争对手?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.onSubmit()
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    async onSubmit(){
      this.form.sa_competitorid = this.id
      const res = await this.$api.requested({
        "id": 20221018164202,
        "content": {
          "sa_competitorids":[this.form.sa_competitorid],
          "deletereason":this.form.deletereason
        },
      })
      this.tool.showMessage(res,() => {
        this.$emit('onSuccess')
        this.$store.dispatch('changeDetailDrawer',false)
      })
    }
  }
}
</script>

<style scoped>

</style>