<template>
	<div>
		<el-row :gutter="20" class="elrow">
			<el-col :span="colNum_4" class="mb-2">
				<el-card shadow="hover" class="cardrelative aftercolor4">
					<div class="contentc">
						<div class="contenttitle">小区数</div>
						<div class="contentnum">{{ projectNum }}</div>
						<img src="../assets/img/ld.png" alt="" class="pzimg" />
					</div>
				</el-card>
			</el-col>
			<el-col :span="colNum_4" class="mb-2">
				<el-card shadow="hover" class="cardrelative aftercolor4">
					<div class="contentc">
						<div class="contenttitle">楼栋数</div>
						<div class="contentnum">{{ buildingNum }}</div>
						<img src="../assets/img/ld.png" alt="" class="pzimg" />
					</div>
				</el-card>
			</el-col>
			<el-col :span="colNum_4" class="mb-2">
				<el-card shadow="hover" class="cardrelative aftercolor4">
					<div class="contentc">
						<div class="contenttitle">总房间</div>
						<div class="contentnum">{{ roomNum }}</div>
						<img src="../assets/img/ld.png" alt="" class="pzimg" />
					</div>
				</el-card>
			</el-col>
			<el-col :span="colNum_4" class="mb-2">
				<el-card shadow="hover" class="cardrelative aftercolor2">
					<div class="contentc">
						<div class="contenttitle">已入住</div>
						<div class="contentnum">{{ checkin }}</div>
						<img src="../assets/img/ld.png" alt="" class="pzimg right20" />
					</div>
				</el-card>
			</el-col>
			<el-col :span="colNum_4" class="mb-2">
				<el-card shadow="hover" class="cardrelative aftercolor2">
					<div class="contentc">
						<div class="contenttitle">空房间</div>
						<div class="contentnum">{{ emptyroomNum }}</div>
						<img src="../assets/img/f.png" alt="" class="pzimg right20" />
					</div>
				</el-card>
			</el-col>
			<el-col :span="colNum_4" class="mb-2">
				<el-card shadow="hover" class="cardrelative aftercolor2">
					<div class="contentc">
						<div class="contenttitle">维修房</div>
						<div class="contentnum">0</div>
						<img src="../assets/img/ms.png" alt="" class="pzimg" />
					</div>
				</el-card>
			</el-col>
			<el-col :span="colNum_4" class="mb-2">
				<el-card shadow="hover" class="cardrelative aftercolor2">
					<div class="contentc">
						<div class="contenttitle">到期房</div>
						<div class="contentnum">0</div>
						<img src="../assets/img/ms.png" alt="" class="pzimg" />
					</div>
				</el-card>
			</el-col>
			<el-col :span="colNum_4" class="mb-2">
				<el-card shadow="hover" class="cardrelative aftercolor5">
					<div class="contentc">
						<div class="contenttitle">未绑定门锁</div>
						<div class="contentnum">{{ unboundNum }}</div>
						<img src="../assets/img/ms.png" alt="" class="pzimg" />
					</div>
				</el-card>
			</el-col>
		</el-row>
		<el-row :gutter="20" class="elrow">
			<el-col :span="24" v-if="activeiconfont">
				<el-card shadow="nerver" class="searchlist">
					<el-row :gutter="20" class="searchlist1">
						<div class="selectoptionClass" v-if="userInfo.type == 0">
							<selectoption></selectoption>
						</div>
						<!-- <selectoption></selectoption> -->
						<el-input placeholder="请输入校区名称" v-model="input5" :clearable="true" class="inputBox mb-2"
							size="small"></el-input>
						<el-cascader :options="optionsData" ref="cascaderAddr1" size="small" class="mb-2"
							v-model="selectedOptionsData1" @change="handleChangeMethods1" placeholder="请选择具体地址"
							clearable></el-cascader>
						<el-button type="primary" @click="queryfirstall" class="mb-2" size="small"
							style="background: #FA8E00; border: none;">查询</el-button>
						<el-button type="primary" @click="handleSearch1" class="mb-2" size="small"
							style="background: #FA8E00; border: none;">添加</el-button>
						<el-button type="primary" @click="resetInput" class="mb-2" size="small"
							style="background: #FA8E00; border: none;">重置</el-button>
					</el-row>
				</el-card>
			</el-col>
		</el-row>
		<div class="userlist" v-if="activeiconfont">
			<div class="switchiconfont">
				<i class="iconfont httpicon-liebiao1" :class="activeiconfont1 ? 'active' : ''" @click="activeiconfun(true)"
					title="切换方块展示"></i>
				<i class="iconfont httpicon-liebiao" :class="activeiconfont1 ? '' : 'active'" @click="activeiconfun(false)"
					title="切换表格展示"></i>
			</div>
			<div class="adddbtn">
				<el-button type="primary" @click="backFun1" size="mini"
					style="background: #FA8E00; border: none;">房间管理</el-button>
				<el-button type="primary" @click="exportSelect" size="mini"
					style="background: #FA8E00; border: none;">导出房源</el-button>
			</div>
			<div class="taball">
				<div class="roomcontent" v-if="activeiconfont1">
					<div class="roomconli" v-for="(item, index) in schoollist" :key="index">
						<roomLi :data="item"></roomLi>
						<div class="button-list">
							<div @click="see(index, item)">查看</div>
							<div @click="handleEdit1(index, item)">添加下级</div>
							<div @click="handleEdit4(index, item)">编辑</div>
							<div @click="handleDelete(index, item)">删除</div>
							<div @click="exportRoomDevice(index, item)">导出</div>
						</div>
					</div>
					<div class="paging">
						<el-pagination @current-change="handleCurrentChange1" :current-page="rootcurrentPage"
							:page-size="10" layout="total, prev, pager, next" :total="schooltotal">
						</el-pagination>
					</div>
				</div>
				<div class="" v-if="!activeiconfont1">
					<el-table :data="schoollist" border class="table" stripe ref="multipleTable"
						header-cell-class-name="table-header" @selection-change="handleSelectionChange" height="600"
						width="100%">
						<el-table-column type="selection" width="70" align="center"></el-table-column>
						<el-table-column prop="id" label="ID" width="70" align="center"></el-table-column>
						<el-table-column prop="name" label="名称"></el-table-column>
						<el-table-column prop="count" label="入住"></el-table-column>
						<el-table-column prop="address" label="地址"></el-table-column>
						<el-table-column label="户型" align="center">
							<template #default="scope">
								<div v-if="scope.row.layout == 0">单间</div>
								<div v-else-if="scope.row.layout == 1">一室一厅</div>
								<div v-else-if="scope.row.layout == 2">两室一厅</div>
								<div v-else-if="scope.row.layout == 3">三室一厅</div>
								<div v-else-if="scope.row.layout == 4">三室二厅</div>
								<div v-else-if="scope.row.layout == 5">四室二厅</div>
								<div v-else>空</div>
							</template>
						</el-table-column>
						<el-table-column prop="acreage" label="面积/m²"></el-table-column>
						<el-table-column label="操作" width="250" align="center">
							<template #default="scope">
								<el-button type="text" @click="see(scope.$index, scope.row)">查看</el-button>
								<el-button type="text" @click="handleEdit1(scope.$index, scope.row)">添加下级</el-button>
								<el-button type="text" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
								<el-button type="text" class="red" @click="handleDelete(scope.$index, scope.row)">删除
								</el-button>
							</template>
						</el-table-column>
					</el-table>
					<div class="paging">
						<el-pagination @current-change="handleCurrentChange1" :current-page="currentPage" :page-size="10"
							layout="total, prev, pager, next" :total="schooltotal">
						</el-pagination>
					</div>
				</div>
			</div>
		</div>
		<div class="tablelist" v-if="!activeiconfont">
			<div class="switchiconfont">
				<i class="iconfont httpicon-liebiao1" :class="activeiconfont2 ? 'active' : ''" @click="activeiconfun1(true)"
					title="切换方块展示"></i>
				<i class="iconfont httpicon-liebiao" :class="activeiconfont2 ? '' : 'active'" @click="activeiconfun1(false)"
					title="切换表格展示"></i>
			</div>
			<div class="adddbtn">
				<el-button type="primary" @click="handleSearch1" size="mini" class="mb-2"
					style="background: #FA8E00; border: none;">添加</el-button>
				<el-button type="primary" @click="selectmoredel" size="mini" class="mb-2"
					style="background: #FA8E00; border: none;">批量删除</el-button>
				<!-- <el-button type="primary" @click="dbing" size="mini"
          >管理绑定</el-button
        > -->
				<el-button type="primary" @click="exportfun" size="mini" class="mb-2"
					style="background: #FA8E00; border: none;">导出房源</el-button>
				<el-button type="primary" @click="backFun" size="mini" class="mb-2"
					style="background: #FA8E00; border: none;">返回</el-button>
			</div>
			<el-row :gutter="20">
				<el-card shadow="nerver" class="m20">
					<el-col :span="colNum_6">
						<div class="ZTREE">
							<el-card shadow="nerver" class="h700">
								<el-tree :data="zNodes" node-key="id" :highlight-current="true"
									:expand-on-click-node="false" :props="defaultProps" @node-click="onClick" ref="tree"
									class="treeclass" :default-expanded-keys="expandedKeys">
									<span class="custom-tree-node" slot-scope="{ node, data }">
										<span>{{ node.label }}</span>
										<span>
											<el-button type="text" size="mini" @click="() => modifyEnterprise(node, data)">
												添加层级
											</el-button>
											<el-button type="text" size="mini" @click="() => modifyEnterprise1(node, data)">
												添加房间
											</el-button>
											<el-button type="text" size="mini" @click="() => handleEdit(node, data)">
												编辑
											</el-button>
											<el-button type="text" size="mini" @click="() => remove(node, data)">
												删除
											</el-button>
										</span>
									</span>
								</el-tree>
							</el-card>
						</div>
					</el-col>
					<el-col :span="colNum_18">
						<div class="" style="margin-bottom: 20px">
							<el-input placeholder="请输入房间名称" v-model="input6" size="small" :clearable="true"
								class="inputBox mb-2">
							</el-input>
							<el-select v-model="searchRoomStatus" placeholder="请选择房间状态" size="small" class="mb-2" clearable>
								<el-option key="1" label="空房间" value="0">
								</el-option>
								<el-option key="2" label="已入住" value="1">
								</el-option>
								<el-option key="3" label="到期房" value="2">
								</el-option>
								<el-option key="4" label="维修房" value="3">
								</el-option>
							</el-select>
							<el-select v-model="roomLayout" placeholder="请选择房间户型" size="small" class="mb-2" clearable>
								<el-option key="1" label="单房" value="0">
								</el-option>
								<el-option key="2" label="一室一厅" value="1">
								</el-option>
								<el-option key="3" label="两室一厅" value="2">
								</el-option>
								<el-option key="4" label="三室一厅" value="3">
								</el-option>
								<el-option key="5" label="三室两厅" value="4">
								</el-option>
								<el-option key="6" label="四室两厅" value="5">
								</el-option>
							</el-select>
							<el-select v-model="searchSelectStatus" placeholder="请选择设备绑定情况" size="small" class="mb-2"
								clearable>
								<el-option key="1" label="未绑定" value="2">
								</el-option>
								<el-option key="2" label="已绑定" value="1">
								</el-option>
							</el-select>
							<el-button type="primary" @click="getlist3" size="small" class="mb-2"
								style="background: #FA8E00; border: none;">查询</el-button>
							<el-button type="primary" @click="resetInput" size="small" class="mb-2"
								style="background: #FA8E00; border: none;">重置</el-button>
						</div>

						<el-table :data="userlist" border stripe class="table" ref="multipleTable"
							header-cell-class-name="table-header" @selection-change="handleSelectionChange" height="530"
							v-if="!activeiconfont2">
							<el-table-column type="selection" width="70" align="center"></el-table-column>
							<el-table-column prop="id" label="ID" width="70" align="center"></el-table-column>
							<el-table-column prop="name" label="名称"></el-table-column>
							<!-- <el-table-column prop="address" label="地址"></el-table-column> -->
							<el-table-column prop="count" label="入住"></el-table-column>
							<el-table-column prop="path" label="地址" width="300"></el-table-column>
							<el-table-column label="户型" align="center">
								<template #default="scope">
									<div v-if="scope.row.layout == 0">单间</div>
									<div v-if="scope.row.layout == 1">一室一厅</div>
									<div v-if="scope.row.layout == 2">两室一厅</div>
									<div v-if="scope.row.layout == 3">三室一厅</div>
									<div v-if="scope.row.layout == 4">三室两厅</div>
									<div v-if="scope.row.layout == 5">四室两厅</div>
								</template>
							</el-table-column>
							<el-table-column prop="acreage" label="面积/m²"></el-table-column>
							<el-table-column label="操作" width="250" align="center">
								<template #default="scope">
									<el-button type="text" @click="doorLock(scope.$index, scope.row)">门锁</el-button>
									<el-button type="text" @click="getroomperson(scope.$index, scope.row)">租户
									</el-button>
									<el-button type="text" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
									<el-button type="text" class="red" @click="handleDelete1(scope.$index, scope.row)">
										删除</el-button>
								</template>
							</el-table-column>
						</el-table>
						<div class="roomcontent roomcontentheight" v-else>
							<div class="roomconli roomconli1" v-for="(item, index) in userlist" :key="index">
								<roomLi1 :data="item"></roomLi1>
								<div class="button-list">
									<div @click="doorLock(index, item)">门锁</div>
									<div @click="getroomperson(index, item)">住户</div>
									<div @click="handleEdit(index, item)">编辑</div>
									<div @click="handleDelete1(index, item)">删除</div>
								</div>
							</div>
						</div>
						<div class="paging">
							<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
								:current-page="currentPage4" :page-size="20" layout="total, prev, pager, next, jumper"
								:total="total">
							</el-pagination>
						</div>
					</el-col>
				</el-card>
			</el-row>
		</div>
		<!-- 编辑弹出框 -->
		<el-dialog title="添加" :visible.sync="editVisible" width="30%">
			<el-tabs v-model="activeName" @tab-click="handleClick">
				<el-tab-pane label="单个创建" name="first">
					<el-form ref="form" :model="form" label-width="70px">
						<el-form-item label="名称">
							<el-input v-model="form.name" :clearable="true" placeholder="请输入名称"></el-input>
						</el-form-item>
						<el-form-item label="地址">
							<!-- <div class="address">
                <v-distpicker @selected="onSelected"></v-distpicker>
              </div> -->
							<el-cascader size="large" :options="optionsData" v-model="selectedOptionsData"
								@change="handleChangeMethods" placeholder="请选择具体地址" clearable></el-cascader>
						</el-form-item>
						<el-form-item label="户型">
							<el-select v-model="form.layout" placeholder="请选择" clearable>
								<el-option v-for="item in layoutlist" :key="item.value" :label="item.label"
									:value="item.value">
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="面积">
							<el-input v-model="form.acreage" :clearable="true" placeholder="请输入数字"></el-input>
						</el-form-item>
						<el-form-item label="是否房间">
							<el-switch v-model="form.isRoom" active-color="#13ce66" inactive-color="#ff4949">
							</el-switch>
						</el-form-item>
						<span class="dialog-footer">
							<el-button @click="editVisible = false">取 消</el-button>
							<el-button type="primary" @click="saveEdit">添加</el-button>
						</span>
					</el-form>
				</el-tab-pane>
				<el-tab-pane label="模板创建" name="second">
					<el-form ref="form" :model="form" label-width="70px">
						<el-form-item label="层级名称">
							<el-input v-model="form.name" :clearable="true"
								placeholder="例如：宿舍区、宿舍楼、 楼栋单元、楼层、房间，多个以‘、’隔开"></el-input>
						</el-form-item>
						<el-form-item label="地址">
							<el-cascader size="large" :options="optionsData" ref="cascaderAddr"
								v-model="selectedOptionsData" @change="handleChangeMethods" placeholder="请选择具体地址"
								clearable></el-cascader>
							<!-- <div class="address">
                <v-distpicker @selected="onSelected"></v-distpicker>
              </div> -->
						</el-form-item>
						<el-form-item label="层级数量">
							<el-input v-model="form.counts" :clearable="true" placeholder="请输入对应层级数量，多个以‘、’隔开">
							</el-input>
						</el-form-item>
						<el-form-item label="户型">
							<el-select v-model="form.layout" placeholder="请选择" clearable>
								<el-option v-for="item in layoutlist" :key="item.value" :label="item.label"
									:value="item.value">
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="面积">
							<el-input v-model="form.acreage" :clearable="true" placeholder="请输入数字"></el-input>
						</el-form-item>
						<span class="dialog-footer">
							<el-button @click="editVisible = false">取 消</el-button>
							<el-button type="primary" @click="saveEdit1">添加</el-button>
						</span>
					</el-form>
				</el-tab-pane>
			</el-tabs>
		</el-dialog>
		<el-dialog title="添加" :visible.sync="editVisible1" width="30%">
			<el-tabs v-model="activeName1" @tab-click="handleClick1">
				<el-tab-pane label="单个添加" name="first">
					<el-form ref="form" :model="form" label-width="70px">
						<el-form-item label="房间名称">
							<el-input v-model="form.name" :clearable="true" placeholder="请输房间名称"></el-input>
						</el-form-item>
						<el-form-item label="户型">
							<el-select v-model="form.layout" placeholder="请选择" clearable>
								<el-option v-for="item in layoutlist" :key="item.value" :label="item.label"
									:value="item.value">
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="面积">
							<el-input :clearable="true" v-model="form.acreage" placeholder="请输入数字"></el-input>
						</el-form-item>
						<el-form-item label="是否房间">
							<el-switch v-model="form.isRoom" active-color="#13ce66" inactive-color="#ff4949">
							</el-switch>
						</el-form-item>
						<span class="dialog-footer">
							<el-button @click="editVisible1 = false">取 消</el-button>
							<el-button type="primary" @click="saveEdit2">添加</el-button>
						</span>
					</el-form>
				</el-tab-pane>
				<el-tab-pane label="模板添加" name="second">
					<el-form ref="form" :model="form" label-width="70px">
						<el-form-item label="楼层">
							<el-input v-model="form.name" :clearable="true" placeholder="请输入楼层"></el-input>
						</el-form-item>
						<el-form-item label="房间数量">
							<el-input v-model="form.count" :clearable="true" placeholder="请输入对应楼层的房间数"></el-input>
						</el-form-item>
						<el-form-item label="户型">
							<el-select v-model="form.layout" placeholder="请选择" clearable>
								<el-option v-for="item in layoutlist" :key="item.value" :label="item.label"
									:value="item.value">
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="面积">
							<el-input v-model="form.acreage" :clearable="true" placeholder="请输入数字"></el-input>
						</el-form-item>
						<el-form-item label="是否房间">
							<el-switch v-model="form.isRoom" active-color="#13ce66" inactive-color="#ff4949">
							</el-switch>
						</el-form-item>
						<span class="dialog-footer">
							<el-button @click="editVisible1 = false">取 消</el-button>
							<el-button type="primary" @click="saveEdit3">添加</el-button>
						</span>
					</el-form>
				</el-tab-pane>
			</el-tabs>
		</el-dialog>
		<el-dialog title="修改" :visible.sync="editVisible2" width="30%">
			<el-form ref="form" :model="form" label-width="70px">
				<el-form-item label="房间名称">
					<el-input v-model="form.name" :clearable="true" placeholder="请输入公寓名称"></el-input>
				</el-form-item>
				<el-form-item label="地址">
					<el-cascader size="large" :options="optionsData" ref="cascaderAddr" v-model="selectedOptionsData"
						@change="handleChangeMethods" placeholder="请选择具体地址" clearable></el-cascader>
					<!-- <div class="address">
            <v-distpicker @selected="onSelected1" :province="selectaddress.province" :city="selectaddress.city"
              :area="selectaddress.area"></v-distpicker>
          </div> -->
				</el-form-item>
				<el-form-item label="所属部门" v-if="userInfo.type == 0">
					<el-select v-model="form.enterpriseId" placeholder="请选择" clearable>
						<el-option v-for="item in enterpriselist" :key="item.id" :label="item.name" :value="item.id">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="户型">
					<el-select v-model="form.layout" placeholder="请选择" clearable>
						<el-option v-for="item in layoutlist" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="面积">
					<el-input v-model="form.acreage" :clearable="true" placeholder="请输入数字"></el-input>
				</el-form-item>
				<span class="dialog-footer">
					<el-button @click="editVisible2 = false">取 消</el-button>
					<el-button type="primary" @click="modifyfun">修 改</el-button>
				</span>
			</el-form>
		</el-dialog>
		<el-dialog title="修改" :visible.sync="editVisible3" width="30%">
			<el-form ref="form" :model="form" label-width="70px">
				<el-form-item label="房间名称">
					<el-input v-model="form.name" :clearable="true" placeholder="请输入公寓名称"></el-input>
				</el-form-item>
				<el-form-item label="户型">
					<el-select v-model="form.layout" placeholder="请选择" clearable>
						<el-option v-for="item in layoutlist" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="面积">
					<el-input v-model="form.acreage" :clearable="true" placeholder="请输入数字"></el-input>
				</el-form-item>
				<el-form-item label="是否房间">
					<el-switch v-model="form.isRoom" active-color="#13ce66" inactive-color="#ff4949">
					</el-switch>
				</el-form-item>
				<span class="dialog-footer">
					<el-button @click="editVisible3 = false">取 消</el-button>
					<el-button type="primary" @click="modifyfun1">修 改</el-button>
				</span>
			</el-form>
		</el-dialog>
		<el-dialog title="绑定" :visible.sync="editDeding" width="30%">
			<el-select v-model="userselectid" placeholder="请选择绑定用户" clearable>
				<el-option v-for="(item, index) in userselect" :key="index" :label="item.username" :value="item.id">
				</el-option>
			</el-select>
			<el-button @click="editDeding = false">取 消</el-button>
			<el-button type="primary" @click="Debinding">绑 定</el-button>
			<el-button type="primary" @click="Unbundling">解 绑</el-button>
		</el-dialog>
		<!-- 抽屉门锁 -->
		<el-drawer title="" :visible.sync="devicetable" :show-close="false" direction="rtl"
			custom-class="operationclass position-relative" size="60%">
			<div class="position-absolute left-15 top-10 color-666 d-inlie-block" style="width: 40px;cursor: pointer;"
				@click="handleClose">
				<img src="../assets/img/leftjt.svg" alt="" class="width-percentage-100">
			</div>
			<span class="font-size-16 colorBlue position-absolute right-40 top-20">{{ drawerTitle }}</span>
			<div class="temporary">
				<div v-if="selecttable">
					<el-table :data="gridData" label-width="80px" border height="300">
						<el-table-column label="房间名称" width="200">
							<template slot-scope="scope">
								<span class="blue" v-if="scope.row.roomName">{{ scope.row.roomName }}</span>
								<span class="" v-else>空</span>
							</template>
						</el-table-column>
						<el-table-column label="在线状态" align="center">
							<template #default="scope">
								<el-tag
									:type="scope.row.isOnline == '1' ? 'success' : scope.row.isOnline == '0' ? 'danger' : ''"><span
										v-if="scope.row.isOnline == 1">在线</span>
									<span v-else>离线</span>
								</el-tag>
							</template>
						</el-table-column>
						<el-table-column label="电量">
							<template slot-scope="scope">
								<i class="iconfont httpicon-dianchi-didianliang red" v-if="scope.row.battery <= 20"></i>
								<i class="iconfont httpicon-icon-test orange"
									v-else-if="20 < scope.row.battery && scope.row.battery < 60"></i>
								<i class="iconfont httpicon-icon-test green"
									v-else-if="60 < scope.row.battery && scope.row.battery < 100"></i>
								<i class="iconfont httpicon-icon-test red" v-else></i><span class="spanli dling"> {{
									scope.row.battery || 0 }}%</span>
							</template>
						</el-table-column>
						<el-table-column prop="" label="信号强度" width="150">
							<template slot-scope="scope">
								<i class="iconfont httpicon-xinhao38 red" v-if="scope.row.rssi <= 20"></i>
								<i class="iconfont httpicon-xinhao38 orange"
									v-else-if="20 < scope.row.rssi && scope.row.rssi < 60"></i>
								<i class="iconfont httpicon-xinhao38 green"
									v-else-if="60 <= scope.row.rssi && scope.row.rssi <= 100"></i>
								<i class="iconfont httpicon-wuxinhao red" v-else></i><span class="spanli dling"> {{
									scope.row.rssi || 0 }}</span>
							</template>
						</el-table-column>
						<el-table-column prop="deviceNum" label="设备号" width="200"></el-table-column>
						<el-table-column prop="imei" label="IMEI" width="150">
							<template slot-scope="scope">
								<span class="" v-if="scope.row.imei">{{ scope.row.imei }}</span>
								<span class="" v-else>空</span>
							</template>
						</el-table-column>
					</el-table>
				</div>
				<div v-if="!selecttable">
					<el-table :data="gridDataFirst" border class="table" ref="multipleTable2" height="300"
						header-cell-class-name="table-header">
						<!--						<el-table-column prop="card" label="ID" width="55" align="center"></el-table-column>-->
						<el-table-column prop="name" label="名称"></el-table-column>
						<el-table-column prop="phone" label="手机号"></el-table-column>
						<el-table-column prop="number" label="身份证"></el-table-column>
						<el-table-column label="人员类型">
							<template #default="scope">
								{{ scope.row.type === 0 ? '租客' : '物业' }}
							</template>
						</el-table-column>
						<el-table-column label="租期">
							<template #default="scope">
								{{ scope.row.startTime }} 至 {{ scope.row.endTime }}
							</template>
						</el-table-column>
						<el-table-column label="性别" align="center">
							<template #default="scope">
								{{ scope.row.sex == 1 ? "男" : "女" }}
							</template>
						</el-table-column>
					</el-table>
				</div>
				<div>
					<el-table :data="tableData" border class="table" style="margin-top: 20px;" height="300"
						ref="multipleTable3" header-cell-class-name="table-header">
						<el-table-column prop="deviceNum" label="设备号"></el-table-column>
						<el-table-column prop="roomName" label="房间名"></el-table-column>
						<el-table-column prop="name" label="人员名称"></el-table-column>
						<el-table-column prop="pzname" label="凭证名称"></el-table-column>
						<!-- <el-table-column prop="cardName" label="人员名称"></el-table-column> -->
						<el-table-column label="类型">
							<template #default="scope">
								<span v-if="scope.row.type == 0">人脸</span>
								<span v-if="scope.row.type == 1">指纹</span>
								<span v-if="scope.row.type == 2">身份证</span>
								<span v-if="scope.row.type == 3">NFC</span>
								<span v-if="scope.row.type == 4">密码</span>
							</template>
						</el-table-column>
						<el-table-column prop="number" width="400" label="租期">
							<template #default="scope">
								<span>{{ scope.row.startTimeText }} - {{ scope.row.endTimeText }}</span>
							</template>
						</el-table-column>
						<el-table-column label="下发状态" prop="statusText"></el-table-column>
						<el-table-column prop="createAt" label="创建时间"></el-table-column>
					</el-table>
					<div class="pagepg">
						<el-pagination @size-change="handleSizeChangeSearch" @current-change="handleCurrentChangeSearch"
							:current-page="pageNumSearch" :page-sizes="[10, 30, 100, 200]" :page-size="pageSizeSearch"
							layout="total, sizes, prev, pager, next, jumper" :total="totalSearch" ref="pagination">
						</el-pagination>
					</div>
				</div>
			</div>
		</el-drawer>
		<el-dialog title="紧急密码，每天仅能用一次" :visible.sync="getEmergenceStatus" width="30%">
			<span>{{ getEmergenceNum }}</span>
			<span slot="footer" class="dialog-footer">
				<el-button @click="getEmergenceStatus = false">取 消</el-button>
				<el-button type="primary" @click="getEmergenceStatus = false">确 定</el-button>
			</span>
		</el-dialog>
		<el-dialog title="请选择需要导出的房源" :visible.sync="exportRoomStatus" width="30%">
			<el-cascader :options="zNodes" size="small" :props="{ checkStrictly: true }" v-model="searchRoom"
				@change="checkNode" :clearable="true">
			</el-cascader>
			<span slot="footer" class="dialog-footer">
				<el-button @click="exportRoomStatus = false">取 消</el-button>
				<el-button type="primary" @click="confirmExportRoomDevice">确 定</el-button>
			</span>
		</el-dialog>
	</div>
