<template>
  <div class="card-edit">
    <a-divider orientation="left">求职意向基本信息</a-divider>
    <a-descriptions bordered>
      <a-descriptions-item label="姓名">{{ jobHuntInfo.jobUserName }}</a-descriptions-item>
      <a-descriptions-item label="人才类型">{{ jobHuntInfo.jobUserTypeStr }}</a-descriptions-item>
      <a-descriptions-item label="月薪要求">
        {{ showSalary(jobHuntInfo.minSalary, jobHuntInfo.maxSalary) }}
      </a-descriptions-item>
      <a-descriptions-item label="工作年限">{{ jobHuntInfo.workYear }}</a-descriptions-item>
      <a-descriptions-item label="求职类型">{{ jobHuntInfo.jobHuntTypeStr }}</a-descriptions-item>
      <a-descriptions-item label="求职岗位">{{ jobHuntInfo.professionName }}</a-descriptions-item>
      <a-descriptions-item label="希望工作地区">{{ jobHuntInfo.areaWork }}</a-descriptions-item>
      <a-descriptions-item label="可到职日期">
        {{ jobHuntInfo.inDate ? dayjs(jobHuntInfo.inDate).format('YYYY-MM-DD') : '' }}
      </a-descriptions-item>
      <a-descriptions-item label="最后更新人">
        {{ jobHuntInfo.modifyUserName }}
      </a-descriptions-item>
      <a-descriptions-item label="最后更新时间">
        {{ jobHuntInfo.modifyTime ? dayjs(jobHuntInfo.modifyTime).format('YYYY-MM-DD') : '' }}
      </a-descriptions-item>
    </a-descriptions>
    <a-divider orientation="left">其他信息</a-divider>
    <a-descriptions bordered>
      <a-descriptions-item :span="3" label="备注">{{ jobHuntInfo.otherDemand }}</a-descriptions-item>
    </a-descriptions>
  </div>
</template>

<script setup lang="ts">
import {onMounted, reactive} from "vue";
import {getJobHuntByID} from "@/api/jobUserManager/jobhunt";
import dayjs from "dayjs";

// 求职意向数据
const jobHuntInfo = reactive({
  jobUserName: "",
  jobUserTypeStr: "",
  minSalary: "",
  maxSalary: "",
  workYear: "",
  jobHuntTypeStr: "",
  professionName: "",
  areaWork: "",
  inDate: "",
  otherDemand: "",
  modifyUserName: "",
  modifyTime: "",
})

// 获取求职意向数据
function loadData(id: string) {
  getJobHuntByID(id).then((result: any) => {
    Object.keys(jobHuntInfo).forEach(key => {
      jobHuntInfo[key] = result[key];
    })
  });
}

const showSalary = (minSalary: any, maxSalary: any) => {
  if (minSalary != null) {
    if (maxSalary != null) {
      return minSalary.toString() + "-" + maxSalary.toString();
    } else {
      return "≥" + minSalary.toString();
    }
  } else {
    if (maxSalary != null) {
      return "≤" + maxSalary.toString();
    } else {
      return "";
    }
  }
}

// 页面初始化
onMounted(() => {
  const id = history.state.params?.id;
  loadData(id);
})
</script>

<script lang="ts">
// 设置页面名称进行组件缓存
export default {
  name: "JobHuntDetail"
}
</script>

<style scoped>

</style>
