<template>
  <div class="hot-box">
    <div class="sub-li" v-for="(item, index) in list" :key="index">
      <!-- 公司信息 -->
      <div class="company-info-top" @click="handleClickEnterprise(item)">
        <div class="float-left">
          <v-img src="../../assets/logo.png" :alt="item.anotherName" :width="40" style="height: 40px;border-radius: 4px;"/>
        </div>
        <div class="company-info">
          <h3>{{ item.anotherName }}</h3>
          <p>{{ item.financingName }}<span class="vline"></span>{{ item.scaleName }}<span class="vline"></span>{{ item.industryName }}</p>
        </div>
      </div>
      <!-- 职位列表 -->
      <ul class="company-job-list">
        <li class="company-job-item" v-for="(k, i) in item.jobList" :key="i">
          <div class="job-info" @mouseenter="k.active = true" @mouseleave="k.active = false" @click="handleClickPosition(k)">
            <div class="mb-2 d-flex">
              <p :class="['name', {'default-active': k.active }]">{{ k.name }}</p>
              <v-icon size="20" class="message">mdi-message-processing</v-icon>
              <span class="salary">{{ k.payFrom }}-{{ k.payTo }}/{{ k.payName }}</span>
            </div>
            <div style="height: 24px; overflow: hidden;">
              <v-chip size="x-small" label class="mr-1" color="#666" v-for="j in desc" :key="j">{{ k[j.value] }}</v-chip>
            </div>
          </div>
        </li>
      </ul>
      <div class="moreBtn">
        <v-btn class="buttons" color="primary" variant="outlined">{{ $t('position.moreBtn') }}</v-btn>
      </div>
    </div>
  </div>
</template>

<script setup name="hotPromoted">
import { ref, watch } from 'vue'
const props = defineProps({
  items: {
    type: Array,
    default: () => []
  }
})
const list = ref([])
watch(
  () => props.items, 
  (newVal) => {
    list.value = newVal
  },
  { immediate: true },
  { deep: true }
)
const desc = [
  { value: 'areaName' },
  { value: 'eduName' },
  { value: 'expName' }
]

// 职位详情
const handleClickPosition = (k) => {
  window.open(`/recruit/position/details/${k.positionId}`)
}
// 企业详情
const handleClickEnterprise = (item) => {
  window.open(`/enterprise/details/${item.id}`)
}
</script>

<style lang="scss" scoped>
.hot-box {
  display: flex;
  flex-wrap: wrap;
}
.sub-li {
  position: relative;
  width: calc((100% - 24px) / 3);
  min-width: calc((100% - 24px) / 3);
  max-width: calc((100% - 24px) / 3);
  margin: 0 12px 12px 0;
  height: 388px;
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  transition: all .2s linear;
  background-color: #fff;
  cursor: pointer;
  &:nth-child(3n) {
    margin-right: 0;
  }
  &:hover {
    box-shadow: 0 16px 40px 0 rgba(153, 153, 153, .3);
  }
}
.company-info {
  float: left;
  margin-left: 16px;
  width: 282px;
}
.company-info-top {
  display: flex;
  height: 76px;
  padding: 16px 20px;
  overflow: hidden;
  background: linear-gradient(90deg, #f2fafa 0, #fcfbfa 100%);
}
.company-info h3 {
  height: 22px;
  font-size: 16px;
  font-weight: 400;
  color: #222;
  line-height: 22px;
  margin: 0 0 4px 0;
  padding: 0;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.company-info p {
  height: 18px;
  font-size: 13px;
  font-weight: 400;
  color: #999;
  line-height: 18px;
}
.vline {
  display: inline-block;
  width: 1px;
  height: 10px;
  vertical-align: middle;
  background-color: #e0e0e0;
  margin: 0 10px;
}
.company-job-list {
  display: block;
  padding: 4px 20px 12px;
  margin-right: -16px;
  overflow: hidden;
}
ul li {
  list-style: none
}
.company-job-item {
  display: block;
  height: auto;
  width: 344px;
  padding: 12px 0;
  margin: 0;
}
.salary {
  font-size: 16px;
  float: right;
  font-weight: 700;
  color: #fe574a;
  line-height: 22px;
  max-width: none;
  text-align: right;
  flex: 1;
}
.name {
  position: relative;
  max-width: 200px;
  line-height: 22px;
  font-weight: 500;
  color: #222;
  margin-right: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all linear .2s;
}
.message {
  color: #bfc1c9;
  &:hover {
    color: var(--v-primary-base);
  }
}
.moreBtn {
  position: absolute;
  bottom: 25px;
  left: 50%;
  translate: -50%;
}
</style>