<template>
  <div class="app-container">
    <el-card shadow="always" style="width: 55%; margin: 0 auto">
      <p><b>基本资料</b></p>
      <el-form
        ref="postRef"
        :model="formData"
        :rules="rules"
        label-width="100px"
      >
        <el-form-item label="姓名:" prop="name">
          <el-input v-model="form.name" placeholder="请输入姓名" />
        </el-form-item>
        <el-form-item label="手机:" prop="phone">
          <el-input v-model="form.phone" placeholder="请输入手机号" />
        </el-form-item>
        <el-form-item label="邮箱:" prop="email">
          <el-input v-model="form.email" placeholder="请输入邮箱" />
        </el-form-item>
        <el-form-item label="职务:" prop="email">
          <el-input v-model="form.email" placeholder="请输入职务" />
        </el-form-item>
        <el-form-item label="固定电话:" prop="dutyParagraph">
          <el-input v-model="form.dutyParagraph" placeholder="请输入固定电话" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm">提交</el-button>
        </el-form-item>
      </el-form>
      <p><b>专家资料</b></p>
      <ExpertForm
        v-model="form"
        :isAdd="false"
        :labelWidth="labelWidth"
        ref="expertForm"
      />
      <div :style="{ marginLeft: labelWidth + 'px' }">
        <el-button type="primary" @click="submitForm">提交</el-button>
      </div>
    </el-card>
  </div>
</template>
<script setup>
import { expert } from "@/api/identity/index";
import ExpertForm from "@/views/identity/components/ExpertForm";
const data = reactive({
  formData: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    postCode: undefined,
  },
  rules: {
    name: [{ required: true, message: "公司名称不能为空", trigger: "blur" }],
    dutyParagraph: [
      { required: true, message: "公司税号不能为空", trigger: "blur" },
    ],
    bank: [{ required: true, message: "开户行不能为空", trigger: "blur" }],
    bankAccount: [
      { required: true, message: "开户行账号不能为空", trigger: "blur" },
    ],
    bankPhone: [
      { required: true, message: "开户行电话不能为空", trigger: "blur" },
    ],
    email: [{ required: true, message: "电子邮箱不能为空", trigger: "blur" }],
    phone: [{ required: true, message: "联系电话不能为空", trigger: "blur" }],
    address: [{ required: true, message: "地址不能为空", trigger: "blur" }],
    username: [{ required: true, message: "联系人不能为空", trigger: "blur" }],
    userPhone: [
      { required: true, message: "联系人电话不能为空", trigger: "blur" },
    ],
    userAddress: [
      { required: true, message: "邮寄地址不能为空", trigger: "blur" },
    ],
  },
});

const { queryParams, formData, rules } = toRefs(data);

const { proxy } = getCurrentInstance();
const labelWidth = 140;
const form = reactive({
  laboratory_id: undefined, // 所属实验室
  gender: 1,
});
function submitForm(status) {
  if (proxy.$refs.expertForm.submitForm()) {
    expert(form).then((res) => {
      proxy.$modal.msgSuccess("新增成功");
      proxy.$router.go(-1);
    });
  } else {
    console.log("校验未通过");
  }
}
</script>