<template>
  <div class="content-box">
    <div class="title">{{ title }}</div>
    <div class="risk-select">
      <a-select style="width: 308px; font-size: 16px" v-model:value="selectVal" allowClear class="code-mode-select" @change="changeSelect">
        <a-select-option v-for="item in selectList" :key="item.orgname" :value="item.orgcode">{{ item.orgname }} </a-select-option>
      </a-select>
      <ArrowRightOutlined class="go-icon" @click="goDetail()" />
    </div>
    <div class="dust-content">
      <div class="dust-scroll-content">
        <!-- <template v-for="(data, selectIndex) in selectData" :key="selectIndex">
          <div class="monitor-item">
            <div class="title-box">{{ data['devicePos'] }}</div>
            <div class="monitor-content-top">
              <div v-for="(dustItem, index) in dustMonitorColumnTop" :key="index" class="top-item-box" :class="`top-item-box-${index + 1}`">
                <div class="item-top-title">{{ dustItem.title }}</div>
                <div class="item-top-value">{{ data[dustItem.code] }}</div>
              </div>
            </div>
            <div class="monitor-content-bottom">
              <div v-for="(dustItem, index) in dustMonitorColumnBootom" :key="index" class="bottom-item-box" :class="`bottom-item-box-${index + 1}`">
                <div class="item-bottom-title">{{ dustItem.title }}</div>
                <div class="item-bottom-value">{{ data[dustItem.code] }}</div>
              </div>
            </div>
          </div>
        </template> -->
        <a-carousel dot-position="left" dotsClass="dots-class" :dots="true" :autoplay="true">
          <template v-for="(data, selectIndex) in selectData" :key="selectIndex">
            <div class="monitor-item">
              <div class="title-box">{{ data['devicePos'] }}</div>
              <div class="monitor-content-top">
                <div v-for="(dustItem, index) in dustMonitorColumnTop" :key="index" class="top-item-box" :class="`top-item-box-${index + 1}`">
                  <div class="item-top-title">{{ dustItem.title }}</div>
                  <div class="item-top-value">{{ data[dustItem.code] }}</div>
                </div>
              </div>
              <div class="monitor-content-bottom">
                <div
                  v-for="(dustItem, index) in dustMonitorColumnBootom"
                  :key="index"
                  class="bottom-item-box"
                  :class="`bottom-item-box-${index + 1}`"
                >
                  <div class="item-bottom-title">{{ dustItem.title }}</div>
                  <div class="item-bottom-value">{{ data[dustItem.code] }}</div>
                </div>
              </div>
            </div>
          </template>
        </a-carousel>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
  import { ref, defineProps, watch } from 'vue';
  import { dustMonitorColumnTop, dustMonitorColumnBootom } from '../dust.data';
  import { ArrowRightOutlined } from '@ant-design/icons-vue';
  import { useGo } from '/@/hooks/web/usePage';

  let props = defineProps({
    compositeData: {
      type: Array,
      default: () => {
        return [];
      },
    },
  });
  const go = useGo();
  let selectVal = ref('sdmtjtbetmk');
  let selectList = ref<any>([]);
  const selectData = ref<any>([]);
  const title = ref('粉尘测点监测详情');

  function changeSelect(val) {
    const index = selectList.value.findIndex((item) => item['orgcode'] == val);
    if (index > -1) {
      selectData.value = selectList.value[index]['dust_data'];
    }
  }
  function goDetail() {
    //本地模拟跳转
    go('/staticSheets/dust');
  }
  watch(
    () => props.compositeData,
    (newS, oldV) => {
      if (newS.length != 0) {
        selectList.value = newS;
        if (!oldV || oldV.length == 0) {
          const index = selectList.value.findIndex((item) => item['orgcode'] == selectVal.value);
          if (index > -1) {
            selectData.value = selectList.value[index]['dust_data'];
          }
        }
      }
    },
    {
      immediate: true,
      deep: true,
    }
  );
</script>

