<template>
  <el-dialog title="审核" width="600px" v-model="visible" @closed="resetHandle">
    <el-form :model="form" label-width="100" label-position="right">
      <el-form-item label="审核">
        <el-radio-group v-model="form.type">
          <el-radio label="通过" :value="1"></el-radio>
          <el-radio label="驳回" :value="2"></el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="驳回原因">
        <el-input type="textarea" :maxlength="50" show-word-limit v-model="form.reason"
          placeholder="请输入驳回原因"></el-input>
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog_footer">
        <div class="btn">
          <el-button size="large" style="width: 100%;" @click="visible = false">取 消</el-button>
        </div>
        <div class="btn">
          <el-button size="large" type="primary" style="width: 100%;" @click="handleOk">确 定</el-button>
        </div>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import { ref } from 'vue'

const visible = ref(false)

const form = ref({
  type: 1,        // 1 通过 2驳回
  reason: '',     // 驳回原因
})

// 重置
function resetHandle() {
  form.value.type = 1
  form.value.reason = ''
}

const emits = defineEmits(['confirm'])
function handleOk() {
  emits('confirm', form.value)
  visible.value = false
}

function show() {
  visible.value = true
}

defineExpose({
  show,
})
</script>

<style scoped lang="scss">
.dialog_footer {
  display: flex;
  gap: 14px;

  .btn {
    flex: 1;
  }
}
</style>