<template>
  <div class="content-box">
    <div class="left">
      <!-- <el-icon :size="23" class="camera"><VideoCameraFilled /></el-icon> -->
      <span class="cameratxt">门锁管理</span>
    </div>
    <div class="middles">
      <div class="middle">
        <div class="filter">
          <div class="condition">
            <el-input
              :clearable="true"
              @clear="searchBtn"
              v-model.trim="searchInput.keyWord"
              class="w-50 m-2"
              placeholder="请输入关键字查询"
              style="width: 230px"
            />
            <el-button
              style="margin-left: 20px"
              color="rgba(41, 109, 227, 1)"
              type="primary"
              class="search"
              @click="searchBtn"
              ><el-icon>
                <Search />
              </el-icon>
              <span>查询</span></el-button
            >
            <el-button
              v-if="flagBtn.daoru==1"
              style="margin-left: 20px"
              color="rgba(41, 109, 227, 1)"
              type="primary"
              class="search"
              @click="bulkImportClick"
              >批量导入</el-button
            >
            <div class="condition" style="margin-left:30px">
              <span>楼栋单元</span>
              <el-select
                v-model="searchInput.buildingId"
                placeholder="请选择楼栋单元"
                style="width: 200px;margin-left:10px"
                @change="searchBtn"
                :clearable="true"
              >
                <el-option
                  v-for="item in buildData"
                  :key="item.id"
                  :label="`${item.building}${item.element}`"
                  :value="item.id"
                />
              </el-select>
            </div>
            <div class="condition" style="margin-left:30px">
              <span>房间类型</span>
              <el-select
                style="width: 180px;margin-left:10px"
                v-model="searchInput.houseType"
                class="m-2"
                placeholder="请选择类型"
                :clearable="true"
                @change="searchBtn"
              >
                <el-option label="全日房" value="1" />
                <el-option label="钟点房" value="2" />
              </el-select>
            </div>
          </div>
        </div>
        <div class="changeItems">
          <div
            class="changeItem"
            :class="roomTypeIndex == '全部' ? 'changeItem_active' : ''"
            @click="changeTypes('全部')"
          >
            全部
          </div>
          <div
            v-for="i in roomTypes"
            class="changeItem"
            :class="roomTypeIndex == i ? 'changeItem_active' : ''"
            @click="changeTypes(i)"
          >
            {{ i }}
          </div>
        </div>
        <!-- <div class="changeItems">
          <el-button
            color="rgba(41, 109, 227, 1)"
            type="primary"
            class="search"
            @click="searchBtn"
          >
            重置管理员密码</el-button
          >
          <el-button
            color="rgba(41, 109, 227, 1)"
            type="primary"
            class="search"
            @click="addTemporaryCard"
          >
            添加总卡</el-button
          >
          <el-button
            color="rgba(41, 109, 227, 1)"
            type="primary"
            class="search"
            @click="searchBtn"
          >
            批量下发开门密码</el-button
          >
          <el-button
            color="rgba(41, 109, 227, 1)"
            type="primary"
            class="search"
            @click="searchBtn"
          >
            批量导入</el-button
          >
        </div> -->
      </div>
      <div class="footer" v-loading="loading">
        <div class="floor" v-for="item in roomList.list">
          <div class="title">
            <span class="t1"
              >{{ item.name }}
              <span style="color: #1e7dfb"
                >( {{ item.roomType == 1 ? "全" : "钟" }} )</span
              ></span
            >
            <span class="t2"> / 共{{ item.total }}间</span>
          </div>
          <div class="roomList">
            <div class="room" v-for="i in item.vos">
              <el-popover
                popper-class="roominfoPopper"
                placement="bottom-start"
                :width="460"
                trigger="click"
                effect="light"
                :visible="i.visible"
              >
                <template #reference>
                  <div @click="itemClick(i)">
                    <div class="roomNum">{{ i.roomNumber }}</div>
                    <div class="rLock">房间锁</div>
                    <div class="wifi">
                      <img
                        v-if="i.equipmentState == 1"
                        src="@/assets/icons/wifiOpen.png"
                        alt=""
                      />
                      <img v-else src="@/assets/icons/wifiClose.png" alt="" />
                      {{ i.equipmentType }}
                    </div>
                  </div>
                </template>
                <div class="roomInfo">
                  <div class="close" @click="closeRoom(i)">
                    <img src="@/assets/icons/close.png" alt="" />
                  </div>
                  <div class="title">{{ i.roomNumber }} (房间锁)</div>
                  <div class="content">
                    <div class="lefts">
                      <div>
                        <span>设备型号</span>
                        <span>{{ i.equipmentType }}</span>
                      </div>
                      <div>
                        <span>网络类型</span>
                        <span>{{ i.networkType }}</span>
                      </div>
                      <div>
                        <span>WIFI MAC</span>
                        <span>{{ i.wifiMac }}</span>
                      </div>
                      <div>
                        <span>绑定时间</span>
                        <span>{{ i.bindingTime }}</span>
                      </div>
                      <div>
                        <span>电量</span>
                        <span v-if="electricQuantity"
                          >{{ electricQuantity }}%</span
                        >
                      </div>
                      <div>
                        <span>网络状态</span>
                        <span v-if="i.networkState == 1">在线</span>
                        <span v-if="i.networkState == 0">离线</span>
                        <span v-if="i.networkState == null"></span>
                      </div>
                      <div>
                        <span>设备状态</span>
                        <span v-if="i.equipmentState == 1">在线</span>
                        <span v-if="i.equipmentState == 0">离线</span>
                        <span v-if="i.equipmentState == null"></span>
                      </div>
                    </div>
                    <div class="rigths">
                      <!-- <div @click="forbiddenClick">
                        <img src="@/assets/icons/forbidden.png" alt="" />
                        <span>禁用门锁</span>
                      </div> -->
                      <div @click="keyClick(i)" v-if="flagBtn.daoru==1">
                        <img src="@/assets/icons/key.png" alt="" />
                        <span>钥匙管理</span>
                      </div>
                      <div @click="newsClick(i)" v-if="flagBtn.daoru==1">
                        <img src="@/assets/icons/news.png" alt="" />
                        <span>消息列表</span>
                      </div>
                      <div @click="unlockingClick(i)" v-if="flagBtn.daoru==1">
                        <img src="@/assets/icons/unlocking.png" alt="" />
                        <span>远程开锁</span>
                      </div>
                      <!-- <div @click="resetPassClick">
                        <img src="@/assets/icons/resetPass.png" alt="" />
                        <span>重置管理员密码</span>
                      </div> -->
                      <div
                        @click="bindingClick(i)"
                        v-if="i.equipmentState != 1 && flagBtn.daoru==1"
                      >
                        <img
                          class="deblocking"
                          src="@/assets/icons/binding.png"
                          alt=""
                        />
                        <span>绑定设备</span>
                      </div>
                      <div
                        @click="deblockingClick(i)"
                        v-if="i.equipmentState == 1 && flagBtn.daoru==1"
                      >
                        <img
                          class="deblocking"
                          src="@/assets/icons/deblocking.png"
                          alt=""
                        />
                        <span>解绑设备</span>
                      </div>
                      <div
                        @click="nfcClick(i,1)"
                        v-if="nfcFunction==0 && flagBtn.daoru==1"
                      >
                        <img
                          class="deblocking"
                          src="@/assets/icons/nfc.png"
                          alt=""
                        />
                        <span>NFC启用</span>
                      </div>
                      <div
                        @click="nfcClick(i,0)"
                        v-if="nfcFunction==1"
                      >
                        <img
                          class="deblocking"
                          src="@/assets/icons/nfc.png"
                          alt=""
                        />
                        <span>NFC禁用</span>
                      </div>
                    </div>
                  </div>
                </div>
              </el-popover>
            </div>
          </div>
        </div>
      </div>
      <!-- 消息列表 -->
      <el-dialog
        class="newsDialog"
        v-model="newsVisible"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        title="消息列表"
        align-center
        width="1000"
        :before-close="cancelNews"
      >
        <div class="middle">
          <div class="changeItems">
            <div
              class="changeNews"
              :class="newsIndex == 1 ? 'changeNews_active' : ''"
              @click="changeNews(1)"
            >
              开锁记录
            </div>
            <div
              class="changeNews"
              :class="newsIndex == 2 ? 'changeNews_active' : ''"
              @click="changeNews(2)"
            >
              操作记录
            </div>
          </div>
        </div>
        <div v-if="newsIndex == 1">
          <div class="footers" v-loading="loading">
            <el-table
              :row-class-name="tableRowClassName"
              :data="newTableList"
              @selection-change="handleSelectionChange"
              style="width: 100%; height: 550px"
              :header-cell-style="{
                background: 'rgba(240, 243, 247, 1)',
                height: '50px',
                border: 0,
              }"
            >
              <el-table-column align="center" prop="roomNumber" label="房间号">
              </el-table-column>
              <el-table-column align="center" prop="type" label="类型" />
              <el-table-column align="center" prop="unlockType" label="操作" />

              <el-table-column
                align="center"
                prop="updateTime"
                label="消息时间"
              >
              </el-table-column>
            </el-table>
          </div>
          <div class="pageSize">
            <span></span>
            <el-pagination
              background
              :current-page="newsPage"
              :page-size="newsSize"
              layout="total, prev, pager, next, jumper, slot"
              :total="newsTotal"
              @update:current-page="newsHandleCurrentChange"
            />
          </div>
        </div>
        <div v-if="newsIndex == 2">
          <div class="footers" v-loading="loading">
            <el-table
              :row-class-name="tableRowClassName"
              :data="newTableList"
              @selection-change="handleSelectionChange"
              style="width: 100%; height: 550px"
              :header-cell-style="{
                background: 'rgba(240, 243, 247, 1)',
                height: '50px',
                border: 0,
              }"
            >
              <el-table-column align="center" prop="roomNumber" label="房间号">
              </el-table-column>
              <el-table-column align="center" prop="type" label="类型" />
              <el-table-column
                align="center"
                prop="operatorName"
                label="操作人"
              />
              <el-table-column
                align="center"
                prop="dataTime"
                label="操作时间"
              />
              <el-table-column align="center" prop="content" label="操作内容">
              </el-table-column>
            </el-table>
          </div>
          <div class="pageSize">
            <span></span>
            <el-pagination
              background
              :current-page="newsPage"
              :page-size="newsSize"
              layout="total, prev, pager, next, jumper, slot"
              :total="newsTotal"
              @update:current-page="newsHandleCurrentChange"
            />
          </div>
        </div>
      </el-dialog>

      <!-- 远程开锁 -->
      <el-dialog
        class="unlockingDialog"
        v-model="unlockingVisible"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        title="远程开锁"
        align-center
        width="400"
        :before-close="cancelUnlocking"
      >
        <div class="middle">
          <div class="content">确定远程开锁吗？<br/><span class="marning">注: 远程开锁前，门锁需要先按“4#”进入请求远程开锁模式</span></div>
          
          <div class="options">
            <el-button
              color="rgba(41, 109, 227, 1)"
              class="queding"
              type="primary"
              @click="unlockingSubmit"
            >
              确定
            </el-button>
            <el-button @click="cancelUnlocking">取消</el-button>
          </div>
        </div>
      </el-dialog>

      <!-- 绑定设备 -->
      <el-dialog
        class="BindingDialog"
        v-model="bindingVisible"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        title="绑定设备"
        align-center
        width="450"
        :before-close="cancelBinding"
      >
        <div class="middle">
          <el-form
            ref="bindingRef"
            :model="bindingList"
            :rules="bindingrules"
            label-width="100px"
            class="demo-ruleForm"
            :size="formSize"
            label-position="left"
            status-icon
          >
            <el-form-item label="绑定设备 :" prop="luid">
              <el-input
                style="width: 250px"
                v-model.trim="bindingList.luid"
                placeholder="请输入设备id"
                clearable
              />
            </el-form-item>
            <el-form-item class="options">
              <el-button
                color="rgba(0, 97, 255, 1)"
                class="queding"
                type="primary"
                @click="bindingSubmit(bindingRef)"
              >
                确定
              </el-button>
              <el-button @click="cancelBinding">取消</el-button>
            </el-form-item>
          </el-form>
        </div>
      </el-dialog>

      <!-- 解绑设备 -->
      <el-dialog
        class="unlockingDialog"
        v-model="deblockingVisible"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        title="解绑设备"
        align-center
        width="400"
        :before-close="cancelDeblocking"
      >
        <div class="middle">
          <div class="content">确定解绑设备吗？</div>
          <div class="options">
            <el-button
              color="rgba(41, 109, 227, 1)"
              class="queding"
              type="primary"
              @click="deblockSubmit"
            >
              确定
            </el-button>
            <el-button @click="cancelDeblocking">取消</el-button>
          </div>
        </div>
      </el-dialog>

      <!-- 批量导入 -->
      <el-dialog
        class="bulkImportDialog"
        v-model="bulkImportVisible"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        title="批量导入"
        align-center
        width="570"
        :before-close="cancelBulkImport"
      >
        <div class="middle">
          <el-upload
            style="width: 500px"
            class="upload-demo"
            ref="bulkImportref"
            drag
            action="#"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :on-change="handleChange"
            :http-request="handleUpload"
            :before-upload="beforeAvatarUpload"
            :limit="1"
            :on-exceed="handleExceed"
          >
            <el-icon class="el-icon--upload"><upload-filled /></el-icon>
            <div class="el-upload__text">
              <span style="font-size: 20px">点击上传或拖拽文件</span><br />
              <em>请按照标准模板填写信息</em><br />
              <em>&nbsp;</em>
            </div>
            <!-- <template #tip>
            <div class="el-upload__tip">
              jpg/png files with a size less than 500kb
            </div>
          </template> -->
          </el-upload>
          <div class="startImport">
            <el-button
              v-if="bulkImportFile"
              type="primary"
              color="rgba(0, 97, 255, 1)"
              style="width: 200px"
              @click="bulkImportConfig"
              plain
              >开始导入</el-button
            >
            <span
              v-else
              type="primary"
              color="rgba(236, 245, 255, 1)"
              style="
                display: inline-block;
                width: 200px;
                height: 42px;
                text-align: center;
                line-height: 42px;
                color: rgb(160, 207, 255);
                border: 1px solid #dcdfe6;
                border-radius: 4px;
              "
              plain
              >开始导入</span
            >
            <span
              style="
                width: 120px;
                margin-left: 20px;
                cursor: pointer;
                color: rgba(0, 97, 255, 1);
              "
              @click="resetImport"
              >重置</span
            >
            <span class="downLoad" @click="downbulkImport">下载模板</span>
          </div>
          <!-- <div class="options">
            <el-button
              color="rgba(41, 109, 227, 1)"
              class="queding"
              type="primary"
              @click="bulkImportConfig"
            >
              确定
            </el-button>
            <el-button @click="cancelBulkImport">取消</el-button>
          </div> -->
        </div>
      </el-dialog>

      <!-- 钥匙管理 -->
      <el-dialog
        class="keyDialog"
        v-model="keyVisible"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        :title="keyTitle"
        align-center
        width="1200"
        :before-close="cancelKey"
      >
        <div class="footers" v-loading="loading">
          <div class="title">
            <div class="keyTitle">
              <span class="txt">住客</span>
            </div>
            <el-collapse v-model="activeUser">
              <el-collapse-item name="1">
                <div class="table">
                  <el-table
                    :row-class-name="tableRowClassName"
                    :data="userList"
                    @selection-change="handleSelectionChange"
                    style="width: 100%; height: 200px"
                    :header-cell-style="{
                      background: 'rgba(240, 243, 247, 1)',
                      height: '50px',
                      border: 0,
                    }"
                  >
                    <el-table-column align="center" prop="name" label="姓名">
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="phone"
                      label="手机号"
                    />
                    <el-table-column
                      align="center"
                      prop="roomlength"
                      label="类型"
                    >
                      <template #default="{ row }">
                        <span v-if="row.lockStatus == 1">密码</span>
                        <span v-if="row.lockStatus == 2">卡片</span>
                        <span v-if="row.lockStatus == 3">指纹</span>
                        <span v-if="row.lockStatus == 4">身份证</span>
                        <span v-if="row.lockStatus == 5">钥匙</span>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="roomlength"
                      label="时效"
                    >
                      <template #default="{ row }">
                        <span v-if="row.type == 1">管理员用户</span>
                        <span v-if="row.type == 2">普通用户</span>
                        <span v-if="row.type == 4">时效性用户</span>
                        <span v-if="row.type == 5">一次性时效密码用户</span>
                        <span v-if="row.type == 100">时效性无网络密码用户</span>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="startTime"
                      label="开始时间"
                      width="120"
                    >
                      <template #default="{ row }">
                        <span v-if="row.type == 4 || row.type == 100">{{
                          row.startTime
                        }}</span>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="endTime"
                      label="结束时间"
                      width="120"
                    >
                      <template #default="{ row }">
                        <span v-if="row.type == 4 || row.type == 100">{{
                          row.endTime
                        }}</span>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="createTime"
                      label="创建时间"
                      width="120"
                    >
                    </el-table-column>
                    <el-table-column align="center" label="操作" width="200">
                      <template #default="scope">
                        <div class="options">
                          <div class="reset" @click="edit(scope.row)">修改</div>
                          <el-popconfirm
                            width="220"
                            confirm-button-text="确认"
                            cancel-button-text="取消"
                            :icon="InfoFilled"
                            icon-color="#f89626"
                            title="是否删除此账号?"
                            @confirm="del(scope.row)"
                            @cancel="cancelEvent"
                          >
                            <template #reference>
                              <div class="reset">删除</div>
                            </template>
                          </el-popconfirm>
                        </div>
                      </template>
                    </el-table-column>
                  </el-table>
                </div>
              </el-collapse-item>
            </el-collapse>
          </div>
          <div class="title titles">
            <div class="keyTitle">
              <span class="txt">员工</span>
              <div class="dropdown">
                <el-dropdown trigger="click" :hide-on-click="false">
                  <el-button type="primary"> 添加电子钥匙 </el-button>
                  <template #dropdown>
                    <el-dropdown-menu>
                      <el-dropdown-item @click="passManagementClick('系统')"
                        >密码</el-dropdown-item
                      >
                      <el-dropdown-item @click="identityCardClick('系统','房卡')"
                        >房卡</el-dropdown-item
                      >
                      <el-dropdown-item @click="fingerprintClick('系统')"
                        >指纹</el-dropdown-item
                      >
                      <el-dropdown-item @click="identityCardClick('系统','身份证')"
                        >身份证</el-dropdown-item
                      >
                    </el-dropdown-menu>
                  </template>
                </el-dropdown>
              </div>
            </div>
            <el-collapse v-model="activeSystem">
              <el-collapse-item name="2">
                <div class="table">
                  <el-table
                    :row-class-name="tableRowClassName"
                    :data="systemUserList"
                    @selection-change="handleSelectionChange"
                    style="width: 100%; height: 200px"
                    :header-cell-style="{
                      background: 'rgba(240, 243, 247, 1)',
                      height: '50px',
                      border: 0,
                    }"
                  >
                    <el-table-column align="center" prop="name" label="姓名">
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="phone"
                      label="手机号"
                      width="130"
                    />
                    <el-table-column
                      align="center"
                      prop="roomlength"
                      label="类型"
                    >
                      <template #default="{ row }">
                        <span v-if="row.lockStatus == 1">密码</span>
                        <span v-if="row.lockStatus == 2">房卡</span>
                        <span v-if="row.lockStatus == 3">指纹</span>
                        <span v-if="row.lockStatus == 4">身份证</span>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="passWord"
                      label="密码"
                      width="110"
                    >
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="roomlength"
                      label="时效"
                      width="200"
                    >
                      <template #default="{ row }">
                        <div>{{ row.startTime }}</div>
                        <div>{{ row.endTime }}</div>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="roomlength"
                      label="状态"
                    >
                      <template #default="{ row }">
                        <span v-if="row.type == 1">管理员用户</span>
                        <span v-if="row.type == 2">普通用户(永久)</span>
                        <span v-if="row.type == 4">时效性用户</span>
                        <span v-if="row.type == 5">一次性时效密码用户</span>
                        <span v-if="row.type == 100">时效性无网络密码用户</span>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="createTime"
                      label="创建时间"
                      width="200"
                    >
                    </el-table-column>
                    <el-table-column align="center" label="操作" width="200">
                      <template #default="scope">
                        <div class="options">
                          <!-- <div
                            class="reset"
                            @click="fingerprintEdit(scope.row)"
                          >
                            修改
                          </div> -->
                          <el-popconfirm
                            width="220"
                            confirm-button-text="确认"
                            cancel-button-text="取消"
                            :icon="InfoFilled"
                            icon-color="#f89626"
                            title="是否删除此用户?"
                            @confirm="fingerprintDel(scope.row)"
                            @cancel="cancelEvent"
                          >
                            <template #reference>
                              <div class="reset">删除</div>
                            </template>
                          </el-popconfirm>
                        </div>
                      </template>
                    </el-table-column>
                  </el-table>
                </div>
              </el-collapse-item>
            </el-collapse>
          </div>
          <div class="title titles">
            <div class="keyTitle">
              <span class="txt">自定义用户</span>
              <div class="dropdown">
                <el-dropdown trigger="click" :hide-on-click="false">
                  <el-button type="primary">
                    添加电子钥匙
                    <!-- <el-icon class="el-icon--right"><arrow-down /></el-icon> -->
                  </el-button>
                  <template #dropdown>
                    <el-dropdown-menu>
                      <el-dropdown-item @click="passManagementClick('自定义')"
                        >密码</el-dropdown-item
                      >
                      <el-dropdown-item @click="identityCardClick('自定义','房卡')"
                        >房卡</el-dropdown-item
                      >
                      <el-dropdown-item @click="fingerprintClick('自定义')"
                        >指纹</el-dropdown-item
                      >
                      <el-dropdown-item @click="identityCardClick('自定义','身份证')"
                        >身份证</el-dropdown-item
                      >
                    </el-dropdown-menu>
                  </template>
                </el-dropdown>
              </div>
            </div>
            <el-collapse v-model="activeCustom">
              <el-collapse-item name="3">
                <div class="table">
                  <el-table
                    :row-class-name="tableRowClassName"
                    :data="customList"
                    @selection-change="handleSelectionChange"
                    style="width: 100%; height: 200px"
                    :header-cell-style="{
                      background: 'rgba(240, 243, 247, 1)',
                      height: '50px',
                      border: 0,
                    }"
                  >
                    <el-table-column align="center" prop="name" label="姓名">
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="phone"
                      label="手机号"
                      width="130"
                    />
                    <el-table-column
                      align="center"
                      prop="roomlength"
                      label="类型"
                    >
                      <template #default="{ row }">
                        <span v-if="row.lockStatus == 1">密码</span>
                        <span v-if="row.lockStatus == 2">房卡</span>
                        <span v-if="row.lockStatus == 3">指纹</span>
                        <span v-if="row.lockStatus == 4">身份证</span>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="passWord"
                      label="密码"
                      width="110"
                    >
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="roomlength"
                      label="时效"
                      width="200"
                    >
                      <template #default="{ row }">
                        <div>{{ row.startTime }}</div>
                        <div>{{ row.endTime }}</div>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="roomlength"
                      label="状态"
                    >
                      <template #default="{ row }">
                        <span v-if="row.type == 1">管理员用户</span>
                        <span v-if="row.type == 2">普通用户(永久)</span>
                        <span v-if="row.type == 4">时效性用户</span>
                        <span v-if="row.type == 5">一次性时效密码用户</span>
                        <span v-if="row.type == 100">时效性无网络密码用户</span>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="createTime"
                      label="创建时间"
                      width="200"
                    >
                    </el-table-column>
                    <el-table-column align="center" label="操作" width="200">
                      <template #default="scope">
                        <div class="options">
                          <!-- <div class="reset" @click="edit(scope.row)">修改</div> -->
                          <el-popconfirm
                            width="220"
                            confirm-button-text="确认"
                            cancel-button-text="取消"
                            :icon="InfoFilled"
                            icon-color="#f89626"
                            title="是否删除此用户?"
                            @confirm="customDel(scope.row)"
                            @cancel="cancelEvent"
                          >
                            <template #reference>
                              <div class="reset">删除</div>
                            </template>
                          </el-popconfirm>
                        </div>
                      </template>
                    </el-table-column>
                  </el-table>
                </div>
              </el-collapse-item>
            </el-collapse>
          </div>
        </div>
      </el-dialog>

      <!-- 添加电子钥匙 密码管理 -->
      <el-dialog
        class="passManagementDialog"
        v-model="passManagementVisible"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        title="密码管理"
        align-center
        width="650"
        :before-close="cancelPassManagement"
      >
        <el-tabs
          v-model="passManagementIndex"
          class="demo-tabs"
          @tab-change="passManagementHandleClick"
        >
          <el-tab-pane label="时效密码" :name="1"> </el-tab-pane>
          <!-- <el-tab-pane label="无网络密码" :name="2"> </el-tab-pane>
          <el-tab-pane label="临时密码" :name="3"> </el-tab-pane> -->
        </el-tabs>
        <el-form
          ref="passManagementRef"
          :model="passManagementRuleForm"
          :rules="passManagementRules"
          label-width="100px"
          class="demo-ruleForm"
          :size="formSize"
          label-position="left"
          status-icon
        >
          <!-- <el-form-item
            label="角色 :"
            prop="level"
            v-if="keypassflag == '系统'"
          >
            <el-cascader
              @change="fingerprintChange"
              v-model="passManagementRuleForm.level"
              :options="fingerprintoptions"
              :props="fingerprintprops"
              :show-all-levels="false"
              :clearable="false"
            />
          </el-form-item> -->
          <el-form-item label="用户 :" prop="name">
            <el-select
              v-model="passManagementRuleForm.name"
              class="m-2"
              placeholder="请选择用户"
              style="width: 500px"
              @change="staffChange($event,'密码')"
              v-if="keypassflag == '系统'"
            >
              <el-option
                v-for="i in staffList"
                :label="`${i.userName} ( ${i.department} )`"
                :value="i.id"
              />
            </el-select>
            <el-input
              v-model.trim="passManagementRuleForm.name"
              placeholder="请输入用户"
              style="width: 500px"
              v-if="keypassflag == '自定义'"
            >
            </el-input>
          </el-form-item>
          <el-form-item
            label="号码 :"
            prop="phone"
            v-if="keypassflag == '自定义'"
          >
            <el-input
              v-model.trim="passManagementRuleForm.phone"
              placeholder="请输入号码"
              style="width: 500px"
            >
            </el-input>
          </el-form-item>
          <el-form-item label="密码 :" prop="pass">
            <el-input
              v-model.trim="passManagementRuleForm.pass"
              placeholder="请输入6-8位数密码或者点击随机生成"
              style="width: 500px"
            >
              <template #append>
                <div @click="randomCipher">随机生成</div>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item label="生效时间 :" prop="effectiveTime">
            <div class="block">
              <el-date-picker
                v-model="passManagementRuleForm.effectiveTime"
                type="datetime"
                placeholder="选择生效时间"
                style="width: 500px"
                format="YYYY-MM-DD HH:mm:ss"
                value-format="YYYY-MM-DD HH:mm:ss"
              />
            </div>
          </el-form-item>
          <el-form-item label="失效时间 :" prop="failureTime">
            <div class="block">
              <el-date-picker
                v-model="passManagementRuleForm.failureTime"
                type="datetime"
                placeholder="选择失效时间"
                style="width: 500px"
                format="YYYY-MM-DD HH:mm:ss"
                value-format="YYYY-MM-DD HH:mm:ss"
              />
            </div>
          </el-form-item>
          <el-form-item class="options">
            <el-button
              color="rgba(41, 109, 227, 1)"
              class="queding"
              type="primary"
              @click="passManagementSend(passManagementRef)"
            >
              确定
            </el-button>
            <el-button @click="cancelPassManagement(passManagementRef)"
              >取消</el-button
            >
          </el-form-item>
        </el-form>
      </el-dialog>

      <!-- 添加电子钥匙 添加指纹 -->
      <el-dialog
        class="fingerprintDialog"
        v-model="fingerprintVisible"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        title="添加指纹"
        align-center
        width="550"
        :before-close="cancelFingerprint"
      >
        <el-form
          ref="fingerprintRef"
          :model="fingerprintRuleForm"
          :rules="fingerprintRules"
          label-width="100px"
          class="demo-ruleForm"
          :size="formSize"
          label-position="left"
          status-icon
        >
          <!-- <el-form-item
            label="角色 :"
            prop="level"
            v-if="keypassflag == '系统'"
          >
            <el-cascader
              @change="fingerprintChange"
              v-model="fingerprintRuleForm.level"
              :options="fingerprintoptions"
              :props="fingerprintprops"
              :show-all-levels="false"
              :clearable="false"
            />
          </el-form-item> -->
          <el-form-item label="用户 :" prop="name">
            <el-select
              v-model="fingerprintRuleForm.name"
              class="m-2"
              placeholder="请选择用户"
              style="width: 214px"
              @change="staffChange($event,'指纹')"
              v-if="keypassflag == '系统'"
            >
              <el-option
                v-for="i in staffList"
                :label="`${i.userName} ( ${i.department} )`"
                :value="i.id"
              />
            </el-select>
            <el-input
              v-model.trim="fingerprintRuleForm.name"
              placeholder="请输入用户"
              style="width: 214px"
              v-if="keypassflag == '自定义'"
            />
          </el-form-item>
          <el-form-item
            label="号码 :"
            prop="phone"
            v-if="keypassflag == '自定义'"
          >
            <el-input
              v-model.trim="fingerprintRuleForm.phone"
              placeholder="请输入号码"
              style="width: 214px"
            >
            </el-input>
          </el-form-item>
          <el-form-item label="指纹 :" prop="fingerprintNum">
            <el-input
              v-model="fingerprintRuleForm.fingerprintNum"
              placeholder="请录入指纹"
              style="width: 300px"
              type="textarea"
              rows="4"
            />
            <span
              style="
                color: rgba(0, 97, 255, 1);
                margin-left: 10px;
                cursor: pointer;
              "
              @click="fingerprintNext"
              >录入</span
            >
          </el-form-item>
          <el-form-item label="生效时间 :" prop="effectiveTime">
            <div class="block">
              <el-date-picker
                v-model="fingerprintRuleForm.effectiveTime"
                type="datetime"
                placeholder="选择生效时间"
                style="width: 214px"
                format="YYYY-MM-DD HH:mm:ss"
                value-format="YYYY-MM-DD HH:mm:ss"
              />
            </div>
          </el-form-item>
          <el-form-item label="失效时间 :" prop="failureTime">
            <div class="block">
              <el-date-picker
                v-model="fingerprintRuleForm.failureTime"
                type="datetime"
                placeholder="选择失效时间"
                style="width: 214px"
                format="YYYY-MM-DD HH:mm:ss"
                value-format="YYYY-MM-DD HH:mm:ss"
              />
            </div>
          </el-form-item>
          <el-form-item class="options">
            <el-button
              color="rgba(41, 109, 227, 1)"
              class="queding"
              type="primary"
              @click="fingerprintconfig(fingerprintRef)"
            >
              确定
            </el-button>
          </el-form-item>
        </el-form>
      </el-dialog>

      <!-- 指纹读取弹窗 -->
      <el-dialog
        class="fingerprint"
        v-model="addFingerprintVisible"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        title="添加指纹"
        align-center
        width="550"
        :before-close="cancelAddFingerprint"
      >
        <div class="el-footer">
          <div style="height: 350px; margin: 30px auto">
            <el-steps direction="vertical" :active="stepindex">
              <el-step
                v-for="i in step.list"
                :key="i.id"
                :title="`步骤 ${i.id}`"
                :description="i.title"
              ></el-step>
            </el-steps>
          </div>
        </div>
      </el-dialog>

      <!-- 添加电子钥匙 添加身份证 -->
      <el-dialog
        class="identityCard"
        v-model="identityCardVisible"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        title="添加身份证"
        align-center
        width="550"
        :before-close="cancelIdentityCard"
      >
        <el-form
          ref="identityCardRef"
          :model="identityCardRuleForm"
          :rules="identityCardRules"
          label-width="100px"
          class="demo-ruleForm"
          :size="formSize"
          label-position="left"
          status-icon
        >
          <!-- <el-form-item
            label="角色 :"
            prop="level"
            v-if="keypassflag == '系统'"
          >
            <el-cascader
              @change="fingerprintChange"
              v-model="identityCardRuleForm.level"
              :options="fingerprintoptions"
              :props="fingerprintprops"
              :show-all-levels="false"
              :clearable="false"
            />
          </el-form-item> -->
          <el-form-item label="用户 :" prop="name">
            <el-select
              v-model="identityCardRuleForm.name"
              class="m-2"
              placeholder="再请选择用户"
              style="width: 214px"
              @change="staffChange($event,'房卡')"
              v-if="keypassflag == '系统'"
            >
              <el-option
                v-for="i in staffList"
                :label="`${i.userName} ( ${i.department} )`"
                :value="i.id"
              />
            </el-select>
            <el-input
              v-model.trim="identityCardRuleForm.name"
              placeholder="请输入用户"
              style="width: 214px"
              v-if="keypassflag == '自定义'"
            />
          </el-form-item>
          <el-form-item
            label="号码 :"
            prop="phone"
            v-if="keypassflag == '自定义'"
          >
            <el-input
              v-model.trim="identityCardRuleForm.phone"
              placeholder="请输入号码"
              style="width: 214px"
            />
          </el-form-item>
          <!-- <el-form-item label="类型 :" prop="cardType">
            <el-radio-group v-model="identityCardRuleForm.cardType">
              <el-radio :value="1">密码</el-radio>
              <el-radio :value="2">房卡</el-radio>
              <el-radio :value="3">指纹</el-radio>
              <el-radio :value="4">身份证</el-radio>
              <el-radio :value="5">钥匙</el-radio>
            </el-radio-group>
          </el-form-item> -->
          <el-form-item label="卡号 :" prop="icCard">
            <el-input
              v-model.trim="identityCardRuleForm.icCard"
              placeholder="请输入卡号"
              style="width: 300px"
              type="textarea"
              rows="4"
            >
            </el-input>
            <span
              style="
                color: rgba(0, 97, 255, 1);
                margin-left: 10px;
                cursor: pointer;
              "
              @click="identityCardNext"
              >读卡</span
            >
          </el-form-item>
          <el-form-item label="生效时间 :" prop="effectiveTime">
            <div class="block">
              <el-date-picker
                v-model="identityCardRuleForm.effectiveTime"
                type="datetime"
                placeholder="选择生效时间"
                style="width: 200px"
                format="YYYY-MM-DD HH:mm:ss"
                value-format="YYYY-MM-DD HH:mm:ss"
              />
            </div>
          </el-form-item>
          <el-form-item label="失效时间 :" prop="failureTime">
            <div class="block">
              <el-date-picker
                v-model="identityCardRuleForm.failureTime"
                type="datetime"
                placeholder="选择失效时间"
                style="width: 200px"
                format="YYYY-MM-DD HH:mm:ss"
                value-format="YYYY-MM-DD HH:mm:ss"
              />
            </div>
          </el-form-item>
          <el-form-item class="options">
            <el-button
              color="rgba(41, 109, 227, 1)"
              class="queding"
              type="primary"
              @click="identityCardConfig(identityCardRef)"
            >
              确定
            </el-button>
          </el-form-item>
        </el-form>
      </el-dialog>

      <!-- 身份证读卡弹窗 -->
      <el-dialog
        class="addIdentityCard"
        v-model="addIdentityCardVisible"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        title="添加身份证"
        align-center
        width="650"
        :before-close="cancelAddIdentityCard"
      >
        <!-- <div class="el-footer">
          {{ identityCardTitle }}
        </div>
        <div class="el-footer">卡号 :{{ identityCardNum }}</div> -->
        <div class="steps">
          <el-steps
            :space="200"
            :active="identityCardIndex"
            finish-status="success"
          >
            <el-step title="环境准备" />
            <el-step title="配置" />
            <el-step title="完成" />
          </el-steps>
        </div>
        <div
          class="title"
          v-if="identityCardIndex == 0 || identityCardIndex == 1"
          style="color: #fc2307"
        >
          {{ identityCardTitle }}
        </div>
        <div class="title" v-else style="color: #68c23c">
          {{ identityCardTitle }}
        </div>
        <div class="icons">
          <img
            v-if="identityCardIndex == 0 || identityCardIndex == 1"
            src="@/assets/icons/error.png"
            alt=""
          />
          <img
            v-if="identityCardIndex == 2"
            class="loading"
            src="@/assets/icons/loading.png"
            alt=""
          />
          <img
            v-if="identityCardIndex == 3"
            src="@/assets/icons/success.png"
            alt=""
          />
        </div>
        <div class="retry">可以尝试<span @click="retry">重试</span></div>
      </el-dialog>
    </div>
  </div>
