<template>
  <div class="right-section">
    <div class="data-box1" style="margin-top: 9px">
      <div class="title-box">
        <div class="gradient-text">公共服务承灾体总数</div>
      </div>
      <div class="box-content" style="padding: 5px 0 5px 5px; height: 195px">
        <div class="box4">
          <div v-for="(item, index) in riskData" :key="index" class="item" :title="item.name" :style="{ backgroundImage: `url(${item.icon})` }">
            <div class="text1">{{ item.name }}</div>
            <div class="text2">{{ item.value }}</div>
          </div>
        </div>
      </div>
    </div>
    <div class="data-box1" style="margin-top: 9px">
      <div class="title-box2">
        <div class="gradient-text">茂名市公共服务承灾体数量</div>
      </div>
      <div class="box-content" style="padding: 5px 0 5px 5px; height: 220px">
        <Chart :option="option1" />
      </div>
    </div>
    <div class="data-box1" style="margin-top: 9px">
      <div class="title-box3">
        <div class="gradient-text">茂名市公共服务承灾体数量统计表</div>
      </div>
      <div class="box-content" style="padding: 5px 0 5px 5px; height: 255px">
        <div class="box4">
          <div class="common-table">
            <div class="table-header">
              <div class="td" style="width: 152px">区县</div>
              <div class="td" style="width: 152px">星级饭店</div>
              <div class="td" style="width: 152px">旅游景区</div>
            </div>
            <div v-for="(item, index) in tableData" :key="index" class="tr">
              <div class="td">{{ item.area }}</div>
              <div class="td">{{ item.data1 }}</div>
              <div class="td">{{ item.data2 }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup name="RightSection">
import { getImageUrl } from './data';

let riskData = reactive([
  { name: '学校', value: '1', icon: getImageUrl('school2') },
  { name: '医疗卫生机构', value: '1', icon: getImageUrl('hospital2') },
  { name: '提供住宿的社会服务机构', value: '1', icon: getImageUrl('socialInstitution2') },
  { name: '公共文化场所', value: '1', icon: getImageUrl('publicPlace2') },
  { name: '旅游景区', value: '1', icon: getImageUrl('scenicSpot2') },
  { name: '星级饭店', value: '1', icon: getImageUrl('restaurant2') },
  { name: '体育场馆', value: '1', icon: getImageUrl('gymnasium2') },
  { name: '宗教活动场所', value: '1', icon: getImageUrl('religiousPlace2') },
  { name: '大型超市', value: '1', icon: getImageUrl('supermarket2') }
]);
let option1 = reactive({
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow'
    }
  },
  color: ['#3172f3', '#5cc4f1'],
  legend: {
    textStyle: {
      color: '#9a9ea7'
    }
  },
  grid: {
    top: '25',
    left: '10px',
    right: '20px',
    bottom: '10px',
    containLabel: true
  },
  xAxis: {
    type: 'value',
    boundaryGap: [0, 0.01],
    axisLabel: {
      color: '#9a9ea7'
    },
    splitLine: {
      show: false
    },
    axisLine: {
      show: true,
      lineStyle: {
        color: '#2b3446'
      }
    }
  },
  yAxis: {
    type: 'category',
    axisLine: {
      lineStyle: {
        color: '#2b3446'
      }
    },
    axisTick: {
      show: false
    },
    axisLabel: {
      color: '#9a9ea7'
    },
    data: []
  },
  series: [
    {
      name: '星级饭店',
      type: 'bar',
      data: []
    },
    {
      name: '旅游景点',
      type: 'bar',
      data: []
    }
  ]
});
//
const tableData = ref([]);
const getData = () => {
  tableData.value = [
    { area: '茂南区', data1: '123', data2: '74' },
    { area: '电白区', data1: '23', data2: '12' },
    { area: '高州区', data1: '14', data2: '23' },
    { area: '化州区', data1: '25', data2: '14' },
    { area: '信宜区', data1: '21', data2: '24' }
  ];
  option1.yAxis.data = ['茂南区', '电白区', '高州区', '化州区', '信宜区'];
  option1.series[0].data = [182, 234, 290, 104, 131];
  option1.series[1].data = [193, 234, 310, 121, 134];
};
onMounted(() => {
  getData();
});
</script>

