<template>
  <el-dialog v-model="visible" title="考评结果" :on-close="fnClose">
    <el-form ref="formRef" :model="form" :rules="rules">
      <el-form-item label="考评结果" prop="DESCRITPTION">
        <el-input-number v-model="form.DESCRITPTION" :min="0" :precision="1" />
      </el-form-item>
    </el-form>
    <template #footer>
      <el-button @click="fnClose">关闭</el-button>
      <el-button type="primary" @click="fnSubmit">确定</el-button>
    </template>
  </el-dialog>
</template>

<script setup>
import { useVModels } from "@vueuse/core";
import { ref } from "vue";
import useFormValidate from "@/assets/js/useFormValidate.js";

const props = defineProps({
  visible: {
    type: Boolean,
    required: true,
    default: false,
  },
  form: {
    type: Object,
    required: true,
    default: () => ({}),
  },
});
const emits = defineEmits(["update:visible", "update:form", "submit"]);
const { visible, form } = useVModels(props, emits);
const rules = {
  DESCRITPTION: [
    { required: true, message: "请输入考评结果", trigger: "blur" },
    { type: "number", message: "请输入数字", trigger: "blur" },
  ],
};
const formRef = ref(null);
const fnClose = () => {
  formRef.value.resetFields();
  visible.value = false;
};
const fnSubmit = async () => {
  await useFormValidate(formRef);
  emits("submit", form.value.DESCRITPTION);
  fnClose();
};
</script>

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