<template>
  <div class="inline-16">
    <el-button slot="reference" size="small" type="text" @click="dialogToVoidVisible = true">作 废</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:["data"],
  data(){
    return {
      dialogToVoidVisible:false,
      form:{
        "sa_project_competeid": '',
        "deletereason":""
      },
      rules:{
        deletereason:[
          { required: true, message: '作废原因不能为空', trigger: 'blur' },
        ]
      }
    }
  },
  methods:{
    toVoidRow(){
      this.dialogToVoidVisible = true
      this.form.sa_project_competeid = this.data.sa_project_competeid
    },
    onSubmit(){
      this.$refs['form'].validate(async (valid) => {
        if (!valid) return false
        const res = await this.$api.requested({
          "id": "20221019165902",
          "content": {
            "sa_project_competeids": [this.form.sa_project_competeid],
            "deletereason":this.form.deletereason
          },
        })
        this.tool.showMessage(res,()=>{
          this.$emit("toVoidSuccess")
          this.$refs['form'].resetFields()
          this.dialogToVoidVisible = false
        })
      })
    }
  }
}
</script>

<style scoped>

</style>