<template>
  <div class="position-box">
    <div class="sub-li" v-for="(item, index) in list" :key="index" @mouseenter="item.active = true" @mouseleave="item.active = false">
      <div class="job-info">
        <div class="sub-li-top">
          <div class="sub-li-info">
            <p :class="['name', {'default-active': item.active }]">{{ item.name }}</p>
            <v-chip size="x-small" color="error" label variant="outlined" class="mr-1">急聘</v-chip>
            <v-chip size="x-small" color="warning" label variant="outlined">NEW</v-chip>
          </div>
          <p class="salary">{{ item.payFrom }}-{{ item.payTo }}/{{ item.payName }}</p>
        </div>
        <div style="height: 24px;overflow: hidden;">
          <v-chip size="x-small" label v-for="(k, i) in item.tagList" :key="i" class="mr-1" color="#666">{{ k }}</v-chip>
        </div>
        <div>
          <v-chip size="x-small" label v-for="(j, i) in desc" :key="i" class="mr-1" color="#666" :prepend-icon="j.mdi">{{ item[j.value] }}</v-chip>
        </div>
      </div>
      <div class="sub-li-bottom">
        <div class="user-info">
          <div class="d-flex align-center">
            <v-img src="../../assets/logo.png" width="40" style="height: 40px;" />
            <span class="names ml-2" style="font-size: 14px">{{ item.anotherName }}</span>
          </div>
          <p class="names float-right">
            <span>{{ item.industryName }}</span>
            <span class="vline"></span>
            <span>{{ item.scaleName }}</span>
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
defineOptions({ name: 'position-card-item' })
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 = [
  { 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>
.position-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: 165px;
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  transition: all .2s linear;
  background-color: #fff;
  &:nth-child(3n) {
    margin-right: 0;
  }
  &:hover {
    box-shadow: 0 16px 40px 0 rgba(153, 153, 153, .3);
  }
}
.job-info {
  padding: 16px 20px;
}
.sub-li-top {
  display: flex;
  width: 100%;
  align-items: center;
  margin-bottom: 12px;
}
.sub-li-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  height: 22px;
  overflow: hidden;
  flex: 1;
}
.salary {
  font-size: 16px;
  font-weight: 700;
  color: #fe574a;
  line-height: 22px;
  flex: none;
}
.job-text {
  white-space: normal;
  padding-right: 0;
  height: 22px;
  line-height: 22px;
  overflow: hidden;
  word-break: break-all;
  max-width: none;
}
.sub-li-info .name {
  position: relative;
  max-width: 200px;
  margin-right: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  &:hover {
    color: var(--v-primary-base);
  }
}
.sub-li-bottom {
  position: absolute;
  width: 100%;
  bottom: -6px;
  left: 0;
  background: linear-gradient(90deg, #f5fcfc 0, #fcfbfa 100%);
  margin-top: 10px;
  padding-top: 0;
  display: block;
  border: none;
}
.user-info {
  display: flex;
  padding: 12px 20px;
  align-items: center;
  justify-content: space-between;
}
.names {
  color: #666;
  font-size: 13px;
}
.vline {
  display: inline-block;
  width: 1px;
  height: 10px;
  vertical-align: middle;
  background-color: #e0e0e0;
  margin: 0 10px;
}
</style>