<template>
  <el-dialog
      model-value="edialogaddVisible"
      :title="dialogTitle"
      width="30%"
      @close="handleClose"
  >
    <el-form
        ref="formRef"
        :model="form"

        label-width="100px"
    >
      <el-form-item label="用户账号" prop="userAccount">
        <el-input v-model="form.userAccount" />
      </el-form-item>
      <el-form-item label="用户密码" prop="userPassword">
        <el-input v-model="form.userPassword" />
      </el-form-item>
      <el-form-item label="用户昵称" prop="manicuristName">
        <el-input v-model="form.manicuristName"/>
      </el-form-item>
      <el-form-item label="性别" prop="gender">
        <el-input v-model="form.gender"/>
      </el-form-item>
      <el-form-item label="电话" prop="phone">
        <el-input v-model="form.phone"/>
      </el-form-item>
      <el-form-item label="邮箱" prop="email">
        <el-input v-model="form.email"/>
      </el-form-item>
      <el-form-item label="工作名称" prop="specialties">
        <el-input v-model="form.specialties"/>
      </el-form-item>
      <el-form-item label="评分" prop="rating">
        <el-input v-model="form.rating"/>
      </el-form-item>
      <el-form-item label="余额" prop="salary">
        <el-input v-model="form.salary"/>
      </el-form-item>
      <el-form-item label="认证号" prop="certification_number">
        <el-input v-model="form.certification_number"/>
      </el-form-item>
      <el-form-item label="认证路径" prop="certificate_path">
        <el-input v-model="form.certificate_path"/>
      </el-form-item>
      <el-form-item label="组织认证" prop="issuing_authority">
        <el-input v-model="form.issuing_authority"/>
      </el-form-item>
    </el-form>

    <template #footer>
<span class="dialog-footer">
<el-button @click="handleClose">取消</el-button>
<el-button type="primary" @click="handleConfirm">确认</el-button>
</span>
    </template>
  </el-dialog>
</template>
<script setup>
import {defineEmits, defineProps, ref, watch} from "vue";
import axios from "@/util/axios";
import { ElMessage } from "element-plus";
const props=defineProps({
  dialogTitle:{
    type:String,
    default:'',
    required:true
  }
})
const form=ref({
  userAccount:"",
  userPassword:"",
  certificate_path: "",
  certification_number: "",
  email: "",
  gender: null,
  issuing_authority: "",
  manicuristName: "",
  phone: "",
  rating: null,
  salary: null,
  specialties: ""

})

const formRef=ref(null);

// 定义父组件事件
const emits=defineEmits(['update:modelValue','initEmployeeList'])
const handleClose=()=>{
  console.log("用户添加关闭xxx")
// 调用执行
  emits('update:modelValue',false)
}
const handleConfirm=()=>{
  formRef.value.validate(async(valid)=>{
    if(valid){
      let result=await axios.post("manicurist/adminAdd",form.value)
      console.log(result.data)
      let data=result.data;
      if(data.code==0){
        ElMessage.success("执行添加成功！");
        formRef.value.resetFields();
        emits("initEmployeeList");
        handleClose();
      }else{
        ElMessage.error(data.description);
      }
    }else{
      console.log("fail")
      return false
    }
  })
}
</script>
<style scoped>
</style>