<!-- 分享职位 -->
<template>
  <div style="background-color: #f0f0f0;" :style="{'padding': '10px'}">
    <v-card
      class="py-3 px-5"
      style="min-height: calc(100vh - 20px); box-sizing: border-box; margin: 0 auto;width: 900px;"
    >
      <div v-if="!Object.keys(info).length">加载失败</div>
      <div v-else>
        <div class="d-flex justify-space-between">
          <h2 class="JobName ellipsis">{{ info.name }}</h2>
          <span class="salary">{{ info.payFrom }}-{{ info.payTo }}/{{ positionInfo.payName }}</span>
        </div>
        <div class="d-flex justify-space-between mt-4">
          <div class="banner-tags">
            <div v-for="k in desc" :key="k.mdi" class="mr-3">
              <v-icon color="var(--color-666)" size="20">{{ k.mdi }}</v-icon>
              <span class="f-w-600 ml-1">{{ positionInfo[k.value] }}</span>
            </div>
          </div>
        </div>
        <div class="mt-4" v-if="info?.tagList">
          <v-chip size="small" class="mr-1 mb-1" color="primary" label v-for="(k, i) in info.tagList" :key="i">{{ k }}</v-chip>
        </div>
        <div class="text-end d-flex align-center justify-space-between mt-3">
          <svg-icon v-if="info.hire" name="pin" size="50"></svg-icon>
        </div>
        <div v-if="info.hire" class="mt-3">
          <v-chip v-if="info.hirePrice" label color="primary">赏金：{{ commissionCalculation(info.hirePrice, 1) }}元</v-chip>
          <v-chip v-if="info.hirePoint" label color="primary">积分：{{ commissionCalculation(info.hirePoint, 1) }}点</v-chip>
        </div>
        <v-divider class="mt-3"></v-divider>
        <div class="mt-3 mb-1 f-w-600">{{ $t('position.jobResponsibilities') }}</div>
        <div v-if="info.content" class="requirement" v-html="info.content?.replace(/\n/g, '</br>')"></div>
        <div v-else>暂无</div>
        <div class="mt-3 mb-1 f-w-600">{{ $t('position.jobRequirements') }}</div>
        <div v-if="info.requirement" class="requirement" v-html="info.requirement?.replace(/\n/g, '</br>')"></div>
        <div v-else>暂无</div>
        <v-divider class="my-3"></v-divider>
        <div class="contact">
          <h4>公司信息</h4>
          <div class="mt-5">
            <!-- <v-img :src="info.contact?.avatar || 'https://minio.citupro.com/dev/menduner/7.png'" :width="45" style="height: 45px;"></v-img> -->
            <div class="contact-name">{{ info.enterprise?.name }}</div>
            <div v-if="info?.enterprise?.tagList" class="mt-3">
              <v-chip size="small" class="mr-1 mb-1" color="primary" label v-for="(k, i) in info.enterprise?.tagList" :key="i">{{ k }}</v-chip>
            </div>
            <div class="contact-info">招聘者：{{ info.contact?.name }} · {{ info.contact?.postNameCn }}</div>
          </div>
        </div>
        <v-divider class="my-3"></v-divider>
        <div>
          <h4>{{ $t('position.address') }}</h4>
          <div class="mt-1">
            <v-icon size="25" color="primary">mdi-map-marker</v-icon>
            <span style="color: var(--color-666);font-size: 15px;">{{ info.address }}</span>
          </div>
        </div>
      </div>
    </v-card>

  </div>
</template>

<script setup>
import { commissionCalculation } from '@/utils/position'
defineOptions({name: 'recruit-personal-shareJob-index'})
import { ref } from 'vue';
import { getPositionDetails } from '@/api/position'
import { dealDictObjData } from '@/utils/position'

// 职位详情
const props = defineProps({
  jobId: String
})
const info = ref({})
const positionInfo = ref({})
const getPositionDetail = async () => {
  const data = await getPositionDetails({ id: props.jobId })
  info.value = data
  positionInfo.value = { ...dealDictObjData({}, info.value), ...info.value }
}
if (props.jobId) getPositionDetail()

const desc = [
  { mdi: 'mdi-map-marker-outline', value: 'areaName' },
  { mdi: 'mdi-school-outline', value: 'eduName' },
  { mdi: 'mdi-clock-time-ten-outline', value: 'expName' }
]
</script>

<style lang="scss" scoped>
.f-w-600 { font-weight: 600; }
.radius { border-radius: 8px; }
.salary {
  color: var(--v-error-base);
  line-height: 41px;
  font-weight: 600;
  height: auto;
  display: inline-block;
  vertical-align: sub;
}
.JobName {
  color: #37576c;
  font-size: 28px;
  margin-right: 30px;
  margin-top: 1px;
  vertical-align: middle;
  flex: 1;
}
.banner-tags { display: flex; flex-wrap: wrap; }
.requirement {
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 28px;
  color: var(--color-333);
  font-size: 15px;
  text-align: justify;
  letter-spacing: 0;
}
.contact-name {
  font-size: 20px;
  font-weight: 500;
  color: var(--color-222);
  line-height: 28px;
}
.contact-info {
  font-size: 15px;
  color: var(--color-666);
  line-height: 21px;
  margin-top: 8px;
}
.button-item {
  min-width: 110px;
  height: 36px
}
</style>
