index.vue 10.3 KB
<template>
  <div @wheel="handleWheel" ref="fleetContentBox" :class="{ scrolling: isScrolling }" class="fleet-content-box">
    <!-- <vue3-seamless-scroll :list="item.fleetInfos" :step="1" :hoverStop="true" :hover="true"> -->
    <!-- 线路信息 -->
    <div v-for="(childItem, childIndex) in item.fleetInfos" :key="childItem.lineName" class="fleet-line-info-container">
      <!-- <div class="line-box" style="height: 1px; margin: 5px; background-color: #0761ba;"></div> -->

      <div :id="childItem.lineName" class="fleet-line-title">
        {{ childItem.lineName }}
      </div>
      <div class="line-box" style="height: 2px; margin: 10px 0; background: #d9e0e2;"></div>
      <div ref="fleetNbbmInfoContainer" class="fleet-nbbm-info-container">
        <div v-for="(sunItem, sunIndex) in childItem.lineInfos" :key="sunItem.nbbm" class="fleet-nbbm-info-item">
          <div v-if="sunItem.saleInfoVo != null" class="fleet-nbbm-info-have-sale">
            <el-popover popper-class="fleet-popover-style" placement="top" :title="childItem.lineName" :width="320"
              :show-after="200" @after-enter="alterEnterHandler(sunItem.driverInfoVo.jobCode)">
              <ConstForm :showFlag="personSignInfo.jobCode == sunItem.driverInfoVo.jobCode"
                :currentDateKey="currentDateKey" :jobCode="sunItem.driverInfoVo.jobCode" />
              <template #reference>
                <div class="fleet-nbbm-have-sale-driver" :style="signStyleColor[sunItem.driverInfoVo.signStatus]">
                </div>
              </template>
            </el-popover>
            <div class="fleet-nbbm-have-sale-txt-box">
              <span class="fleet-nbbm-have-sale-txt">
                <span :style="{ color: sunItem.driverInfoVo.signStatus != 1 ? 'white' : 'black' }">
                  {{ sunItem.nbbm.substring(0, Math.floor(sunItem.nbbm.length / 2)) }}</span>
                <span :style="{ color: sunItem.saleInfoVo.signStatus != 1 ? 'white' : 'black' }">
                  {{ sunItem.nbbm.substring(Math.floor(sunItem.nbbm.length / 2), sunItem.nbbm.length) }}
                </span>
              </span>
            </div>
            <el-popover popper-class="fleet-popover-style" placement="top" :title="childItem.lineName" :width="320"
              :show-after="200" @after-enter="alterEnterHandler(sunItem.saleInfoVo.jobCode)">
              <ConstForm :showFlag="personSignInfo.jobCode == sunItem.saleInfoVo.jobCode" :currentDateKey="currentDateKey"
                :jobCode="sunItem.saleInfoVo.jobCode" />
              <template #reference>
                <div class="fleet-nbbm-have-sale-sale" :style="signStyleColor[sunItem.saleInfoVo.signStatus]">
                </div>
              </template>
            </el-popover>
          </div>
          <el-popover v-else :show-after="200" @after-enter="alterEnterHandler(sunItem.driverInfoVo.jobCode)"
            placement="top" :title="childItem.lineName" popper-class="fleet-popover-style" :width="320">
            <ConstForm :showFlag="personSignInfo.jobCode == sunItem.driverInfoVo.jobCode" :currentDateKey="currentDateKey"
              :jobCode="sunItem.driverInfoVo.jobCode" />
            <template #reference>
              <div class="fleet-nbbm-info-no-sale" :style="signStyleColor[sunItem.driverInfoVo.signStatus]">
                <span class="fleet-nbbm-info-no-sale-text">
                  {{ sunItem.nbbm }}
                </span>
              </div>
            </template>
          </el-popover>
        </div>
      </div>
    </div>
    <!-- </vue3-seamless-scroll> -->
  </div>
</template>
<script setup>
import ConstForm from '@/components/ConstForm/index.vue';
import { nextTick, onMounted, ref } from 'vue';
const props = defineProps({
  item: {
    type: Object,
    required: true
  },
  currentDateKey: {
    type: String,
    required: true
  },
  handleLoadSuccess: {
    type: Function,
    required: true
  },
  signStyleColor: {
    type: Object,
    required: true
  }
})

/** 签到信息 */
const personSignInfo = reactive(
  {
    jobCode: null,
    date: null
  }
);
// 控制滚动
const isScrolling = ref(false);
// 元素信息
const fleetNbbmInfoContainer = ref();
const fleetContentBox = ref()
/**
 * 显示弹窗
 * @param {*} val 工号
 */
const alterEnterHandler = (val) => {
  personSignInfo.jobCode = val;
}

/**
 * 处理容器滚动回调函数
 * @param container HTML parent element
 */
const handleContainerScrollCallBack = (container) => {
  if (container.scrollHeight > container.clientHeight) {
    // 内容溢出
    isScrolling.value = true;
  } else {
    // 内容未溢出
    isScrolling.value = false;
  }
  props.handleLoadSuccess(false);
}

/**
 * 鼠标滚轮触发了
 * @param {*} el
 */
const handleWheel = (el) => {
  const containerElement = fleetContentBox.value;
  // 内容溢出
  if (containerElement.scrollHeight > containerElement.clientHeight) {
    // el.preventDefault();
    // 根据滚轮滚动的距离来计算滚动量
    const scrollAmount = el.deltaY > 0 ? 100 : -100;

    // 修改盒子的滚动位置
    containerElement.scrollTop += scrollAmount;

  }

}