</template>

<script>
import houseing from "../components/houseing.vue";
import zTree from "../components/zTree1.vue";
import roomLi from "../components/roomLi.vue";
import roomLi1 from "../components/houseing1.vue";
import utils from "../utils/util.js";
import {
	httpGet,
	httpPost,
	download
} from "../api";
import RequestSet from "../api/allFun.js"
import {
	ztreeToElementTree,
	recursion,
	uniqueArray
} from "../utils/index";
import VDistpicker from 'v-distpicker'
import moment from 'moment'
export default {
	inject: ['reload'],
	name: "room",
	data() {
		return {
			emptyroomNum: 0,
			unboundNum: 0,
			checkin: 0,
			buildingNum: 0,
			colNum_4: 4,
			colNum_6: 6,
			colNum_18: 18,
			roomLayout: '',
			searchRoomStatus: '',
			searchRoom: '',
			exportRoomStatus: false,
			searchAddress: {
				address: '',
				area: ''
			},
			searchAddress1: {
				address: '',
				area: ''
			},
			optionsData: [],
			selectedOptionsData: [],
			selectedOptionsData1: [],
			expandedKeys: [],
			selectoption: [],
			selectoptionValue: '',
			options5: [],
			// options5: [],
			selectedOptions: [],
			selectedOptions1: [],
			getEmergenceStatus: false,
			getEmergenceNum: "",
			rootcurrentPage: 1,
			projectNum: 0,
			offline: 0,
			roomNum: 0,
			pro: 0,
			activeName: "first",
			activeName1: "first",
			vacantRoom: 0,
			schooltotal: 0,
			layoutlist: [{
				value: 0,
				label: "单间",
			}, {
				value: 1,
				label: "一室一厅",
			}, {
				value: 2,
				label: "两室一厅",
			}, {
				value: 3,
				label: "三室一厅",
			}, {
				value: 4,
				label: "三室二厅",
			}, {
				value: 5,
				label: "四室二厅",
			},],
			editVisible: false,
			editVisible1: false,
			editVisible2: false,
			editVisible3: false,
			editDeding: false,
			housingResources: [""],
			form: {
				sex: 1,
				cardState: 1,
				name: "",
				number: "",
				cardId: "",
				phone: "",
				address: "",
			},
			currentPage4: 1,
			currentPage: 1,
			activeiconfont: true,
			userlist: [],
			options: [{
				value: "选项1",
				label: "公寓1",
			}, {
				value: "选项2",
				label: "公寓2",
			},],
			options1: [{
				value: "选项1",
				label: "1号楼",
			}, {
				value: "选项2",
				label: "2号楼",
			},],
			options2: [{
				value: "选项1",
				label: "1单元",
			}, {
				value: "选项2",
				label: "2单元",
			},],
			options3: [{
				value: "选项1",
				label: "1楼",
			}, {
				value: "选项2",
				label: "2楼",
			},],
			value: "",
			value1: "",
			value2: "",
			value3: "",
			input1: "",
			input2: "",
			input3: "",
			input4: "",
			input5: "",
			select: "",
			searchDeviceNum: '',
			total: 0,
			userselect: [],
			multipleSelection: [],
			userselectid: "",
			zNodes: [],
			type: "",
			pid: "",
			showIndex: 0,
			pageTotal: 0,
			ztreeObj: null,
			setting: {
				edit: {
					enable: true,
					drag: {
						isMove: true,
					},
					showRemoveBtn: false,
					showRenameBtn: true,
					renameTitle: "添加",
				},
				check: {
					enable: false,
				},
				data: {
					simpleData: {
						enable: true,
						pIdKey: "pid",
					},
				},
				view: {
					showIcon: true,
					showLine: true,
					addHoverDom: this.addHoverDom,
					removeHoverDom: this.removeHoverDom,
				},
			},
			addrow: {},
			schoolnum: 0,
			Building: 0,
			schoollist: [],
			activeiconfont1: true,
			activeiconfont2: true,
			devicetable: false,
			gridData: [],
			gridDataFirst: [],
			selecttable: true,
			rowimei: {},
			selectrow: {},
			defaultProps: {
				children: "children",
				label: "name",
			},
			pageuserlist: [],
			allCertificates: [],
			input6: '',
			dataProvince: {
				province: {
					code: '',
					value: ''
				},
				city: {
					code: '',
					value: ''
				},
				area: {
					code: '',
					value: ''
				}
			},
			selectaddress: {
				province: '',
				city: '',
				area: ''
			},
			selectaddress1: {
				province: '',
				city: '',
				area: ''
			},
			selectaddress2: {
				province: {
					code: '',
					value: ''
				},
				city: {
					code: '',
					value: ''
				},
				area: {
					code: '',
					value: ''
				}
			},
			isRoom: false,
			treeNodePid: '',
			searchSelectStatus: '',
			enterpriselist: [],
			userInfo: {
				type: ''
			},
			dataProvince1: {},
			tableData: [],
			totalSearch: 0,
			pageNumSearch: 1,
			pageSizeSearch: 10,
			drawerTitle: '',
			allRoomList: [],
			AboutDevice: [],
			selectRoomId: ''
		};
	},
	components: {
		houseing,
		zTree,
		roomLi,
		roomLi1,
		VDistpicker
	},
	created() {
		this.optionsData = this.$MANUFACTURER.mapData
		this.getlist();
		this.getvacancy();
		this.getcount('');
		this.queryfirst1();
		this.getAllCertificates()
		this.getdevice()
		this.getEnterprise()
		this.getalllist()
		this.queryfirstall();
		this.userInfo = JSON.parse(localStorage.getItem('info'))
		this.selectoption = JSON.parse(localStorage.getItem('selectoption'))
		this.selectoptionValue = localStorage.getItem('tenantId')
		this.getAboutDevice()
		if (document.documentElement.clientWidth < 1080) {
			this.colNum_4 = 12
			this.colNum_6 = 24
			this.colNum_18 = 24
		} else {
			this.colNum_4 = 4
			this.colNum_6 = 6
			this.colNum_18 = 18
		}
	},
	mounted() {
		window.onresize = () => {
			return (() => {
				if (document.documentElement.clientWidth < 1080) {
					this.colNum_4 = 12
					this.colNum_6 = 24
					this.colNum_18 = 24
				} else {
					this.colNum_4 = 4
					this.colNum_6 = 6
					this.colNum_18 = 18
				}
			})()
		}
	},
	methods: {
		checkNode(e) {
			var id = e[e.length - 1]
			this.selectRoomId = id
		},
		confirmExportRoomDevice() {
			var item = {
				id: this.selectRoomId
			}
			this.exportRoomDevice(0, item)
			this.exportRoomStatus = false
		},
		// 导出房源
		exportSelect() {
			this.exportRoomStatus = true
		},
		handleChangeMethods(value) {
			var checkedNodes = this.$refs['cascaderAddr'].getCheckedNodes() // 获取当前点击的节点
			this.searchAddress.address = checkedNodes[0].pathLabels.join(',')
			this.searchAddress.area = value.join(',')
		},
		handleChangeMethods1(value) {
			var checkedNodes = this.$refs['cascaderAddr1'].getCheckedNodes() // 获取当前点击的节点
			this.searchAddress1.address = checkedNodes[0].pathLabels.join(',')
			this.searchAddress1.area = value.join(',')
		},
		getCertificatesSearch() {
			if (this.rowimei.imei) {
				var data = {
					pageNum: this.pageNumSearch,
					pageSize: this.pageSizeSearch,
					q: JSON.stringify({
						imei: this.rowimei.imei,
						types: '0,1,2,3,4',
						status: 1
					}),
					orderBy: "create_at desc",
				};
				httpGet(data, this.$api.getCertificates).then((res) => {
					let dataOne = utils.zlib_unzip(res.data)
					dataOne.map((li) => {
						li.createAt = moment(li.createAt).format("YYYY-MM-DD HH:mm:ss")
						li.userTelephone = JSON.parse(li.content).userTelephone;
						li['pzname'] = JSON.parse(li.content).pzname
						li['statusText'] = utils.statusCode(li.status)
						li['startTimeText'] = utils.formatTime(li.startTime)
						li['endTimeText'] = utils.formatTime(li.endTime)
						li.roomName = JSON.parse(li.content).roomName || "";
					});
					this.tableData = dataOne;
					this.totalSearch = res.data.total;
				});
			} else {
				this.tableData = []
				this.totalSearch = 0
			}
		},
		selectTenantId(e) {
			localStorage.setItem('tenantId', e)
			this.reload()
		},
		getEnterprise() {
			httpGet("", this.$api.getEnterprise).then((res) => {
				this.enterpriselist = res.data.list;
			});
		},
		addressChange(arr) {
			console.log(arr);
			console.log(CodeToText[arr[0]], CodeToText[arr[1]], CodeToText[arr[2]]);
		},
		onSelected1(data) {
			this.dataProvince1 = data
		},
		onSelected(data) {
			this.dataProvince = data
		},
		onChangeProvince(data) {
			this.selectaddress2.province = data
			console.log(this.selectaddress2, data)
		},
		onChangeCity(data) {
			this.selectaddress2.city = data
			console.log(this.selectaddress2, data)
		},
		onChangeArea(data) {
			this.selectaddress2.area = data
			console.log(this.selectaddress2, data)
		},
		handleChange() {
			var loc = "";
			for (let i = 0; i < this.selectedOptions.length; i++) {
				loc += " " + CodeToText[this.selectedOptions[i]];
			}
		},
		// 临时密码
		getEmergence(index, row) {
			var data = {
				code: "zg/getEmergence",
				data: {
					lockerId: row.deviceNum
				},
			}
			httpPost(data, this.$api.sendCommand).then(res => {
				if (res.success) {
					this.$message.success("获取成功")
					this.getEmergenceNum = res.data.data
					this.getEmergenceStatus = true
				} else {
					this.$message.error("获取失败")
				}
			})
		},
		resetInput() {
			this.input5 = ''
			this.input6 = ''
			this.searchSelectStatus = ''
			this.searchDeviceNum = ''
			this.searchRoomStatus = ''
			this.roomLayout = ''
			this.searchAddress = {
				address: '',
				area: ''
			}
			this.queryfirstall();
			this.getlistChildren(this.selectrow);
		},
		// 超级用户密码重置
		cz(row) {
			var str2 = {
				imei: row.imei,
				deviceNum: row.deviceNum,
				operateMode: 9,
				order: 6209,
				password: '2021081318',
				userPassword: '949468',
				userTelephone: '18270949468',
				passwordStartTime: "20210813010101",
				passwordEndTime: "20680813010101",
				is: false,
			};
			httpPost(str2, this.$api.getDeviceOperateUserInfo).then((res2) => {
				var str3 = {
					imei: row.imei,
					deviceNum: row.deviceNum,
					operateMode: 7,
					order: 6209,
					password: '2021110309',
					userPassword: '949468',
					userTelephone: '18270949468',
					passwordStartTime: "20210813010101",
					passwordEndTime: "20680813010101",
					is: false,
				};
				httpPost(str3, this.$api.getDeviceOperateUserInfo).then((res2) => { })

			});
		},
		// 重置添加管理员
		AddAdministrator(row) {
			var str = {
				deviceNum: row.deviceNum,
				imei: row.imei,
				order: 6101,
			};
			httpPost(str, this.$api.getDeviceRegisterManager).then((res1) => {
				var str1 = {
					imei: row.imei, //row.imsi,
					deviceNum: row.deviceNum,
					operateMode: 7,
					is: true,
					order: 6207,
					passwordStartTime: "20210813010101",
					passwordEndTime: "20680813010101",
				};
				httpPost(str1, this.$api.getDeviceOperateUserInfo).then((res2) => { });
				var str2 = {
					imei: row.imei, //row.imsi,
					deviceNum: row.deviceNum,
					operateMode: 4,
					is: true,
					order: 6204,
					passwordStartTime: "20210813010101",
					passwordEndTime: "20680813010101",
				};
				httpPost(str2, this.$api.getDeviceOperateUserInfo).then((res3) => {
					if (res3.success) {
						this.$message.success("初始化成功");
					}
				});
			});
		},
		// 重置门锁
		Reset(row) {
			this.$confirm("是否确认重置门锁?", "提示", {
				confirmButtonText: "确定",
				cancelButtonText: "取消",
				type: "warning",
			})
				.then(() => {
					var data = {
						q: JSON.stringify({
							deviceNum: row.deviceNum
						}),
					};
					httpGet(data, this.$api.getCertificates).then((res) => {
						let dataOne = utils.zlib_unzip(res.data)
						Promise.all(
							dataOne.map((element) => {
								return new Promise(function (resolve, reject) {
									resolve(element.id);
								});
							})
						).then((allId) => {
							var data1 = {
								ids: allId,
							};
							// if (allId.length != 0) {
							//   httpPost(data1, this.$api.deleteCertificates).then(
							//     (res1) => {}
							//   );
							// }
							var data2 = {
								code: "isp/restoreSetting",
								data: {
									order: 6501,
									imei: row.imei,
									deviceNum: row.deviceNum,
									managerTelephone: "18270949468",
									managerPassword: "202108",
								},
							};
							httpPost(data2, this.$api.sendCommand).then((res2) => {
								if (res2.data.success) {
									this.$message.success("重置成功");
								} else {
									this.$message.error(res2.msg);
								}
							});
						});
					});
				})
				.catch(() => { });
		},
		remove(node, data) {
			var that = this;
			this.$confirm("删除后人员和设备的关系都会删除，确定要删除吗？", "提示", {
				type: "warning",
			})
				.then(() => {
					this.getshsite(data.id, function (data) {
						var data = {
							ids: data,
						};
						httpPost(data, that.$api.deleteSite).then((res) => {
							that.$message.success("删除成功");
							that.getlistChildren1();
						});
					});
				})
		},
		// 选择的所有子级
		getshsite(id, callback) {
			var q = {
				ancestor: id,
			};
			var data = {
				q: JSON.stringify(q),
			};
			httpGet(data, this.$api.getSiteList).then((res) => {
				var arr = []
				res.data.list.list.map(li => {
					let countNum = res.data.tenants.filter(item => item.id == li.id)[0]
					if (countNum) {
						li.count = countNum.count
					} else {
						li.count = 0
					}
					var name = utils.findIndexArray(this.zNodes, li.id, [])
					var path = ''
					if (name) {
						path = name.join('/')
					}
					li['path'] = path
					arr.push(li.id)
				})
				callback(arr);
			});
		},
		handleNodeClick(data) {
			this.enterpriseId = data.id;
		},
		modifyEnterprise(node, data) {
			var that = this;
			this.addid = data.id;
			this.isRoom = false
			this.onetypeget(data.id, function (data) {
				that.addrow = data;
			});
			this.editVisible1 = true;
		},
		modifyEnterprise1(node, data) {
			var that = this;
			this.addid = data.id;
			this.isRoom = true
			this.onetypeget(data.id, function (data) {
				that.addrow = data;
				console.log(that.addrow)
			});
			this.editVisible1 = true;
		},
		onetypeget(id, callback) {
			var q = {
				id: id,
			};
			var data = {
				q: JSON.stringify(q),
			};
			httpGet(data, this.$api.getSiteList).then((res) => {
				res.data.list.list.map(li => {
					let countNum = res.data.tenants.filter(item => item.id == li.id)[0]
					if (countNum) {
						li.count = countNum.count
					} else {
						li.count = 0
					}
				})
				callback(res.data.list.list[0]);
			});
		},
		//下发锁用户
		operation1(row) {
			if (this.rowimei.imei) {
				var str = {
					imei: this.rowimei.imei,
					deviceNum: this.rowimei.deviceNum,
					userTelephone: JSON.parse(row.info).userTelephone,
					// cardId:this.personInfo.cardId,
					userPassword: JSON.parse(row.info).userPassword,
					password: "20210816",
					operateMode: 1,
					order: 6201,
					passwordStartTime: "20210813010101",
					passwordEndTime: "20680813010101",
					is: false,
				};
				var str1 = {
					imei: this.rowimei.imei,
					deviceNum: this.rowimei.deviceNum,
					userTelephone: JSON.parse(row.info).userTelephone,
					operateMode: 4,
					order: 6204,
					password: JSON.parse(row.info).userPassword,
					userPassword: JSON.parse(row.info).userPassword,
					passwordStartTime: "20210813010101",
					passwordEndTime: "20680813010101",
					is: false,
				};
				var str2 = {
					imei: this.rowimei.imei,
					deviceNum: this.rowimei.deviceNum,
					userTelephone: JSON.parse(row.info).userTelephone,
					operateMode: 10,
					order: 6210,
					password: row.cardId,
					userPassword: JSON.parse(row.info).userPassword,
					passwordStartTime: "20210813010101",
					passwordEndTime: "20680813010101",
					is: false,
				};
				httpPost(str, this.$api.getDeviceOperateUserInfo).then((res2) => {
					if (res2.success) {
						this.$message.success("下发成功");
						httpPost(str1, this.$api.getDeviceOperateUserInfo).then(
							(res2) => { }
						);
						httpPost(str2, this.$api.getDeviceOperateUserInfo).then(
							(res3) => { }
						);
					} else {
						this.$message.error("操作失败");
					}
				});
			} else {
				this.$message.error("房间未绑定门锁");
			}
		},
		// 房间管理
		backFun1() {
			this.activeiconfont = false;
			this.getlistChildren(this.schoollist[0]);
		},
		// 返回
		backFun() {
			this.activeiconfont = true;
		},
		// 远程开锁
		RemoteUnlocking(index, row) {
			var str2 = {
				imei: row.imei,
				roomId: row.roomId,
				openLockType: 2,
				is: true,
			};
			httpPost(str2, this.$api.openLock).then((res3) => {
				if (res3.success) {
					this.$message.success("开锁成功！");
					this.Unlocking = false;
				} else {
					this.$message.error("开锁失败！");
				}
			});
		},
		handleClose() {
			this.devicetable = false
		},
		// 查询门锁
		doorLock(index, row) {
			var that = this
			this.drawerTitle = row.path
			this.rowimei = row;
			var q = {
				roomIds: [row.id],
				lockType: 1
			};
			var data = {
				pageNum: 1,
				pageSize: 10,
				q: JSON.stringify(q),
			};
			httpPost(data, this.$api.getDeviceItems).then((res) => {
				res.data.list.map((li) => {
					li.createAt = moment(li.createAt).format('YYYY-MM-DD HH:mm:ss')
				});
				that.gridData = res.data.list;
				that.pageNumSearch = 1
				that.pageSizeSearch = 10
				that.getCertificatesSearch()
				that.devicetable = true;
				that.selecttable = true;
			});
		},
		// 查询租户
		getroomperson(index, row) {
			var that = this
			var q = {
				id: row.id,
			};
			this.rowimei = row;
			this.drawerTitle = row.path
			var data = {
				q: JSON.stringify(q),
			};
			httpGet(data, this.$api.getSiteTenant).then((res) => {
				res.data.list.map((li) => {
					li.startTime = moment(li.startTime).format('YYYY-MM-DD HH:MM:SS') || '';
					li.endTime = moment(li.endTime).format('YYYY-MM-DD HH:MM:SS') || '';
				})
				that.gridDataFirst = res.data.list.sort((a, b) => {
					return b.type - a.type
				});
				that.devicetable = true;
				that.selecttable = false;
				that.getCertificatesSearch()
			});
		},
		timestampToTime(cjsj) {
			var date = new Date(cjsj); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
			var Y = date.getFullYear() + "-";
			var M =
				(date.getMonth() + 1 < 10 ?
					"0" + (date.getMonth() + 1) :
					date.getMonth() + 1) + "-";
			var D = date.getDate();
			var h = date.getHours();
			var m = date.getMinutes();
			var s = date.getSeconds();
			return (
				Y +
				M +
				(D < 10 ? "0" + D : D) +
				" " +
				(h < 10 ? "0" + h : h) +
				":" +
				(m < 10 ? "0" + m : m) +
				":" +
				(s < 10 ? "0" + s : s)
			);
		},

		//查看校区房源
		see(index, row) {
			this.pid = row.id;
			this.selectrow = row;
			this.activeiconfont = !this.activeiconfont;
			// this.getlist()
			this.getlistChildren(row);
			this.expandedKeys = [row.id]
		},
		getParentId(list, id) {
			for (let i in list) {
				if (list[i].id == id) {
					return [list[i]]
				}
				if (list[i].children) {
					let node = this.getParentId(list[i].children, id);
					if (node !== undefined) {
						return node.concat(list[i])
					}
				}
			}
		},
		getId(list, id) {
			for (let i in list) {
				if (list[i].id == id) {
					return [list[i]]
				}
				if (list[i].children) {
					let node = this.getParentId(list[i].children, id);
					if (node !== undefined) {
						return node;
					}
				}
			}
		},
		getNodeId(list, newNodeId = []) {
			for (let i in list) {
				newNodeId.push(list[i].id)
				if (list[i].children) {
					this.getNodeId(list[i].children, newNodeId);
				}
			}
			return newNodeId;
		},
		getTotal(id) {
			// var arr = this.getId(this.zNodes, id)
			// var listarr=[arr[0]]
			// var obj = this.getNodeId(listarr)
			// var data={
			//   pageSize:1,
			//   pageNum:1,
			//   q:JSON.stringify({
			//     roomIds:obj
			//   })
			// }
			return new Promise((resolve, reject) => {
				httpGet("", `/v1/statistics/order/sites/${id}`).then((res1) => {
					if (res1.success) {
						resolve(res1.data)
					} else {
						resolve(0)
					}
				})
			})
		},
		// 获取校区，楼栋，房间数量
		async queryfirstall() {
			var q = {
				type: 0,
				name: this.input5,
				address: this.searchAddress1.address,
				area: this.searchAddress1.area
			};
			var data = {
				q: JSON.stringify(q),
				type: 0,
				pageNum: 1,
				pageSize: 10
			};
			await this.getcount(data)
			httpGet(data, this.$api.getSiteList).then(res => {
				console.log(res)
				this.projectNum = res.data.list.total
				var schoollist = res.data.list.list;
				this.schoollist = schoollist
				this.setSchoolTotal()
				this.schooltotal = res.data.list.total;
			});
		},
		setSchoolTotal() {
			var schoollist = this.schoollist
			schoollist.map((li, index) => {
				this.getTotal(li.id).then(res => {
					this.activeiconfont1 = false
					this.$nextTick(() => {
						this.schoollist[index].total = res
						this.activeiconfont1 = true
					})
				})
			})
		},
		queryfirst1() {
			var q = {
				type: 1,
			};
			var data = {
				q: JSON.stringify(q),
			};
			httpGet(data, this.$api.getSiteList).then((res) => {
				this.Building = res.data.list.total;
			});
		},
		// 获取房间总数
		getcount(data) {
			// var data = {
			//   type: 5,
			// };
			// httpGet(data, this.$api.getStatisticsTotal).then((res) => {
			//   // this.roomNum = res.data[0].room;
			//   this.pageTotal = res.data[0].device
			//   this.offline = res.data[0].offline
			// });
			httpGet(data, this.$api.getSiteList).then((res) => {
				console.log(res);
				var roomNum = 0;
				var buildingNum = 0
				var checkin = 0
				var unboundNum = 0
				res.data.list.list.map((li, index) => {
					// 楼栋数
					if (li.pid % 10 == 1 && li.type == 1) {
						buildingNum++
					}
					// 已入住
					if (li.isRoom == 1 && li.count != 0) {
						checkin++
					}
					// 未绑定门锁
					if (!li.imei && li.isRoom == 1) {
						unboundNum++
					}
					// 房间总数
					let countNum = res.data.tenants.filter(item => item.id == li.id)[0]
					if (countNum) {
						li.count = countNum.count
					} else {
						li.count = 0
					}
					if (li.expand) {
						if (JSON.parse(li.expand).type == "0") {
							if (li.layout != null) {
								roomNum++;
							}
						}
					}
				});
				this.roomNum = roomNum;
				this.buildingNum = buildingNum
				this.checkin = checkin
				this.unboundNum = unboundNum
				this.emptyroomNum = roomNum - unboundNum - checkin
			})
		},
		// 获取设备
		getdevice() {
			RequestSet.getAnalysis("", -1, (callback) => {
				this.pageTotal = callback.total;
				// this.offline = callback.offlineTotal;
			})
		},
		// 查询空房总数
		getvacancy() {
			// var data = {
			//   level: 0, //0-天、1-周、2-月、3-季、4-年
			// };
			// httpGet(data, this.$api.getStatisticsVacancy).then((res) => {
			//   if (res.data.length > 0) {
			//     this.vacantRoom = res.data[0].count || 0;
			//   }
			// });
			var q = {
				// type: 0,
			};
			var data = {
				pageNum: 1,
				pageSize: 1,
				q: JSON.stringify(q),
			};
			httpPost(data, this.$api.getlistNum).then((res) => {
				this.vacantRoom = res.data.total
			})
		},
		onClick(treeNode) {
			var arr = [];
			arr.push(treeNode);
			// 点击事件
			this.treeNodePid = treeNode.id
			this.selectrow = treeNode
			this.fatherMethod(treeNode.id);
		},
		fatherMethod1(pageNum) {
			var pageuserlist = JSON.parse(JSON.stringify(this.pageuserlist));
			var num1 = (pageNum - 1) * 20;
			var num2 = pageNum * 20;
			var userlist = [];
			pageuserlist.map((li, index) => {
				var data = {
					q: JSON.stringify({
						imei: li.imei
					}),
				};
				httpGet(data, this.$api.getDeviceList).then((res) => {
					// li.imei=res.data[0].imei
					if (num1 <= index && index <= num2) {
						userlist.push(li);
					}
				});
			});
			this.userlist = userlist;
			this.total = this.pageuserlist.length;
		},
		fatherMethod(id) {
			var q = {
				ancestor: id,
				isRoom: 1
			};
			var data = {
				q: JSON.stringify(q),
			};
			httpGet(data, this.$api.getSiteList).then((res) => {
				var pageuserlist = [],
					userlist = [];
				res.data.list.list.map((li, index) => {
					let countNum = res.data.tenants.filter(item => item.id == li.id)[0]
					if (countNum) {
						li.count = countNum.count
					} else {
						li.count = 0
					}
					var name = utils.findIndexArray(this.zNodes, li.id, [])
					var path = ''
					if (name) {
						path = name.join('/')
					}

					li['path'] = path
					li['vocuNum'] = this.getVoucherNum(li.imei) || 0
					// if (li.imei) {
					// 	li['vocuNum'] = this.getvoucher(li.imei, index);
					// } else {
					// 	li['vocuNum'] = 0;
					// }
					pageuserlist.push(li);
				});
				this.pageuserlist = pageuserlist;
				pageuserlist.map((li, index) => {
					if (0 <= index && index < 20) {
						userlist.push(li);
					}
				});
				this.userlist = userlist;
				this.total = pageuserlist.length;
			});
		},
		getOperationStatus(imei) {
			var operationStatus = "";
			if (imei) {
				var data1 = {
					q: JSON.stringify({
						imei: imei
					}),
				};
				httpGet(data1, this.$api.getDeviceList).then((res) => {
					operationStatus = res.data.list[0].operationStatus;
				});
			} else {
				operationStatus = 2;
			}
			return operationStatus;
		},
		exportfun() {
			var q = {
				expand: {
					type: "0",
				},
			};
			var data = {
				q: JSON.stringify(q),
				fileName: "宿舍房源",
			};
			download(data, this.$api.exportSite).then((res) => {
				const link = document.createElement("a");
				let blob = new Blob([res], {
					type: "application/vnd.ms-excel"
				});
				var objectUrl = URL.createObjectURL(blob);
				link.href = objectUrl;
				link.download = "宿舍房源.xlsx";
				link.click();
				URL.revokeObjectURL(objectUrl);
			});
		},
		query(val) {
			var homelist = val ? this.options.find((ele) => ele.id === val) : "";
			this.type = homelist.type;
			this.pid = homelist.pid;
			var q = {
				pid: val,
			};
			var data = {
				q: JSON.stringify(q),
			};
			httpGet(data, this.$api.getSiteList).then((res) => {
				var userlist = [];
				res.data.list.list.map((li, index) => {
					let countNum = res.data.tenants.filter(item => item.id == li.id)[0]
					if (countNum) {
						li.count = countNum.count
					} else {
						li.count = 0
					}
					var name = utils.findIndexArray(this.zNodes, li.id, [])
					var path = ''
					if (name) {
						path = name.join('/')
					}
					li['path'] = path

					if (li.expand) {
						if (JSON.parse(li.expand).type == "0") {
							li['vocuNum'] = this.getVoucherNum(li.imei) || 0
							// if (li.imei) {
							// 	li['vocuNum'] = this.getvoucher(li.imei, index);
							// } else {
							// 	li['vocuNum'] = 0;
							// }
							userlist.push(li);
						}
					}
				});
				this.total = userlist.length;
				this.options1 = userlist;
			});
		},
		query1(val) {
			var homelist = val ? this.options1.find((ele) => ele.id === val) : "";
			this.type = homelist.type;
			this.pid = homelist.pid;
			var q = {
				pid: val,
			};
			var data = {
				q: JSON.stringify(q),
			};
			httpGet(data, this.$api.getSiteList).then((res) => {
				var userlist = [];
				res.data.list.list.map((li, index) => {
					let countNum = res.data.tenants.filter(item => item.id == li.id)[0]
					if (countNum) {
						li.count = countNum.count
					} else {
						li.count = 0
					}
					var name = utils.findIndexArray(this.zNodes, li.id, [])
					var path = ''
					if (name) {
						path = name.join('/')
					}
					li['path'] = path

					if (li.expand) {
						if (JSON.parse(li.expand).type == "0") {
							li['vocuNum'] = this.getVoucherNum(li.imei) || 0
							// if (li.imei) {
							// 	li['vocuNum'] = this.getvoucher(li.imei, index);
							// } else {
							// 	li['vocuNum'] = 0;
							// }
							userlist.push(li);
						}
					}
				});
				this.total = userlist.length;
				this.options2 = userlist;
			});
		},
		query2(val) {
			var homelist = val ? this.options2.find((ele) => ele.id === val) : "";
			this.type = homelist.type;
			this.pid = homelist.pid;
			var q = {
				pid: val,
			};
			var data = {
				q: JSON.stringify(q),
			};
			httpGet(data, this.$api.getSiteList).then((res) => {
				var userlist = [];
				res.data.list.list.map((li, index) => {
					let countNum = res.data.tenants.filter(item => item.id == li.id)[0]
					if (countNum) {
						li.count = countNum.count
					} else {
						li.count = 0
					}
					var name = utils.findIndexArray(this.zNodes, li.id, [])
					var path = ''
					if (name) {
						path = name.join('/')
					}
					li['path'] = path
					if (li.expand) {
						if (JSON.parse(li.expand).type == "0") {
							li['vocuNum'] = this.getVoucherNum(li.imei) || 0
							// if (li.imei) {
							// 	li['vocuNum'] = this.getvoucher(li.imei, index);
							// } else {
							// 	li['vocuNum'] = 0;
							// }
							userlist.push(li);
						}
					}
				});
				this.total = userlist.length;
				this.options3 = userlist;
			});
		},
		query3(val) {
			var homelist = val ? this.options3.find((ele) => ele.id === val) : "";
			this.type = homelist.type;
			this.pid = val;
			var q = {
				pid: val,
			};
			var data = {
				q: JSON.stringify(q),
			};
			httpGet(data, this.$api.getSiteList).then((res) => {
				var userlist = [];
				res.data.list.list.map((li, index) => {
					let countNum = res.data.tenants.filter(item => item.id == li.id)[0]
					if (countNum) {
						li.count = countNum.count
					} else {
						li.count = 0
					}
					var name = utils.findIndexArray(this.zNodes, li.id, [])
					var path = ''
					if (name) {
						path = name.join('/')
					}
					li['path'] = path

					if (li.expand) {
						if (JSON.parse(li.expand).type == "0") {
							li['vocuNum'] = this.getVoucherNum(li.imei) || 0
							// if (li.imei) {
							// 	li['vocuNum'] = this.getvoucher(li.imei, index);
							// } else {
							// 	li['vocuNum'] = 0;
							// }
							userlist.push(li);
						}
					}
				});
				this.total = userlist.length;
				this.options4 = userlist;
			});
		},
		queryfirst(id) {
			var q = {
				ancestor: id,
			};
			var data = {
				q: JSON.stringify(q),
			};
			httpGet(data, this.$api.getSiteList).then((res) => {
				var userlist = [],
					pageuserlist = [];
				res.data.list.list.map((li, index) => {
					let countNum = res.data.tenants.filter(item => item.id == li.id)[0]
					if (countNum) {
						li.count = countNum.count
					} else {
						li.count = 0
					}
					var name = utils.findIndexArray(this.zNodes, li.id, [])
					var path = ''
					if (name) {
						path = name.join('/')
					}
					li['path'] = path
					if (li.expand) {
						if (JSON.parse(li.expand).type == "0") {
							li['vocuNum'] = this.getVoucherNum(li.imei) || 0
							// if (li.imei) {
							// 	li['vocuNum'] = this.getvoucher(li.imei, index);
							// } else {
							// 	li['vocuNum'] = 0;
							// }
							userlist.push(li);
						}
					}
				});
				this.pageuserlist = userlist;
				this.total = userlist.length;
				this.options = userlist;
			});
		},
		// 获取用户列表
		getUserList() {
			var data = {
				pageNum: 1,
				pageSize: 100,
			};
			httpGet(data, this.$api.getUserList).then((res) => {
				this.userselect = res.data.list;
			});
		},

		handleClick(tab, event) { },
		handleClick1(tab, event) {
			console.log(tab, event);
		},
		getalllist() {
			var data = {};
			httpGet(data, this.$api.getTree).then((res) => {
				var userlist = [];
				var temp = {},
					arr = [];
				res.data.forEach((item, index) => {
					if (!temp[item.id]) {
						arr.push(item);
						temp[item.id] = true;
					}
				});
				arr.map((li) => {
					if (li.expand) {
						if (JSON.parse(li.expand).type == "0") {
							userlist.push(li);
						}
					}
				});
				this.queryfirst(userlist[1].id);
				var list = res.data.sort((pre, cur) => pre.id - cur.id)
				var arrdata = uniqueArray(list, "id")
				this.allRoomList = arrdata
				this.zNodes = ztreeToElementTree(arrdata, {});
			});
		},
		getalllist1(row) {
			var q = {
				ancestor: row.pid,
				expand: {
					type: 0
				},
			};
			var data = {
				q: JSON.stringify(q),
			};
			httpGet(data, this.$api.getTree).then((res) => {
				var userlist = [];
				var temp = {},
					arr = [];
				res.data.map((item, index) => {
					if (!temp[item.id]) {
						arr.push(item);
						temp[item.id] = true;
					}
				});
				arr.map((li) => {
					if (li.expand) {
						if (JSON.parse(li.expand).type == "0") {
							userlist.push(li);
						}
					}
				});
				var list = res.data.sort((pre, cur) => pre.id - cur.id)
				var arrdata = uniqueArray(list, "id")
				this.zNodes = ztreeToElementTree(arrdata, {});
			});
		},
		// 获取列表
		getlist3() {
			var userlist = this.userlist
			// var array = []
			// if (this.input6 == '') {
			//     userlist.map(li => {
			//         if (li.name == this.input6) {
			//             array.push(li)
			//         }
			//     })
			//     this.userlist = array
			// } else {}
			this.getlistChildren(this.selectrow);
		},

		// 获取列表
		getlistxq() {
			var q = {}
			if (this.selectaddress2.province.code == '') {
				q = {
					name: this.input5,
					type: 0,
				};
			} else {
				var area = this.selectaddress2.province.code ? this.selectaddress2.province.code : ''
				area = area + ',' + this.selectaddress2.city.code ? this.selectaddress2.city.code : ''
				area = area + ',' + this.selectaddress2.area.code ? this.selectaddress2.area.code : ''
				q = {
					name: this.input5,
					type: 0,
					area: area
				};
			}
			var strq = {}
			for (let key in q) {
				if (q[key]) {
					strq[key] = q[key]
				}
			}
			var data = {}
			if (JSON.stringify(strq) == '{}') {
				data = {
					type: 0,
					pageNum: 1,
					pageSize: 10
				};
			} else {
				data = {
					q: JSON.stringify(strq),
					type: 0,
					pageNum: 1,
					pageSize: 10
				};
			}
			httpGet(data, this.$api.getSiteList).then((res) => {
				var pageuserlist = [],
					userlist = [];
				res.data.list.list.map((li, index) => {
					let countNum = res.data.tenants.filter(item => item.id == li.id)[0]
					if (countNum) {
						li.count = countNum.count
					} else {
						li.count = 0
					}
					var name = utils.findIndexArray(this.zNodes, li.id, [])
					var path = ''
					if (name) {
						path = name.join('/')
					}
					li['path'] = path

					if (li.expand) {
						if (JSON.parse(li.expand).type == "0") {
							li['vocuNum'] = this.getVoucherNum(li.imei) || 0
							// if (li.imei) {
							// 	li['vocuNum'] = this.getvoucher(li.imei, index);
							// } else {
							// 	li['vocuNum'] = 0;
							// }
							pageuserlist.push(li);
						}
					}
				});
				this.pageuserlist = pageuserlist;
				pageuserlist.map((li, index) => {
					if (0 <= index && index <= 20) {
						userlist.push(li);
					}
				});
				this.schooltotal = userlist.length;
				this.total = pageuserlist.length;
			});
		},
		getlistChildren1() {
			var row = this.selectrow;
			var q = {
				// name: row.name,
				ancestor: row.pid,
				expand: {
					type: 0
				},
			};
			var data = {
				q: JSON.stringify(q),
			};
			this.getalllist1(row);
			httpGet(data, this.$api.getSiteList).then((res) => {
				var pageuserlist = [],
					userlist = [];
				res.data.list.list.map((li, index) => {
					let countNum = res.data.tenants.filter(item => item.id == li.id)[0]
					if (countNum) {
						li.count = countNum.count
					} else {
						li.count = 0
					}
					var name = utils.findIndexArray(this.zNodes, li.id, [])
					var path = ''
					if (name) {
						path = name.join('/')
					}
					li['path'] = path
					if (li.expand) {
						if (JSON.parse(li.expand).type == "0") {
							li['vocuNum'] = this.getVoucherNum(li.imei) || 0
							// if (li.imei) {
							// 	li['vocuNum'] = this.getvoucher(li.imei, index);
							// } else {
							// 	li['vocuNum'] = 0;
							// }
							pageuserlist.push(li);
						}
					}
				});
				this.pageuserlist = pageuserlist;
				pageuserlist.map((li, index) => {
					if (0 <= index && index <= 20) {
						userlist.push(li);
					}
				});
				this.userlist = userlist;
				this.total = pageuserlist.length;
			});
		},
		getFullPathHousing(item, data, name) {
			if (item.id == item.pid) {
				name.push(item.name)
				return name
			} else {
				var str = data.filter(_item => _item.id == item.pid)[0]
				if (str) {
					name.push(str.name)
					this.getFullPathHousing(str, data, name)
				} else {
					return name
				}
			}
		},
		getVoucherNum(imei) {
			return this.allCertificates.filter(item => item.imei == imei).length
		},
		getAboutDevice() {
			var data = {
				pageNum: 0,
				pageSize: 0,
			};
			httpPost(data, this.$api.getDeviceItems).then((res) => {
				this.AboutDevice = res.data.list;
			});
		},
		// 导出房源和设备
		exportRoomDevice(index, item) {
			var q = {
				ancestor: item.id,
				isRoom: 1,
				expand: {
					type: 0
				},
			};
			var data = {
				q: JSON.stringify(q),
			};
			httpGet(data, this.$api.getSiteList).then((res) => {
				let newArr = []
				res.data.list.list.map(li => {
					let countNum = res.data.tenants.filter(item => item.id == li.id)[0]
					if (countNum) {
						li.count = countNum.count
					} else {
						li.count = 0
					}
					var lt = this.AboutDevice.filter(ll => ll.imei == li.imei)[0]
					if (lt) {
						li.deviceNum = lt.deviceNum
						li.name = lt.roomName
					}
					var str = {
						roomName: li.name,
						deviceNum: li.deviceNum,
						imei: li.imei
					}
					newArr.push(str)
				})
				this.jsonToExcel(newArr)
			})

		},
		jsonToExcel(data, name = '房源信息') {
			let str = '';
			let keyData = [];
			data.forEach((item, i) => {
				if (keyData.length > 0) {
					let items = {};
					for (let key in keyData) {
						items[keyData[key]] = item[keyData[key]] ? item[keyData[key]] : ''
					}
					item = items
				}
				// 拼接json数据, 增加 \t 为了不让表格显示科学计数法或者其他格式
				for (let key in item) {
					if (i == 0) {
						keyData.push(key)
					}
					str = `${str + item[key] + '\t'},`
				}
				str += '\n'
			});
			// console.log(str)
			// encodeURIComponent解决中文乱码
			const uri = 'data:text/xlsx;charset=utf-8,\ufeff' + encodeURIComponent(str);
			// 通过创建a标签实现
			const link = document.createElement("a");
			link.href = uri;
			// 对下载的文件命名
			link.download = `${name + '.xlsx'}`;
			link.click();
		},
		// 获取列表
		getlistChildren(row) {
			var q = {
				name: this.input6,  // 房间名称
				deviceNum: this.searchDeviceNum,  // 设备号
				ancestor: row.id,
				operationStatus: this.searchSelectStatus,  // 绑定情况
				isRoom: 1,
				layout: this.roomLayout,  // 房间户型
				roomStatus: this.searchRoomStatus,
				// expand: {
				// 	type: this.searchRoomStatus
				// },
			};
			var data = {
				q: JSON.stringify(q),
			};
			this.getalllist1(row);
			httpGet(data, this.$api.getSiteList).then((res) => {
				var pageuserlist = [],
					userlist = [];
				res.data.list.list.map((li, index) => {
					let countNum = res.data.tenants.filter(item => item.id == li.id)[0]
					if (countNum) {
						li.count = countNum.count
					} else {
						li.count = 0
					}
					var name = utils.findIndexArray(this.zNodes, li.id, [])
					var path = ''
					if (name) {
						path = name.join('/')
					}
					li['path'] = path
					if (li.expand) {
						if (JSON.parse(li.expand).type == "0") {
							li['vocuNum'] = this.getVoucherNum(li.imei) || 0
							// if (li.imei) {
							// 	li['vocuNum'] = this.getvoucher(li.imei, index);
							// } else {
							// 	li['vocuNum'] = 0;
							// }
							pageuserlist.push(li);
						}
					}
				});
				this.pageuserlist = pageuserlist;
				pageuserlist.map((li, index) => {
					if (0 <= index && index <= 20) {
						userlist.push(li);
					}
				});
				this.userlist = userlist;
				this.total = pageuserlist.length;
			});
		},
		// 获取凭证数量
		getvoucher(imei, index) {
			var sum = 0
			this.allCertificates.map(li => {
				if (li.imei == imei) {
					sum += 1
				}
			})
			return sum
		},
		// 获取所有凭证
		getAllCertificates() {
			var data = {
				pageNum: 0,
				pageSize: 0,
				orderBy: "create_at desc",
				q: JSON.stringify({
					types: '0,1,2,3,4',
					status: 1
				}),
			}
			httpGet(data, this.$api.getCertificates).then((res) => {
				let dataOne = utils.zlib_unzip(res.data)
				this.allCertificates = dataOne;
			});
		},
		// 获取列表
		getlist() {
			var q = {
				name: this.input5,
				pid: this.pid,
				ancestor: this.pid,
			};
			var data = {
				q: JSON.stringify(q),
			};
			httpGet(data, this.$api.getSiteList).then((res) => {
				console.log(res);
				var pageuserlist = []
				res.data.list.list.map((li, index) => {
					let countNum = res.data.tenants.filter(item => item.id == li.id)[0]
					if (countNum) {
						li.count = countNum.count
					} else {
						li.count = 0
					}
					if (li.expand) {
						if (JSON.parse(li.expand).type == "0") {
							li['vocuNum'] = this.getVoucherNum(li.imei) || 0
							// if (li.imei) {
							// 	li['vocuNum'] = this.getvoucher(li.imei, index);
							// } else {
							// 	li['vocuNum'] = 0;
							// }
							pageuserlist.push(li);
						}
					}
					let count = res.data.tenants.filter(item => item.id == li.id)[0]
					if (count) {
						li.count = count
					} else {
						li.count = 0
					}
				});
				console.log(pageuserlist);
				this.pageuserlist = pageuserlist;
				var userlist = []
				pageuserlist.map((li, index) => {
					if (0 <= index && index <= 20) {
						userlist.push(li);
					}
				});
				console.log(userlist);
				this.userlist = userlist;
				this.total = pageuserlist.length;
			});
		},
		//减少层级
		delHierarchy() {
			if (this.housingResources.length <= 1) {
				this.$message.error("已到第一级");
			} else {
				this.housingResources.splice(-1, 1);
			}
		},
		// 增加层级
		addHierarchy() {
			this.housingResources.push("");
		},
		handleSelectionChange(val) {
			this.multipleSelection = val;
		},
		handleSearch1() {
			this.editVisible = true;
		},
		// 编辑操作
		handleEdit4(index, row) {
			this.idx = index;
			this.form = row;
			var adarray = ['', '', ''],
				adarray1 = ['', '', '']
			if (row.address) {
				this.searchAddress.address = row.address
			}
			if (row.area) {
				this.searchAddress.area = row.area
				this.selectedOptionsData = row.area.split(',')
			}
			// this.selectaddress.province = adarray[0]
			// this.selectaddress.city = adarray[1]
			// this.selectaddress.area = adarray[2]
			// this.selectaddress.code = adarray1
			this.editVisible2 = true;
		},
		// 编辑操作
		handleEdit(index, row) {
			this.idx = index;
			this.form = row;
			if (this.form.isRoom == 1) {
				this.form.isRoom = true
			} else {
				this.form.isRoom = false
			}
			this.editVisible3 = true;
		},
		// 单个添加
		handleEdit1(index, row) {
			if (row.isRoom == 1) {
				this.$message.error('房间不能添加下级')
			} else {
				this.addid = row.id;
				this.addrow = row;
				this.editVisible1 = true;
			}
		},
		//批量删除
		selectmoredel() {
			var list = this.multipleSelection;
			var idlist = [];
			list.map((li) => {
				idlist.push(li.id);
			});
			if (list.length == 0) {
				this.$message.error("请勾选需要删除的数据");
			} else {
				this.$confirm("删除后人员和设备的关系都会删除，确定要删除吗？", "提示", {
					type: "warning",
				})
					.then(() => {
						var data = {
							ids: idlist,
						};
						httpPost(data, this.$api.deleteSite).then((res) => {
							this.getlist();
							this.$message.success("删除成功");
						});
					})
					.catch(() => { });
			}
		},
		// 单个绑定
		dbing() {
			var list = this.multipleSelection;
			console.log(this.multipleSelection);
			if (list.length == 0) {
				this.$message.error("请勾选需要删除的数据");
			} else {
				this.editDeding = true;
			}
		},
		// 解绑
		Unbundling() {
			var list = this.multipleSelection;
			var idlist = [];
			list.map((li) => {
				var idli = {
					id: li.id,
					userId: this.userselectid,
				};
				idlist.push(idli);
			});
			if (list.length == 0) {
				this.$message.error("请勾选需要解绑的数据");
			} else {
				this.editDeding = true;
				this.$confirm("确定要解绑吗？", "提示", {
					type: "warning",
				})
					.then(() => {
						httpPost(idlist, this.$api.removeAssign).then((res) => {
							this.$message.success("解绑成功");
						});
					})
					.catch(() => { });
			}
		},
		// 管理绑定页面
		Debinding() {
			var list = this.multipleSelection;
			var idlist = [];
			list.map((li) => {
				var idli = {
					id: li.id,
					userId: this.userselectid,
				};
				idlist.push(idli);
			});
			if (list.length == 0) {
				this.$message.error("请勾选需要管理的数据");
			} else {
				this.editDeding = true;
				this.$confirm("确定要绑定吗？", "提示", {
					type: "warning",
				})
					.then(() => {
						httpPost(idlist, this.$api.siteAssign).then((res) => {
							this.$message.success("绑定成功");
						});
					})
					.catch(() => { });
			}
		},
		// 删除操作
		handleDelete(index, row) {
			var that = this;
			this.$confirm("删除后人员和设备的关系都会删除，确定要删除吗？", "提示", {
				type: "warning",
			})
				.then(() => {
					this.getshsite(row.id, function (data) {
						var data = {
							ids: data,
						};
						httpPost(data, that.$api.deleteSite).then((res) => {
							that.$message.success("删除成功");
							that.getlistChildren1();
							that.queryfirstall()
						});
					});
				})
		},
		// 删除操作
		handleDelete1(index, row) {
			// 二次确认删除
			this.$confirm("确定要删除吗？", "提示", {
				type: "warning",
			})
				.then(() => {
					var ids = [];
					ids.push(row.id);
					var data = {
						ids: ids,
					};
					httpPost(data, this.$api.deleteSite).then((res) => {
						this.$message.success("删除成功");
						this.getlistChildren1();
					});
				})
				.catch(() => { });
		},
		// 保存编辑
		saveEdit() {
			var info = localStorage.getItem("info");
			var expand = {
				type: "0",
			};
			var isRoom = ''
			if (this.form.isRoom) {
				isRoom = 1
			} else {
				isRoom = 0
			}
			var str = this.searchAddress.area
			var str1 = this.searchAddress.address
			var data = {
				acreage: parseInt(this.form.acreage),
				area: str,
				address: str1,
				isRoom: isRoom,
				layout: this.form.layout,
				name: this.form.name,
				expand: JSON.stringify(expand),
				enterpriseId: JSON.parse(info).enterpriseId,
				type: 0,
			};
			if (this.form.name == "") {
				this.$message.error("公寓名称不能为空");
			} else {
				httpPost(data, this.$api.siteAddRoot).then((res) => {
					this.editVisible = false;
					// this.getlist();
					this.queryfirstall()
				});
			}
		},
		// 修改
		modifyfun() {
			// return
			var str = this.searchAddress.area
			var str1 = this.searchAddress.address
			var data = {
				acreage: parseInt(this.form.acreage),
				layout: this.form.layout,
				name: this.form.name,
				area: str,
				address: str1,
				enterpriseId: this.form.enterpriseId,
				id: this.form.id,
			};
			if (this.form.name == "") {
				this.$message.error("公寓名称不能为空");
			} else {
				httpPost(data, this.$api.siteUpdate).then((res) => {
					this.editVisible2 = false;
					this.editVisible3 = false;
					this.getalllist();
					this.getlistxq()
					// this.getlist();
				});
			}
		},
		// 修改
		modifyfun1() {
			var isRoom = ''
			if (this.form.isRoom) {
				isRoom = 1
			} else {
				isRoom = 0
			}
			var data = {
				acreage: parseInt(this.form.acreage),
				layout: this.form.layout,
				name: this.form.name,
				isRoom: isRoom,
				// area: str,
				address: '',
				id: this.form.id,
			};
			if (this.form.name == "") {
				this.$message.error("公寓名称不能为空");
			} else {
				httpPost(data, this.$api.siteUpdate).then((res) => {
					this.editVisible2 = false;
					this.editVisible3 = false;
					// this.getalllist();
					this.getlistxq()
					// this.getlist();
				});
			}
		},
		// 模板创建
		saveEdit1() {
			var info = localStorage.getItem("info");
			var names = this.form.name.split("、");
			var counts = this.form.counts.split("、");
			var expand = {
				type: "0",
			};
			var str = this.searchAddress.area
			var str1 = this.searchAddress.address
			var data = {
				acreage: parseInt(this.form.acreage),
				layout: this.form.layout,
				counts: counts,
				expand: JSON.stringify(expand),
				area: str,
				address: str1,
				names: names,
				enterpriseId: JSON.parse(info).enterpriseId,
			};
			if (this.form.name == "") {
				this.$message.error("公寓单元名称不能为空");
			} else if (this.form.counts == "") {
				this.$message.error("公寓层数不能为空");
			} else if (names.length != counts.length) {
				this.$message.error("公寓单元和层数数量需要对应");
			} else {
				httpPost(data, this.$api.sitCreateMod).then((res) => {
					this.editVisible = false;
					// this.getlist();
					// this.getlistxq()
					// this.getlistChildren1();
					// this.getalllist();
					this.queryfirstall()
				});
			}
		},
		// 单个房间创建
		saveEdit2() {
			var info = localStorage.getItem("info");
			var expand = {
				type: "0",
			};
			var isRoom = ''
			if (this.form.isRoom) {
				isRoom = 1
			} else {
				isRoom = 0
			}
			console.log(this.addrow)
			var data = {
				acreage: parseInt(this.form.acreage),
				ancestor: this.addid,
				expand: JSON.stringify(expand),
				layout: this.form.layout,
				name: this.form.name,
				isRoom: isRoom,
				type: parseInt(this.addrow.type) + 1,
				enterpriseId: JSON.parse(info).enterpriseId,
			};
			console.log("123")
			if (this.form.name == "") {
				this.$message.error("公寓名称不能为空");
			} else {
				httpPost(data, this.$api.sitAddChild).then((res) => {
					this.editVisible1 = false;
					this.getlistChildren1();
					this.getlist();
				});
			}
		},
		// 楼层房间批量创建
		saveEdit3() {
			var info = localStorage.getItem("info");
			var expand = {
				type: "0",
			};
			var isRoom = ''
			if (this.form.isRoom) {
				isRoom = 1
			} else {
				isRoom = 0
			}
			var data = {
				acreage: parseInt(this.form.acreage),
				layout: this.form.layout,
				ancestor: this.addid,
				expand: JSON.stringify(expand),
				count: this.form.count,
				name: this.form.name,
				isRoom: isRoom,
				type: 2,
				enterpriseId: JSON.parse(info).enterpriseId,
			};
			if (this.form.name == "") {
				this.$message.error("楼层名称不能为空");
			} else if (this.form.counts == "") {
				this.$message.error("房间数不能为空");
			} else {
				httpPost(data, this.$api.sitAddNodes).then((res) => {
					this.editVisible1 = false;
					this.getlistChildren1();
					this.getlist();
				});
			}
		},
		activeiconfun(t) {
			this.activeiconfont1 = t;
		},
		activeiconfun1(t) {
			this.activeiconfont2 = t;
		},
		handleSizeChange(val) {
			console.log(`每页 ${val} 条`);
		},
		handleSizeChangeSearch(val) {
			this.pageSizeSearch = val
			this.getCertificatesSearch()
		},
		handleCurrentChangeSearch(val) {
			this.pageNumSearch = val
			this.getCertificatesSearch()
		},
		handleCurrentChange(val) {
			var pageuserlist = JSON.parse(JSON.stringify(this.pageuserlist));
			var num1 = (val - 1) * 20;
			var num2 = val * 20;
			var userlist = [];
			pageuserlist.map((li, index) => {
				if (num1 <= index && index < num2) {
					userlist.push(li);
				}
			});
			this.userlist = userlist;
			this.currentPage4 = val
			this.total = this.pageuserlist.length;
		},
		handleCurrentChange1(val) {
			var q = {
				type: 0,
			};
			var data = {
				q: JSON.stringify(q),
				type: 0,
				pageNum: val,
				pageSize: 10
			};
			httpGet(data, this.$api.getSiteList).then((res) => {
				var schoollist = res.data.list.list;
				this.schoollist = schoollist
				this.setSchoolTotal()
				this.rootcurrentPage = val
				this.$store.commit("increment", val);
			});
		},
	},
};
</script>

