<!--  -->
<template>
  <el-skeleton :loading="loading" animated>
    <el-card shadow="never">
      <template #header>
        <CardTitle title="最新发布职位" />
      </template>
      <div class="header-box">
        <div v-for="(k, i) in headers" :key="i" class="header-item">{{ k }}</div>
      </div>
      <div v-if="list.length" class="scroll-box">
        <vue3-seamless-scroll :list="list" style="height: 100%;" :step="0.5">
          <div v-for="val in list" :key="val.id" class="!h-40px list-item">
            <div>{{ formatName(val.name) }}</div>
            <div>{{ formatName(val.enterpriseName) }}</div>
            <div>{{ timesTampChange(val.createTime) }}</div>
          </div>
        </vue3-seamless-scroll>
      </div>
      <div v-else class="noDataText">暂无数据</div>
    </el-card>
  </el-skeleton>
</template>

<script lang="ts" setup>
defineOptions({name: 'JobCount'})
import { statisticAnalysisApi } from '@/api/menduner/system/analysis/statisticAnalysis'
import { timesTampChange } from '@/utils/transform/date'
import { Vue3SeamlessScroll } from "vue3-seamless-scroll"
import { formatName } from '@/utils'

const props = defineProps({
  queryParams: Object
})

const headers = ['职位名称', '发布企业', '发布时间']
const loading = ref(false)
const list = ref([])
const getData = async (queryParams: any) => {
  loading.value = true
  try {
    const data = await statisticAnalysisApi.getJobDetails(queryParams)
    list.value = data || []
  } catch (err) {
    console.log(err);
    loading.value = false
  } finally {
    loading.value = false
  }
}

watch(() => props.queryParams, (newVal) => {
  getData(newVal)
}, { immediate: true, deep: true })
</script>

<style lang="scss" scoped>
.scroll-box {
  height: 372px;
  overflow: hidden;
}

.list-item {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: #333;

  div {
    width: 33.3%;
    max-width: 33.3%;
    padding-right: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.header-box {
  display: flex;
  align-items: center;
  margin-bottom: 10px;

  .header-item {
    width: 33.3%;
    font-size: 13px;
    font-weight: 700;
  }
}

.noDataText {
  height: 332px;
  margin-top: 50px;
  font-size: 14px;
  color: #666;
  text-align: center;
}
</style>