<template>
  <div class="app-container">
    <el-card shadow="always" style="width: 55%; margin: 0 auto">
      <ExpertForm
        v-model="form"
        :isAdd="false"
        :labelWidth="labelWidth"
        ref="expertFormRef"
      />
      <div :style="{ marginLeft: labelWidth + 'px' }">
        <el-button @click="$router.go(-1)">{{
          t("admin.common.cancel")
        }}</el-button>
        <el-button type="primary" @click="submitForm">{{
          t("admin.common.submit")
        }}</el-button>
      </div>
    </el-card>
  </div>
</template>
<script setup>
import { insertCasExpert } from "@/api/identity";
import ExpertForm from "@/views/components/ExpertForm";
import { ElMessage } from "element-plus";
import { useRouter } from "vue-router";
import { reactive, ref } from "vue";
import { useI18n } from "vue-i18n";
const { t } = useI18n();
const router = useRouter();
const labelWidth = 140;
const form = reactive({
  gender: 1,
});
const expertFormRef = ref();
const submitForm = async (status) => {
  if (await expertFormRef.value.validateForm()) {
    form.area = form.district;
    await insertCasExpert(form);
    ElMessage.success("申请已提交");
    router.back();
  } else {
    console.log("validation failed");
  }
};
</script>
