<template>
  <el-dialog
    v-model="show"
    title="审核用户"
    width="400px"
    style="margin-top: 15vh"
  >
    <el-input
      v-model="form.content"
      type="textarea"
      :autosize="{
        minRows: 4,
      }"
      placeholder="请输入审核意见"
    />
    <template #footer>
      <el-button type="success" @click="submit(2)">
        <el-icon style="margin-right: 5px"><Select /></el-icon>
        通过
      </el-button>
      <el-button type="danger" @click="submit(3)">
        <el-icon style="margin-right: 5px"><Close /></el-icon>
        不通过
      </el-button>
    </template>
  </el-dialog>
</template>

<script setup>
import * as UserApi from '@/api/system/user'

const { proxy } = getCurrentInstance();
const emits = defineEmits(["success"]);
const show = ref(false);
const form = ref({
  content: "",
  userId: undefined,
  audit: undefined,
});

function open(param) {
  form.value.userId = param.id;
  show.value = true;
}

function submit(type) {
  form.value.audit = type;

  UserApi.examineUser(form.value).then((res) => {
    proxy.$modal.msgSuccess("审批成功");
    emits("success");
    show.value = false;
  });
}

defineExpose({ open });
</script>

<style scoped lang="scss"></style>
