index.vue 13 KB
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 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 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 289 290 291 292 293 294 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 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441
<template>
	<div class="lpbContent-wrap"  ref="lpbContentWrap">
		<div class="lpbContent"  ref="lpbContent" v-loading='loading'>
			<div :class="(lpbData.cs.length == 0 && lpbData.zdys.length == 0) ? 'bottom40 ljz-wrap':'ljz-wrap'"  :style="{'width':ljzWidth+'px'}" v-show="lpbData.ljzs.length>0">
				<!-- 循环逻辑幢数据 -->
				<div class="ljz" ref="ljz" v-for="(ljzs,ljzIndex) in lpbData.ljzs" :key="ljzIndex">
					<div  class="ljz-zdy-wrap" :style="{'min-height':ljzzdyHeight+40+'px'}">
						<!-- 循环逻辑幢下的幢单元 -->
  						<div class="ljz-zdy"  :style="{'min-height':ljzzdyHeight+40+'px'}" ref="ljzzdy" v-show="ljzs.zdys.length>0" v-for="(zdys,zdyIndex) in ljzs.zdys" :key="zdyIndex" >
							<!-- 循环幢单元下的层户 -->
							<!-- <div class="chTable-wrap"> -->
								<table  class="chTable" :style="{'top':(ljzzdyHeight-1-zdys.cs.length*65)+'px'}" border="1" cellspacing="0" cellpadding="0" v-show="zdys.cs.length>0">
									<tr v-for="(cs,csIndex) in zdys.cs" :key="csIndex">
										<!-- 显示层数 -->
										<td class="floor">{{cs.sjc}}</td>
										<!-- 显示户 -->
										<td v-for="(hs,hsIndex) in cs.hs" :data-bsm="hs.bsm" ref="hBsm" :key="hsIndex" :class="(searchNum == hs.shbw || searchNum == hs.bdcdyh) ? 'tdSelect':''" @click="handleTdClick($event,hs.bsm)" @dblclick="dbclick(hs.bsm)">{{hs.shbw}}</td>
									</tr>
								</table>
							<!-- </div> -->
							<!-- 幢单元名称 -->
							<div class="zdy-name name">
								{{zdys.zdymc}}
							</div>
						</div>
						<!-- 循环逻辑幢下的层户 -->
						<div class="ljz-ch" :style="{'min-height':ljzzdyHeight+40+'px'}"  v-if="ljzs.cs.length>0">
							<table  class="chTable" :style="{'top':(ljzzdyHeight+40-1-ljzs.cs.length*65)+'px'}" border="1" cellspacing="0" cellpadding="0">
								<tr v-for="(cs) in ljzs.cs" :key="cs.bsm">
									<!-- 显示层数 -->
									<td class="floor">{{cs.sjc}}</td>
									<!-- 显示户 -->
									<td v-for="(hs,hsIndex) in cs.hs" :data-bsm="hs.bsm" ref="hBsm" :key="hsIndex" :class="(searchNum == hs.shbw || searchNum == hs.bdcdyh) ? 'tdSelect':''" @click="handleTdClick($event,hs.bsm)" @dblclick="dbclick(hs.bsm)">{{hs.shbw}}</td>
								</tr>
							</table>
						</div>
					</div>

					<!-- 逻辑幢名称 -->
					<div class="ljz-name name">
						{{ljzs.ljzmc}}
					</div>
				</div>
			</div>
			<div class="zdy-wrap" :style="{'width':zdyWidth+'px'}">
				<!-- 循环自然幢下的幢单元 -->
				<div class="zdy column-reverse" ref="zdy" v-for="(zdys,zdyIndex) in lpbData.zdys" :key="zdyIndex" :style="{'min-height':zdyHeight+'px'}">
					<!-- 幢单元名称 -->
					<div class="zdy-name name">
						{{zdys.zdymc}}
					</div>
					<!-- 循环幢单元下的层户 -->
					<table  class="chTable" border="1" cellspacing="0" cellpadding="0" v-show="zdys.cs.length>0">
						<tr v-for="(cs,csIndex) in zdys.cs" :key="csIndex">
							<!-- 显示层数 -->
							<td class="floor">{{cs.sjc}}</td>
							<!-- 显示户 -->
							<td v-for="(hs,hsIndex) in cs.hs" :data-bsm="hs.bsm" ref="hBsm" :key="hsIndex" :class="(searchNum == hs.shbw || searchNum == hs.bdcdyh) ? 'tdSelect':''" @click="handleTdClick($event,hs.bsm)"  @dblclick="dbclick(hs.bsm)">{{hs.shbw}}</td>
						</tr>
					</table>
				</div>
				<!-- 循环自然幢下的独立层户 -->
				<!-- <template > -->
				<div class="zdy column-reverse" :style="{'min-height':cHeight+'px'}">
					<table  class="chTable" ref="ch" border="1"  cellspacing="0" cellpadding="0" v-show="lpbData.cs != null && lpbData.cs.length>0" >
						<tr v-for="(cs,csIndex) in lpbData.cs" :key="csIndex">
							<!-- 显示层数 -->
							<td class="floor">{{cs.sjc}}</td>
							<!-- 显示户 -->
							<td v-for="(hs,hsIndex) in cs.hs" :data-bsm="hs.bsm" ref="hBsm" :key="hsIndex" :class="(searchNum == hs.shbw || searchNum == hs.bdcdyh) ? 'tdSelect':''" @click="handleTdClick($event,hs.bsm)"  @dblclick="dbclick(hs.bsm)">{{hs.shbw}}</td>
						</tr>
					</table>
				</div>
				<!-- </template> -->
			</div>
			<!-- <div class="ch-wrap">层户</div> -->
		</div>
		<div
			class="zrz"
			:style="{ width: lpbContentWidth + 'px'}"
		>
			{{ lpbData.xmmc }}
		</div>
	</div>