</template>

<script setup>
import {
  ref,
  reactive,
  nextTick,
  watch,
  onBeforeMount,
  onUnmounted,
} from "vue";
import { useRouter } from "vue-router";
import { ElMessage, ElMessageBox,genFileId } from "element-plus";
import { Calendar } from "@element-plus/icons-vue";
import vidiconsApi from "@/api/vidicons.js";
import { dayjs } from "element-plus";
import lodash from "lodash";
import axios from "axios";
import { useStore } from "vuex";
const store = useStore();
const api = ref("");
const router = useRouter();

const flagBtn = ref(); // 按钮权限
const nowDay = ref(dayjs().format("YYYY-MM-DD HH:mm:ss"));
// 表格数据
const loading = ref(false);
const tableData = reactive({
  list: [
    { roomlength: "/ 共3间" },
    { roomlength: "/ 共3间" },
    { roomlength: "/ 共3间" },
    { roomlength: "/ 共3间" },
    { roomlength: "/ 共3间" },
    { roomlength: "/ 共3间" },
    { roomlength: "/ 共3间" },
    { roomlength: "/ 共3间" },
    { roomlength: "/ 共3间" },
  ],
});

const searchInput = reactive({
  keyWord: "",
  buildingId:"",
  houseType:''
}); // 搜索按钮数据
const buildData = ref(); // 楼栋数据

