<!--
 * @Author: 纪泽龙 jizelong@qq.com
 * @Date: 2026-01-12 14:23:40
 * @LastEditors: 纪泽龙 jizelong@qq.com
 * @LastEditTime: 2026-04-07 10:24:39
 * @FilePath: /huaxindd-web/src/views/Ind2/components/Bottom.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="bottom">
    <div class="l" v-if="left != 0" @click="left += 152"></div>
    <div
      class="r"
      v-if="left != -([...itemArr1,...itemArr2].length - 3) * 152"
      @click="left -= 152"
    ></div>

    <div class="container">
      <div class="container-scroll" :style="{ left: left + 'px' }">
        <div
          class="item"
          :class="{ active: activeArr1.indexOf(item.val) >= 0 }"
          v-for="item in itemArr1"
          :key="item.val"
          @click="activeChange1(item.val)"
        >
          <div class="text">{{ item.name }}</div>
          <div
            class="ac"
            :class="{ active: activeArr1.indexOf(item.val) >= 0 }"
          ></div>
        </div>

        <div
          class="item"
          :class="{ active: activeArr2.indexOf(item.val) >= 0 }"
          v-for="item in itemArr2"
          :key="item.val"
          @click="activeChange2(item.val)"
        >
          <div class="text">{{ item.name }}</div>
          <div
            class="ac"
            :class="{ active: activeArr2.indexOf(item.val) >= 0 }"
          ></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      left: 0,
      changeW: 152,
      itemArr1: [
        { name: "高压", val: 0 },
        { name: "次高压", val: 1 },
        { name: "中压", val: 2 },
      ],
      itemArr2: [
        { name: "调压箱", val: 3 },
        { name: "阀门井", val: 4 },
        { name: "场站", val: 5 },
        { name: "工业户", val: 6 },
      ],
      activeArr1: [0, 1, 2],
      activeArr2: [],
    };
  },
  methods: {
    activeChange1(val) {
      const ind = this.activeArr1.indexOf(val);
      if (ind >= 0) {
        this.activeArr1.splice(ind, 1);
      } else {
        this.activeArr1.push(val);
      }
      this.$emit("change", ind, val,this.activeArr1);
    },

    activeChange2(val) {
      const ind = this.activeArr2.indexOf(val);
      if (ind >= 0) {
        this.activeArr2.splice(ind, 1);
      } else {
        this.activeArr2.push(val);
      }
      this.$emit("change", ind, val,this.activeArr1);
    },
  },
};
</script>
<style lang="scss" scoped>
.bottom {
  position: absolute;
  bottom: 10px;
  left: 50%;
  margin-left: -343px;
  width: 686px;
  height: 50px;
  // display: flex;
  // justify-content: space-between;
  background: url("~@/assets/bigwindowImg/ind3Img/bigBg.png") no-repeat center
    center;
  display: flex;
  align-items: center;
  .l,
  .r {
    position: absolute;
    cursor: pointer;
    transition: all 0.5s;
    top: 18px;

    &:hover {
      opacity: 0.8;
    }
  }
  .l {
    left: 88px;
    width: 20px;
    height: 14px;
    background: url("~@/assets/bigwindowImg/ind3Img/l.png") no-repeat center
      center;
  }
  .r {
    right: 88px;
    width: 20px;
    height: 14px;
    background: url("~@/assets/bigwindowImg/ind3Img/r.png") no-repeat center
      center;
  }
  .container {
    width: 432px;
    height: 28px;
    // background: red;
    margin: 0 auto;
    overflow: hidden;

    .container-scroll {
      position: relative;
      // left: 0;
      transition: all 0.5s;

      display: flex;
      // width: 1000px;
      .item {
        flex-shrink: 0;
        width: 128px;
        height: 28px;
        margin-right: 24px;
        position: relative;
        text-align: center;
        line-height: 28px;
        background: url("~@/assets/bigwindowImg/ind3Img/boxbg.png") no-repeat
          center center;
        color: #fff;
        font-size: 14px;
        cursor: pointer;
        &.active {
          background: rgba(0, 0, 0, 0);
        }
        .text {
          position: absolute;
          width: 100%;
          height: 100%;
          text-align: center;
          line-height: 28px;
          left: 0;
          top: 0;
          z-index: 99;
        }
        .active {
          width: 128px;
          height: 28px;
          background: url("~@/assets/bigwindowImg/ind3Img/active.png") no-repeat
            center center;
          position: absolute;
          top: 0;
          left: 0;
          // transition: all 0.5s;
          opacity: 0.8;
        }
      }
    }
  }
}
</style>