onMounted(() => {
  // 处理容器滚动
  // nextTick(() => {
  //   if (containerElement != null) {
  //     // containerElement.forEach((el) => {
  //     //   const nbbmHaveSaleInfo = el.firstElementChild.firstElementChild;
  //     //   if ("fleet-nbbm-info-have-sale" == nbbmHaveSaleInfo.className) {
  //     //     const textWidth = nbbmHaveSaleInfo.children[1].firstElementChild.offsetWidth;
  //     //     // 有售票员
  //     //     for (let index = 0; index < el.children.length; index++) {
  //     //       const element = el.children[index];
  //     //       element.style.width = `${textWidth}px`;
  //     //     }
  //     //     // 无售票员
  //     //   } else {
  //     //     const textWidth = nbbmHaveSaleInfo.firstElementChild.offsetWidth;
  //     //     for (let index = 0; index < el.children.length; index++) {
  //     //       const element = el.children[index];
  //     //       element.style.width = `${textWidth}px`;
  //     //     }
  //     //   }
  //     // })
  //     loading.value = false;
  //   } else {

  //   }
  // })
  nextTick(() => {
    const containerElement = fleetContentBox.value;
    handleContainerScrollCallBack(containerElement);
  })
})

</script>

<style lang="scss" scoped>
.fleet-content-box {
  height: calc(100% - clamp(0.8rem, -0.907rem + 5.71vw, 1.3rem));
  // height: auto;
  width: auto;
  // overflow-y: hidden;
  // overflow-x: hidden;
  overflow: hidden;

  .scrolling {
    animation: scroll 5s linear infinite;
  }

  @keyframes scroll {
    0% {
      transform: translateY(0);
    }

    100% {
      transform: translateY(-100%);
    }
  }

  // 线路信息
  .fleet-line-info-container {
    width: 100%;
    height: auto;

    .fleet-line-title {
      margin-top: clamp(0.8rem, -0.549rem + 4.09vw, 1.2rem);
      margin-bottom: calc(clamp(0.8rem, -0.549rem + 4.09vw, 1.2rem) - 0.4vw);
      box-sizing: border-box;
      font-weight: bold;
    }

    .fleet-nbbm-info-container {
      width: 100%;
      height: auto;
      box-sizing: border-box;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      // justify-content: flex-start;
      font-size: 0.8vw;

      .fleet-nbbm-info-item {
        width: 6vw;
        height: 2.4vh;
        box-sizing: border-box;
        margin-top: 0.4vw;
        // margin-right: 0.4vw;
        color: black;

        .fleet-nbbm-info-have-sale {
          width: 100%;
          height: 100%;
          display: flex;

          .fleet-nbbm-have-sale-driver {
            border-radius: 1 solid #0761ba;
            border-radius: 5px 0 0 5px;
            height: 100%;
            width: 100%;
            margin-right: 0.2vw;
            position: relative;
            display: flex;
            align-items: center;
          }

          .fleet-nbbm-have-sale-sale {
            width: 100%;
            height: 100%;
            border-radius: 0 5px 5px 0;
            display: flex;
            justify-content: center;
            align-items: center;
          }

          .fleet-nbbm-have-sale-txt-box {
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;

            .fleet-nbbm-have-sale-txt {
              position: absolute;
              width: auto;
              /* 防止文字换行 */
              white-space: nowrap;

              padding-left: 0.5vw;
              padding-right: 0.5vw;
              /** 防止元素遮挡 */
              pointer-events: none;
            }
          }
        }

        .fleet-nbbm-info-no-sale {
          width: 100%;
          height: 100%;
          position: relative;
          display: flex;
          justify-content: center;
          align-items: center;
          box-sizing: border-box;
          border-radius: 5px;

          /* 防止文字换行 */
          .fleet-nbbm-info-no-sale-text {
            position: absolute;
            width: auto;
            white-space: nowrap;
            padding-left: 0.5vw;
            padding-right: 0.5vw;
            /* 防止文字换行 */
          }
        }
      }
    }




  }
}



/* 定义滚动条样式 */
.fleet-content-box::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

/*定义滑块 内阴影+圆角*/
.fleet-content-box::-webkit-scrollbar-thumb {
  border-radius: 6px;
  // box-shadow: inset 0 0 0px rgba(237, 44, 37, .5);
  background-color: #01366c;
  background-image: url('../assets/bigview/scroll-box.png');
}

/* 设置滚动条拖拽按钮的样式 */
.fleet-content-box::-webkit-scrollbar-thumb:vertical {
  background-color: #0761ba;
  /* 背景图片的尺寸适应滑块 */
  background-size: cover;
}

.fleet-content-box::-webkit-scrollbar-button {
  display: none;
}

/*定义滚动条轨道 内阴影+圆角*/
.fleet-content-box::-webkit-scrollbar-track {
  box-shadow: inset 0 0 0px #01DEDD;
  border-radius: 6px;
  background-color: #121622;
}
</style>
<style>
.fleet-popover-style {
  color: black !important;
  margin: 10px 0 10px 0;
  min-width: 100px;
}

.el-popover.fleet-popover-style {
  border-color: #146EBD;
  background-color: #062a5ac5;
}

.fleet-popover-style .el-popover__title {
  color: black;
  font-weight: bold;
}

.el-popper[data-popper-placement^=top]>.el-popper__arrow::before {
  border-top-color: #062a5ac5 !important;
  background-color: #062a5ac5 !important;
}
</style>