Blame view

src/views/lpb/lpbContent/ch.vue 7.61 KB
1 2 3 4
<!--
 * @Author: yangwei
 * @Date: 2023-02-28 15:47:12
 * @LastEditors: yangwei
yangwei committed
5
 * @LastEditTime: 2023-06-16 16:14:51
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
 * @FilePath: \bdcdj-web\src\views\lpb\lpbContent\ch.vue
 * @Description: 
 * 
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. 
-->
<template>
  <div class="ch-wrap">
    <table
      class="chTable"
      ref="ch"
      border="1"
      cellspacing="0"
      cellpadding="0"
      v-show="ch.length"
    >
      <tr v-for="(cs, csIndex) in ch" :key="csIndex">
        <!-- 显示层数 -->
        <td
          class="floor"
          ref="cBsm"
          @contextmenu.prevent="openMenu($event, cs, 'c')"
          @click="handleClickC($event, cs)"
        >
          {{ cs.sjc }}
        </td>
        <!-- 显示户 -->
        <td
          v-for="(hs, hsIndex) in cs.hs"
          :rowspan="hs.sjcs"
          :colspan="hs.sjhs"
          :data-bsm="hs.bsm"
          :data-qszt="hs.qszt"
          ref="hBsm"
          :key="hsIndex"
yangwei committed
40
          :style="{'border-color': borderColor}"
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
          :class="hs.select ? 'tdSelect' : ''"
          @click="handleClickH($event.target, hs.bsm, hs)"
          @dblclick="dbclick(hs.bsm)"
          @contextmenu.prevent="openMenu($event, hs, 'h')"
        >
          {{ hs.shbw }}
          <span @click.stop="" class="hqszt lin" v-show="hs.qszt == '0'"
            ></span
          >
          <span @click.stop="" class="hqszt zheng" v-show="hs.qszt == '1'"
            ></span
          >
          <span @click.stop="" class="hqszt xian" v-show="hs.qszt == '2'"
            ></span
          >
          <ul @click.stop="hDyztClick($event, hs.bsm, hs)" class="dyzt">
            <li style="background-color: #6edee1" v-show="hs.qqzt == '1'">

            </li>
            <li style="background-color: #8adc88" v-show="hs.bazt == '1'">

            </li>
            <li style="background-color: #ff8282" v-show="hs.dyzt == '1'">

            </li>
            <li style="background-color: #d7cecf" v-show="hs.cfzt == '1'">

            </li>
            <li style="background-color: #d4a3eb" v-show="hs.yyzt == '1'">

            </li>
            <li style="background-color: #a5a3fb" v-show="hs.xzzt == '1'">

            </li>
          </ul>
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
export default {
  name: "BdcdjWebCh",
yangwei committed
85 86 87 88 89 90
  inject: {
    openMenu:{value:'openMenu',default:null},
    selectAll:{value:'selectAll',default:null},
    changeChoosedObj:{value:'changeChoosedObj',default:null},
    clearChangeChoosedObj:{value:'clearChangeChoosedObj',default:null}
  },
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
  props: {
    ch: {
      type: Array,
      default: function () {
        return [];
      },
    },
  },
  data() {
    return {
      //选中户bsm合集
      hbsmList: [],
      //选中层bsm合集
      cbsmList: [],
      //选中户qszt集合
      hqsztList: [],
      //区分单双击事件的定时器
      time: null,
yangwei committed
109 110
      // 边框颜色
      borderColor:'rgb(230, 230, 230)'
111 112 113 114 115 116 117
    };
  },
  mounted() {},
  methods: {
    // 层选中事件
    handleClickC(e, item) {
      //判断点击的层是否选中
yangwei committed
118 119 120 121 122 123 124 125 126
      // if (e.target.className.indexOf("tdSelect") == -1) {
      //   //未选中→选中
      //   e.target.className += " tdSelect"; //加边框
      //   this.cbsmList.push(item.bsm);
      // } else {
      //   //选中→未选中
      //   e.target.className = "floor";
      //   this.cbsmList = this.cbsmList.filter((i) => i != item.bsm);
      // }
127 128 129 130 131 132 133
      // this.$parent.getCbsm(this.cbsmList);
    },
    //户单击事件
    handleClickH(e, bsm, hs) {
    },
    // 户单元状态点击事件
    hDyztClick(e, bsm, hs) {
yangwei committed
134
      // this.handleClickH(e.target.parentNode, bsm, hs);
135 136 137
    },
    //户双击事件
    dbclick(bsm) {
yangwei committed
138
      // clearTimeout(this.time);
139 140
    },
    //幢单元全选/反选
yangwei committed
141 142 143
    zdySelectAll(val,flag) {
      // 手动点击全部取消选中
      !flag &&  this.clearChangeChoosedObj()
144 145 146 147 148 149 150 151
      this.ch.forEach((c) => {
        c.hs.forEach((h) => {
          if (val) {
            h.select = true;
            // 使用hbsmList时,需要去重
            this.hbsmList.push(h.bsm)
          } else {
            h.select = false;
yangwei committed
152
            this.borderColor = 'rgb(230, 230, 230)'
153 154 155 156
            this.hbsmList = []
          }
        });
      });
yangwei committed
157 158 159 160 161
      this.$refs.hBsm && this.$refs.hBsm.forEach((item) => {
        // item.style.borderColor = this.borderColor
        item.style.backgroundColor =  '#fff';
        // item.style.border = `1px solid ${this.borderColor}`
      });
162 163 164 165 166 167 168 169 170 171
    },
  },
  watch: {
    selectAll: {
      handler(val) {
        this.zdySelectAll(val.selectAll);
      },
      immediate: true,
      deep: true,
    },
yangwei committed
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
    changeChoosedObj: {
      handler(val) {
        debugger
        //清除选中户
        this.borderColor = 'rgb(230, 230, 230)';
        this.zdySelectAll(false,true)
        if (val.bsms.length) {
          this.$refs.hBsm.forEach((item) => {
            val.bsms.forEach((i,ind) => {
              if (item.dataset.bsm == i) {
                if (ind == 0) {
                  //定位到第一个户所在位置
                  window.lpbContent.$refs.lpbContent.scrollTop = item.offsetTop;
                  window.lpbContent.$refs.lpbContent.scrollLeft = item.offsetLeft;
                }
                item.style.border = '1px solid '+ val.color;
                // item.style.backgroundColor =  val.color;
              }
            });
          });
        }else{
          this.borderColor = 'rgb(230, 230, 230)'
        }

      },
      immediate: true,
      deep: true,
    },
200 201 202 203 204 205 206 207 208
  },
};
</script>

