<!--
 * @Author: changjun
 * @FilePath: /yuan-qingdao-zld-browser/src/views/screen/SafeComponents/NetEventCompanyTop10.vue
 * @Date: 2022-09-07 09:37:29
 * @Description: 
 * @LastEditTime: 2023-09-01 17:37:28
 * @LastEditors: 曹文丽
-->
<script setup lang="ts">
import { reactive, ref, onMounted, watch, unref } from 'vue'

import { useGetChartData } from "../../../components/chart/logic";
import { useGlobalSafeScreen } from "../logic/useGlobalSafeScreen";
import { mapMapping } from "../../../assets/map/provinceData";
import { bigNumberTransform } from "../../../utils/utils";
const mapData = mapMapping();
const { currentCity, currentDate } = useGlobalSafeScreen();

const list = ref([]) as any;
const getData = async () => {
  const params = {
    type: unref(currentDate),
  } as any;
  if (unref(currentCity) !== mapData?.name) {
    params.region = unref(currentCity);
  }
  const res = await useGetChartData(
    "largeScreen/comprehensiveSituation/queryInfluenceEnterprise",
    (res) => res,
    params
  );
  list.value = res || [];
  list.value.forEach((item) => {
    item.num = bigNumberTransform(item.num);
  });
};

const init = () => {
  getData();
};

onMounted(() => {
  init();
});

watch(currentDate, () => {
  getData();
});

watch(currentCity, () => {
  getData();
});
</script>

<template>
  <div class="block" :class="mapData?.en == 'anhui' ? 'safe-block-height' : ''">
    <div class="table-box">
      <div class="table-box-header">
        <div class="item">排名</div>
        <div class="item">企业名称</div>
        <div class="item">事件数量（个）</div>
      </div>
      <div class="table-box-content" v-if="list.length">
        <div class="table-box-row" v-for="(item, index) in list" :key="index">
          <div class="item">
            <div class="rank-box" :class="index < 3 && 'rank-front-three'">
              {{ index + 1 }}
            </div>
          </div>
          <div class="item name">
            <CustomTooltip :show="true" :text="item.enterpriseName || '-'"></CustomTooltip>
          </div>
          <div class="item count">{{ item.num }}</div>
        </div>
      </div>
      <ya-empty v-else></ya-empty>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.block {
  width: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;

  .table-box {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding-top: 18px;
    box-sizing: border-box;

    .table-box-header {
      width: 100%;
      height: 28px;
      // background: rgba(255, 255, 255, 0.05);
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      line-height: 28px;
      font-size: 16px;
      font-weight: 400;
      color: #8ce7ff;
      padding: 0 7px;
      box-sizing: border-box;

      .item {
        font-family: "Microsoft YaHei" !important;
      }
    }

    .table-box-content {
      width: 100%;
      display: flex;
      flex-direction: column;
      flex: 1;

      // justify-content: space-between;
      .table-box-row {
        position: relative;
        width: 100%;
        height: 10%;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        // line-height: 28px;
        font-size: 14px;
        font-weight: 400;
        padding: 0px 7px;
        // box-sizing: border-box;
        color: rgba(179, 179, 179, 1);
        background-image: url("../../../assets/image/screen/icon_box_line.png");
        background-size: 100% 26%;
        background-repeat: no-repeat;
        background-position: bottom;
      }

      .table-box-row::after {
        position: absolute;
        bottom: -1px;
        left: 0;
        content: "";
        display: block;
        width: 100%;
        height: 1px;
        background-size: 100%;
        background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAtAAAAACCAMAAABG4BujAAAAOVBMVEWZwNKav9KZwNIAAACZwNOawNKZwtKZwdKZv9KZwdOZydCYwdKZwNKawtKZwNKZwNIOzv0Jz/8Iz//IHKa8AAAAEnRSTlNIRUIAPxkJDzovBR8lEzUp5uArkSxsAAAA5ElEQVQ4y+3RWW7EIBAE0K5uFrPP5P6HDdgmMphofIBB4u+pQFUkQhQtqBimLIo22YglE3whsoEoaSKdOgI5P6O4Qjwi01CoSIPCgBSpHbkD2R3RvwgDSnfEKxRPlJ+j9vmGeg0d2Q9In6iYFYo40dT6Ouk7zYNpfv6OhQiJgLVljoZRRCHLhk0ylC9QJoKtriA1hAN5BTegUFG9Se8INySuJXW0TtomhPZkuKB8QaonjUhdUBkQGooz8mVKsg0xXK/BNxTBZkZmRqWiuEQ8otZVR7fW3dz6d5oH07ze79dxLYv8AkerHcemH5XqAAAAAElFTkSuQmCC) no-repeat;
      }

      .rank-box {
        width: 26px;
        height: 26px;
        font-size: 12px;
        font-weight: 400;
        font-family: YouSheBiaoTiHei;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #ffffff;
        background-image: url("../../../assets/image/screen/icon_round_blue.png");
      }

      .rank-front-three {
        color: #ffffff;
        background-image: url("../../../assets/image/screen/icon_round_yellow.png");
      }

      .name {
        cursor: default;
        color: rgba(179, 179, 179, 1);
        // font-family: Adobe Heiti Std;
        color: #8cecff;
        font-size: 16px;
        padding-top: 6px;
      }
    }

    .item {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      font-size: 14px;
      // font-family: Adobe Heiti Std;
      color: #8cecff;
    }

    .item:nth-of-type(1) {
      width: 50px;
      margin-right: 10px;
    }

    .item:nth-of-type(2) {
      display: inline-block !important;
      flex: 1;
      align-items: flex-start;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .item:nth-of-type(3) {
      width: 100px;
      min-width: 0;
      margin-left: 12px;
      overflow: hidden;
      font-family: PangMenZhengDao;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
}
</style>
