Top.vue 9.87 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
<template>
  <!-- 设备按钮 -->

  <div class="typelist-div" @click.stop="">
    <div class="t flex" :class="{ show: searchShow }" @click.stop="">
      <div class="device-btn-wrapper flex">
        <div
          class="list"
          v-for="(item, index) in arr"
          :key="index"
          :class="selarr1.indexOf(item.val) >= 0 ? 'active' : ''"
          @click.stop="sel1(index, item)"
        >
          <img
            :src="item.imgurl"
            style="margin-top: 2px; float: left; margin-right: 3px"
          />
          {{ item.name }}
        </div>
      </div>

      <div class="img-wrapper flex">
        <img
          @click.stop="searchChange"
          :class="{ show: searchShow }"
          class="active"
          src="@/assets/firstimage/top-down.png"
          alt=""
        />
      </div>
      <div class="search flex">
        <div class="input-wrapper flex">
          <input v-model="searchVal" type="text" />
        </div>
        <div @click.stop="searchClick" class="btn-wrapper">搜索</div>
      </div>
      <img src="@/assets/firstimage/index-top-line.png" class="bottom-line" />
    </div>

    <!-- <div class="b"> -->
    <transition name="fadeBottom" mode="out-in">
      <div
        @click.stop=""
        class="device-container gdt"
        v-if="searchShow && searchItemShow"
      >
        <div
          class="devie-item zzz"
          v-for="item in searchList"
纪泽龙's avatar
纪泽龙 committed
50
          :key="item.id + '' + item.type"
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
          @click="deviceItemClick(item)"
        >
          <!-- {{ item.NAME }} -->
          <div class="a">{{ devviceData[item.type] }}</div>
          <div class="b">{{ item.NAME }}</div>
        </div>
      </div>
    </transition>
    <!-- </div> -->
  </div>
</template>