<style lang="scss" scoped>
.ch-wrap {
  display: flex;
  flex-direction: column-reverse;
  .chTable {
yangwei committed
209
    // margin-left: -1px;
210 211 212 213 214
    border-color: #e4ebf4 !important;
    border-collapse: collapse;
    border-spacing: 0;
    // position: relative;
    tr {
yangwei committed
215 216 217 218 219 220 221 222 223 224
      .floor {
        min-width: 56px;
        background: #e8f2ff;
        border: 1px solid #acbae8;
      }
      &:first-child {
        .floor {
          border-radius: 4px 0px 0px 1px;
        }
      }
225 226
      td {
        min-width: 138px;
yangwei committed
227 228
        height: 64px;
        line-height: 64px;
229 230 231 232 233 234 235 236 237 238 239 240 241
        text-align: center;
        cursor: pointer;
        position: relative;
        .hqszt {
          display: inline-block;
          width: 16px;
          height: 16px;
          font-size: 12px;
          line-height: 16px;
          position: absolute;
          left: 6px;
          top: 6px;
          border: 1px solid;
yangwei committed
242
          border-radius: 3px 0px 3px 0px;
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
        }
        .lin {
          color: #f7b500;
          border-color: #f7b500;
        }
        .zheng {
          color: #1ad6e1;
          border-color: #1ad6e1;
        }
        .xian {
          color: #45aefd;
          border-color: #45aefd;
        }
        .dyzt {
          user-select: none;
          width: 138px;
          height: 18px;
          position: absolute;
yangwei committed
261
          bottom: 28px;
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
          box-sizing: border-box;
          padding: 0 6px;
          li {
            display: inline-block;
            width: 18px;
            height: 18px;
            font-size: 12px;
            line-height: 18px;
            color: #ffffff;
            border: 1px solid;
            border-radius: 9px;
          }
        }
      }
      .tdSelect {
yangwei committed
277 278
        border: 1px solid ;
        border-color: #5A78DE !important;
279 280 281 282 283 284 285 286 287 288 289 290 291
        background-image: url("./images/tdSelect.png");
        background-repeat: no-repeat;
        background-position: right top;
        background-size: 30px;
      }
      .hasBorder {
        border-width: 1px;
        border-style: solid;
      }
    }
  }
}
</style>