<style scoped>
/* @import "../assets/css/zTreeStyle.css";
#areaTree {
  border: 1px solid #e5e5e5;
  margin-bottom: 2px;
  border-radius: 4px;
  overflow: hidden;
  max-height: 800px;
  height: 400px;
  overflow-y: scroll;
}
.box-title {
  border-radius: 3px 3px 0 0;
  background-color: #f5f5f5;
}
.box-title a {
  color: #2fa4e7;
  text-decoration: none;
  font-size: 14px;
  display: block;
  padding: 8px 15px;
  cursor: pointer;
}
.box-title .fa {
  float: right;
  line-height: 20px;
} */

.handle-box .handle-input:last-child {
	display: inline-block;
}

.handle-input {
	width: 75%;
	display: inline-block;
	margin-bottom: 10px;
}

.mr10 {
	margin-right: 10px;
}

.marginb20 {
	margin-bottom: 20px;
}

.contentc {
	display: flex;
	align-items: center;
}

.cardrelative::before {
	content: " ";
	position: absolute;
	top: 50%;
	left: 0;
	transform: translateY(-50%);
	width: 8px;
	height: 57px;
}

.aftercolor1::before {
	background: #f2827c;
}

.aftercolor2::before {
	background: #ffd791;
}

.aftercolor3::before {
	background: #90d09e;
}