</template>

<script>
import {getLpb} from "../../../../../api/lpb"
export default {
	name: "",
	components: {},
	props: {},
	data() {
		return {
			lpbData: {
				ljzs:[],
				cs:[],
				zdys:[]
			},
			lpbContentWidth: "",
			ljzWidth:10000,
			zdyWidth:1000,
			cHeight:0, //独立层户的div高度
			zdyHeight:0, //独立幢单元的div高度
			ljzcHeight:0, //逻辑幢下层户的div高度
			ljzzdyHeight:0, //逻辑幢下幢单元的div高度
			loading:true,
			hbsmList:[],
			time:null, //区分单双击事件的定时器
			searchNum:Math.random(),
			//接收父组件传入的根据单元状态/房屋性质/房屋用途筛选的户bsmList
			choosedList:[]
		};
	},
	created() {
	},
	mounted() {
		this.getLpb(this.$store.state.zrzbsm);
		setTimeout(() => {
			//tab-content宽度 - 右侧图例宽度 - lp-overview滚动条宽度 - lpbContent的pandingRight
			this.lpbContentWidth = this.$store.state.contentWidth - 34 - 20; 
			//让滚动条滚动至最下面 -6是横向滚动条的高度
			this.$refs.lpbContent.scrollTop = this.$refs.lpbContent.scrollHeight - this.$refs.lpbContent.clientHeight - 6;
		}, 200);
	},
	methods: {
		//获取楼盘表数据
		getLpb(zrzbsm){
			getLpb(zrzbsm)
			.then((res => {
				if (res.code == 200) {
					this.loading = false;
					this.lpbData = res.result == null ? this.lpbData:res.result;
					setTimeout(() => {
						//渲染楼盘表
						this.dataChange()
					}, 200);
				} else {
					this.$message({
						message: res.message,
						type: "warning",
					});
				}
			}))
		},
		//按照bdcdyh或shbw筛选户
		lpbDataMap(sh){
			// console.log('查询'+sh);
			this.searchNum = sh;
		},
		//自然幢下元素高度宽度计算
		dataChange(){
			//计算逻辑幢宽度  20为marginRight值
			this.ljzWidth -= 9980;
			if(this.$refs.ljz!=undefined){
				this.$refs.ljz.forEach(item=>{
					this.ljzWidth += item.offsetWidth + 20
				})
			}else{

			}
			//计算独立幢单元和独立层户宽度
			//考虑this.$refs.zdy的length为0的情况,即自然幢下没有独立幢单元
			if(this.$refs.zdy != undefined && this.$refs.zdy.length > 0){
				//判断自然幢下有没有比层户高的幢单元
				let higher = true;
				//记录最高的幢单元高度 默认为第一个幢单元高度
				let highest = this.$refs.zdy[0].offsetHeight;
				this.zdyWidth -= 980;
				this.$refs.zdy.forEach(item=>{
					this.zdyWidth += item.offsetWidth + 21; 
					this.cHeight = item.offsetHeight > this.cHeight ? item.offsetHeight : this.cHeight;
					highest = highest > item.offsetHeight ? highest:item.offsetHeight;
				})
				//判断有无独立层户
				if(this.$refs.ch != undefined){
					//计算自然幢下的幢单元高度,如果有比层户高的幢单元,则幢单元高度设为最高的幢单元高度,如果没有,则设为层户高度
					higher = highest > this.$refs.ch.offsetHeight ? true:false;
					this.zdyHeight = higher ? highest : this.$refs.ch.offsetHeight
					this.zdyWidth += this.$refs.ch.offsetWidth;
				}else{
					this.zdyHeight = highest;
				}
			}else{
				// this.zdyWidth = 124;
			}

			//计算逻辑幢下的幢单元和层户的高度
			if(this.$refs.ljzzdy != undefined && this.$refs.ljzzdy.length > 0){
				//判断自然幢下有没有比层户高的幢单元
				let higher = true;
				//记录最高的幢单元高度 默认为第一个幢单元高度
				let highest = this.$refs.ljzzdy[0].offsetHeight;
				this.$refs.ljzzdy.forEach(item=>{
					this.ljzcHeight = item.offsetHeight > this.ljzcHeight ? item.offsetHeight : this.ljzcHeight;
					highest = highest > item.offsetHeight ? highest:item.offsetHeight;
				})
				//判断有无独立层户
				if(this.$refs.ljzch != undefined){
					//计算自然幢下的幢单元高度,如果有比层户高的幢单元,则幢单元高度设为最高的幢单元高度,如果没有,则设为层户高度
					higher = highest > this.$refs.ljzch.offsetHeight ? true:false;
					this.ljzzdyHeight  = higher ? highest : this.$refs.ljzch.offsetHeight
				}else{
					this.ljzzdyHeight = highest;
				}
			}else{
				// this.zdyWidth = 124;
			}
		},
		//户单击事件
		handleTdClick(e,bsm){
			let self = this;
			// 开启延时器,200ms的间隔区分单击和双击,解决双击时执行两次单击事件
			clearTimeout(self.time);
			self.time = setTimeout(() => {
				//判断点击的户是否选中
				if(e.target.className.indexOf('tdSelect') == -1){
					//未选中→选中
					e.target.className = 'tdSelect'; //加边框
					this.hbsmList.push(bsm) // 将户bsm放进hbsmList
				}else{
					//选中→未选中
					e.target.className = '';
					this.deleteArrOption(this.hbsmList,bsm);
				}
				this.$parent.getHbsm(this.hbsmList,false);
			}, 200);
		},
		//户双击事件
		dbclick(bsm){
			clearTimeout(this.time);
			this.hbsmList.push(bsm) // 将户bsm放进hbsmList
			this.$parent.getHbsm(this.hbsmList,true);
		},
		//删除多重数组中的某一项
		deleteArrOption(arr, item) {
			for (var i = arr.length; i > 0; i--) {
				if (arr[i - 1] == item) {
					arr.splice(i - 1, 1);
				}
			}
		},
		//清除选中户
		clearChoosedH(){
			this.$nextTick(()=>{
				//将每个选中的户的选中状态清除
				this.$refs.hBsm.forEach(item=>{
					if(item.className == 'tdSelect'){
						item.className = '';
					}
				});
				// 清空hbsmList
				this.hbsmList = [];
			})
		}
	},
	computed: {
		createFlagChange() {
			return this.$parent.createFlag;
		},
		legendToggleFlagChange() {
			return this.$parent.legendToggleFlag;
		},
	},
	watch: {
		createFlagChange: function(val) {
			setTimeout(() => {
				this.lpbContentWidth = this.$refs.lpbContent.offsetWidth -6;
			}, 501);
		},
		legendToggleFlagChange: function(val) {
			setTimeout(() => {
				this.lpbContentWidth = this.$refs.lpbContent.offsetWidth -6;
			}, 501);
		},
		//监听有无通过输入框查询选择到的户,如果有,将其bsm放入hbsmList
		searchNum(n){
			//清除之前选中户
			this.clearChoosedH();
			// 渲染查询到的户
			this.$nextTick(()=>{
				this.$refs.hBsm.forEach(item=>{
					if(item.className == 'tdSelect'){
						console.log(item.dataset.bsm,'item.dataset.bsm');
						// 判断hbsmList中是否已经存在
						if(this.hbsmList.indexOf(item.dataset.bsm) == -1){
							this.hbsmList.push(item.dataset.bsm) // 将户bsm放进hbsmList
						}
					}
				})
			})
		},
		//父组件中选择单元状态改变choosedList
		choosedList(n){
			this.$refs.hBsm.forEach(item=>{
				this.choosedList.forEach(i=>{
					if(item.dataset.bsm == i){
						item.className = 'tdSelect'
					}
				})
			})
		}
	},
};
</script>
<style scoped lang="less">
.lpbContent-wrap {
	width: 100%;
	height: 100%;
	overflow: hidden;
	position: relative;
	.lpbContent {
		width: 100%;
		height: 100%;
		position: relative;
		overflow: scroll;
		-webkit-user-select:none;
		-moz-user-select:none;
		-ms-user-select:none;
		user-select:none;
		.ljz-wrap {
			height: auto;
			overflow: hidden;
			margin-bottom: 20px;
			.ljz{
				float: left;
				margin-right: 20px;
				// position: relative;
				.ljz-zdy-wrap{
					.ljz-zdy{
						height: auto;
						margin-right: 20px;
						float: left;
						position: relative;
						.zdy-name{
    						width: 100%;
							bottom: 0;
							position: absolute;
							height: 40px;
							background-color: rosybrown;
						}
						// .chTable-wrap{
						// 	position: absolute;
						// 	bottom: 40px;
						// }
					}
					.ljz-ch{
						float: left;
					}
					.ljz-zdy:last-child{
						margin-right: 0;
					}
					.column-reverse{
						display:flex;
						flex-direction: column-reverse;
					}
				}
				.ljz-name{
					width: 100%;
					height: 40px;
					background-color: darkorange;
				}
			}
			div:last-child{
				margin-right: 0;
			}
		}
		.bottom40{
			position: absolute;
			bottom: 40px;
		}
		.zdy-wrap {
			height: auto;
			overflow: hidden;
			margin-bottom: 60px;
			.zdy{
				float: left;
				margin-right: 20px;
				
				.zdy-zdy-wrap{
					.zdy-zdy{
						height: auto;
						margin-right: 20px;
						display: inline-table;
						.zdy-name{
    						bottom: 0;
							background-color: blanchedalmond;
						}
					}
					.zdy-zdy:last-child{
						margin-right: 0;
					}
				}
				.zdy-name{
					width: 100%;
					height: 40px;
					background-color: rosybrown;
				}
			}
			.column-reverse{
				display:flex;
				flex-direction: column-reverse;
			}
		}

		// 公共部分样式 start
		.chTable{
			position: relative;
			tr{
				.floor{
					background-color: blanchedalmond;
				}
				td{
					width: 124px;
					height: 64px;
					line-height: 64px;
					text-align: center;
					cursor: pointer;
				}
				.tdSelect{
					border: 1px solid #0091FF!important;
				}
			}
		}
		.name{
			line-height: 40px;
			text-align: center;
		}
		// end
	}
	.zrz {
		height: 60px;
		line-height: 60px;
		background-color: darkgoldenrod;
		position: absolute;
		bottom: 6px;
		text-align: center;
		transition: 0.5s;
	}
}
</style>