<style lang="less" scoped>
  @font-face {
    font-family: 'douyuFont';
    src: url('../../../../assets/font/douyuFont.otf');
  }

  .content-box {
    position: relative;
    width: 100%;
    height: 100%;

    .title {
      position: absolute;
      left: 50px;
      top: 12px;
      color: #fff;
      font-family: 'douyuFont';
      font-size: 14px;
    }
    .risk-select {
      position: relative;
      width: 90%;
      height: 30px;
      left: 50%;
      transform: translate(-50%, 0);
      top: 45px;

      background: url('../../../../../assets/images/company/content-label.png') no-repeat center;
      background-size: 100% 100%;
      z-index: 9999;

      .zxm-select {
        position: absolute;
        top: 50%;
        transform: translate(0, -50%);

        &:nth-child(1) {
          left: 10px;
        }
      }
      .go-icon {
        position: absolute;
        right: 2px;
        top: 8px;
        color: #fff;
        cursor: pointer;
        font-size: 20px;
        &:hover {
          color: #00d8ff;
        }
      }
    }

    .dust-content {
      height: 100%;
      padding-top: 52px;
      padding-left: 20px;
      box-sizing: border-box;
      .dust-scroll-content {
        width: 100%;
        height: 420px;
        overflow-y: auto;
        overflow-x: hidden;
        .monitor-item {
          margin-bottom: 15px;
          .title-box {
            color: #fff;
            width: 100%;
            height: 40px;
            margin-left: 5px;
            margin-top: 00px;
            margin-bottom: 5px;
            padding-left: 40px;
            padding-top: 6px;
            background: url('../../../../../assets//images//company//lentj.png') no-repeat;
            background-size: 199px 100%;
            font-size: 15px;
            font-weight: 600;
          }
          .monitor-content-top {
            width: 100%;
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;
            color: #fff;
            .top-item-box {
              width: 193px;
              height: 64px;
              display: flex;
              justify-content: space-between;
              align-items: center;
              padding: 0 28px;
            }
            .top-item-box-1 {
              background: url('../../../../../assets//images//company//dust//tip-bg-1.png');
            }
            .top-item-box-2 {
              background: url('../../../../../assets//images//company//dust//tip-bg-2.png');
            }
            .top-item-box-3 {
              background: url('../../../../../assets//images//company//dust//tip-bg-3.png');
            }
            .top-item-box-4 {
              background: url('../../../../../assets//images//company//dust//tip-bg-4.png');
            }
          }
          .monitor-content-bottom {
            padding: 0 20px;
            color: #fff;
            .bottom-item-box {
              width: 358px;
              height: 43px;
              display: flex;
              justify-content: space-between;
              align-items: center;
              margin-top: 14px;
              position: relative;
              .item-bottom-title {
                margin-left: 65px;
              }
              .item-bottom-value {
                margin-right: 20px;
              }
            }
            .bottom-item-box-1 {
              background: url('../../../../../assets//images//company//dust//tip-bg1-1.png');
              &::after {
                content: '';
                width: 25px;
                height: 25px;
                position: absolute;
                left: 13px;
                top: 7px;
                background: url('../../../../../assets//images//company//dust//dustCon-icon.png');
              }
            }
            .bottom-item-box-2 {
              background: url('../../../../../assets//images//company//dust//tip-bg1-2.png');
              &::after {
                content: '';
                width: 25px;
                height: 25px;
                position: absolute;
                left: 12px;
                top: 6px;
                background: url('../../../../../assets//images//company//dust//respirableDustCon-icon.png');
              }
            }
            .bottom-item-box-3 {
              background: url('../../../../../assets//images//company//dust//tip-bg1-1.png');
              &::after {
                content: '';
                width: 28px;
                height: 22px;
                position: absolute;
                left: 10px;
                top: 7px;
                background: url('../../../../../assets//images//company//dust//SiO2Content-icon.png');
              }
            }
            .bottom-item-box-4 {
              background: url('../../../../../assets//images//company//dust//tip-bg1-2.png');
              &::after {
                content: '';
                width: 26px;
                height: 20px;
                position: absolute;
                left: 11px;
                top: 8px;
                background: url('../../../../../assets//images//company//dust//respirableDustRatio-icon.png');
              }
            }
          }
        }
      }
    }
  }
  .dots-class {
    width: 8px;
  }
  ::v-deep .slick-dots-left {
    left: 0 !important;
  }
  ::v-deep .zxm-select-single:not(.zxm-select-customize-input) .zxm-select-selector {
    height: 24px;
  }

  ::v-deep .zxm-select-single:not(.zxm-select-customize-input) .zxm-select-selector .zxm-select-selection-search-input {
    height: 24px;
  }

  ::v-deep .zxm-select-selection-placeholder {
    color: #fff !important;
    line-height: 22px !important;
  }

  ::v-deep .zxm-select-single:not(.zxm-select-customize-input) .zxm-select-selector::after {
    line-height: 24px;
  }

  ::v-deep .zxm-select:not(.zxm-select-customize-input) .zxm-select-selector {
    background-color: transparent;
    border-top: 0px;
    border-bottom: 0px;
    border-left: 2px solid;
    border-right: 2px solid;
    border-image: linear-gradient(to bottom, transparent, rgba(49, 184, 255, 1), transparent) 1 1 1;
  }

  ::v-deep .zxm-select-arrow {
    color: #fff !important;
  }

  ::v-deep .zxm-select-selection-item {
    color: #fff !important;
  }

  ::v-deep .zxm-select-single .zxm-select-selector .zxm-select-selection-item {
    line-height: 24px !important;
  }
</style>