.aftercolor4::before {
	background: #73cde2;
}

.aftercolor5::before {
	background: #128bf1;
}

.contentc .contenttitle {
	font-size: 16px;
	color: #333;
	line-height: 30px;
	margin-left: 10px;
}

.contentc .contentnum {
	font-size: 35px;
	color: #333;
	line-height: 58px;
	margin-left: 30px;
}

.cardrelative {
	position: relative;
}

.cardrelative .pzimg {
	position: absolute;
	max-width: 100%;
	bottom: 0;
	right: 0;
}

.cardrelative .right20 {
	right: -15px;
	bottom: -4px;
}

.paddcontent {
	padding: 14px 0;
}

.contentc1 {
	display: block;
}

.contentleft {
	width: 48%;
	box-sizing: border-box;
	margin-left: 30px;
	display: inline-block;
	vertical-align: top;
}

.pieChart {
	width: 50%;
	height: 200px;
	display: inline-block;
	vertical-align: top;
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
}

.pieChart .schart {
	height: 100%;
}

.heightbt {
	height: 220px;
}

.contentleft .contenttitle {
	display: inline-block;
}

.contentleft .contentnum {
	display: inline-block;
}

.contentleft>ul {
	box-sizing: border-box;
	margin-left: 30px;
}

.contentul li {
	display: flex;
	align-items: center;
	line-height: 40px;
	position: relative;
	color: #333333;
}