<script>
import { searchDevice, searchDeviceDetail } from "@/api/bigWindow/getDevice.js";
export default {
  name: "",
  data() {
    return {
69
      selarr1: [1],
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
      searchShow: false,
      searchItemShow: false,
      searchVal: "",
      searchList: [],
      devviceData: {
        1: "阀井 :",
        2: "调压箱 :",
        3: "场站 :",
        4: "居民用户 :",
        5: "商业用户 :",
        6: "工业用户 :",
        7: "监控 :",
        8: "餐饮单位液化气用户 :",
        9: "管道 :",
      },
      arr: [
        {
          val: 3,
          ischeck: false,
          imgurl: require("@/assets/firstimage/famen.png"),
          name: "阀门井",
        },
        {
          val: 4,
          ischeck: false,
          imgurl: require("@/assets/firstimage/changzhan.png"),
          name: "场 站",
        },
        {
99
          val: 2,
100
          ischeck: false,
101 102
          imgurl: require("@/assets/firstimage/tiaoyaxiang.png"),
          name: "调压箱",
103 104
        },
        {
105
          val: 1,
106
          ischeck: false,
107 108
          imgurl: require("@/assets/firstimage/guandao.png"),
          name: "管道",
109 110 111 112 113 114 115
        },
        {
          val: 5,
          ischeck: false,
          imgurl: require("@/assets/firstimage/jiankong.png"),
          name: "监 控",
        },
116 117 118 119 120 121 122 123 124 125 126 127
        {
          val: 6,
          ischeck: false,
          imgurl: require("@/assets/firstimage/user.png"),
          name: "居民用户",
        },
        {
          val: 61,
          ischeck: false,
          imgurl: require("@/assets/firstimage/syUser.png"),
          name: "商业用户",
        },
128 129 130 131
        {
          val: 18,
          ischeck: false,
          imgurl: require("@/assets/firstimage/yhq.png"),
132
          name: "餐饮用户",
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
        },
      ],
    };
  },
  methods: {
    searchChange() {
      this.searchShow = !this.searchShow;
      // 如果关闭了搜索框,那么搜索联动数据框也要关闭
      if (!this.searchShow) {
        this.searchItemShow = false;
      }
    },
    searchClick() {
      searchDevice({ name: this.searchVal }).then((res) => {
        if (res.code == 200) {
          this.searchList = Object.values(res.data).flat();
纪泽龙's avatar
纪泽龙 committed
149 150
          this.searchItemShow = true;

151 152 153 154 155 156 157
          console.log(this.searchList);
        }
      });
    },
    deviceItemClick(item) {
      searchDeviceDetail({ type: item.type, id: item.id }).then((res) => {
        if (res.code == 200) {
158 159 160 161 162 163 164 165 166
          let data = null;
          // console.log(res);
          // console.log(item);

          // 1.阀井 iconType=3
          // 2.调压箱  iconType=2
          // 3.场站  iconType=4
          // 4.居民用户 6
          // 5.商业用户 61
纪泽龙's avatar
纪泽龙 committed
167
          // 6.工业用户
168 169 170
          // 7.监控  5
          // 8.餐饮单位液化气用户 conType=18
          // 9.管道  1
纪泽龙's avatar
纪泽龙 committed
171 172 173
          // 1,2,3的时候 是res.data.data才能获取数据,结构为数组。
          // 4,5 是 res.data就能获取数据,结构为数组
          // 7,8,9的时候,res.data能获取数据,结构为对象
174 175 176
          const type = item.type;
          if (type < 4) {
            data = res.data.data[0];
纪泽龙's avatar
纪泽龙 committed
177

178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
            if (type == 1) {
              data.iconType = 3;
            } else if (type == 2) {
              data.iconType = 2;
            } else {
              data.iconType = 4;
            }
          } else if (type < 7) {
            data = res.data[0];
            if (type == 4) {
              data.iconType = 6;
            } else if (type == 5) {
              data.iconType = 61;
            } else {
              data.iconType = 62;
            }
          } else {
            data = res.data;
            if (type == 7) {
              data.iconType = 5;
            } else if (type == 8) {
              data.iconType = 18;
            } else {
              data.iconType = 1;
            }
          }
          this.$emit("deviceSearchClick", item, data);
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
        }
      });
    },
    clearSearchContainer() {
      this.searchItemShow = false;
    },
    sel1(index, item) {
      const ind = this.selarr1.indexOf(item.val);
      if (ind >= 0) {
        this.selarr1.splice(ind, 1);
      } else {
        this.selarr1.push(item.val);
      }
      this.$emit("sel1", this.selarr1);
      // this.map.allfilter(this.selarr, this.selarr1);
    },
  },
};
</script>
<style lang="scss" scoped>
.typelist-div {
  transition: all 0.2s linear;
227
  width: 840px;
228 229 230 231 232
  // height: 96px;
  // height: 56px;
  z-index: 9999;
  position: fixed;
  top: 90px;
233
  margin-left: calc((100% - 840px) / 2);
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
  background: rgba(2, 41, 81, 0.25);
  border: 1px solid #275275;
  box-sizing: border-box;
  padding-top: 10px;
  transform: scale(1);
  .t {
    transition: all 0.2s linear;
    height: 40px;
    // background: blue;
    position: relative;
    overflow: hidden;
    &.show {
      height: 85px;
    }

    .list {
      z-index: 9999;
      float: left;
      margin-left: 15px;
      height: 28px;
      // margin-bottom:10px;
      color: #fff;
      line-height: auto;
      text-align: center;
      /* background: linear-gradient(86deg, #112238 0%, #086187 62%, #112238 100%);
  box-shadow: inset 0px 1px 2px 1px #125c9b; */
      font-size: 12px;
      padding: 1px 10px;
      cursor: pointer;
      line-height: 26px;
      background: rgba(31, 106, 215, 0.32);
      box-sizing: border-box;
      border: 1px solid #2d64b4;
      border-radius: 2px;
    }

    .list.active {
      /* background: linear-gradient(86deg, #112238 0%, #32a3d3 62%, #112238 100%);
  box-shadow: inset 0px 1px 2px 1px #125c9b; */
      // font-size: 12px;
      // color: #00ffff;
      // border: 1px solid #0f6ca1;
      // box-shadow: inset 0px 0px 10px 1px #0f6ca1;
      // background-size: 100% 100%;
      // background-repeat: no-repeat;
      background: linear-gradient(180deg, #ffb464 0%, #e96310 100%);
      border-radius: 2px;
      box-sizing: border-box;
      border: 1px solid #ffa065;
    }
    .list img {
      width: 20px;
      height: 20px;
    }
    .device-btn-wrapper {
289
      width: 780px;
290 291 292 293
      margin-right: 5px;
      flex-wrap: wrap;
    }
    .search {
294
      width: 785px;
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
      position: absolute;
      top: 40px;
      .input-wrapper {
        background: #082337;
        box-sizing: border-box;
        border: 1px solid #1a498e;
        margin-left: 15px;
        margin-right: 12px;
        box-sizing: border-box;
        // width: 600px;
        flex: 1;

        height: 28px;
        align-items: center;
        input {
          border: none;
          background: none;
          color: #fff;
          width: 100%;
          padding-left: 8px;

          &:focus {
            outline: none;
          }
        }
      }
      .btn-wrapper {
        width: 50px;
        height: 28px;
        color: #fff;
        text-align: center;
        line-height: 28px;
        background: linear-gradient(180deg, #19d6fe 0%, #1684e5 100%);
        box-sizing: border-box;
        border: 1px solid #72c1ff;
        cursor: pointer;
        &:hover {
          opacity: 0.7;
        }
      }
    }
    .img-wrapper {
      width: 28px;
      height: 28px;
      background: rgba(3, 39, 70, 0.8);
      border: 1px solid #125c98;
      margin-right: 10px;
      align-items: center;
      justify-content: center;

      img {
        width: 20px;
        height: 12px;
        transform: rotateZ(0deg);
        transition: all 0.2s linear;

        cursor: pointer;
        &.show {
          transform: rotateZ(180deg);
        }
      }
    }
    .bottom-line {
      position: absolute;
      right: 0;
      bottom: 0;
      width: 280px;
      height: 1px;
      // background: red;
    }
  }
  .device-container {
    width: 755px;
    max-height: 400px;
    position: absolute;
    background: rgba(2, 41, 81, 0.7);
    border: 1px solid #275275;
    box-sizing: border-box;
    top: 100px;
    padding: 10px;
    padding-bottom: 0;
    overflow-y: auto;

    .devie-item {
      color: #fff;
      margin-bottom: 10px;
      height: 28px;
      line-height: 28px;
      cursor: pointer;
      box-sizing: border-box;
      padding: 0 2px;
      display: flex;
      .a {
        width: 150px;
      }
      &:hover {
        background: linear-gradient(180deg, #ffb464 0%, #e96310 100%);
      }
    }
  }
}
</style>