<style lang="scss" scoped>
.right-section {
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: #ffffff;
  padding-right: 20px;
  .data-box1 {
    &::after {
      content: '';
      display: block;
      width: 517px;
      height: 19px;
      background: url('@/assets/images/censusDataAnalysis/line.png') no-repeat;
      background-size: 100% 100%;
      margin-top: -8px;
    }
    .title-box {
      width: 450px;
      height: 40px;
      background: url('@/assets/images/censusDataAnalysis/titleBox6.png') no-repeat;
      background-size: 100% 100%;
      padding-left: 50px;
      .gradient-text {
        font-size: 24px;
      }
    }
    .title-box2 {
      width: 516px;
      height: 40px;
      background: url('@/assets/images/censusDataAnalysis/titleBox4.png') no-repeat;
      background-size: 100% 100%;
      padding-left: 50px;
      .gradient-text {
        font-size: 24px;
      }
    }
    .title-box3 {
      width: 518px;
      height: 40px;
      background: url('@/assets/images/censusDataAnalysis/titleBox5.png') no-repeat;
      background-size: 100% 100%;
      padding-left: 50px;
      .gradient-text {
        font-size: 24px;
      }
    }
    .box-content {
      min-height: 123px;
      background: url('@/assets/images/censusDataAnalysis/box.png') no-repeat;
      background-size: 100% 100%;
      padding: 5px 28px;
      .btn-box {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        margin-top: -23px;
        padding-right: 20px;
        .line {
          margin: 0 5px;
        }
        .text {
          font-size: 14px;
          color: #ffffff;
          cursor: pointer;
        }
        .text-active {
          color: #00fce7;
        }
      }
      .box1 {
        display: flex;
        align-items: center;
        width: 235px;
        height: 20px;
        background: url('@/assets/images/censusDataAnalysis/forestFire/box1.png') no-repeat bottom left;
        background-size: 100% 13px;
        .icon-address {
          width: 11px;
          height: 10px;
          background: url('@/assets/images/censusDataAnalysis/forestFire/address.png') no-repeat;
          background-size: 100% 100%;
          margin-right: 5px;
        }
        .text1 {
          font-size: 12px;
          color: #edfaff;
          display: flex;
          align-items: center;
        }
      }
      .box2 {
        display: flex;
        flex-wrap: wrap;
        margin-top: 8px;
        .box-item {
          display: flex;
          margin-left: 42px;
          &:nth-child(1),
          &:nth-child(4) {
            margin-left: 0;
          }
          .icon1 {
            background: url('@/assets/images/censusDataAnalysis/forestFire/iconRisk1.png') no-repeat;
          }
          .icon2 {
            background: url('@/assets/images/censusDataAnalysis/forestFire/iconRisk2.png') no-repeat;
          }
          .icon3 {
            background: url('@/assets/images/censusDataAnalysis/forestFire/iconRisk3.png') no-repeat;
          }
          .icon4 {
            background: url('@/assets/images/censusDataAnalysis/forestFire/iconRisk4.png') no-repeat;
          }
          .icon5 {
            background: url('@/assets/images/censusDataAnalysis/forestFire/iconRisk5.png') no-repeat;
          }
          .icon1,
          .icon2,
          .icon3,
          .icon4,
          .icon5 {
            width: 48px;
            height: 49px;
            background-size: 100% 100%;
          }
          .text-box {
            margin-left: 8px;
            .text-box2 {
              display: flex;
              align-items: baseline;
              margin-bottom: 6px;
              .red-text,
              .orange-text,
              .yellow-text,
              .blue-text,
              .green-text {
                min-width: 25px;
                font-size: 16px;
                color: transparent;
                -webkit-background-clip: text;
                background-clip: text;
                display: inline-block;
                font-family: BEBAS-1;
              }
              .red-text {
                background-image: linear-gradient(to bottom, #ffffff 30%, #ffc4be 50%, #ff2f3c 100%);
              }
              .orange-text {
                background-image: linear-gradient(to bottom, #ffffff 30%, #ffddc7 50%, #f88726 100%);
              }
              .yellow-text {
                background-image: linear-gradient(to bottom, #ffffff 30%, #fcfed0 50%, #f7f71e 100%);
              }
              .blue-text {
                background-image: linear-gradient(to bottom, #ffffff 30%, #c1dbff 50%, #2c81ff 100%);
              }
              .green-text {
                background-image: linear-gradient(to bottom, #ffffff 30%, #d1ffdb 50%, #22fb81 100%);
              }
            }
            .text1 {
              font-size: 12px;
              color: #a8ccde;
            }
            .text2 {
              font-size: 12px;
              color: #ffffff;
            }
          }
        }
      }
      .box3 {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        .item {
          width: 116px;
          height: 58px;
          background: url('@/assets/images/censusDataAnalysis/forestFire/box2.png') no-repeat;
          background-size: 100% 100%;
          display: flex;
          align-items: center;
          position: relative;
          padding-left: 40px;
          box-sizing: border-box;
          .icon1 {
            background: url('@/assets/images/censusDataAnalysis/forestFire/town.png') no-repeat;
          }
          .icon2 {
            background: url('@/assets/images/censusDataAnalysis/forestFire/population.png') no-repeat;
          }
          .icon3 {
            background: url('@/assets/images/censusDataAnalysis/forestFire/area.png') no-repeat;
          }
          .icon4 {
            background: url('@/assets/images/censusDataAnalysis/forestFire/gdp.png') no-repeat;
          }
          .icon1,
          .icon2,
          .icon3,
          .icon4 {
            position: absolute;
            left: -32px;
            top: -24px;
            flex-shrink: 0;
            display: inline-block;
            width: 106px;
            height: 106px;
            margin-right: 10px;
            background-size: 100% 100%;
          }
          .text-box {
            .text1 {
              font-size: 14px;
              color: #ffffff;
            }
            .text-box2 {
              display: flex;
              align-items: baseline;
              .text2 {
                font-size: 16px;
                min-width: 40px;
                color: transparent;
                -webkit-background-clip: text;
                background-clip: text;
                display: inline-block;
                font-family: BEBAS-1;
                background-image: linear-gradient(to bottom, #ffffff 30%, #c1dbff 50%, #2c81ff 100%);
              }
              .text3 {
                font-size: 12px;
                color: #a8ccde;
              }
            }
          }
        }
      }
      .box4 {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        .item {
          box-sizing: border-box;
          padding-top: 5px;
          padding-left: 70px;
          width: 163px;
          height: 57px;
          background-repeat: no-repeat;
          background-size: 100% 100%;
          margin-left: 10px;
          margin-top: 7px;
          //&:nth-child(1),
          //&:nth-child(2),
          //&:nth-child(3) {
          //  margin-top: 0;
          //}
          &:nth-child(3n + 1) {
            margin-left: 0;
          }
          .text1 {
            font-size: 14px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
          }
          .text2 {
            font-size: 18px;
            color: transparent;
            -webkit-background-clip: text;
            background-clip: text;
            display: inline-block;
            font-family: BEBAS-1;
            background-image: linear-gradient(to bottom, #ffffff 30%, #c1dbff 50%, #2c81ff 100%);
            margin-top: 5px;
          }
        }
      }
    }
  }
  .data-box2 {
    width: 506px;
    height: 135px;
    background: url('@/assets/images/censusDataAnalysis/box2.png') no-repeat;
    background-size: 100% 100%;
    padding: 8px 10px;
    .box-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .header-left {
        display: flex;
        align-items: center;
        .header-title {
          font-size: 16px;
          color: transparent;
          background-image: linear-gradient(to bottom, #fff 40%, #65a3ff 70%, #3385ff 100%);
          -webkit-background-clip: text;
          background-clip: text;
          display: inline-block;
        }
        .time {
          color: #edfaff;
          font-size: 12px;
          margin-left: 15px;
        }
      }
      .btn {
        width: 106px;
        height: 40px;
        background: url('@/assets/images/censusDataAnalysis/btn.png') no-repeat;
        background-size: 100% 100%;
        font-size: 12px;
        color: #edfaff;
        display: flex;
        justify-content: center;
        align-items: center;
        padding-left: 15px;
        cursor: pointer;
      }
    }
    .box-content {
      display: flex;
      align-items: center;
      .icon {
        display: inline-block;
        flex-shrink: 0;
        width: 64px;
        height: 65px;
        background: url('@/assets/images/censusDataAnalysis/riskOverview.png') no-repeat;
        background-size: 100% 100%;
      }
      .line {
        width: 1.5px;
        height: 39px;
        margin: 0 10px;
        background-color: #535353;
      }
      .text {
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 4;
        font-size: 14px;
      }
    }
  }
}
.flex-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 16px;
  color: #c9daf0;
  .icon-chart {
    width: 79px;
    height: 62px;
    background: url('@/assets/images/censusDataAnalysis/forestFire/chart.png') no-repeat;
    background-size: 100% 100%;
  }
}
.common-table {
  .table-header {
    padding: 0;
  }
  .tr {
    padding: 2px 0;
  }
}
</style>