.contentul li::before {
	content: "●";
	position: absolute;
	top: 50%;
	left: -20px;
	transform: translateY(-50%);
	color: #128bf1;
}

.contentul li>span {
	width: 50%;
}

.userlist {
	justify-content: space-between;
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	position: relative;
	margin-top: 20px;
}

/* .userlist::after{
  content: '';
  flex: auto;
} */

.userlist .userli {
	display: inline-block;
	box-sizing: border-box;
	overflow: hidden;
}

.userlist .ko {
	height: 0;
	overflow: hidden;
	padding: 0;
	width: 300px;
}

.paging {
	padding: 20px 0;
	text-align: center;
}

.add {
	width: 300px;
	height: 276px;
	cursor: pointer;
}

.add .adddiv {
	margin-top: 50px;
	background: #fff;
	border-radius: 6px;
	box-shadow: 0px 0px 9px 0px rgba(6, 6, 6, 0.06);
	height: 226px;
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
}

.add .adddiv img {
	max-width: 100%;
}

/* 搜索 */

.searchlist {
	margin-top: 20px;
}

/* .searchlist1 {
		margin-bottom: 20px;
	} */

.inputBox {
	width: 75%;
	display: inline-block;
	position: relative;
}

.selectBox {
	position: absolute;
	top: 0;
}