const roomTypes = ref(); // 房间类型数据
const roomTypeIndex = ref("全部"); // 选中的房间类型
const roomList = reactive({
  list: [
    {
      title: "18#1单元-2层",
      roomlength: "/ 共3间",
      children: [
        {
          roomNum: "201",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "202",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "203",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
      ],
    },
    {
      title: "18#1单元-3层",
      roomlength: "/ 共3间",
      children: [
        {
          roomNum: "201",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "202",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "203",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "204",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "205",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "206",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "207",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "208",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "209",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
      ],
    },
    {
      title: "18#1单元-4层",
      roomlength: "/ 共3间",
      children: [
        {
          roomNum: "201",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "202",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "203",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "204",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "205",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "206",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "207",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "208",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
        {
          roomNum: "209",
          shebei: "L6-VVIFI-QINGKE",
          wangluo: "WIFI",
          wifiMAC: "80A036AE239D",
          lanyaMAC: "F3F401122AF2",
          time: "2022年11月24日10:27:04",
          dianliang: "75%",
          statu: "在线",
          shebeiStatu: "启用",
          lastLock: "2023年11月02日 15:45:34",
          visible: false,
        },
      ],
    },
  ],
});
const electricQuantity = ref(); // 每个房间的电量
const nfcFunction = ref(); // nfc标识
const houseLockId=ref();// 门锁表id

// 设置临时总卡 (头部按钮--------------------------------------------------------）
const temporaryCardVisible = ref(false);
const temporaryCardRef = ref();
const temporaryCardRuleForm = reactive({
  level: 1,
  name: "",
  effectiveTime: "",
  failureTime: "",
  serialNumber: "",
  id: "",
});
var checkFullName = (rule, value, callback) => {
  if (!value) {
    return callback(new Error("请输入姓名"));
  }

  var reg = /^[\u4e00-\u9fa5]{2,6}$/;
  if (!reg.test(value)) {
    callback(new Error("必须为2-6个汉字！"));
  } else {
    callback();
  }
};
// 表单验证
const temporaryCardRules = reactive({
  name: [
    { required: true, message: "姓名不能为空", trigger: "blur" },
    { validator: checkFullName, trigger: "blur" },
  ],
  level: [
    {
      required: true,
      message: "角色不能为空",
      trigger: "blur",
    },
  ],
  effectiveTime: [
    {
      required: true,
      message: "生效时间不能为空",
      trigger: "blur",
    },
  ],
  failureTime: [
    {
      required: true,
      message: "失效时间不能为空",
      trigger: "blur",
    },
  ],
  serialNumber: [
    {
      required: true,
      message: "至少选择一间房",
      trigger: "blur",
    },
  ],
});

// 消息列表弹窗(----------------------------------------------------)
const newsVisible = ref(false);
const newsIndex = ref(1);
const newshouseNumberId = ref();
const newsPage = ref(1); // 当前页
const newsSize = ref(10);
const newsTotal = ref(20); // 当前总数
const newTableList = ref();

// 远程开锁（--------------------------------------------------------）
const unlockingVisible = ref(false);
const unlockList = reactive({ luid: "", roomNumber: "", houseNumberId: "" });

// 绑定设备 (--------------------------------------------------------）
const bindingVisible = ref(false);
const bindingRef = ref();
const bindingList = reactive({ houseNumberId: "", luid: "" });
// 表单验证
const bindingrules = reactive({
  luid: [{ required: true, message: "设备id不能为空", trigger: "blur" }],
});

// 解绑设备 (--------------------------------------------------------）
const deblockingVisible = ref(false);
const dellockList = reactive({ houseNumberId: "" });

// 批量导入 (--------------------------------------------------------）
const bulkImportVisible = ref(false);
const uploadFileShow=ref(false)
const bulkImportref=ref()
const bulkImportFile=ref()

// 重置管理员密码 (--------------------------------------------------------）
const resetPassVisible = ref(false);
const resetPassRef = ref();
const resetPassRuleForm = reactive({
  password: "",
  againPass: "",
  id: "",
});
// 表单验证
const resetPassRules = reactive({
  password: [
    {
      required: true,
      message: "密码不能为空",
      trigger: "blur",
    },
    {
      min: 8,
      max: 20,
      pattern:
        /^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*,\._\+(){}])[0-9a-zA-Z!@#$%^&*,\\._\+(){}]{8,20}$/,
      message: "请输入8-20位正确密码（大小写字母·字符·数字）",
      trigger: "blur",
    },
  ],
  againPass: [
    {
      required: true,
      message: "确认密码不能为空",
      trigger: "blur",
    },
    {
      min: 8,
      max: 20,
      pattern:
        /^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*,\._\+(){}])[0-9a-zA-Z!@#$%^&*,\\._\+(){}]{8,20}$/,
      message: "请输入8-20位正确密码（大小写字母·字符·数字）",
      trigger: "blur",
    },
  ],
  // desc: [{ required: true, message: "Please input activity form", trigger: "blur" }],
});
// 钥匙管理 (--------------------------------------------------------）
const keyVisible = ref(false);
const keyData = reactive({
  houseNumberId: "",
  equipmentType: "",
});
const activeUser=ref('1')
const activeSystem=ref('2')
const activeCustom=ref('3')
const keyTitle = ref();
const userList = ref(); // 用户
const systemUserList = ref(); // 系统用户
const customList = ref(); // 自定义用户
const keypassflag = ref(''); // 添加系统或者自定义用户
const cardFlag = ref(''); // 判断是添加房卡还是身份证
// 钥匙管理 密码管理(--------------------------------------------------------）
const passManagementVisible = ref(false);
const passManagementIndex = ref(1); // 默认选中 时效密码
const passManagementRef = ref();
const passManagementRuleForm = reactive({
  // level: '',
  name: "",
  phone: "",
  effectiveTime: "",
  failureTime: "",
  pass: "",
  id: "",
});
// 表单验证
const passManagementRules = reactive({
  name: [
    { required: true, message: "姓名不能为空", trigger: "blur" },
  ],
  phone: [{ required: true, message: "号码不能为空", trigger: "blur" }],
  level: [
    {
      required: true,
      message: "角色不能为空",
      trigger: "blur",
    },
  ],
  effectiveTime: [
    {
      required: true,
      message: "生效时间不能为空",
      trigger: "blur",
    },
  ],
  failureTime: [
    {
      required: true,
      message: "失效时间不能为空",
      trigger: "blur",
    },
  ],
  pass: [
    {
      required: true,
      message: "密码不能为空",
      trigger: "blur",
    },
  ],
});

const staffList=ref();// 选择的员工数据

// 钥匙管理 添加指纹(--------------------------------------------------------）
const fingerprintVisible = ref(false);
const fingerprintRef = ref();
const fingerprintprops = {
  checkStrictly: true,
  label: "name",
  value: "id",
};
const fingerprintoptions = ref();
// const fingerprintChangeList = ref();
const fingerprintRuleForm = reactive({
  level: "",
  name: "",
  phone: "",
  fingerprintNum: "",
  effectiveTime: "",
  failureTime: "",
  id: "",
});
var fingerprintName = (rule, value, callback) => {
  if (!value) {
    return callback(new Error("请输入姓名"));
  }

  var reg = /^[\u4e00-\u9fa5]{2,6}$/;
  if (!reg.test(value)) {
    callback(new Error("必须为2-6个汉字！"));
  } else {
    callback();
  }
};
// 表单验证
const fingerprintRules = reactive({
  name: [{ required: true, message: "姓名不能为空", trigger: "blur" }],
  phone: [{ required: true, message: "号码不能为空", trigger: "blur" }],
  level: [
    {
      required: true,
      message: "角色不能为空",
      trigger: "blur",
    },
  ],
  fingerprintNum: [
    {
      required: true,
      message: "指纹不能为空",
      trigger: "blur",
    },
  ],
  effectiveTime: [
    {
      required: true,
      message: "生效时间不能为空",
      trigger: "blur",
    },
  ],
  failureTime: [
    {
      required: true,
      message: "失效时间不能为空",
      trigger: "blur",
    },
  ],
});

// 添加指纹弹窗
const addFingerprintVisible = ref(false);
const stepindex = ref(0); // 录取指纹步骤
const step = reactive({
  list: [
    { id: 1, title: "" },
    { id: 2, title: "" },
    { id: 3, title: "" },
    { id: 4, title: "" },
  ],
}); // 指纹步骤数据
const ws = ref("");

// 钥匙管理 添加身份证(--------------------------------------------------------）
const identityCardVisible = ref(false);
const identityCardRef = ref();
const identityCardRuleForm = reactive({
  level: "",
  name: "",
  phone: "",
  icCard: "",
  cardType: "",
  effectiveTime: "",
  failureTime: "",
  id: "",
});
// 表单验证
const identityCardRules = reactive({
  name: [{ required: true, message: "姓名不能为空", trigger: "blur" }],
  phone: [{ required: true, message: "号码不能为空", trigger: "blur" }],
  level: [
    {
      required: true,
      message: "角色不能为空",
      trigger: "blur",
    },
  ],
  cardType: [
    {
      required: true,
      message: "类型不能为空",
      trigger: "blur",
    },
  ],
  icCard: [
    {
      required: true,
      message: "卡号不能为空",
      trigger: "blur",
    },
  ],
  effectiveTime: [
    {
      required: true,
      message: "生效时间不能为空",
      trigger: "blur",
    },
  ],
  failureTime: [
    {
      required: true,
      message: "失效时间不能为空",
      trigger: "blur",
    },
  ],
});
// 添加身份证弹窗
const addIdentityCardVisible = ref(false);
// const wsidentityCard = ref("");
const identityCardTitle = ref("");
// const identityCardNum = ref(""); // 身份证卡号
const identityCardIndex = ref(0); // 读卡步骤

// 点击房间查看面板操作 (--------------------------------------------------)
const itemClick = async (i) => {
  roomList.list.forEach((item) => {
    item.vos.forEach((ii) => {
      ii.visible = false;
    });
  });
  i.visible = true
  let data = {
    houseNumberId: i.houseNumberId,
    permissionSettingId: sessionStorage.getItem("permissionSettingId"),
  };
  let res = await axios({
    method: "get",
    url: api.value + "/house-lock/particular",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    params: data,
  });
  console.log(res, "门锁详情");
  if (res.data.code == 200) {
    electricQuantity.value = res.data.data.electricQuantity;
    nfcFunction.value = res.data.data.nfcFunction;
    houseLockId.value = res.data.data.id;
    // i.visible = true;
  } else {
    // i.visible = false;
    electricQuantity.value = "";
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};
// 关闭操作面板
const closeRoom = (i) => {
  i.visible = false;
};

// 房型列表展示条
const roomNameTypeData = async () => {
  let res = await axios({
    method: "get",
    url: api.value + "/house/roomNameType",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("user_head"),
    },
  });
  console.log(res, "房型管理");
  if (res.data.code == 200) {
    roomTypes.value = res.data.data;
    // roomTypeIndex.value=roomTypes.value[0]
    loading.value = false;
    // ElMessage({
    //   type: "success",
    //   showClose: true,
    //   message: res.data.message,
    //   center: true,
    // });
  } else {
    loading.value = false;
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};
const changeTypes = (val) => {
  console.log(val);
  roomTypeIndex.value = val;
  getList().then(() => {
    roomList.list.forEach((item) => {
      item.vos.forEach((ii) => {
        ii.visible = false;
      });
    });
  });
};

// 楼栋单元数据
const schoolData = async () => {
  let res = await axios({
    method: "get",
    url: api.value + "/building/beDisplayBar",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("user_head"),
    },
  });
  console.log(res, "楼栋单元下拉框");
  if (res.data.code == 200) {
    buildData.value = res.data.data;
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};

// 查看员工列表
const getList = async () => {
  loading.value = true;
  let data = {
    roomNumber: searchInput.keyWord,
    permissionSettingId: sessionStorage.getItem("permissionSettingId"),
    roomName: roomTypeIndex.value,
    buildingId:searchInput.buildingId,
    houseType:searchInput.houseType
  };
  if (roomTypeIndex.value == "全部") {
    data.roomName = "";
  }
  let res = await axios({
    method: "get",
    url: api.value + "/house-lock/list",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    params: data,
  });
  console.log(res, "门锁页面展示");
  if (res.data.code == 200) {
    loading.value = false;
    let arr=[]
    res.data.data.forEach((item) => {
      if(item.vos){
        item.total = item.vos.length;
        arr.push(item)
      }
    });
    roomList.list = arr;
  } else {
    loading.value = false;
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};

// 搜索功能
const searchBtn = lodash.debounce(async () => {
    getList();
}, 300);

// 消息列表 (---------------------------------------------------------------)
const newsClick = async (row) => {
  newsVisible.value = true;
  console.log(row, "消息列表");
  newshouseNumberId.value = row.houseNumberId;
  if (newsIndex.value == 1) {
    let data = {
      houseNumberId: newshouseNumberId.value,
      permissionSettingId: sessionStorage.getItem("permissionSettingId"),
      page: newsPage.value,
      size: newsSize.value,
    };
    let res = await axios({
      method: "get",
      url: api.value + "/unlocking-record/pageList",
      headers: {
        token: sessionStorage.getItem("token"),
        user_head: sessionStorage.getItem("userhead"),
      },
      params: data,
    });
    console.log(res, "开锁记录");
    if (res.data.code == 200) {
      newTableList.value = res.data.data.records;
      newsTotal.value = res.data.data.total;
    } else {
      ElMessage({
        type: "error",
        showClose: true,
        message: res.data.message,
        center: true,
      });
    }
  } else if (newsIndex.value == 2) {
    let data = {
      houseNumberId: newshouseNumberId.value,
      permissionSettingId: sessionStorage.getItem("permissionSettingId"),
      page: newsPage.value,
      size: newsSize.value,
    };
    let res = await axios({
      method: "get",
      url: api.value + "/operating-record/pageList",
      headers: {
        token: sessionStorage.getItem("token"),
        user_head: sessionStorage.getItem("userhead"),
      },
      params: data,
    });
    console.log(res, "操作记录");
    if (res.data.code == 200) {
      newTableList.value = res.data.data.records;
      newsTotal.value = res.data.data.total;
    } else {
      ElMessage({
        type: "error",
        showClose: true,
        message: res.data.message,
        center: true,
      });
    }
  }
};
// 切换消息列表
const changeNews = async (ind) => {
  newsIndex.value = ind;
  if (ind == 1) {
    let data = {
      houseNumberId: newshouseNumberId.value,
      permissionSettingId: sessionStorage.getItem("permissionSettingId"),
      page: newsPage.value,
      size: newsSize.value,
    };
    let res = await axios({
      method: "get",
      url: api.value + "/unlocking-record/pageList",
      headers: {
        token: sessionStorage.getItem("token"),
        user_head: sessionStorage.getItem("userhead"),
      },
      params: data,
    });
    console.log(res, "开锁记录");
    if (res.data.code == 200) {
      newTableList.value = res.data.data.records;
      newsTotal.value = res.data.data.total;
    } else {
      ElMessage({
        type: "error",
        showClose: true,
        message: res.data.message,
        center: true,
      });
    }
  } else if (ind == 2) {
    let data = {
      houseNumberId: newshouseNumberId.value,
      permissionSettingId: sessionStorage.getItem("permissionSettingId"),
      page: newsPage.value,
      size: newsSize.value,
    };
    let res = await axios({
      method: "get",
      url: api.value + "/operating-record/pageList",
      headers: {
        token: sessionStorage.getItem("token"),
        user_head: sessionStorage.getItem("userhead"),
      },
      params: data,
    });
    console.log(res, "开锁记录");
    if (res.data.code == 200) {
      newTableList.value = res.data.data.records;
      newsTotal.value = res.data.data.total;
    } else {
      ElMessage({
        type: "error",
        showClose: true,
        message: res.data.message,
        center: true,
      });
    }
  }
};
// 关闭弹窗列表
const cancelNews = () => {
  newsVisible.value = false;
};
// 消息列表分页
const newsHandleCurrentChange = (value) => {
  // console.log(value);
  newsPage.value = value;
  changeNews(newsIndex.value);
};

// 远程开锁(-----------------------------------------------------------------)
const unlockingClick = (row) => {
  console.log(row, "远程开锁");
  unlockingVisible.value = true;
  unlockList.luid = row.equipmentType;
  unlockList.roomNumber = row.roomNumber;
  unlockList.houseNumberId = row.houseNumberId;
};
// 确定远程开锁
const unlockingSubmit = async () => {
  let data = {
    luid: unlockList.luid,
    roomNumber: unlockList.roomNumber,
    houseNumberId: unlockList.houseNumberId,
    permissionSettingId: sessionStorage.getItem("permissionSettingId"),
  };
  let res = await axios({
    method: "post",
    url: api.value + "/house-lock/remoteUnlocking",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    data: data,
  });
  console.log(res, "确定远程开锁");
  if (res.data.code == 200) {
    unlockingVisible.value = false;
    getList();
    ElMessage({
      type: "success",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};
const cancelUnlocking = () => {
  unlockingVisible.value = false;
};

// 绑定设备(-----------------------------------------------------------------)
const bindingClick = (row) => {
  console.log(row, "绑定设备");
  bindingVisible.value = true;
  bindingList.houseNumberId = row.houseNumberId;
};
// 确定绑定设备
const bindingSubmit = async (formEl) => {
  if (!formEl) return;
  await formEl.validate(async (valid, fields) => {
    if (valid) {
      let data = {
        permissionSettingId: sessionStorage.getItem("permissionSettingId"),
        houseNumberId: bindingList.houseNumberId, //房间号id
        adminId: sessionStorage.getItem("id"), //管理员id
        luid: bindingList.luid, //锁设备ID
      };
      let res = await axios({
        method: "post",
        url: api.value + "/house-lock/binding",
        headers: {
          token: sessionStorage.getItem("token"),
          user_head: sessionStorage.getItem("user_head"),
        },
        data: data,
      });
      console.log(res, "确定绑定设备");
      if (res.data.code == 200) {
        getList();
        ElMessage({
          type: "success",
          showClose: true,
          message: res.data.message,
          center: true,
        });
        bindingVisible.value = false;
        bindingRef.value.resetFields();
      } else {
        ElMessage({
          type: "error",
          showClose: true,
          message: res.data.message,
          center: true,
        });
      }
    } else {
      console.log("error submit!", fields);
    }
  });
}
// 取消绑定设备
const cancelBinding = () => {
  bindingVisible.value = false;
  bindingRef.value.resetFields()
};

// nfc操作
const nfcClick= async (row,flag)=>{
  console.log(row,'nfc操作');
  let data = {
    houseLockId: houseLockId.value,
    nfcFunction: flag,
  };
  let res = await axios({
    method: "get",
    url: api.value + "/house-lock/nfc",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    params: data,
  });
  console.log(res, "nfc操作");
  if (res.data.code == 200) {
    getList();
    roomList.list.forEach((item) => {
      item.vos.forEach((ii) => {
        ii.visible = false;
      });
    });
    ElMessage({
      type: "success",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
}

// 解绑设备(-----------------------------------------------------------------)
const deblockingClick = (row) => {
  console.log(row, "解绑设备");
  deblockingVisible.value = true;
  dellockList.houseNumberId = row.houseNumberId;
};
// 确定解绑设备
const deblockSubmit = async () => {
  let data = {
    houseNumberId: dellockList.houseNumberId,
    permissionSettingId: sessionStorage.getItem("permissionSettingId"),
    adminId: sessionStorage.getItem("id"),
  };
  let res = await axios({
    method: "get",
    url: api.value + "/house-lock/unbind",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    params: data,
  });
  console.log(res, "确定解绑设备");
  if (res.data.code == 200) {
    deblockingVisible.value = false;
    getList();
    ElMessage({
      type: "success",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};
// 取消绑定
const cancelDeblocking = () => {
  deblockingVisible.value = false;
};

// 批量导入(-----------------------------------------------------------------)
const bulkImportClick = () => {
  bulkImportVisible.value = true;
  bulkImportFile.value = "";
  nextTick(()=>{
    bulkImportref.value.clearFiles();
  })
};
// 移出照片
const handleRemove = (uploadFile, uploadFiles) => {
  bulkImportFile.value = "";
};
// 点击图片的查看按钮
const handlePreview = (file) => {
  console.log(file);
};
// 限制上传图片的大小
const beforeAvatarUpload = (rawFile) => {
  console.log(rawFile.type, "文件类型");
  if (
    rawFile.type !==
    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  ) {
    ElMessage.error("文件格式必须为xlsx格式!");
    return false;
  } else if (rawFile.size / 1024 / 1024 > 100) {
    ElMessage.error("文件的大小不能超过100MB!");
    return false;
  }
  return true;
};
// 添加照片时往fileList列表中添加图片信息
const handleChange = async (file, fileLists) => {
  console.log(file, "1111");
  // fileList.list.push(file);
  bulkImportFile.value = file.raw;
  uploadFileShow.value=true
};
// 可以获取图片参数
const handleUpload = async (file) => {
  // if (fileList.list.length >= 6) {
  //   ElMessage.error("最多可上传6张图片!");
  //   return false;
  // }
  console.log(file, "22222222");
  // let data = new FormData();
  // data.set("files", file.file);
  // let res = await axios({
  //   method: "post",
  //   url: api.value + "/file/cos/upload",
  //   headers: {},
  //   data: data,
  // });
  // console.log(res, "图片上传成功详情图");
  // if (res.data.code == 1) {
  //   // res.data.data.uid = file.file.uid;
  //   // console.log([res.data.data]);
  //   let arr = {
  //     uid: file.file.uid,
  //     url: res.data.data,
  //   };

  //   fileList.list = fileList.list.concat([arr]);
  //   ruleForm.fileListJson = fileList.list;
  // }
};
// 上传文件时覆盖上一个文件
const handleExceed = (files) => {
  bulkImportref.value.clearFiles();
  const file = files[0];
  file.uid = genFileId();
  bulkImportref.value.handleStart(file);
};
// 重置按钮 重置上传文件
const resetImport = () => {
  bulkImportFile.value = "";
  bulkImportref.value.clearFiles();
};
// 下载模板
const downbulkImport=async ()=>{
  let res = await axios({
      method: "get",
      url: api.value + "/house-lock/lockExport",
      headers: {
        token: sessionStorage.getItem("token"),
        user_head: sessionStorage.getItem("userhead"),
      },
      responseType: "blob",
    });
    console.log(
      res,
      "批量导入模板下载"
    );
    if (res.status == 200) {
      let name = `门锁模板`;
      var content = res.data;
      var datas = new Blob([content]);
      var downloadUrl = window.URL.createObjectURL(datas);
      var anchor = document.createElement("a");
      anchor.href = downloadUrl;
      anchor.download = name + ".xlsx";
      anchor.click();
      window.URL.revokeObjectURL(datas);
      ElMessage({
        type: "success",
        showClose: true,
        message: "下载成功",
        center: true,
      });
    } else {
      ElMessage({
        type: "error",
        showClose: true,
        message: res.data.message,
        center: true,
      });
    }
}
// 确定导入
const bulkImportConfig=async () =>{
  let data=new FormData();
  data.append('file',bulkImportFile.value)
  let res = await axios({
    method: "post",
    url: api.value + "/house-lock/lockImport",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    data:data
  });
  console.log(
    res,
    "确定导入"
  );
  if (res.status == 200) {
    getList()
    bulkImportVisible.value = false;
    ElMessage({
      type: "success",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
}
const cancelBulkImport = () => {
  bulkImportVisible.value = false;
};

// 钥匙管理(-----------------------------------------------------------------)
const keyListData = async () => {
  let data = {
    permissionSettingId: sessionStorage.getItem("permissionSettingId"),
    houseNumberId: keyData.houseNumberId,
  };
  let res = await axios({
    method: "get",
    url: api.value + "/house-lock/key",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    params: data,
  });
  console.log(res, "住客，系统用户");
  if (res.data.code == 200) {
    userList.value = res.data.data.order;
    systemUserList.value = res.data.data.employee;
    customList.value = res.data.data.custom;
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};
// 员工数据
const staffData=async ()=>{
  // let data = {
  //   permissionSettingId: sessionStorage.getItem("permissionSettingId"),
  //   houseNumberId: keyData.houseNumberId,
  // };
  let res = await axios({
    method: "get",
    url: api.value + "/employeeUsers/getAllUser",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
  });
  console.log(res, "员工数据");
  if (res.data.code == 200) {
    staffList.value=res.data.data;
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
}
// 改变用户选择
const staffChange=(val,flag)=>{
  console.log(val,flag,'改变用户选择');
  if(flag=='房卡'){
    staffList.value.forEach(i=>{
      if(i.id==val){
        // console.log(i,'房卡  用户数据');
        if(cardFlag.value=='房卡'){
          identityCardRuleForm.icCard=""
        }else if(cardFlag.value=='身份证'){
          identityCardRuleForm.icCard=i.idCardInformation
        }
      }
    })
  }else if(flag=='指纹'){
    staffList.value.forEach(i=>{
      if(i.id==val){
        console.log(i,'指纹  用户数据');
        fingerprintRuleForm.fingerprintNum=i.fingerprint
      }
    })
  }
}
const keyClick = async (row) => {
  console.log(row, "钥匙管理");
  keyTitle.value = row.roomNumber;
  keyData.houseNumberId = row.houseNumberId;
  keyData.equipmentType = row.equipmentType;
  keyVisible.value = true;
  keyListData();// 住客，员工  自定义用户
  staffData();// 员工筛选数据
};
const cancelKey = () => {
  keyVisible.value = false;
};
// 钥匙管理 密码管理(-----------------------------------------------------------------)
const passManagementClick = (val) => {
  keypassflag.value=val
  // rolesList();
  // fingerprintChangeList.value=""
  passManagementVisible.value = true;
  // passManagementRuleForm.level = "";
  passManagementRuleForm.name = "";
  passManagementRuleForm.phone = "";
  passManagementRuleForm.effectiveTime = "";
  passManagementRuleForm.failureTime = "";
  passManagementRuleForm.pass = "";
  nextTick(()=>{
    passManagementRef.value.resetFields()
  })
};
const cancelPassManagement = () => {
  passManagementVisible.value = false;
  passManagementRef.value.resetFields()
};
// 判断切换  时效密码  无网络密码  临时密码
const passManagementHandleClick = (value) => {
  console.log(value);
  passManagementRef.value.resetFields();
};
// 确定密码
const passManagementSend = (formEl) => {
  if (!formEl) return;
  formEl.validate(async (valid, fields) => {
    if (valid) {
      if(keypassflag.value=='系统'){
        let data = {
          permissionSettingId: sessionStorage.getItem("permissionSettingId"), //权限表id
          adminId: sessionStorage.getItem("id"), //管理员id
          houseNumberId: keyData.houseNumberId, //房间号id
          startTime: passManagementRuleForm.effectiveTime, //    开始时间
          endTime: passManagementRuleForm.failureTime, //结束时间
          usersId: passManagementRuleForm.name, //用户id
          equipmentType: keyData.equipmentType, //设备id
          passWord: passManagementRuleForm.pass, // 密码
          type: "4", //1：管理员用户，2：普通用户（永久），4：时效性用户，5：一次性时效密码用户，100：时效性无网络密码用户
        };
        let res = await axios({
          method: "post",
          url: api.value + "/unlocking-employee/savePassWord",
          headers: {
            token: sessionStorage.getItem("token"),
            user_head: sessionStorage.getItem("userhead"),
          },
          data: data,
        });
        console.log(res, "系统添加密码");
        if (res.data.code == 200) {
          passManagementVisible.value = false;
          keyListData();
          ElMessage({
            type: "success",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        } else {
          ElMessage({
            type: "error",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        }
      }else if(keypassflag.value=='自定义'){
        let data = {
          permissionSettingId: sessionStorage.getItem("permissionSettingId"), //权限表id
          adminId: sessionStorage.getItem("id"), //管理员id
          houseNumberId: keyData.houseNumberId, //房间号id
          startTime: passManagementRuleForm.effectiveTime, //    开始时间
          endTime: passManagementRuleForm.failureTime, //结束时间
          userName: passManagementRuleForm.name, //用户id
          phone: passManagementRuleForm.phone, //用户id
          equipmentType: keyData.equipmentType, //设备id
          passWord: passManagementRuleForm.pass, // 密码
          type: "4", //1：管理员用户，2：普通用户（永久），4：时效性用户，5：一次性时效密码用户，100：时效性无网络密码用户
        };
        let res = await axios({
          method: "post",
          url: api.value + "/unlocking-custom/savePassWord",
          headers: {
            token: sessionStorage.getItem("token"),
            user_head: sessionStorage.getItem("userhead"),
          },
          data: data,
        });
        console.log(res, "自定义添加密码");
        if (res.data.code == 200) {
          passManagementVisible.value = false;
          keyListData();
          ElMessage({
            type: "success",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        } else {
          ElMessage({
            type: "error",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        }
      }
    } else {
      console.log("error submit!", fields);
    }
  });
};
// 随机八位数密码
const randomCipher =async () => {
  let res = await axios({
    method: "get",
    url: api.value + "/unlocking-admin/getPassWord",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
  });
  console.log(res, "随机密码");
  if (res.data.code == 200) {
    passManagementRuleForm.pass = res.data.data.passWord;
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
};

// // 获取管理端角色信息
// const rolesList = async () => {
//   let res = await axios({
//     method: "get",
//     url: api.value + "/admin-menu/getUserRole",
//     headers: {
//       token: sessionStorage.getItem("token"),
//       user_head: sessionStorage.getItem("userhead"),
//     },
//   });
//   console.log(res, "管理端角色");
//   if (res.data.code == 200) {
//     fingerprintoptions.value = res.data.data;
//   } else {
//     ElMessage({
//       type: "error",
//       showClose: true,
//       message: res.data.message,
//       center: true,
//     });
//   }
// };
// // 改变管理端角色  获取用户角色信息
// const fingerprintChange = async (val) => {
//   console.log(val);
//   let data = {
//     adminMenuId: val[val.length - 1],
//   };
//   let res = await axios({
//     method: "get",
//     url: api.value + "/admin/userList",
//     headers: {
//       token: sessionStorage.getItem("token"),
//       user_head: sessionStorage.getItem("userhead"),
//     },
//     params: data,
//   });
//   console.log(res, "用户角色");
//   if (res.data.code == 200) {
//     fingerprintChangeList.value = res.data.data;
//   } else {
//     ElMessage({
//       type: "error",
//       showClose: true,
//       message: res.data.message,
//       center: true,
//     });
//   }
// };

// 钥匙管理 添加指纹(-----------------------------------------------------------------)
const fingerprintClick = (val) => {
  console.log("添加指纹",val);
  keypassflag.value=val
  // rolesList();
  // fingerprintChangeList.value=""
  fingerprintVisible.value = true;
  // fingerprintRuleForm.level = "";
  fingerprintRuleForm.name = "";
  fingerprintRuleForm.phone = "";
  fingerprintRuleForm.fingerprintNum = "";
  fingerprintRuleForm.effectiveTime = "";
  fingerprintRuleForm.failureTime = "";
  nextTick(()=>{
    fingerprintRef.value.resetFields();
  })
};

const cancelFingerprint = () => {
  fingerprintVisible.value = false;
  fingerprintRef.value.resetFields();
};
// 指纹录取
const fingerprintNext = (formEl) => {
  addFingerprintVisible.value = true;
  step.list = [
    { id: 1, title: "" },
    { id: 2, title: "" },
    { id: 3, title: "" },
    { id: 4, title: "" },
  ];
  stepindex.value = 0;
  var wsUrl = "ws://localhost:8181/";
  let websocket = new WebSocket(wsUrl);
  ws.value = websocket;
  websocket.onopen = function (evt) {
    var params = { type: 101, data: null };
    websocket.send(JSON.stringify(params));
  };
  websocket.onmessage = function (evt) {
    // console.log(evt.data, "输出指纹数据");
    let data = JSON.parse(evt.data);
    if (data.type == 0) {
      console.log(data.data.portNames);
      let num=0
      if(data.data.portNames){
        num=data.data.portNames.length
        console.log(JSON.parse(evt.data).data.portNames[num-1]);
      }
      // console.log(JSON.parse(evt.data).data.portNames[1]); // 获取到 USB接口
      let params1 = {
        type: 1,
        data: {
          type: 0,
          portName: JSON.parse(evt.data).data.portNames[num-1],
          baudRate: 115200,
        },
      };
      websocket.send(JSON.stringify(params1));
    } else if (data.type == 110) {
      console.log("已获取设备信息");
    } else if (data.type == 11) {
      var params2 = {
        type: 2,
        data: {
          totalStep: 4,
        },
      };
      websocket.send(JSON.stringify(params2));
    } else if (data.type == 21) {
      if (data.data.step == 0) {
        // console.log("请按压指纹");
        ElMessage({
          message: "请开始按压指纹",
          type: "success",
        });
      } else {
        // console.log(`请按下同一指纹，第${data.data.step}次按压`);
        if (data.data.step <= 4) {
          step.list.forEach((item) => {
            if (item.id == data.data.step) {
              item.title = `请按下同一指纹，第${data.data.step}次录入指纹成功`;
            }
          });
        }
        stepindex.value = data.data.step;
      }
      // _this.$message.warning("请将手指按在传感器上");
      if (data.data.step > 4) {
        var params = {
          type: 3,
          data: {
            id: data.data.id,
          },
        };
        websocket.send(JSON.stringify(params));
      }
    } else if (data.type == 31) {
      fingerprintRuleForm.fingerprintNum = data.data.template;
      console.log(data.data.template, "指纹数据");
      addFingerprintVisible.value = false;
      ws.value.close();
      ElMessage({
        message: "指纹录取成功",
        type: "success",
      });
      // setTimeout(() => {
      //   _this.fingerprintShow = false;
      //   ws.value.close();
      // }, 1500);
    } else {
      ElMessage({
        message: "设备连接失败，请刷新重新录入",
        type: "error",
      });
    }
  };
  websocket.onclose = function (evt) {
    console.log("关闭连接");
    // ws.value.close();
  };
  websocket.onerror = function (evt) {
    // console.log("错误提示");
  };
};
const fingerprintconfig = (formEl) => {
  if (!formEl) return;
  formEl.validate(async (valid, fields) => {
    if (valid) {
      if(keypassflag.value=='系统'){
        let data = {
          permissionSettingId: sessionStorage.getItem("permissionSettingId"), //权限表id
          adminId: sessionStorage.getItem("id"), //管理员id
          houseNumberId: keyData.houseNumberId, //房间号id
          startTime: fingerprintRuleForm.effectiveTime, //    开始时间
          endTime: fingerprintRuleForm.failureTime, //结束时间
          usersId: fingerprintRuleForm.name, //用户id
          luid: keyData.equipmentType, //设备id
          fingerprintData: fingerprintRuleForm.fingerprintNum, //指纹特征值
          type: "4", //1：管理员用户，2：普通用户（永久），4：时效性用户，5：一次性时效密码用户，100：时效性无网络密码用户
        };
        let res = await axios({
          method: "post",
          url: api.value + "/unlocking-employee/saveFingerprint",
          headers: {
            token: sessionStorage.getItem("token"),
            user_head: sessionStorage.getItem("userhead"),
          },
          data: data,
        });
        console.log(res, "系统添加指纹钥匙");
        if (res.data.code == 200) {
          fingerprintVisible.value = false;
          keyListData();
          ElMessage({
            type: "success",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        } else {
          ElMessage({
            type: "error",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        }
      }else if(keypassflag.value=='自定义'){
        let data = {
          permissionSettingId: sessionStorage.getItem("permissionSettingId"), //权限表id
          adminId: sessionStorage.getItem("id"), //管理员id
          houseNumberId: keyData.houseNumberId, //房间号id
          startTime: fingerprintRuleForm.effectiveTime, //    开始时间
          endTime: fingerprintRuleForm.failureTime, //结束时间
          userName: fingerprintRuleForm.name, //用户id
          phone: fingerprintRuleForm.phone, //用户id
          luid: keyData.equipmentType, //设备id
          fingerprintData: fingerprintRuleForm.fingerprintNum, //指纹特征值
          type: "4", //1：管理员用户，2：普通用户（永久），4：时效性用户，5：一次性时效密码用户，100：时效性无网络密码用户
        };
        let res = await axios({
          method: "post",
          url: api.value + "/unlocking-custom/saveFingerprint",
          headers: {
            token: sessionStorage.getItem("token"),
            user_head: sessionStorage.getItem("userhead"),
          },
          data: data,
        });
        console.log(res, "自定义添加指纹钥匙");
        if (res.data.code == 200) {
          fingerprintVisible.value = false;
          keyListData();
          ElMessage({
            type: "success",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        } else {
          ElMessage({
            type: "error",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        }
      }
    }
  });
};
// 钥匙管理中删除系统用户
const fingerprintDel=async (row)=>{
  console.log(row);
  let data = {
    unlockingEmpId: row.id, //权限表id
  };
  let res = await axios({
    method: "get",
    url: api.value + "/unlocking-employee/deleteLock",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    params: data,
  });
  console.log(res, "删除指纹钥匙");
  if (res.data.code == 200) {
    keyListData();
    ElMessage({
      type: "success",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
}
// 钥匙管理中删除自定义用户
const customDel=async (row)=>{
  console.log(row);
  let data = {
    unlockingAdminId: row.id, //权限表id
  };
  let res = await axios({
    method: "get",
    url: api.value + "/unlocking-custom/deleteLock",
    headers: {
      token: sessionStorage.getItem("token"),
      user_head: sessionStorage.getItem("userhead"),
    },
    params: data,
  });
  console.log(res, "删除指纹钥匙");
  if (res.data.code == 200) {
    keyListData();
    ElMessage({
      type: "success",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
}
// 关闭指纹录入
const cancelAddFingerprint = () => {
  addFingerprintVisible.value = false;
  // var wsUrl = "ws://localhost:8181/";
  // const websocket = new WebSocket(wsUrl);
  ws.value.close();
};

// 钥匙管理 添加身份证(-----------------------------------------------------------------)
const identityCardClick = (val,card) => {
  keypassflag.value=val
  if(card){
    cardFlag.value=card
  }else{
    cardFlag.value=""
  }
  // rolesList();
  // fingerprintChangeList.value=""
  identityCardVisible.value = true;
  identityCardRuleForm.level = "";
  identityCardRuleForm.name = "";
  identityCardRuleForm.phone = "";
  identityCardRuleForm.icCard = "";
  identityCardRuleForm.cardType = "";
  identityCardRuleForm.effectiveTime = "";
  identityCardRuleForm.failureTime = "";
  nextTick(()=>{
    identityCardRef.value.resetFields();
  })
};
const cancelIdentityCard = () => {
  identityCardVisible.value = false;
  identityCardRef.value.resetFields();
};
const Card = () => {
  var wsUrl = "ws://localhost:8181/";
  let websocket = new WebSocket(wsUrl);
  // wsidentityCard.value = websocket;
  websocket.onopen = function (evt) {
    var params = { type: 104, data: null };
    websocket.send(JSON.stringify(params));
  };

  websocket.onmessage = function (evt) {
    let data = JSON.parse(evt.data);
    console.log(data);
    if (data.type == 141) {
      identityCardTitle.value = "请插入设备";
      identityCardIndex.value = 0;
    } else if (data.type == 150) {
      identityCardTitle.value = "配置失败，请检查卡片是否已放置设备上";
      identityCardIndex.value = 1;
    } else if (data.type == 140) {
      // identityCardNum.value = data.data.uid;
      console.log(data.data.uid, "读取的卡号");

      identityCardIndex.value = 2;
      identityCardTitle.value = "读卡中";

      if (data.data.uid) {
        setTimeout(() => {
          identityCardIndex.value = 3;
          identityCardTitle.value = "读卡成功";
        }, 1500);
      }

      // ElMessage({
      //   type: "success",
      //   showClose: true,
      //   message: "添加卡片成功",
      //   center: true,
      // });

      // identityCardTitle.value = "获取卡号成功";

      // addIdentityCardVisible.value = false;
      // identityCardVisible.value = false;
      // identityCardRef.value.resetFields();

      // setTimeout(() => {
      //   _this.icCardShow = false;
      // }, 2000);
    }
  };
};
// 身份证读卡
const identityCardNext = () => {
  addIdentityCardVisible.value = true;
  Card();
};
const identityCardConfig = (formEl) => {
  if (!formEl) return;
  formEl.validate(async (valid, fields) => {
    if (valid) {
      if(keypassflag.value=='系统'){
        if(cardFlag.value=='房卡'){
          identityCardRuleForm.cardType=0  // 0:房卡  1:身份证
        }else if(cardFlag.value=='身份证'){
          identityCardRuleForm.cardType=1
        }
        let data = {
          permissionSettingId: sessionStorage.getItem("permissionSettingId"), //权限表id
          adminId: sessionStorage.getItem("id"), //管理员id
          houseNumberId: keyData.houseNumberId, //房间号id
          startTime: identityCardRuleForm.effectiveTime, //    开始时间
          endTime: identityCardRuleForm.failureTime, //结束时间
          usersId: identityCardRuleForm.name, //用户id
          luid: keyData.equipmentType, //设备id
          card: identityCardRuleForm.icCard, //指纹特征值
          cardType: identityCardRuleForm.cardType, //指纹特征值
          type: "4", //1：管理员用户，2：普通用户（永久），4：时效性用户，5：一次性时效密码用户，100：时效性无网络密码用户
        };
        
        let res = await axios({
          method: "post",
          url: api.value + "/unlocking-employee/saveCard",
          headers: {
            token: sessionStorage.getItem("token"),
            user_head: sessionStorage.getItem("userhead"),
          },
          data: data,
        });
        console.log(res, "系统添加卡片钥匙");
        if (res.data.code == 200) {
          identityCardVisible.value = false;
          keyListData();
          ElMessage({
            type: "success",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        } else {
          ElMessage({
            type: "error",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        }
      }else if(keypassflag.value=='自定义'){
        if(cardFlag.value=='房卡'){
          identityCardRuleForm.cardType=0  // 0:房卡  1:身份证
        }else if(cardFlag.value=='身份证'){
          identityCardRuleForm.cardType=1
        }
        let data = {
          permissionSettingId: sessionStorage.getItem("permissionSettingId"), //权限表id
          adminId: sessionStorage.getItem("id"), //管理员id
          houseNumberId: keyData.houseNumberId, //房间号id
          startTime: identityCardRuleForm.effectiveTime, //    开始时间
          endTime: identityCardRuleForm.failureTime, //结束时间
          userName: identityCardRuleForm.name, //用户id
          phone: identityCardRuleForm.phone, //用户id
          luid: keyData.equipmentType, //设备id
          card: identityCardRuleForm.icCard, //指纹特征值
          cardType: identityCardRuleForm.cardType, //指纹特征值
          type: "4", //1：管理员用户，2：普通用户（永久），4：时效性用户，5：一次性时效密码用户，100：时效性无网络密码用户
        };
        let res = await axios({
          method: "post",
          url: api.value + "/unlocking-custom/saveCard",
          headers: {
            token: sessionStorage.getItem("token"),
            user_head: sessionStorage.getItem("userhead"),
          },
          data: data,
        });
        console.log(res, "自定义添加卡片钥匙");
        if (res.data.code == 200) {
          identityCardVisible.value = false;
          keyListData();
          ElMessage({
            type: "success",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        } else {
          ElMessage({
            type: "error",
            showClose: true,
            message: res.data.message,
            center: true,
          });
        }
      }
    }
  });
};
// 重试 身份卡
const retry = () => {
  // identityCardNum.value = "";
  Card();
};
const cancelAddIdentityCard = () => {
  addIdentityCardVisible.value = false;
  identityCardIndex.value = 0;
};

//导出功能
const importExcel = lodash.debounce(async () => {
  let data = {
    ledgerParam: searchInput.keyWord,
    managerId: sessionStorage.getItem("token"),
  };
  if (searchInput.createTime) {
    data.payStartTime = searchInput.createTime[0];
    data.payEndTime = searchInput.createTime[1];
  }
  if (searchInput.status) {
    data.orderStatus = searchInput.status;
  }
  let res = await axios({
    method: "post",
    url: api.value + "/mhotel/booktoBookExcel.action",
    headers: {
      // token: sessionStorage.getItem("token"),
    },
    params: data,
  });
  console.log(res, "导出订单管理");
  if (res.data.code == 200) {
    var downloadPath = res.data.downurl;
    // window.open(downloadPath);
    window.location.href = downloadPath;
    var downloadLink = document.createElement("a");
    downloadLink.style.display = "none"; // 使其隐藏
    downloadLink.href = downloadPath;
    downloadLink.download = "";
    downloadLink.click();
    document.body.appendChild(downloadLink);
    document.body.removeChild(downloadLink);
    ElMessage({
      type: "success",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  } else {
    ElMessage({
      type: "error",
      showClose: true,
      message: res.data.message,
      center: true,
    });
  }
}, 1000);

// 表格斑马纹颜色修改
const tableRowClassName = ({ row, rowIndex }) => {
  if (rowIndex % 2 === 0) {
    return "even";
  } else if (rowIndex % 2 !== 0) {
    return "odd";
  }
  return "";
};
// 分页
const handleCurrentChange = (value) => {
  // console.log(value);
  currentPage.value = value;
  getList();
};

onBeforeMount(async () => {
  api.value = store.state.user.api;
  const btnflag = JSON.parse(sessionStorage.getItem("btnflag"));
  flagBtn.value = btnflag.doorLock;
  console.log(flagBtn.value, "按钮权限");
  roomNameTypeData();
  getList();
  schoolData()
});
onUnmounted(() => {
  // document.removeEventListener("keyup", Enters);
});
</script>

<style scoped lang="scss">
.content-box {
  width: 97.5%;
  height: calc(100vh - 105px);
  margin: 20px auto;
  background-color: #fff;
  color: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: 0px 3px 10px rgba(0, 97, 255, 0.2);

  .left {
    // width: calc(100wh - 40px);
    display: flex;
    align-items: center;
    height: 60px;
    margin: 0 30px;
    border-bottom: 1px solid #ccc;
    color: rgb(0, 0, 0);
    font-size: 18px;
    font-weight: 600;
    .cameratxt {
      height: 60px;
      line-height: 60px;
    }
  }

  .middles {
    height: calc(100% - 81px);
    display: flex;
    flex-direction: column;

  }

  .middle {
    width: calc(100% - 60px);
    margin: 0 auto;

    color: #000;

    // border-bottom: 1px solid rgb(231, 231, 231);
    .filter {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      padding: 10px 0 0 0;

      .search {
        color: #fff;
      }

      .condition {
        display: flex;
        align-items: center;
        // margin: 0 0 10px 0;
      }
    }
    .changeItems {
      display: flex;
      flex-wrap: wrap;
      margin:10px 0 0 0;
      .changeItem {
        padding: 0 15px;
        height: 30px;
        background-color: rgba(230, 230, 230, 1);
        text-align: center;
        line-height: 30px;
        font-size: 14px;
        margin:0 15px 10px 0;
        border-radius: 3px;
        color: rgba(166, 166, 166, 1);
        cursor: pointer;
        border: 1px solid transparent;
      }
      .changeItem_active {
        background-color: rgba(222, 234, 252, 1);
        color: rgba(0, 97, 255, 1);
        border: 1px solid rgba(0, 97, 255, 1);
      }
      .search {
        margin-right: 5px;
      }
    }

    .gongneng {
      margin: 10px 0 20px 0;

      span {
        color: #fff;
      }
    }

    :deep(.cont) {
      width: 60%;
      margin: 20px auto;
    }

    :deep(.download) {
      display: flex;
      align-items: center;
      margin: 10px;
    }

    :deep(.download span) {
      font-size: 16px;
      margin-left: 20px;
    }

    :deep(.cont .el-button) {
      margin-left: 60px;
      margin-bottom: 30px;
    }

    :deep(.cont .accomplish) {
      width: 100%;
      display: flex;
      justify-content: center;
    }

    :deep(.cont .accomplish .el-button) {
      width: 50%;
      margin: 0;
    }
  }

  .footer {
    width: calc(100% - 60px);
    flex: 1;
    overflow: auto;
    margin: 0 auto;
    color: #000;
    overflow: auto;
    .floor {
      .title {
        margin: 8px 0;
        .t1 {
          font-weight: 600;
          margin-right: 10px;
        }
        .t2 {
          font-size: 13px;
          color: rgba(102, 102, 102, 1);
        }
      }
      .roomList {
        display: flex;
        flex-wrap: wrap;
        font-size: 14px;
        .room {
          width: 193px;
          height: 114px;
          opacity: 1;
          border-radius: 4px;
          background: rgba(240, 243, 247, 1);
          margin: 5px 18px 18px 0;
          // padding-left: 15px;
          .roomNum {
            font-size: 16px;
            // height: 24px;
            font-weight: 600;
            padding: 15px 0 5px 15px;
          }
          .rLock {
            color: rgba(128, 128, 128, 1);
            padding: 0 0 0 15px;
          }
          .wifi {
            display: flex;
            align-items: center;
            padding: 10px 0 10px 15px;
            color: rgba(51, 51, 51, 1);
            img {
              width: 14px;
              padding-right: 5px;
            }
          }
        }
      }
    }

    // 添加员工弹窗样式
    :deep(.addStaff) {
      // height: 600px;
      overflow: hidden;
      border-radius: 11px;

      .el-dialog__header {
        border-radius: 11px 11px 0 0;
        background: rgba(237, 241, 245, 1);
        font-weight: 600;
        margin: 0;

        .el-dialog__headerbtn {
          outline: none;
        }
      }

      .el-dialog__body {
        overflow: auto;
        padding: 0px 20px 10px 20px;

        .order_info {
          margin: 20px 0 15px 0;

          .title {
            display: flex;
            align-items: center;
            margin: 25px 0 10px 0;

            img {
              width: 20px;
              height: 20px;
              margin-right: 10px;
            }

            span {
              color: #000;
              font-size: 18px;
              font-weight: 800;
            }
          }

          // 排列模式样式
          .workNum {
            display: flex;
            align-items: center;
            margin-bottom: 12px;
            font-size: 16px;

            .titles {
              color: rgba(128, 128, 128, 1);
              margin-right: 12px;
              font-weight: 200;
              width: 80px;
            }

            span {
              color: #000;
              font-weight: 600;
            }

            ul {
              list-style: none;
              display: flex;
              flex-wrap: wrap;
              margin: 0;
              padding: 0;

              li {
                border: 1px solid rgba(166, 166, 166, 1);
                margin-right: 10px;
                padding: 1px 4px;
                border-radius: 6px;
                cursor: pointer;
              }

              li.is_active {
                background-color: rgba(9, 101, 98, 1);
                color: #fff;
              }
            }

            // .el-checkbox-button {
            //   margin-right: 10px;
            //   border: 1px solid #ccc;
            //   border-radius: 4px;
            //   box-sizing: border-box;
            //   .el-checkbox-button__inner {
            //     border: none;
            //     border-radius: 3px;
            //   }
            // }
            // .el-checkbox-button.is-focus {
            //   .el-checkbox-button__inner {
            //     color: #fff;
            //     background-color: rgba(9, 101, 98, 1);
            //   }
            // }
          }
        }

        .options {
          margin: 0 0 10px 0;
          width: 95%;
          display: flex;
          flex-direction: row-reverse;

          .queding {
            margin-left: 20px;
            color: #fff;
          }
        }

        .houseNumber {
          margin: 20px 0;

          // .el-checkbox-button {
          //   margin-right: 10px;
          //   border: 1px solid #ccc;
          //   border-radius: 4px;
          //   box-sizing: border-box;
          //   .el-checkbox-button__inner {
          //     border: none;
          //     border-radius: 3px;
          //   }
          // }
          // .el-checkbox-button.is-focus {
          //   .el-checkbox-button__inner {
          //     color: #fff;
          //     background-color: rgba(9, 101, 98, 1);
          //   }
          // }
          ul {
            list-style: none;
            display: flex;
            flex-wrap: wrap;
            margin: 0;
            padding: 0;

            li {
              border: 1px solid rgba(166, 166, 166, 1);
              margin-right: 10px;
              padding: 1px 4px;
              border-radius: 6px;
              cursor: pointer;
            }

            li.is_active {
              background-color: rgba(9, 101, 98, 1);
              color: #fff;
            }
          }
        }
      }
    }
  }
  .footer::-webkit-scrollbar-track {
    background-color: #daeeff;
  }

  .footer::-webkit-scrollbar {
    background-color: #0888f8;
    height: 3px;
    width: 4px;
  }

  .footer::-webkit-scrollbar-thumb {
    background: #57b2ff;
    border-radius: 4px;
    height: 3px;
    width: 4px;
  }

  .pageSize {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 30px;

    span {
      color: #000;
    }

    .el-pagination {
      // width: 1600px;
      :deep(.el-pagination__total) {
        color: #000;
      }

      :deep(.el-pagination__goto) {
        color: #000;
      }

      :deep(.el-pagination__classifier) {
        color: #000;
      }

      :deep(.el-input__wrapper) {
        border: 1px solid rgba(0, 0, 0, 1);
        border-radius: 5px;
        box-shadow: none;
      }

      :deep(.el-pager li) {
        margin: 0 5px;
        border: 1px solid rgba(0, 0, 0, 1);
        border-radius: 5px;
        background-color: transparent;
      }

      :deep(.el-pager li.is-active) {
        background-color: rgba(111, 182, 184, 1);
      }

      :deep(.btn-prev) {
        margin-right: 5px;
        border: 1px solid rgba(0, 0, 0, 1);
        border-radius: 5px;
        background-color: transparent;
      }

      :deep(.btn-next) {
        margin-left: 5px;
        border: 1px solid rgba(0, 0, 0, 1);
        border-radius: 5px;
        background-color: transparent;
      }
    }
  }
}

.el-input {
  width: 192px;
}

.firstLogin {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(100vh);
  background-color: rgba(0, 0, 0, 0.2);
  z-index: 1000000;
  display: flex;
  justify-content: center;
  align-items: center;

  .goInfo {
    width: 655px;
    height: 408px;
    background-color: #fff;
    border-radius: 9px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #000;

    h2 {
      margin: 0;
      font-size: 28px;
    }

    p {
      margin: 60px 0;
      padding: 0;
      font-size: 18px;
    }
  }
}

// 弹出的信息框
.roominfoPopper {
  .roomInfo {
    // border: 1px solid red;
    color: #fff;
    font-size: 14px;
    position: relative;
    .close {
      position: absolute;
      cursor: pointer;
      right: -40px;
      top: -30px;
      img {
        width: 30px;
        height: 30px;
      }
    }
    .title {
      font-size: 16px;
      padding: 7.5px 0;
      border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    }
    .content {
      display: flex;
      .lefts {
        border-right: 1px solid rgba(255, 255, 255, 0.5);
        span:nth-child(1) {
          text-align: right;
          display: inline-block;
          width: 72px;
          margin: 5px 15px 5px 0;
        }
        span:nth-child(2) {
          text-align: left;
          display: inline-block;
          width: 190px;
        }
      }
      .rigths {
        width: 140px;
        margin-left: 15px;
        div {
          display: flex;
          align-items: center;
          height: 30px;
          cursor: pointer;
          img {
            width: 18px;
            height: 18px;
            margin-right: 5px;
          }
          span {
            text-align: left;
            display: inline-block;
          }
          .deblocking {
            transform: translateX(3px);
          }
        }
      }
    }
  }
}
// 消息列表弹窗
:deep(.newsDialog) {
  // height: 600px;
  overflow: hidden;
  border-radius: 11px;

  .el-dialog__header {
    border-radius: 11px 11px 0 0;
    background: rgba(237, 241, 245, 1);
    font-weight: 600;
    margin: 0;

    .el-dialog__headerbtn {
      outline: none;
    }
  }

  .el-dialog__body {
    overflow: auto;
    padding: 0px 20px 10px 20px;

    .middle {
      width: 96%;
      margin: 0 auto;

      color: #000;
      //   切换  消息记录  操作记录
      .changeItems {
        display: flex;
        margin: 15px 0 0 0;
        .changeNews {
          //   width: 80px;
          padding: 0 10px;
          height: 30px;
          background-color: rgba(230, 230, 230, 1);
          text-align: center;
          line-height: 30px;
          font-size: 14px;
          margin-right: 15px;
          border-radius: 3px;
          color: rgba(166, 166, 166, 1);
          cursor: pointer;
        }
        .changeNews_active {
          background-color: rgba(222, 234, 252, 1);
          color: rgba(0, 97, 255, 1);
        }
      }
      // border-bottom: 1px solid rgb(231, 231, 231);
      .filter {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        margin: 10px 0 0 0;
        justify-content: start;

        .search {
          color: #fff;
        }

        .condition {
          display: flex;
          align-items: center;
          margin: 10px 30px 10px 0;

          :deep(.el-input .el-input__inner) {
            font-size: 14px;
          }

          // span {
          //   margin: 0 10px 0 0;
          // }
        }
      }

      .gongneng {
        margin: 10px 0 20px 0;

        span {
          color: #fff;
        }
      }

      :deep(.cont) {
        width: 60%;
        margin: 20px auto;
      }

      :deep(.download) {
        display: flex;
        align-items: center;
        margin: 10px;
      }

      :deep(.download span) {
        font-size: 16px;
        margin-left: 20px;
      }

      :deep(.cont .el-button) {
        margin-left: 60px;
        margin-bottom: 30px;
      }

      :deep(.cont .accomplish) {
        width: 100%;
        display: flex;
        justify-content: center;
      }

      :deep(.cont .accomplish .el-button) {
        width: 50%;
        margin: 0;
      }
    }

    .pageSize {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin: 10px 30px;

      span {
        color: #000;
      }

      .el-pagination {
        // width: 1600px;
        .el-pagination__total {
          color: #000;
        }

        .el-pagination__goto {
          color: #000;
        }

        .el-pagination__classifier {
          color: #000;
        }

        .el-input__wrapper {
          border: 1px solid rgba(0, 0, 0, 1);
          border-radius: 5px;
          box-shadow: none;
        }

        .el-pager li {
          margin: 0 5px;
          border: 1px solid rgba(0, 0, 0, 1);
          border-radius: 5px;
          background-color: transparent;
        }

        .el-pager li.is-active {
          // background-color: rgba(111, 182, 184, 1);
          border: 1px solid rgba(0, 97, 255, 1);
          color: rgba(0, 97, 255, 1);
          // border: 1px solid red;
        }

        .btn-prev {
          margin-right: 5px;
          border: 1px solid rgba(0, 0, 0, 1);
          border-radius: 5px;
          background-color: transparent;
        }

        .btn-next {
          margin-left: 5px;
          border: 1px solid rgba(0, 0, 0, 1);
          border-radius: 5px;
          background-color: transparent;
        }
      }
    }

    .footers {
      width: 96%;
      // height: 402px;
      margin: 10px auto 20px;

      .el-table--fit {
        height: 100%;

        .el-table__header-wrapper {
          background-color: #000;
          font-size: 15px;

          tr {
            color: #000;
          }
        }

        .el-table__row {
          height: 50px;
          font-size: 15px;
          color: #000;

          .orderNum {
            color: rgba(111, 182, 184, 1);
            cursor: pointer;
          }
        }

        .el-table__row:nth-child(2n) {
          .el-table-fixed-column--right {
            background-color: rgba(240, 243, 247, 1);
          }
        }

        .el-table__row td {
          padding: 0;
          border: 0;
        }

        .el-button--primary {
          margin-left: 5px;
        }

        .el-table__body .even {
          background-color: #fff;
        }

        .el-table__body .odd {
          background-color: rgba(240, 243, 247, 1);
        }
      }
    }
  }
}
// 远程开锁弹窗
:deep(.unlockingDialog) {
  // height: 600px;
  overflow: hidden;
  border-radius: 11px;

  .el-dialog__header {
    border-radius: 11px 11px 0 0;
    background: rgba(245, 249, 255, 1);
    font-weight: 600;
    height: 60px;
    padding: 0 20px;
    line-height: 60px;
    margin: 0;
    border-bottom: 1px solid rgba(230, 230, 230, 1);

    .el-dialog__headerbtn {
      outline: none;
    }
  }

  .el-dialog__body {
    padding: 0px 20px 20px 20px;
    // height: 200px;
    // display: flex;
    // flex-direction: column-reverse;

    .middle {
      width: 96%;
      color: #000;
      .content {
        height: 100px;
        padding: 50px 0 0 0;
        font-size: 16px;
        letter-spacing: 1px;
      }
      .marning{
        font-size:12px;
        color:red
      }
      .options {
        display: flex;
        flex-direction: row-reverse;
        align-items: center;
        margin: 10px 0;

        .queding {
          margin-left: 20px;
        }
      }
      .item {
        display: flex;
        align-items: center;
        margin: 24px 0;

        .title {
          width: 100px;
          text-align: right;
          margin-right: 10px;
        }
      }
      .againPass {
        margin: 24px 0 40px 0;
      }
    }
  }
}

// 批量导入
:deep(.bulkImportDialog) {
  // height: 600px;
  overflow: hidden;
  border-radius: 11px;

  .el-dialog__header {
    border-radius: 11px 11px 0 0;
    background: rgba(245, 249, 255, 1);
    font-weight: 600;
    height: 60px;
    padding: 0 20px;
    line-height: 60px;
    margin: 0;
    border-bottom: 1px solid rgba(230, 230, 230, 1);

    .el-dialog__headerbtn {
      outline: none;
    }
  }

  .el-dialog__body {
    padding: 20px 0 30px 0;
    // height: 200px;
    // display: flex;
    // flex-direction: column-reverse;

    .middle {
      width: calc(100% - 40px);
      color: #000;
      .content {
        height: 100px;
        padding: 50px 0 0 20px;
        font-size: 16px;
        letter-spacing: 1px;
      }
      .options {
        display: flex;
        flex-direction: row-reverse;
        align-items: center;
        margin: 10px 0;

        .queding {
          margin-left: 20px;
        }
      }
      .startImport {
        .el-button {
          width: 500px;
          height: 42px;
        }
        .downLoad {
          color: rgba(0, 97, 255, 1);
          font-size: 14px;
          margin-left: 15px;
          cursor: pointer;
        }
      }
    }
  }
}

// 绑定设备弹窗
:deep(.BindingDialog) {
  height: 300px;
  overflow: hidden;
  border-radius: 11px;

  .el-dialog__header {
    border-radius: 11px 11px 0 0;
    background: rgba(245, 249, 255, 1);
    font-weight: 600;
    height: 60px;
    padding: 0 20px;
    line-height: 60px;
    margin: 0;
    border-bottom: 1px solid rgba(230, 230, 230, 1);

    .el-dialog__headerbtn {
      outline: none;
    }
  }

  .el-dialog__body {
    padding: 20px;

    .middle {
      width: 96%;
      color: #000;
      .options {
        display: flex;
        flex-direction: row-reverse;
        align-items: center;
        margin: 120px 0 0 0;
        .el-form-item__content {
          flex: none;
        }
        .queding {
          margin-left: 20px;
        }
      }
    }
  }
}

// 设置临时总卡
:deep(.temporaryCardDialog) {
  //   height: 420px;
  border-radius: 11px;
  .el-dialog__header {
    border-radius: 11px 11px 0 0;
    background: rgba(237, 241, 245, 1);
    font-weight: 600;
    margin: 0;
    .el-dialog__headerbtn {
      outline: none;
    }
  }
  .el-dialog__body {
    padding: 30px 20px 10px 20px;
    // .el-input {
    //   // width: 200px;
    //   .el-input__suffix-inner {
    //     color: rgba(61, 81, 232, 1);
    //   }
    // }
    .el-form-item__content {
      width: 200px;
    }

    .options {
      margin: 10px 20px 20px 0;
      width: 100%;
      .el-form-item__content {
        display: flex;
        flex-direction: row-reverse;
      }
      .queding {
        color: #fff;
        margin-left: 15px;
      }
    }
  }
}
// 钥匙管理
:deep(.keyDialog) {
  border-radius: 11px;
  .el-dialog__header {
    border-radius: 11px 11px 0 0;
    background: rgba(237, 241, 245, 1);
    font-weight: 600;
    margin: 0;
    .el-dialog__headerbtn {
      outline: none;
    }
  }
  .el-dialog__body {
    // padding: 10px 20px 10px 20px;
    max-height: 750px;
    overflow: auto;
    .el-form-item__content {
      width: 200px;
    }
    .title {
      margin: 20px;
      box-sizing: border-box;
      .keyTitle {
        width: 1130px;
        height: 50px;
        background: rgba(235, 235, 235, 1);
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: relative;
        z-index: 99;
        .Addkey {
          width: 120px;
        }
        .txt {
          color: rgba(0, 0, 0, 1);
          margin-left: 25px;
          font-weight: 400;
        }
      }
      .el-collapse {
        border: none;
        position: relative;
        top: -50px;
      }
      .el-collapse-item {
        // border-radius: 5px;
        .el-collapse-item__header {
          border: none;
          background: rgba(235, 235, 235, 1);
          width: 33px;
          height: 50px;
          transform: translateX(1130px);
          border-radius: 0;
          outline: none;
        }
        .el-collapse-item__wrap {
          border: 1px solid rgba(229, 229, 229, 1);
        }
      }
      .el-collapse-item__content {
        padding: 0;
        .table {
          width: 1160px;
          margin: 20px auto;
          .el-table--fit {
            .el-table__header-wrapper {
              font-size: 15px;

              tr {
                color: #000;
              }
            }
            .el-table__row {
              height: 50px;
              font-size: 15px;
              color: #000;
            }
            .el-table__row td {
              padding: 0;
              border: 0;
            }
            .el-table__body .even {
              background-color: #fff;
            }

            .el-table__body .odd {
              background-color: rgba(240, 243, 247, 1);
            }
          }
          .options {
            display: flex;
            justify-content: center;
            .reset {
              margin: 0 5px;
              color: rgba(0, 97, 255, 1);
              cursor: pointer;
            }
          }
        }
      }
    }
  }
}
// 钥匙管理 密码管理
:deep(.passManagementDialog) {
  //   height: 420px;
  border-radius: 11px;
  .el-dialog__header {
    border-radius: 11px 11px 0 0;
    background: rgba(237, 241, 245, 1);
    font-weight: 600;
    margin: 0;
    .el-dialog__headerbtn {
      outline: none;
    }
  }
  .el-dialog__body {
    padding: 10px 20px 10px 20px;
    // .el-input {
    //   // width: 200px;
    //   .el-input__suffix-inner {
    //     color: rgba(61, 81, 232, 1);
    //   }
    // }
    .el-form-item__content {
      .el-input-group__append {
        background-color: rgba(222, 234, 252, 1);
        color: rgba(0, 97, 255, 1);
        cursor: pointer;
        user-select: none;
      }
    }

    .options {
      margin: 10px 20px 20px 0;
      width: 100%;
      .el-form-item__content {
        display: flex;
        flex-direction: row-reverse;
      }
      .queding {
        color: #fff;
        margin-left: 15px;
      }
    }
  }
}
// 钥匙管理 添加指纹
:deep(.fingerprintDialog) {
  //   height: 420px;
  border-radius: 11px;
  .el-dialog__header {
    border-radius: 11px 11px 0 0;
    background: rgba(237, 241, 245, 1);
    font-weight: 600;
    margin: 0;
    .el-dialog__headerbtn {
      outline: none;
    }
  }
  .el-dialog__body {
    padding: 30px 20px 10px 20px;
    .el-form-item__content {
      width: 200px;
    }
    .options {
      margin: 10px 20px 20px 0;
      width: 100%;
      .el-form-item__content {
        display: flex;
        flex-direction: row-reverse;
      }
      .options {
        margin: 10px 20px 20px 0;
        width: 100%;
        .el-form-item__content {
          display: flex;
          flex-direction: row-reverse;
        }
        .queding {
          color: #fff;
          margin-left: 15px;
        }
      }
    }
  }
}
// 指纹弹窗
:deep(.fingerprint) {
  width: 611px;
  height: 486px;
  border-radius: 11px;
  .el-dialog__header {
    border-radius: 11px 11px 0 0;
    background: rgba(237, 241, 245, 1);
    font-weight: 600;
    margin: 0;

    .el-dialog__headerbtn {
      outline: none;
    }
  }
  .el-dialog__body {
    padding: 0;
    .elbody {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 20px 20px;
      font-size: 18px;
      color: #000;
      border-bottom: 0.5px solid #ccc;

      i {
        cursor: pointer;
      }
    }
  }
  .el-dialog__footer {
    .el-button--primary {
      background: rgba(41, 109, 227, 1);
    }
  }
}
// 钥匙管理 添加身份证
:deep(.identityCard) {
  //   height: 420px;
  border-radius: 11px;
  .el-dialog__header {
    border-radius: 11px 11px 0 0;
    background: rgba(237, 241, 245, 1);
    font-weight: 600;
    margin: 0;
    .el-dialog__headerbtn {
      outline: none;
    }
  }
  .el-dialog__body {
    padding: 30px 20px 10px 20px;
    .el-form-item__content {
      width: 200px;
    }
    .options {
      margin: 10px 20px 20px 0;
      width: 100%;
      .el-form-item__content {
        display: flex;
        flex-direction: row-reverse;
      }
      .queding {
        color: #fff;
        margin-left: 15px;
      }
    }
  }
}
// 身份证读取
:deep(.addIdentityCard) {
  //   height: 420px;
  border-radius: 11px;
  .el-dialog__header {
    border-radius: 11px 11px 0 0;
    background: rgba(237, 241, 245, 1);
    font-weight: 600;
    margin: 0;
    .el-dialog__headerbtn {
      outline: none;
    }
  }
  .el-dialog__body {
    padding: 30px 20px 10px 20px;
    height: 330px;
    font-size: 16px;
    font-weight: 600;
    color: #000;
    .el-steps {
      width: 600px;
      transform: translateX(90px);
      margin: 0 0 40px 0;
    }
    .title {
      text-align: center;
    }
    .icons {
      display: flex;
      justify-content: center;
      img {
        width: 70px;
        margin: 40px 0;
      }
      .loading {
        animation: move 3s linear;
      }
      @keyframes move {
        0% {
          transform: rotate(0);
        }
        100% {
          transform: rotate(360deg);
        }
      }
    }
    .retry {
      text-align: center;
      span {
        color: red;
        padding: 0 8px;
        cursor: pointer;
      }
    }
  }
}
</style>
<style lang="scss">
.roominfoPopper {
  background: rgba(0, 0, 0, 0.8) !important;
  border: none !important;
  .el-popper__arrow::before {
    background: rgba(0, 0, 0, 0.8) !important;
  }
}
</style>
