<template>
  <el-dialog title="审核" :visible.sync="open" width="800px" append-to-body>
    <el-form ref="form" :model="form" :rules="rules" label-width="140px">
        <el-form-item label="审核结果" prop="checkStatus">
          <el-radio-group v-model="form.checkStatus">
            <el-radio label="3">审核通过</el-radio>
            <el-radio label="4">审核拒绝</el-radio>
          </el-radio-group>
        </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" :disabled="disabled" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import {auditEntApi} from "@/api/admin/ent/ent"
  import {projectAuditApi} from "@/api/admin/project/project"
  export default {
    data () {
      return {
        open: false,
        disabled: false,
        form: {
          checkStatus: ''
        },
        rules: {
          checkStatus: [
            {required: true, message: '请选择审核结果', trigger: 'change'}
          ]
        }
      }
    },
    methods: {
      init(id) {
        this.open = true;
        this.form.id = id;
      },
      submitForm() {
        this.$refs.form.validate(valid => {
          if (valid) {
            this.disabled = true
            projectAuditApi(this.form.id, this.form.checkStatus).then(res => {
              this.disabled = false;
              if(res.code == 200) {
                this.$message({
                  message: '审核成功',
                  type: 'success'
                });
              }
              this.open = false;
              this.$emit('refreshData');
            })
          }
        })
      },
      cancel() {
        this.open = false
      },
    }
  }
</script>

<style>
</style>