.tablelist {
	position: relative;
	margin-top: 20px;
	padding-top: 40px;
}

.switchiconfont {
	position: absolute;
	top: 0;
	left: 0;
	background: #fff;
	color: #333;
	display: flex;
}

.switchiconfont .iconfont {
	font-size: 16px;
	padding: 4px 6px;
	border: 1px solid #dcdfe6;
	cursor: pointer;
}

.switchiconfont .active {
	color: #fff;
	cursor: pointer;
	background: #FA8E00;
	border: 1px solid #FA8E00;
}

.adddbtn {
	display: inline-block;
	position: absolute;
	top: 0;
	left: 100px;
}

.houseinput button {
	font-size: 20px;
}

.m20 {
	margin: 0 10px;
}

.roomcontent .roomconli {
	display: inline-block;
	cursor: pointer;
	position: relative;
}

.taball {
	width: 100%;
	margin-top: 50px;
}

.taball .el-table th>.cell,
.tablelist .el-table th>.cell {
	text-align: center;
	font-size: 14px;
}

.taball>>>.el-table .cell,
.tablelist>>>.el-table .cell {
	text-align: center;
	font-size: 12px;
}

.taball>>>.el-table .el-table__row .el-table__cell,
.tablelist>>>.el-table .el-table__row .el-table__cell {
	padding: 6px 0;
}

