<template>
  <div class="table-style">
    <div class="title-tip">
      <div class="small_title">各网省装备在用率情况</div>
      <div class="more" @click="openDialog">更多 ></div>
    </div>

    <div class="table-list scroll-container">
      <table cellspacing="0" cellpadding="8" style="width: 100%; border-collapse: collapse; text-align: center">
        <!-- 双层表头 -->
        <thead>
          <!-- 第一行：跨列合并 -->
          <tr>
            <th>排名</th>
            <th>单位名称</th>
            <th>在用率</th>
            <th>周转率</th>
          </tr>
        </thead>

        <!-- 表体：使用 v-for 渲染数据 -->
        <tbody>
          <tr v-for="(row, index) in tableData" :key="index">
            <td class="num index-num" style="width: 50px">{{ index + 1 }}</td>
            <td style="width: 200px">{{ row.name }}</td>
            <td class="num">{{ row.proportion }} %</td>
            <td>
              <span class="num">{{ row.turnoverRate }}</span> <span style="font-size: 14px">次/年</span></td
            >
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</template>

<script>
import { getDeptEquipmentApi } from '@/api/wsScreen'

export default {
  data() {
    return {
      tableData: [
        {
          name: '安徽省',
          proportion: '61.55',
          turnoverRate: '2.55',
        },
        {
          name: '山西',
          proportion: '48.25',
          turnoverRate: '2.34',
        },
        {
          name: '河北',
          proportion: '42.36',
          turnoverRate: '2.23',
        },
        {
          name: '江苏',
          proportion: '39.56',
          turnoverRate: '1,91',
        },
        {
          name: '山东',
          proportion: '36.05',
          turnoverRate: '1.81',
        },
      ],
    }
  },
  created() {
    // this.getList()
  },
  methods: {
    async getList() {
      try {
        const res = await getDeptEquipmentApi()
        console.log('🚀 ~ 各单位装备在用率情况 ~ res:', res)
        this.tableData = res.data || []
      } catch (error) {
        console.log('🚀 ~ 各单位装备在用率情况 ~ error:', error)
      }
    },
    openDialog() {
      this.$emit('openDialog')
    },
  },
}
</script>

<style lang="scss" scoped>
.table-style {
  height: 350px;
}
.num {
  font-size: 20px;
  font-weight: 800;
  font-family: 'DIN';
}
.index-num {
  background: linear-gradient(180deg, #fff 19.35%, #5dcbfe 77.42%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.title-tip {
  display: flex;
  justify-content: space-between;
  padding-top: 10px;
  padding-left: 45px;
  font-family: DS-TITLE;
  background: linear-gradient(to bottom, #f0f5f8, #5eb6f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;

  .more {
    margin-right: 20px;
      color: #5b99ad;
      cursor: pointer;
      font-weight: 400;
      font-family: '';
      font-size: 12px;
      /* 清除背景渐变相关属性 */
      background: none;
      background-clip: unset;
      -webkit-background-clip: unset;
      -webkit-text-fill-color: #5b99ad;
  }

  .small_title {
    margin-left: 10px;
    font-size: 20px;
    font-weight: 500;
    background: linear-gradient(180deg, #FFF 19.35%, #5DCBFE 77.42%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  } 


}
.table-list {
  margin-top: 20px;
  height: 280px;
  overflow: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-family: 'Alibaba-PuHuiTi-Regular';
  font-size: 11px;
}

th,
td {
  padding: 10px;
  text-align: center;
  white-space: nowrap;
  // border: 1px solid rgba(255, 255, 255, 0.3); // 边框颜色可根据背景调整
}

th {
  /* background-color: #f5f5f5; */
  font-weight: bold;
}
// 第一行背景
thead {
  background-image: url('../../img/tableHeader.png');
  background-size: 100% 100%;
  color: #7BBBF8;
}

tbody tr {
  background-image: url('../../img/tableTr.png');
  background-size: 100% 100%;
}

/* 奇偶行颜色区分 */
tbody tr:nth-child(even) {
  /* margin: 10px 0; */
}

tbody tr:hover {
  background-image: url('../../img/table-hover.png');
  cursor: pointer;
}
.scroll-container {
  width: 100%;
  overflow: auto;

  /* 隐藏滚动条轨迹 */
  -ms-overflow-style: none;  /* IE / Edge */
  scrollbar-width: none;     /* Firefox */
}

/* Chrome / Safari */
.scroll-container::-webkit-scrollbar {
  width: 0;   /* 或者直接隐藏 */
  height: 0;
  background: transparent; /* 背景透明 */
}
</style>