.button-list {
	position: absolute;
	width: 280px;
	height: 180px;
	background: rgba(0, 0, 0, 0.5);
	top: 0;
	left: 20px;
	border-radius: 10px;
	-ms-flex-wrap: wrap;
	flex-wrap: wrap;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
	padding: 0 10px;
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-ms-flex-line-pack: center;
	align-content: center;
	-webkit-box-align: center;
	-ms-flex-align: center;
	align-items: center;
	-webkit-box-pack: center;
	-ms-flex-pack: center;
	justify-content: center;
	display: none;
}

.button-list div {
	/* width: 55px; */
	padding: 0 14px;
	height: 25px;
	background: rgba(0, 0, 0, 0.4);
	border-radius: 13px;
	margin: 0 5px 10px;
	font-size: 14px;
	font-family: Microsoft YaHei;
	font-weight: 700;
	color: #dedede;
	cursor: pointer;
	text-align: center;
	line-height: 25px;
}

.roomcontent .roomconli:hover .button-list {
	display: flex;
}

.roomcontent .roomconli1 .button-list {
	width: 222px;
	height: 140px;
	left: 0;
	z-index: 999;
}

.roomcontent .roomconli1 {
	vertical-align: top;
	margin-right: 16px;
	margin-bottom: 29px;
}

.roomcontentheight {
	height: 500px;
	overflow-y: auto;
	margin-bottom: 20px;
}

.temporary {
	margin: 20px;
	box-sizing: border-box;
}

.h700 {
	height: 630px;
	overflow: auto;
}

.custom-tree-node {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 14px;
	padding-right: 8px;
}

.inputBox {
	width: 200px;
}

.address {
	display: inline-block;
}

.address>>>.distpicker-address-wrapper {
	display: inline-block;
}

.address>>>.distpicker-address-wrapper select {
	padding: 0 15px;
	height: 40px;
	line-height: 40px;
	font-size: inherit;
	border-radius: 4px;
}

.operationclass>>>.el-drawer__header>:first-child {
	font-size: 24px;
}

.treeclass .el-tree-node.is-current.is-focusable {
	background: #f3f4f5;
}

.selectoptionClass {
	display: inline-block;
}

.ZTREE>>>.el-tree-node.is-expanded>.el-tree-node__children {
	display: inline-block;
}

@media only screen and (max-width: 1024px) {
	.adddbtn {
		left: 70px;
	}

	.h700 {
		height: 300px;
	}
}</style>
