完成签约之后直接添加人员,录入下发凭证
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

7582 lines
271 KiB

<template>
<div>
<zw ref="myChild"></zw>
<getFinger ref="myGetFinger"></getFinger>
<div v-if="!drawer">
<el-row :gutter="20" class="mb-2">
<el-col :span="24">
<el-card shadow="never">
<div class="d-flex flex-wrap align-center justify-space-around font-style">
<div class="flexLi my-3 d-flex flex-nowrap align-center d-inlie-block text-center hand-type">
<div class="mr-2">
<i class="iconfont httpicon-zhanghao font-size-40 color-03A9F4"></i>
</div>
<div>
<div class="color-00000073 font-size-16 font-weight-700 color-03A9F4">总住户</div>
<div class="font-size-24 mt-2">
<NumberGrow :value="total" class="color-03A9F4"></NumberGrow><span
class="font-size-16 color-00000073 ml-1">人</span>
</div>
</div>
</div>
<div class="flexLi my-3 d-flex flex-nowrap align-center d-inlie-block text-center hand-type">
<div class="mr-2">
<i class="iconfont httpicon-tubiaozhizuomoban-101 font-size-40 color-03A9F4"></i>
</div>
<div>
<div class="color-00000073 font-size-16 font-weight-700 color-03A9F4">已入住</div>
<div class="font-size-24 mt-2">
<NumberGrow :value="isCheckin" class="color-03A9F4"></NumberGrow><span
class="font-size-16 color-00000073 ml-1">人</span>
</div>
</div>
</div>
<div class="flexLi my-3 d-flex flex-nowrap align-center d-inlie-block text-center hand-type">
<div class="mr-2">
<i class="iconfont httpicon-chazhaofangyuan font-size-40 color-03A9F4"></i>
</div>
<div>
<div class="color-00000073 font-size-16 font-weight-700 color-03A9F4">未入住</div>
<div class="font-size-24 mt-2">
<NumberGrow :value="noshowNum" class="color-03A9F4"></NumberGrow><span
class="font-size-16 color-00000073 ml-1">人</span>
</div>
</div>
</div>
<div class="flexLi my-3 d-flex flex-nowrap align-center d-inlie-block text-center hand-type">
<div class="mr-2">
<i class="iconfont httpicon-shebei font-size-40 color-03A9F4"></i>
</div>
<div>
<div class="color-00000073 font-size-16 font-weight-700 color-03A9F4">已签约人数</div>
<div class="font-size-24 mt-2">
<NumberGrow :value="checkinNum" class="color-03A9F4"></NumberGrow><span
class="font-size-16 color-00000073 ml-1">人</span>
</div>
</div>
</div>
<div class="flexLi my-3 d-flex flex-nowrap align-center d-inlie-block text-center hand-type">
<div class="mr-2">
<i class="iconfont httpicon-chaxun font-size-40 color-03A9F4"></i>
</div>
<div>
<div class="color-00000073 font-size-16 font-weight-700 color-03A9F4">待签约人数</div>
<div class="font-size-24 mt-2">
<NumberGrow :value="signedNum" class="color-03A9F4"></NumberGrow><span
class="font-size-16 color-00000073 ml-1">人</span>
</div>
</div>
</div>
<div class="flexLi my-3 d-flex flex-nowrap align-center d-inlie-block text-center hand-type">
<div class="mr-2">
<i class="iconfont httpicon-renyuanguanli font-size-40 color-F56C6C"></i>
</div>
<div>
<div class="color-00000073 font-size-16 font-weight-700 color-F56C6C">已欠费人数</div>
<div class="font-size-24 mt-2">
<NumberGrow :value="arrearsNum" class="color-F56C6C"></NumberGrow><span
class="font-size-16 color-00000073 ml-1">人</span>
</div>
</div>
</div>
<div class="flexLi my-3 d-flex flex-nowrap align-center d-inlie-block text-center hand-type">
<div class="mr-2">
<i class="iconfont httpicon-gongdanguanli font-size-40 color-ff9900"></i>
</div>
<div>
<div class="color-00000073 font-size-16 font-weight-700 color-ff9900">已到期人数</div>
<div class="font-size-24 mt-2">
<NumberGrow :value="expiredNum" class="color-ff9900"></NumberGrow><span
class="font-size-16 color-00000073 ml-1">人</span>
</div>
</div>
</div>
</div>
</el-card>
</el-col>
</el-row>
<el-row :gutter="20" class="elrow">
<el-col :span="24">
<el-card shadow="nerver" class="paddcontent">
<div class="handle-box">
<div class="selectoptionClass" v-if="userInfo.type == 0">
<selectoption></selectoption>
</div>
<el-input v-model="query.name" size="small" placeholder="姓名" class="handle-input width-3rem mr10"
:clearable="true">
</el-input>
<el-input v-model="query.number" size="small" placeholder="证件号" class="handle-input width-3rem mr10"
:clearable="true">
</el-input>
<el-input v-model="query.phone" size="small" placeholder="手机号" class="handle-input width-3rem mr10"
:clearable="true">
</el-input>
<el-cascader style="width: 100%;" size="small" :options="roomlistZNodes" collapse-tags
@change="checkNodeSearch" :props="{ multiple: true }" :clearable="true" class="width-3rem"></el-cascader>
<el-button type="primary" size="small" icon="el-icon-search" @click="handleSearch"
style="background: #FA8E00; border: none;">查询</el-button>
</div>
</el-card>
</el-col>
<el-col :span="8" style="display: none">
<el-card shadow="hover" class="cardrelative aftercolor5 heightbt">
<div class="contentc contentc1">
<div class="contentleft">
<div class="contenttitle">凭证</div>
<div class="contentnum">40</div>
<ul class="contentul">
<li><span>密码凭证</span><span>28</span></li>
<li><span>身份凭证</span><span>10</span></li>
<li><span>其他</span><span>2</span></li>
</ul>
<img src="../assets/img/pz15.png" alt="" class="pzimg" />
</div>
<div class="pieChart">
<schart ref="bar" class="schart" canvasId="bar" :options="options"></schart>
</div>
</div>
</el-card>
</el-col>
</el-row>
<div class="userlist" v-if="activeiconfont">
<div class="switchiconfont my-2">
<i class="iconfont httpicon-liebiao1" :class="activeiconfont ? 'active' : ''" @click="activeiconfun(true)"
title="切换方块展示"></i>
<i class="iconfont httpicon-liebiao" :class="activeiconfont ? '' : 'active'" @click="activeiconfun(false)"
title="切换表格展示"></i>
</div>
<div class="adddbtn">
<el-button type="primary" @click="handleSearch1" class="my-2" size="mini"
style="background: #FA8E00; border: none;">添加</el-button>
<el-button type="primary" @click="selectmoredel" class="my-2" size="mini"
style="background: #FA8E00; border: none;">批量删除</el-button>
<el-button type="primary" @click="exportfun" class="my-2" size="mini"
style="background: #FA8E00; border: none;">导出租客</el-button>
<el-button type="primary" @click="batchUpload" class="my-2" size="mini"
style="background: #FA8E00; border: none;">批量上传</el-button>
<!-- <el-button type="primary" @click="batchUploadpl" size="mini">批量生成</el-button>-->
<!-- <el-button type="primary" size="mini" @click="drawerVisible=true">对比上传</el-button>-->
<!-- <el-button type="primary" @click="batchProcessingData" size="mini">批量处理数据</el-button> -->
</div>
<div class="roomcontent">
<div class="roomconli" v-for="(item, index) in userlist" :key="index">
<personLi :data="item"></personLi>
<div class="button-list">
<div @click="operation('0', item)">房间管理</div>
<div @click="operation('1', item)">凭证管理</div>
<div @click="handleEdit(index, item)">编辑</div>
<div @click="handleDelete(index, item)">删除</div>
<div @click="operation('0', item)">续住/退租</div>
<div @click="operation('0', item)">冻结管理</div>
</div>
</div>
</div>
</div>
<div class="tablelist" v-if="!activeiconfont">
<div class="switchiconfont">
<i class="iconfont httpicon-liebiao1" :class="activeiconfont ? 'active' : ''" @click="activeiconfun(true)"
title="切换方块展示"></i>
<i class="iconfont httpicon-liebiao" :class="activeiconfont ? '' : 'active'" @click="activeiconfun(false)"
title="切换表格展示"></i>
</div>
<div class="adddbtn">
<el-button type="primary" @click="handleSearch1" size="mini"
style="background: #FA8E00; border: none;">添加</el-button>
<el-button type="primary" @click="selectmoredel" size="mini"
style="background: #FA8E00; border: none;">批量删除</el-button>
<el-button type="primary" @click="exportfun" size="mini"
style="background: #FA8E00; border: none;">导出租客信息</el-button>
<el-button type="primary" @click="batchUpload" size="mini"
style="background: #FA8E00; border: none;">批量上传</el-button>
<!-- <el-button type="primary" @click="batchProcessingData" size="mini">批量处理数据</el-button> -->
</div>
<el-table :data="userlist" border stripe class="table" ref="multipleTable" header-cell-class-name="table-header"
@selection-change="handleSelectionChange" v-if="userliststatu" height="600">
<el-table-column label="序号" type="index" width="80">
<template slot-scope="scope">
{{ total - ((currentPage4 - 1) * pageSize) - scope.$index }}
</template>
</el-table-column>
<el-table-column prop="id" label="ID" width="55" align="center"></el-table-column>
<el-table-column prop="name" label="名称"></el-table-column>
<el-table-column prop="number" label="身份证号"></el-table-column>
<el-table-column prop="cardId" label="卡号"></el-table-column>
<el-table-column prop="phone" label="手机号"></el-table-column>
<el-table-column prop="phone" label="账号"></el-table-column>
<el-table-column label="性别" align="center">
<template #default="scope">
{{ scope.row.sex == 1 ? "男" : "女" }}
</template>
</el-table-column>
<el-table-column label="门卡状态" align="center">
<template #default="scope">
<span v-if="scope.row.cardState == 1">正常</span>
<span v-if="scope.row.cardState == 2">挂失</span>
<span v-if="scope.row.cardState == 3">挂失冻结</span>
<span v-if="scope.row.cardState == 4">冻结</span>
<span v-if="scope.row.cardState == 5">预开户</span>
<span v-if="scope.row.cardState == 6">过期</span>
</template>
</el-table-column>
<el-table-column label="操作" width="350" align="center">
<template #default="scope">
<el-button type="text" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
<el-button type="text" @click="operation('0', scope.row)">房间管理</el-button>
<el-button type="text" @click="operation('1', scope.row)">凭证管理</el-button>
<el-button type="text" @click="operation('0', scope.row)">续住/退租</el-button>
<el-button type="text" @click="operation('0', scope.row)">冻结管理</el-button>
<el-button type="text" class="red" @click="handleDelete(scope.$index, scope.row)">删除
</el-button>
</template>
</el-table-column>
</el-table>
<div class="nulldiv" v-if="userlist.length == 0">
<img src="../assets/img/no-rooms.dfc2fbf1.png" alt="" class="nullimg" />
<div>暂无房源</div>
</div>
</div>
<div class="paging">
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage4"
:page-sizes="[10, 20, 100, 200, 500, 1000]" :page-size="pageSize" :layout="paginationConfig" :total="total">
</el-pagination>
</div>
</div>
<el-dialog title="批量续租" :visible.sync="batchRenewalShow" width="30%">
<el-form ref="batchRenewalFrom" :model="batchRenewalFrom" label-width="80px" class="temporary">
<el-form-item label="开始时间">
<el-date-picker v-model="batchRenewalFrom.startTime" :picker-options="pickerOptionsBegin" size="small"
type="datetime" placeholder="选择日期时间">
</el-date-picker>
</el-form-item>
<el-form-item label="结束时间">
<el-date-picker v-model="batchRenewalFrom.endTime" :picker-options="pickerOptionsBegin" size="small"
type="datetime" placeholder="选择日期时间">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button size="small" @click="batchRenewalShow = false" type="primary">取消</el-button>
<el-button size="small" @click="batchRenewalMethods" type="primary">确定</el-button>
</el-form-item>
</el-form>
</el-dialog>
<div class="roomContentBox" v-if="drawer">
<el-card class="box-card" v-if="activeName == 0">
<el-button size="mini" @click="backTop">返回</el-button>
<!-- <el-ipnut type="text" size="mini" v-model=""></el-ipnut> -->
<el-button size="mini" @click="bindRoomTop" type="primary">绑定房间</el-button>
<el-button type="primary" size="mini" @click="batchRenewal">批量续租</el-button>
<el-button type="primary" size="mini" @click="batchLeaseback">批量退租</el-button>
<el-button type="primary" size="mini" @click="batchfrozenMethods">批量冻结锁用户</el-button>
<el-button type="primary" size="mini" @click="batchthawMethods">批量解冻锁用户</el-button>
<el-button type="primary" size="mini" @click="issueVoucher">下发凭证</el-button>
<el-table :data="roomScreen" stripe style="width: 100%;margin-top: 10px;" :height="tableheight"
@selection-change="renewalOption">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column type="index" width="50" label="序号">
</el-table-column>
<el-table-column prop="roomName" label="房间名称">
</el-table-column>
<el-table-column prop="name" label="租金名称">
</el-table-column>
<el-table-column label="租期">
<template #default="scope">
{{ scope.row.startTime }} 至 {{ scope.row.endTime }}
</template>
</el-table-column>
<el-table-column prop="address" label="操作">
<template #default="scope">
<el-button type="text" class="red" @click="rentWithdrawal(scope.$index, scope.row)">退租</el-button>
<!-- <el-button type="text" class="red" @click="UnbindFun(scope.$index, scope.row)">解除绑定</el-button>-->
<el-button type="text" class="green" @click="singleRenewalMethods(scope.$index, scope.row)">续租
</el-button>
<el-button type="text" @click="getLimitMethods(scope.$index, scope.row)">获取离线永久密码</el-button>
<el-button type="text" @click="clearAllPassWord(scope.$index, scope.row)">获取清空密码</el-button>
<el-button type="text" @click="timingPassword(scope.$index, scope.row)">获取对时密码</el-button>
<el-button type="text" @click="limitedTimePassword(scope.$index, scope.row)">获取限时密码</el-button>
<el-button type="text" class="red" @click="frozenMethods(scope.$index, scope.row)">冻结锁用户</el-button>
<el-button type="text" class="green" @click="thawMethods(scope.$index, scope.row)">解冻锁用户</el-button>
</template>
</el-table-column>
</el-table>
<el-dialog title="选择冻结时间" :visible.sync="frozenDialog" width="30%">
<el-form ref="bindRoomFormref" :model="frozenDataSelect" label-width="80px" class="temporary">
<el-form-item label="开始时间">
<el-date-picker v-model="value2[0]" size="small" type="datetime" placeholder="选择入住日期时间"
default-time="00:00:00" :picker-options="pickerOptionsBegin">
</el-date-picker>
</el-form-item>
<el-form-item label="结束时间">
<el-date-picker v-model="value2[1]" size="small" start-placeholder="" type="datetime" placeholder="选择退租日期时间"
:picker-options="pickerOptionsEnd" default-time="00:00:00">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button size="small" @click="frozenTimeSureMethods" type="primary">确定</el-button>
</el-form-item>
</el-form>
</el-dialog>
<el-dialog title="选择绑定房间" :visible.sync="bindRoomStatus" width="30%">
<el-form ref="bindRoomFormref" :model="bindRoomForm" label-width="80px" class="temporary">
<el-form-item label="绑定房间">
<el-cascader style="width: 100%;" size="small" :options="bindRoomlist" collapse-tags @change="checkNode"
:props="{ multiple: true }" clearable></el-cascader>
</el-form-item>
<el-form-item label="开始时间">
<el-date-picker v-model="value2[0]" size="small" type="datetime" placeholder="选择入住日期时间"
default-time="00:00:00" :picker-options="pickerOptionsBegin">
</el-date-picker>
</el-form-item>
<el-form-item label="结束时间">
<el-date-picker v-model="value2[1]" size="small" start-placeholder="" type="datetime" placeholder="选择退租日期时间"
:picker-options="pickerOptionsEnd" default-time="00:00:00">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button size="small" @click="bindsave" type="primary">确定</el-button>
</el-form-item>
</el-form>
</el-dialog>
</el-card>
<el-card class="box-card" v-if="activeName == 1">
<div v-if="roomstatus1">
<el-button size="mini" @click="backTop">返回</el-button>
<el-button type="primary" size="mini" @click="bindroom1">添加凭证</el-button>
<el-button type="primary" size="mini" @click="addBindRoom">绑定房间</el-button>
<el-select v-model="credentialSearch.type" placeholder="请选择类型" class="SearchInput" size="mini" clearable>
<el-option label="人脸" value="10"></el-option>
<el-option label="指纹" value="11"></el-option>
<el-option label="身份证" value="12"></el-option>
<el-option label="NFC" value="13"></el-option>
<el-option label="密码" value="14"></el-option>
</el-select>
<el-button type="primary" size="mini" @click="getcertificate">查询</el-button>
<el-button type="primary" size="mini" @click="credentialSearchReset">重置</el-button>
<el-table :data="roomtable1" class="table" style="width: 100%;margin-top: 10px;" :height="tableheight"
ref="multipleTable" @selection-change="handleSelectionChange3" :row-class-name="tableRowClassName"
header-cell-class-name="table-header">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column prop="name" label="租客名称"></el-table-column>
<el-table-column label="凭证名称">
<template #default="scope">
<span>{{ scope.row.pzname }}</span><span v-if="scope.row.fingerprintAlias">—
{{ scope.row.fingerprintAlias }}</span>
</template>
</el-table-column>
<el-table-column label="凭证类型">
<template #default="scope">
<span v-if="scope.row.type == 10">人脸</span>
<span v-if="scope.row.type == 11">指纹</span>
<span v-if="scope.row.type == 12">身份证</span>
<span v-if="scope.row.type == 13">NFC</span>
<span v-if="scope.row.type == 14">密码</span>
</template>
</el-table-column>
<!-- <el-table-column prop="number" width="400" label="凭证有效期">-->
<!-- <template #default="scope">-->
<!-- <span>{{ scope.row.startTimeText }} - {{ scope.row.endTimeText }}</span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="创建时间" prop="createAt" width="200"></el-table-column>
<el-table-column label="操作" width="400" align="center" class-name="tablebutton">
<template #default="scope">
<el-button type="text" @click="bindRoomTop1(scope.$index, scope.row)"
v-if="scope.row.DeletePermissions">批量下发
</el-button>
<el-button type="text" @click="modifyCrai(scope.$index, scope.row)">修改凭证</el-button>
<el-button type="text" @click="viewDistributionRecord(scope.$index, scope.row)">查看下发记录
</el-button>
<el-button type="text" class="red" @click="deletefun1(scope.$index, scope.row)">删除
</el-button>
<el-button type="text" class="red" v-if="userInfo.type == 0"
@click="deleteCertificatesMethod(scope.$index, scope.row)">删除平台记录
</el-button>
</template>
</el-table-column>
</el-table>
<el-dialog title="选择下发房间" :visible.sync="bindRoomStatus1" width="30%">
<el-form ref="bindRoomFormref" :model="bindRoomForm" label-width="80px" class="temporary">
<el-form-item label="房源">
<el-cascader style="width: 100%;" size="small" :options="roomlist" collapse-tags clearable
@change="checkNode1" :props="{ multiple: true }"></el-cascader>
</el-form-item>
<el-form-item label="开始时间">
<el-date-picker v-model="value2[0]" size="small" :picker-options="pickerOptionsBegin" type="datetime"
placeholder="选择开始日期时间" default-time="00:00:00">
</el-date-picker>
</el-form-item>
<el-form-item label="结束时间">
<el-date-picker v-model="value2[1]" size="small" :picker-options="pickerOptionsEnd" type="datetime"
placeholder="选择结束日期时间" default-time="00:00:00">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button size="small" @click="sendVoucher" type="primary">确定</el-button>
</el-form-item>
</el-form>
</el-dialog>
<div class="pagepg">
<el-pagination @size-change="handleSizeChange1" @current-change="handleCurrentChange1"
:current-page="currentPage1" :page-sizes="[10, 30, 100, 200]" :page-size="pageSize1" layout="total"
:total="total1">
</el-pagination>
</div>
<div class="colorTest" style="color: #999;font-size: 12px;">*每行数据颜色背景标注:1、绿色背景代表该凭证对应下发指令都下发成功
2、黄色代表该凭证对应下发指令有下发中指令 3、红色代表该凭证对应下发指令有下发失败指令
</div>
</div>
<div v-else>
<!-- 录入凭证 -->
<div class="ztree">
<el-form ref="formvoucher" :model="voucher" :rules="rulesAdd" label-width="80px" class="temporary">
<el-form-item label="用户名称" prop="username">
<el-input v-model="voucher.username" size="middle" :disabled="true" class="widthRem5"></el-input>
</el-form-item>
<el-form-item label="凭证名称" prop="pzname">
<el-input v-model.trim="voucher.pzname" size="middle" :clearable="true" class="widthRem5"></el-input>
</el-form-item>
<el-form-item label="类型" prop="documentType">
<el-select v-model="documentType" placeholder="请选择" size="middle" class="documentType">
<el-option label="人脸" :value="10"></el-option>
<el-option label="指纹" :value="11"></el-option>
<el-option label="身份证" :value="12"></el-option>
<el-option label="NFC" :value="13"></el-option>
<el-option label="密码" :value="14"></el-option>
</el-select>
</el-form-item>
<el-form-item label="上传照片" v-if="documentType == 10">
<div v-if="documentType == 10">
<el-upload action="#" list-type="picture-card" size="middle" :auto-upload="false"
:modal-append-to-body="false">
<i slot="default" class="el-icon-plus"></i>
<div slot="file" slot-scope="{ file }">
<img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
<span class="el-upload-list__item-actions">
<span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
<i class="el-icon-zoom-in"></i>
</span>
<span v-if="!disabled1" class="el-upload-list__item-delete" @click="handleDownload(file)">
<i class="el-icon-download"></i>
</span>
<span v-if="!disabled1" class="el-upload-list__item-delete" @click="handleRemove(file)">
<i class="el-icon-delete"></i>
</span>
</span>
</div>
</el-upload>
<el-dialog :visible.sync="dialogVisible" :modal-append-to-body="false">
<img width="100%" :src="dialogImageUrl" alt="" />
</el-dialog>
</div>
</el-form-item>
<el-form-item label="指纹" v-if="documentType == 11">
<el-radio-group v-model="voucher.fingerprintAlias" size="small">
<!-- @change="fingerprintAliasMethod" -->
<el-radio-button label="左手大拇指"></el-radio-button>
<el-radio-button label="左手食指"></el-radio-button>
<el-radio-button label="右手大拇指"></el-radio-button>
<el-radio-button label="右手食指"></el-radio-button>
</el-radio-group>
<el-button type="primary" @click="addfir" size="small">GX1000-zh采集指纹</el-button>
<el-button type="primary" @click="getFingerData" size="small">LWJ采集指纹</el-button>
<iframe src="static/equipment/mafp_serial/index.html" frameborder="0" style="width: 100%; height: 350px"
id="iframeBox"></iframe>
</el-form-item>
<el-form-item label="身份证" v-if="documentType == 12" prop="idcard">
<el-input placeholder="请输入内容" v-model.trim="voucher.idcard" class="widthRem5" size="middle"
:clearable="true" @change="avoidRepetition($event, 12)">
<el-button slot="append" @click.native="addNfc">GX1000-zh采集卡</el-button>
</el-input>
</el-form-item>
<el-form-item label="NFC卡号" v-if="documentType == 13" prop="nfc">
<el-input placeholder="请输入内容" v-model.trim="voucher.nfc" class="widthRem5" size="middle" :clearable="true"
@change="avoidRepetition($event, 13)">
<el-button slot="append" @click.native="addNfc">GX1000-zh采集卡</el-button>
</el-input>
<el-switch v-model="regularCard" active-text="是否是常开卡" active-color="#13ce66" inactive-color="#ff4949">
</el-switch>
</el-form-item>
<el-form-item label="密码" v-if="documentType == 14" prop="password">
<el-input v-model.trim="voucher.password" type="number" size="middle" class="widthRem5" maxlength="6"
:clearable="true" @change="avoidRepetition($event, 14)" show-password>
</el-input>
</el-form-item>
<el-form-item label="开始时间">
<el-date-picker v-model="value2[0]" size="small" :picker-options="pickerOptionsBegin" type="datetime"
placeholder="选择开始日期时间" default-time="00:00:00">
</el-date-picker>
</el-form-item>
<el-form-item label="结束时间">
<el-date-picker v-model="value2[1]" size="small" :picker-options="pickerOptionsEnd" type="datetime"
placeholder="选择结束日期时间" default-time="00:00:00">
</el-date-picker>
</el-form-item>
</el-form>
</div>
<el-button type="primary" size="small" @click="bindsave1">保存</el-button>
<el-button type="primary" size="small" @click="bindroom1">返回</el-button>
</div>
</el-card>
<el-card class="box-card" v-if="activeName == 2">
<div>
<el-button @click="continuationManagementBack" size="mini">返回</el-button>
<el-button type="primary" size="mini" @click="deleAll">批量删除</el-button>
<el-input type="text" size="mini" v-model="recordFilterCondition.deviceNum" placeholder="请输入设备号"
class="SearchInput" clearable></el-input>
<el-input type="text" size="mini" v-model="recordFilterCondition.imei" placeholder="请输入IMEI号"
class="SearchInput" clearable></el-input>
<el-cascader :options="bindRoomlist" clearable v-model="recordFilterCondition.roomId" @change="checkNodeRecord"
size="mini" collapse-tags class="SearchInput" placeholder="请选择对应房间"
:props="{ checkStrictly: true }"></el-cascader>
<!-- <el-select v-model="recordFilterCondition.type" placeholder="请选择类型" class="SearchInput" size="mini"
clearable>
<el-option label="指纹" value="1"></el-option>
<el-option label="身份证" value="2"></el-option>
<el-option label="NFC" value="3"></el-option>
<el-option label="密码" value="4"></el-option>
</el-select> -->
<el-select v-model="recordFilterCondition.status" placeholder="请选择下发状态" class="SearchInput" size="mini"
clearable>
<el-option label="下发成功" value="1"></el-option>
<el-option label="等待发送" value="700"></el-option>
<el-option label="下发中" value="0"></el-option>
<el-option label="发送失败" value="702"></el-option>
<el-option label="已作废" value="703"></el-option>
</el-select>
<el-button type="primary" size="mini" @click="obtainVoucherIssuanceRecord">查询</el-button>
<el-button type="primary" size="mini" @click="recordFilterConditionReset">重置</el-button>
<el-table :data="sendListRecords" stripe style="width: 100%;margin-top: 10px;" :height="tableheight"
@selection-change="handleSelectionChange4" border>
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column prop="name" label="租客名称"></el-table-column>
<el-table-column prop="pzname" label="凭证名称"></el-table-column>
<el-table-column prop="roomName" label="房间名称"></el-table-column>
<el-table-column prop="deviceNum" label="设备号"></el-table-column>
<el-table-column label="锁端凭证类型">
<template #default="scope">
<!-- <span v-if="scope.row.type == 0">人脸</span>-->
<span v-if="scope.row.type == 1">指纹</span>
<span v-if="scope.row.type == 2">身份证</span>
<span v-if="scope.row.type == 3">NFC</span>
<span v-if="scope.row.type == 4">密码</span>
</template>
</el-table-column>
<el-table-column width="400" label="锁端凭证有效期">
<template #default="scope">
<span>{{ scope.row.startTimeText }} - {{ scope.row.endTimeText }}</span>
</template>
</el-table-column>
<el-table-column label="下发状态" prop="statusText"></el-table-column>
<el-table-column label="创建时间" prop="createAt" width="200"></el-table-column>
<el-table-column label="操作" width="250" align="center">
<template #default="scope">
<el-button type="text" class="red" @click="Issue(scope.$index, scope.row)">重新下发
</el-button>
<el-button type="text" class="red" @click="deleteCertificateMethod(scope.$index, scope.row)">删除
</el-button>
<el-button type="text" class="red" v-if="userInfo.type == 0"
@click="deleteCertificatesMethod(scope.$index, scope.row)">删除平台记录
</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagepg">
<el-pagination @size-change="handleSizeChange1" @current-change="handleCurrentChange1"
:current-page="currentPage1" :page-sizes="[10, 30, 100, 200]" :page-size="pageSize1"
layout="total, sizes, prev, pager, next, jumper" :total="total1">
</el-pagination>
</div>
</div>
</el-card>
</div>
<el-dialog title="批量上传" :visible.sync="uploadkj" width="70%">
<input class="input-file" type="file" @change="exportData"
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" />
<el-button type="primary" @click="btnClick" size="mini">导入EXCEL</el-button>
<el-button size="mini" class="importBtn" @click="exportBtn">下载模板</el-button>
<div style="overflow: auto;">
<el-table :data="userlist1" v-if="userlist1statu" border class="table" ref="multipleTable1"
header-cell-class-name="table-header" @selection-change="handleSelectionChange1" height="400"
style="width: 100%;">
<el-table-column prop="name" label="名称"></el-table-column>
<el-table-column prop="siteName" label="绑定房间"></el-table-column>
<el-table-column prop="number" label="身份证号" width="150"></el-table-column>
<el-table-column prop="cardId" label="NFC" width="150"></el-table-column>
<el-table-column prop="phone" label="手机号" width="150"></el-table-column>
<el-table-column label="开锁方式" align="center">
<template #default="scope">
<span v-if="scope.row.mode == 4">密码</span>
<span v-else-if="scope.row.mode == 3">NFC</span>
<span v-else="scope.row.mode==2">身份证</span>
</template>
</el-table-column>
<el-table-column prop="modeContent" label="内容" width="150"></el-table-column>
<el-table-column label="有效期" align="center" width="450">
<template #default="scope">
<el-date-picker v-model="value3" type="datetimerange" @input="handleDate" align="right"
start-placeholder="开始日期" end-placeholder="结束日期">
</el-date-picker>
</template>
</el-table-column>
<el-table-column label="性别" align="center">
<template #default="scope">
{{ scope.row.sex == 1 ? "男" : "女" }}
</template>
</el-table-column>
</el-table>
</div>
<template #footer>
<span class="dialog-footer">
<el-button @click="uploadkj = false">取 消</el-button>
<el-button type="primary" @click="batchUploadfun">确 定</el-button>
</span>
</template>
</el-dialog>
<el-dialog title="编辑" :visible.sync="editVisiblelist" width="50%" :lock-scroll="true">
<el-form ref="form" :rules="rules" :model="form" label-width="80px">
<el-form-item label="名称" prop="name">
<el-input v-model="form.name" :clearable="true"></el-input>
</el-form-item>
<el-form-item label="身份证号" prop="number">
<el-input v-model="form.number" :clearable="true"></el-input>
</el-form-item>
<el-form-item label="身份" prop="type">
<el-select v-model="form.type" class="widthThree" placeholder="请选择身份" clearable>
<el-option :label="item.label" :value="item.value" v-for="(item, index) in userTypeList" :key="index">
</el-option>
</el-select>
</el-form-item>
<!-- <el-form-item label="NFC" prop="cardId">-->
<!-- <el-input v-model="form.cardId" :clearable="true" :disabled="modify ? false : true"></el-input>-->
<!-- </el-form-item>-->
<el-form-item label="手机号" prop="phone">
<el-input v-model="form.phone" type="number" placeholder="为11位手机号" :clearable="true"
:disabled="modify ? false : true"></el-input>
</el-form-item>
<!-- <el-form-item label="卡状态">-->
<!-- <el-select v-model="form.cardState" placeholder="请选择" clearable>-->
<!-- <el-option v-for="item in cardstatus" :key="item.value" :label="item.label" :value="item.value">-->
<!-- </el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item label="所属部门" prop="enterpriseId">
<el-cascader :options="enterpriseListOption" v-model="defaultEnterpriseId" ref="cascader" :props="props"
collapse-tags clearable @change="checkEnterpriseList"></el-cascader>
</el-form-item>
<el-form-item label="性别" disabled>
<el-radio v-model="form.sex" :label="1">男</el-radio>
<el-radio v-model="form.sex" :label="2">女</el-radio>
</el-form-item>
<el-form-item label="密码">
<el-input v-model="form.key" :clearable="true"></el-input>
</el-form-item>
<el-form-item label="创建账号" disabled v-if="modify">
<el-switch v-model="WhetherToGreatAnAccount" active-color="#13ce66" inactive-color="#ff4949">
</el-switch>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="editVisiblelist = false">取 消</el-button>
<el-button type="primary" @click="saveEdit" v-if="modify">确 定</el-button>
<el-button type="primary" @click="modifyEdit" v-else>修 改</el-button>
</span>
</template>
</el-dialog>
<el-dialog title="修改" :visible.sync="certificatestatus" width="50%">
<el-form ref="formvoucher1" :model="certificatesContent" label-width="80px" class="temporary">
<el-form-item label="凭证名称">
<el-input v-model="certificatesContent.pzname" :disabled="true" :clearable="true"></el-input>
</el-form-item>
<el-form-item label="开始时间">
<el-date-picker v-model="value2[0]" size="small" :picker-options="pickerOptionsBegin" type="datetime"
placeholder="选择开始日期时间" default-time="00:00:00">
</el-date-picker>
</el-form-item>
<el-form-item label="结束时间">
<el-date-picker v-model="value2[1]" size="small" :picker-options="pickerOptionsBegin" type="datetime"
placeholder="选择结束日期时间" default-time="00:00:00">
</el-date-picker>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="certificatestatus = false">取 消</el-button>
<el-button type="primary" @click="modifyCraiFun">确 定</el-button>
</span>
</template>
</el-dialog>
<el-dialog :title="freeUserTitle" :visible.sync="freeUserDialog" width="40%">
<el-form ref="formvoucher1" :model="certificatesContent" label-width="80px" class="temporary">
<el-form-item label="开始时间">
<el-date-picker v-model="freeUserDate[0]" size="small" type="datetime" placeholder="选择开始日期时间"
default-time="12:00:00">
</el-date-picker>
</el-form-item>
<el-form-item label="结束时间">
<el-date-picker v-model="freeUserDate[1]" size="small" type="datetime" placeholder="选择结束日期时间"
default-time="12:00:00">
</el-date-picker>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="freeUserDialog = false">取 消</el-button>
<el-button type="primary" @click="freeUserConfirm" v-if="batchFreeShow">冻 结</el-button>
<el-button type="primary" @click="batchFreeUserConfirm" v-if="!batchFreeShow">冻结</el-button>
</span>
</template>
</el-dialog>
<el-drawer title="" :visible.sync="drawerVisible" direction="rtl" size="80%" :before-close="handleClose">
<contrast @contrastMethods="backTableMethods" @getAboutRoom="getAboutRoom"></contrast>
</el-drawer>
</div>
</template>
<script>
import Schart from "vue-schart";
import {
httpPost,
download, setCode,
httpGet,
httgetaxio1
} from "../api";
import zTree from "../components/zTree1.vue";
import userContent from "../components/usercontent.vue";
import personLi from "../components/personLi.vue";
import contrast from "../components/contrast/contrast.vue"
import XLSX from "xlsx";
import zw from "./zw.vue"
import getFinger from "./getFinger.vue"
import md5 from 'js-md5'
import ICINLocker from "../utils/equipment.js"
import {
timestampToTime,
dec2hex,
group,
ztreeToElementTree2,
ztreeToElementTree,
recursion,
uniqueArray,
duplicateRemoval,
delArrVal,
isContained,
timeTotimeimp,
getcurrentTime,
getcurrentTime1,
reverse
} from "../utils/index";
let nowDate = new Date()
var currentTime = nowDate
var endcurrentTime = getcurrentTime1(6)
import axios from "axios"
import utils from "../utils/util.js";
import IdentityCodeValid from '../utils/verification.js'
import RequestSet from "../api/allFun.js";
import moment from 'moment'
import NumberGrow from "../components/visualizcomponent/NumberGrow.vue";
export default {
inject: ['reload'],
name: "campus",
data() {
return {
isCheckin: 0, // 已入住人数
checkinNum: 0, // 已签约
noshowNum: 0, // 未入住人数
signedNum: 0, // 待签约
arrearsNum: 0, // 已欠费
expiredNum: 0, // 已到期
frozenDialog: false,//冻结用户选择时间
frozenDataSelect: { time: '', timeOne: '' },
roomScreen: [],//筛选只展示房间,不展示层级
paginationConfig: 'total, sizes, prev, pager, next, jumper',
pickerOptionsBegin: {
disabledDate: time => {
// time为形参,实参就是自动获取到的beginTime元素可以选的值
let maxDateTimeOne = new Date(this.maxDateTime).getTime()
let minDateTimeOne = new Date(this.minDateTime).getTime()
return time.getTime() > maxDateTimeOne || time.getTime() < minDateTimeOne
}
},
pickerOptionsEnd: {
disabledDate: time => {
let maxDateTimeOne = new Date(this.value2[0]).getTime()
return time.getTime() < maxDateTimeOne; /*今天及之前*/
}
},
regularCard: false,
drawerVisible: false,
props: {
multiple: true,
emitPath: false
},
defaultEnterpriseId: [],
defaultEnterpriseIdBack: [],
checkEnterpriseNode: [],
enterpriseListOption: [],
WhetherToGreatAnAccount: false,
dateRange: [],
batchCredentialList: [],
multipleSelection4: [],
// 记录筛选条件
recordFilterCondition: {
imei: '',
deviceNum: '',
status: '',
type: '',
roomId: ''
},
sendListRecords: [],
bindSelectedList: [], //选定绑定房间列表
bindRoomlist: [], //房源列表
rulesAdd: {
username: [{
required: true,
message: '请输入姓名',
trigger: 'blur'
},],
documentType: [{
required: true,
message: '请选择凭证类型',
trigger: 'blur'
},],
pzname: [{
required: true,
message: '请输入凭证名称',
trigger: 'blur'
},],
nfc: [{
required: true,
message: '请输入NFC',
trigger: 'blur'
},],
idcard: [{
required: true,
message: '请输入卡号',
trigger: 'blur'
},],
password: [{
required: true,
message: '请输入密码',
trigger: 'blur'
},]
},
rules: {
roomlistVoucher: [],
SelectedListVoucher: [],
name: [{
required: true,
message: '请输入姓名',
trigger: 'blur'
},],
cardId: [{
required: true,
message: '请输入卡号',
trigger: 'blur'
},],
number: [{
required: true,
message: '请输入身份证号',
trigger: 'blur'
},],
phone: [{
required: true,
message: '请输入电话',
trigger: 'blur'
},],
enterpriseId: [{
required: true,
message: '请选择所属部门',
trigger: 'blur'
},],
type: [{
required: true,
message: '请选择身份角色',
trigger: 'blur'
},],
},
tableheight: 0,
credentialSearch: {
deviceNum: '',
imei: '',
status: '',
roomId: '',
type: ''
},
selectoption: [],
selectoptionValue: '',
enterpriselist: [],
continuationManagementDate: {
time: ''
},
continuationManagementStatus: false,
Reissueform: {},
Reissue: '',
bindRoomStatus: false,
bindRoomStatus1: false,
drawer: false,
zNodes: [],
allroomlist: [],
selectRow: [],
bindRoomForm: {},
modify: true,
roomlistZNodes: [],
roonNameTop: '',
lsmm: {},
roomtablestatus1: true,
SelectedList: [],
documentType1: "请选择",
certificatestatus: false,
dialogImageUrl: "",
dialogVisible: false,
pageSize1: 10,
disabled1: false,
setting: {
edit: {
enable: true,
drag: {
isMove: true,
},
showRemoveBtn: false,
showRenameBtn: false,
},
check: {
enable: false,
},
data: {
simpleData: {
enable: true,
pIdKey: "pid",
},
},
view: {
showIcon: true,
addHoverDom: this.addHoverDom,
removeHoverDom: this.removeHoverDom,
},
},
value2: ['', ''],
value3: ['', ''],
userliststatu: true,
roomstatus: true,
roomstatus1: true,
roomtable: [],
roomtable1: [],
roomtable2: [],
roomtableStatus: true,
activeName: "0",
limitUpload: 1000,
arr: [],
cardstatus: [{
value: 1,
label: "正常",
},
{
value: 4,
label: "冻结",
}
],
currentPage4: 1,
currentPage1: 1,
currentPage2: 1,
editVisiblelist: false,
userlist: [],
userlist1: [],
userlist1statu: true,
modifyStatus: true,
options: {
type: "pie",
xRorate: 25,
legend: {
position: "left",
},
showValue: false,
bgColor: "rgba(255,255,255,0)",
labels: ["密码凭证", "身份凭证", "其他"],
datasets: [{
data: [28, 10, 2],
},],
},
query: {
cardId: "",
number: "",
name: "",
type: 0,
pzname: "",
},
tableData: [],
total1: 0,
total2: 0,
multipleSelection: [],
multipleSelection1: [],
multipleSelection2: [],
multipleSelection3: [],
delList: [],
editVisible: false,
pageTotal: 0,
form: {
sex: 1,
cardState: 1,
name: "",
number: "",
cardId: "",
phone: "",
enterpriseId: '',
type: '',
fingerprintAlias: ''
},
idx: -1,
id: -1,
activeiconfont: true,
normal: 0,
total: 0,
frozen: 0,
lose: 0,
uploadkj: false,
file: "",
fileTemp: "",
files: "",
treedata: {},
drawerRow: {},
deviceList: [],
userlistquery: [],
userlistquery1: [],
temporaryPassword: '',
documentType: "请选择",
voucher: {
username: "",
pzname: "",
nfc: "",
idcard: "",
password: "123456",
fingerprintAlias: ""
},
bindroomstatus: true,
fingerprintTransfer: 0,
fingerprintId: 0,
checkList: "",
margkli: "",
roomlist: [],
roomlist2: [],
defaultProps: {
children: "children",
label: "name",
disabled: this.disabledFn,
},
selectkey: [],
certificatesContent: {
pzname: ""
},
certificatesRow: {},
selectkey1: "",
addroomstatus: true,
selectkeyadd: [],
selectRoomdeletelist: [], //多选删除房间数据
roomlist1: [],
AboutDevice: [],
reissue: {
voucher: ""
},
modifyrow: {},
modifyvalue2: [currentTime, endcurrentTime],
allAboutDevice: [],
localFingerprint: {},
selectRoom: true,
personname: '操作',
pageNum: 1,
pageSize: 10,
userInfo: {
type: ''
},
viewRecordSelected: {
password: ''
},
batchRenewalList: [],
batchRenewalShow: false,
batchRenewalFrom: {
startTime: '',
endTime: ''
},
checkInListing: [],
freeUserManageRow: [],
freeUserDate: [],
freeUserDialog: false,
batchFreeShow: true,
freeUserTitle: '冻结用户',
userTypeList: [],
maxDateTime: '',
minDateTime: ''
};
},
computed: {
},
created() {
this.userTypeList = this.$MANUFACTURER.userType
this.$store.commit('getTree')
this.tableheight = document.documentElement.clientHeight - 240
this.userInfo = JSON.parse(localStorage.getItem('info'))
this.form.enterpriseId = this.userInfo.enterpriseId
this.getAboutRoom();
this.getEnterprise()
this.getalllist();
// this.getcardstatus();
this.getAboutDevice(); //获取和房间相关的设备
this.getlockUser()
this.selectoption = JSON.parse(localStorage.getItem('selectoption'))
this.selectoptionValue = localStorage.getItem('tenantId')
if (document.documentElement.clientWidth < 1080) {
this.paginationConfig = 'total, prev, pager, next'
} else {
this.paginationConfig = 'total, sizes, prev, pager, next, jumper'
}
},
components: {
Schart,
userContent,
zTree,
personLi,
zw, getFinger,
contrast,
NumberGrow
},
mounted() {
// 获取全部合同
this.getLeasesList()
// document.addEventListener('keydown', this.keyDown)
setTimeout(() => {
this.handleSearch()
var q = {};
var data = {
pageNum: 0,
pageSize: 0,
orderBy: "create_time desc",
q: JSON.stringify(q),
};
let roomAbout = this.$store.state.roomAbout
httpPost(data, this.$api.getlistNum).then((res1) => {
res1.data.list.map((li, index) => {
this.$store.commit("increment", 1);
li['rommNameText'] = this.screenRoomName(li.id)
if(li["rommNameText"] != '') {
this.isCheckin++
}else{
this.noshowNum++
}
});
});
}, 800)
},
beforeDestroy() {
this.$store.commit("increment", 1);
},
methods: {
// 获取全部合同
getLeasesList() {
let data = {
pageNum: 0,
pageSize: 0,
orderBy: "create_time desc"
}
httpPost(data, this.$api.postLeasesList).then(res => {
let total = res.data.total
console.log(res);
var checkinNum = 0
var signedNum = 0
var arrearsNum = 0
var expiredNum = 0
if (res.success) {
res.data.list.map(li => {
// 待签约
if (li.status == 0) {
signedNum++
} else if (li.status == 1) {
// 已签约
checkinNum++
} else if (li.status == 2) {
// 已欠费
arrearsNum++
} else if (li.status == 4) {
// 已到期
expiredNum++
}
})
this.signedNum = signedNum
this.checkinNum = checkinNum
this.arrearsNum = arrearsNum
this.expiredNum = expiredNum
} else {
this.$message.error(res.message)
}
})
},
// 限时密码
limitedTimePassword(index, row) {
const startTime = moment(new Date().getTime()).format("YYYY-MM-DD HH:mm:ss")
const endTime = moment(new Date().getTime() + 4 * 60 * 1000).format("YYYY-MM-DD HH:mm:ss")
let data3 = {
code: "/zg/offlinepassword/limit",
data: {
userName: JSON.parse(this.drawerRow.info).userId,
lockId: row.deviceNum,
startTime: startTime,
endTime: endTime
},
};
this.$confirm('此操作将获取限时密码, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
httpPost(data3, this.$api.sendCommand).then((res4) => {
if (res4.success) {
this.$alert(`${res4.data}`, '限时密码', {
confirmButtonText: "确定",
callback: action => {
}
})
}
})
})
},
// 对时密码
timingPassword(index, row) {
const startTime = moment(new Date().getTime()).format("YYYY-MM-DD HH:mm:ss")
const endTime = moment(new Date().getTime() + 24 * 60 * 60 * 1000).format("YYYY-MM-DD HH:mm:ss")
let data3 = {
code: "/zg/offlinepassword/correctTime",
data: {
userName: JSON.parse(this.drawerRow.info).userId,
lockId: row.deviceNum,
},
};
this.$confirm('此操作将获取对时密码, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
httpPost(data3, this.$api.sendCommand).then((res4) => {
if (res4.success) {
this.$alert(`${res4.data}`, '对时密码', {
confirmButtonText: "确定",
callback: action => {
}
})
}
})
})
},
// 清空所有密码
clearAllPassWord(index, row) {
const startTime = moment(new Date().getTime()).format("YYYY-MM-DD HH:mm:ss")
const endTime = moment(new Date().getTime() + 24 * 60 * 60 * 1000).format("YYYY-MM-DD HH:mm:ss")
let data3 = {
code: "/zg/offlinepassword/clear",
data: {
userName: JSON.parse(this.drawerRow.info).userId,
lockId: row.deviceNum,
startTime: startTime,
// endTime:endTime,
},
};
this.$confirm('此操作将获取清空密码, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
httpPost(data3, this.$api.sendCommand).then((res4) => {
if (res4.success) {
this.$alert(`${res4.data}`, '清空密码', {
confirmButtonText: "确定",
callback: action => {
}
})
}
})
})
},
/*获取临时离线密码*/
getLimitMethods(index, row) {
const startTime = moment(new Date().getTime()).format("YYYY-MM-DD HH:mm:ss")
const endTime = moment(new Date().getTime() + 24 * 60 * 60 * 1000).format("YYYY-MM-DD HH:mm:ss")
let data3 = {
code: "/zg/offlinepassword/forever",
data: {
userName: JSON.parse(this.drawerRow.info).userId,
lockId: row.deviceNum,
startTime: startTime,
// endTime:endTime,
},
};
httpPost(data3, this.$api.sendCommand).then((res4) => {
if (res4.success) {
this.$alert(`${res4.data}`, '离线密码', {
confirmButtonText: "确定",
callback: action => {
}
})
}
})
},
// 对比结果
backTableMethods(data) {
console.log(data)
},
tableRowClassName({
row,
rowIndex
}) {
if (row.color == '0') {
return "wait-row"
} else if (row.color == '1') {
return "success-row"
} else if (row.color == '702') {
return "wait-row"
} else if (row.color == '999') {
return 'warning-row';
}
},
keyDown(e) {
//如果是回车则执行登录方法
if (e.keyCode == 13) {
if (this.$route.name == 'userManagement') {
if (!this.drawer) {
this.handleSearch();
}
}
}
},
handleDate(e) {
this.$nextTick(() => {
if (e == null) {
this.value2 = []
this.value3 = []
this.freeUserDate = []
}
})
},
freeUserConfirm() {
this.$confirm('是否冻结该锁用户?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
var row = this.freeUserManageRow[0]
// row.frozenStartTime = moment(this.freeUserDate[0]).format("X")
// row.frozenEndTime = moment(this.freeUserDate[1]).format("X")
RequestSet.freeUserManage(1, row, (callback) => {
if (callback.code == 200) {
this.$message.success("冻结指令下发成功")
this.freeUserDialog = false
} else {
this.$message.error("冻结指令下发失败")
}
})
})
return
if (this.freeUserDate.length != 2) {
this.$confirm('是否冻结该锁用户?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
var row = this.freeUserManageRow[0]
row.frozenStartTime = 1676603379//moment(this.freeUserDate[0]).format("X")
row.frozenEndTime = 1895132615//moment(this.freeUserDate[1]).format("X")
RequestSet.freeUserManage(1, row, (callback) => {
if (callback.code == 200) {
this.$message.success("冻结指令下发成功")
this.freeUserDialog = false
} else {
this.$message.error("冻结指令下发失败")
}
})
})
} else {
this.$message.error("请选择开始结束时间")
}
},
// 冻结锁用户
frozenMethods(index, row) {
var userRow = row
var drawerRow = this.drawerRow
userRow['userId'] = JSON.parse(drawerRow.info).userId || JSON.parse(drawerRow.info).userPassword
userRow['keyId'] = JSON.parse(drawerRow.info).keyId || JSON.parse(drawerRow.info).userPassword
userRow['frozenStartTime'] = moment(row.startTime).format("X")
userRow['frozenEndTime'] = moment(row.endTime).format("X")
this.freeUserDate = [row.startTime, row.endTime]
this.freeUserManageRow = [userRow]
this.freeUserTitle = '冻结锁用户'
this.frozenDialog = true
// this.freeUserConfirm()
// this.batchFreeShow = true
// this.freeUserDialog = true
},
// 冻结用户选择完时间后
async frozenTimeSureMethods() {
this.freeUserManageRow.map(li => {
li.frozenStartTime = moment(this.value2[0]).valueOf() / 1000
li.frozenEndTime = moment(this.value2[1]).valueOf() / 1000
})
await this.freeUserConfirm()
},
// 解冻锁用户
thawMethods(index, row) {
var userRow = row
var drawerRow = this.drawerRow
userRow['userId'] = JSON.parse(drawerRow.info).userId || JSON.parse(drawerRow.info).userPassword
userRow['keyId'] = JSON.parse(drawerRow.info).keyId || JSON.parse(drawerRow.info).userPassword
userRow['frozenStartTime'] = 1676603379//moment(row.startTime).format("X")
userRow['frozenEndTime'] = 1895132615//moment(row.endTime).format("X")
this.$confirm('是否解冻该锁用户?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
RequestSet.freeUserManage(0, userRow, (callback) => {
if (callback.code == 200) {
this.$message.success("解冻指令下发成功")
} else {
this.$message.error("解冻指令下发失败")
}
})
})
},
// 批量冻结用户
batchfrozenMethods() {
this.freeUserTitle = '批量冻结锁用户'
this.freeUserDate = []
this.batchFreeUserConfirm()
// this.batchFreeShow = false
// this.freeUserDialog = true
},
batchFreeUserConfirm() {
var userRow = this.batchRenewalList
var drawerRow = this.drawerRow
this.$confirm('是否冻结这些锁用户?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
userRow.map(li => {
li['userId'] = JSON.parse(drawerRow.info).userId || JSON.parse(drawerRow.info).userPassword
li['keyId'] = JSON.parse(drawerRow.info).keyId || JSON.parse(drawerRow.info).userPassword
li['frozenStartTime'] = 1676603379//moment(this.freeUserDate[0]).format("X")
li['frozenEndTime'] = 1895132615//moment(this.freeUserDate[1]).format("X")
RequestSet.freeUserManage(1, li, (callback) => {
if (callback.code == 200) {
this.$message.success("冻结指令下发成功")
this.batchRenewalList = []
this.freeUserDialog = false
} else {
this.$message.error("冻结指令下发失败")
}
})
})
})
},
// 批量解锁用户
batchthawMethods() {
var userRow = this.batchRenewalList
var drawerRow = this.drawerRow
this.$confirm('是否解冻这些锁用户?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
userRow.map(li => {
li['userId'] = JSON.parse(drawerRow.info).userId || JSON.parse(drawerRow.info).userPassword
li['keyId'] = JSON.parse(drawerRow.info).keyId || JSON.parse(drawerRow.info).userPassword
li['frozenStartTime'] = 1676603379//moment(li.startTime).format("X")
li['frozenEndTime'] = 1895132615//moment(li.endTime).format("X")
RequestSet.freeUserManage(0, li, (callback) => {
if (callback.code == 200) {
this.$message.success("解冻指令下发成功")
this.batchRenewalList = []
this.freeUserDialog = false
} else {
this.$message.error("解冻指令下发失败")
}
})
})
})
},
// 获取锁用户总数
getlockUser() {
var data = {
pageNum: 0,
pageSize: 0,
q: JSON.stringify({
type: 26,
status: 1,
types: "26"
}),
orderBy: "create_at desc",
};
httpGet(data, this.$api.getCertificates).then((res) => {
if (res.code == 200) {
let data = utils.zlib_unzip(res.data)
console.log(res)
// this.total = res.data.total
}
})
},
// 批量退租
batchLeaseback() {
this.$confirm('是否退租?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.batchRenewalList.map((li, index) => {
this.deleteRoomfun(index, li)
})
})
},
// 单个续租
singleRenewalMethods(index, row) {
this.batchRenewalList = [row]
this.batchRenewalShow = true
},
// 批量续租确认
batchRenewalMethods() {
this.$confirm('此操作将延长入住时间, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if (this.batchRenewalFrom.endTime == '' || this.batchRenewalFrom.startTime == '') {
this.$message.error("请选择时间范围")
return
}
var drawerRow = this.drawerRow
this.batchRenewalList.map(li => {
if (li.manufactureId == 101) {
var userTelephone = JSON.parse(drawerRow.info).userTelephone;
var userPassword = JSON.parse(drawerRow.info).userPassword;
var endTime = new Date(this.batchRenewalFrom.endTime).getTime()
var startTime = new Date(this.batchRenewalFrom.startTime).getTime()
var passwordEndTime = moment(endTime).format("YYYYMMDDHHmmss");
var passwordStartTime = moment(startTime).format("YYYYMMDDHHmmss");
var data = {
deviceNum: li.deviceNum,
imei: li.imei,
userTelephone: userTelephone,
userPassword: userPassword,
password: userPassword,
operateMode: 2,
order: 6202,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
cardName: drawerRow.name,
roomName: li.roomName
}
ICINLocker.LDAddUser(data.deviceNum, data.imei, data.userTelephone, data.userPassword, data
.password,
passwordStartTime, passwordEndTime, data.operateMode, data.order, data.cardName,
data
.roomName, false, (callback) => {
if (callback.success) {
var data = {
pageNum: 0,
pageSize: 0,
orderBy: "create_at desc",
q: {
cardId: drawerRow.id,
deviceNum: li.deviceNum,
types: "0,1,2,3,4",
inStatus: "0,1"
},
};
var unbind = {
id: li.id,
startTime: this.batchRenewalFrom.startTime,
endTime: this.batchRenewalFrom.endTime
};
httpPost(unbind, this.$api.setTenant).then((res) => {
})
httpGet(data, this.$api.getCertificates).then((res) => {
let data = utils.zlib_unzip(res.data)
data.map(lt => {
utils.modifyPutCarfid(li, lt, startTime, endTime)
})
})
this.batchRenewalShow = false
} else {
this.$message.error("修改失败")
}
})
} else if (li.manufactureId == 201 || li.manufactureId == 221) {
var endTime = new Date(this.batchRenewalFrom.endTime).getTime()
var startTime = new Date(this.batchRenewalFrom.startTime).getTime()
var unbind = [{
cardId: drawerRow.id,
siteId: li.roomId,
}];
httpPost(unbind, this.$api.unbindCard).then((res) => {
var data1 = [{
cardId: drawerRow.id,
siteId: li.roomId,
startTime: this.batchRenewalFrom.startTime,
endTime: this.batchRenewalFrom.endTime
}];
httpPost(data1, this.$api.bindCard).then((res) => {
this.operation(0, this.drawerRow)
});
})
var data = {
pageNum: 0,
pageSize: 0,
orderBy: "create_at desc",
q: {
cardId: drawerRow.id,
deviceNum: li.deviceNum,
types: "0,1,2,3,4",
inStatus: "0,1"
},
};
httpGet(data, this.$api.getCertificates).then((res) => {
let data = utils.zlib_unzip(res.data)
data.map(lt => {
utils.modifyPutCarfidzg(li, lt, startTime, endTime)
})
})
this.batchRenewalShow = false
} else {
this.$message.error("暂未发现对应设备")
}
})
})
},
batchRenewal() {
this.batchRenewalShow = true
},
// 批量选择续租
renewalOption(val) {
this.batchRenewalList = val
},
batchProcessingData() {
var data = {
pageNum: 0,
pageSize: 0,
orderBy: "create_time desc"
};
// httpPost(data, this.$api.getlistNum).then((res1) => {
this.multipleSelection.map(li => {
this.GetCredentialList(li)
})
// })
},
GetCredentialList(item) {
RequestSet.GetCredentialList(item, 1, (callback) => {
let dataOne = utils.zlib_unzip(callback.data)
if (dataOne.length > 0) {
dataOne.map(li => {
li['fingerprint'] = JSON.parse(li.content).fingerprint
})
var arr = utils.uniqueArray(dataOne, "fingerprint");
arr.map((li, index) => {
RequestSet.completePersonnelVouchers(li, index, 1)
})
}
})
RequestSet.GetCredentialList(item, 2, (callback) => {
let dataOne = utils.zlib_unzip(callback.data)
if (dataOne.length > 0) {
dataOne.map(li => {
li['password'] = JSON.parse(li.content).password
})
var arr = utils.uniqueArray(dataOne, "password");
arr.map((li, index) => {
RequestSet.completePersonnelVouchers(li, index, 2)
})
}
})
RequestSet.GetCredentialList(item, 3, (callback) => {
let dataOne = utils.zlib_unzip(callback.data)
if (dataOne.length > 0) {
dataOne.map(li => {
li['password'] = JSON.parse(li.content).password
})
var arr = utils.uniqueArray(dataOne, "password");
arr.map((li, index) => {
RequestSet.completePersonnelVouchers(li, index, 3)
})
}
})
RequestSet.GetCredentialList(item, 4, (callback) => {
let dataOne = utils.zlib_unzip(callback.data)
if (dataOne.length > 0) {
dataOne.map(li => {
li['password'] = JSON.parse(li.content).password
})
var arr = utils.uniqueArray(dataOne, "password");
arr.map((li, index) => {
RequestSet.completePersonnelVouchers(li, index, 4)
})
}
})
},
// 凭证避免重复
avoidRepetition(e, type) {
var person = this.drawerRow
if (type == 12) {
this.roomtable1.map(li => {
var content = JSON.parse(li.content)
if (li.cardId == person.id && content.password == e && li.type == 12) {
this.$message.error("该身份证已存在")
this.voucher.idcard = ''
}
})
} else if (type == 13) {
this.roomtable1.map(li => {
var content = JSON.parse(li.content)
if (li.cardId == person.id && content.password == e && li.type == 13) {
this.$message.error("该NFC已存在")
this.voucher.nfc = ''
}
})
} else if (type == 14) {
this.roomtable1.map(li => {
var content = JSON.parse(li.content)
if (li.cardId == person.id && content.password == e && li.type == 14) {
this.$message.error("该密码已存在")
this.voucher.password = ''
}
})
}
},
// 指纹别名
fingerprintAliasMethod(e) {
var person = this.drawerRow
this.roomtable1.map(li => {
var content = JSON.parse(li.content)
if (li.cardId == person.id && content.fingerprintAlias == e && li.type == 11) {
this.$message.error("该指纹已存在")
this.voucher.fingerprintAlias = ''
}
})
},
// 删除平台记录
deleteCertificatesMethod(index, row) {
this.$confirm("确定要删除平台记录吗?", "提示", {
type: "warning",
}).then(() => {
var data = {
ids: [row.id],
};
httpPost(data, this.$api.deleteCertificates).then((
res) => {
if (res.success) {
this.$message.success("删除成功!");
this.getcertificate();
this.obtainVoucherIssuanceRecord();
}
});
})
},
// 记录筛选条件重置
recordFilterConditionReset() {
this.recordFilterCondition = {
imei: '',
deviceNum: '',
status: '',
type: '',
roomId: ''
}
},
// 查看下发记录
viewDistributionRecord(index, row) {
this.activeName = 2
this.viewRecordSelected = row
this.obtainVoucherIssuanceRecord()
},
deleteCertificateMethod(index, row) {
this.$confirm("此操作将删除锁上凭证,请确认!", "提示", {
type: "warning",
}).then(() => {
this.deleteLockedCredential(index, row)
}).catch(() => {
})
},
// 删除锁上凭证
deleteLockedCredential(index, row) {
var ids = this.roomtable;
var that = this;
var str = {};
var q = {
deviceNum: row.deviceNum,
imei: row.imei,
lockType: 1
};
var data = {
q: JSON.stringify(q),
pageNum: 1,
pageSize: 10,
};
httpPost(data, this.$api.getDeviceItems).then((res) => {
if (res.data.list.length > 0) {
var cardName = row.name + '-' + JSON.parse(row.content).pzname
if (res.data.list[0].manufactureId == 201 || res.data.list[0].manufactureId == 221) {
if (row.type == 1) {
this.getfiId1(row, function (data) {
if (data.length > 0) {
ICINLocker.delFingerPrints(row.deviceNum, row.imei,
JSON.parse(row.content).userPassword, 2, data[0].face, 0,
row.startTime, row.endTime, cardName, res
.data.list[0].roomName, (callback) => {
if (callback.success) {
var content = JSON.parse(row.content)
content.operateMode = 18
var updatedata = {
id: row.id,
status: 0,
content: JSON.stringify(content),
serial: callback.data.serialNumber,
};
httpPost(updatedata, that.$api.updateCertificates).then((res) => {
});
that.$message.success("下发成功");
that.obtainVoucherIssuanceRecord();
} else {
that.$message.error(callback.msg)
}
})
} else {
that.$message.error("删除失败!");
}
})
} else if (row.type == 2) {
this.getfiId1(row, function (data) {
if (data.length > 0) {
ICINLocker.delCardRegister(row.deviceNum, row.imei,
JSON.parse(row.content).userPassword, 2, 1,
JSON.parse(row.content).password, 36, row
.startTime, row.endTime, 6215, data[0]
.face, cardName, res.data.list[0].roomName, (
callback) => {
if (callback.success) {
var content = JSON.parse(row.content)
content.operateMode = 15
var updatedata = {
id: row.id,
status: 0,
content: JSON.stringify(content),
serial: callback.data.serialNumber,
};
httpPost(updatedata, that.$api.updateCertificates).then((res) => {
});
that.$message.success("下发成功");
that.obtainVoucherIssuanceRecord();
} else {
that.$message.error(callback.msg)
}
})
} else {
that.$message.error("删除失败!");
}
})
} else if (row.type == 3) {
this.getfiId1(row, function (data) {
if (data.length > 0) {
ICINLocker.delCardRegister(row.deviceNum, row.imei,
JSON.parse(row.content).userPassword, 2, 1,
JSON.parse(row.content).password, 50, row
.startTime, row.endTime, 6212, data[0]
.face, cardName, res.data.list[0].roomName, (
callback) => {
if (callback.success) {
var content = JSON.parse(row.content)
content.operateMode = 12
var updatedata = {
id: row.id,
status: 0,
content: JSON.stringify(content),
serial: callback.data.serialNumber,
};
httpPost(updatedata, that.$api.updateCertificates).then((res) => {
});
that.$message.success("下发成功");
that.obtainVoucherIssuanceRecord();
} else {
that.$message.error(callback.msg)
}
})
} else {
that.$message.error("删除失败!");
}
})
} else if (row.type == 4) {
this.getfiId1(row, function (data) {
if (data.length > 0) {
ICINLocker.delForeverPassword(row.deviceNum, row.imei,
JSON.parse(row.content).userPassword, 2, JSON
.parse(row.content).password, 255, row
.startTime, row.endTime, 6209, data[0].face, cardName, res
.data.list[0].roomName, (
callback) => {
if (callback.success) {
var content = JSON.parse(row.content)
content.operateMode = 9
var updatedata = {
id: row.id,
status: 0,
content: JSON.stringify(content),
serial: callback.data.serialNumber,
};
httpPost(updatedata, that.$api.updateCertificates).then((res) => {
});
that.$message.success("下发成功");
that.obtainVoucherIssuanceRecord();
} else {
that.$message.error(callback.msg)
}
})
} else {
that.$message.error("删除失败")
}
})
}
} else if (res.data.list[0].manufactureId == 101) {
if (row.type == 1) {
this.getfiId(row, function (data) {
if (data.length > 0) {
var fpid = "";
if (data[0].face) {
fpid = data[0].face.toString(16);
if (fpid.length != 2) {
fpid = "0" + fpid;
}
} else {
if (data[0].face == 0) {
fpid = data[0].face.toString(16);
fpid = "0" + fpid;
}
}
str = {
imei: row.imei,
deviceNum: row.deviceNum,
userTelephone: JSON.parse(row.content).userTelephone,
operateMode: 18,
order: 6218,
password: fpid,
userPassword: JSON.parse(row.content).userPassword,
is: false,
passwordStartTime: JSON.parse(row.content)
.passwordStartTime,
passwordEndTime: JSON.parse(row.content).passwordEndTime,
cardName: cardName,
roomName: res.data.list[0].roomName
};
if (JSON.parse(row.content).pass) {
str['pass'] = true
} else {
str['pass'] = false
}
httpPost(str, that.$api.getDeviceOperateUserInfo).then(
(res1) => {
if (res1.success) {
var content = JSON.parse(row.content)
content.operateMode = 18
var updatedata = {
id: row.id,
status: 0,
content: JSON.stringify(content),
serial: res1.data.serialNumber,
};
httpPost(updatedata, that.$api.updateCertificates).then((res) => {
});
that.$message.success("下发成功");
that.obtainVoucherIssuanceRecord();
} else {
that.$message.error("删除失败!")
}
});
} else {
that.$message.error("删除失败!")
}
});
return false;
} else if (row.type == 2) {
str = {
imei: row.imei,
deviceNum: row.deviceNum,
userTelephone: JSON.parse(row.content).userTelephone,
operateMode: 15,
order: 6215,
password: JSON.parse(row.content).password,
userPassword: JSON.parse(row.content).userPassword,
is: false,
passwordStartTime: JSON.parse(row.content).passwordStartTime,
passwordEndTime: JSON.parse(row.content).passwordEndTime,
cardName: cardName,
roomName: res.data.list[0].roomName
};
} else if (row.type == 3) {
str = {
imei: row.imei,
deviceNum: row.deviceNum,
userTelephone: JSON.parse(row.content).userTelephone,
operateMode: 12,
order: 6212,
password: JSON.parse(row.content).password,
userPassword: JSON.parse(row.content).userPassword,
is: false,
passwordStartTime: JSON.parse(row.content).passwordStartTime,
passwordEndTime: JSON.parse(row.content).passwordEndTime,
cardName: cardName,
roomName: res.data.list[0].roomName
};
} else if (row.type == 4) {
str = {
imei: row.imei,
deviceNum: row.deviceNum,
userTelephone: JSON.parse(row.content).userTelephone,
operateMode: 9,
order: 6209,
userPassword: JSON.parse(row.content).userPassword,
password: JSON.parse(row.content).password,
is: false,
passwordStartTime: JSON.parse(row.content).passwordStartTime,
passwordEndTime: JSON.parse(row.content).passwordEndTime,
cardName: cardName,
roomName: res.data.list[0].roomName
};
}
if (JSON.parse(row.content).pass) {
str['pass'] = true
} else {
str['pass'] = false
}
httpPost(str, this.$api.getDeviceOperateUserInfo).then((res1) => {
if (res1.success) {
var content = JSON.parse(row.content)
content.operateMode = str.operateMode
var updatedata = {
id: row.id,
status: 0,
content: JSON.stringify(content),
serial: res1.data.serialNumber,
};
httpPost(updatedata, that.$api.updateCertificates).then((res) => {
});
that.$message.success("下发成功");
that.obtainVoucherIssuanceRecord();
} else {
that.$message.error("删除失败!")
}
});
} else if (res.data.list[0].manufactureId == 1201) {
if (row.type == 1) {
} else if (row.type == 4) {
let data = {
code: "lwj/passwordOperate",
data: {
lockerId: row.deviceNum,
lockerUserId: JSON.parse(row.content).userPassword,
action: 2,
password: JSON.parse(row.content).password,
startTime: row.startTime,
endTime: row.endTime,
operateMode: 9,
order: 6209,
cardName: cardName,
roomName: res.data.list[0].roomName
}
}
httpPost(data, this.$api.sendCommand).then(res => {
if (res.success) {
let content = JSON.parse(row.content)
content.operateMode = 9
let updatedata = {
id: row.id,
status: 0,
content: JSON.stringify(content),
serial: res.data.serialNumber,
};
httpPost(updatedata, that.$api.updateCertificates).then((res) => {
});
} else {
this.$message.error(res.msg)
}
})
}
}
} else {
this.$message.error("未找到对应设备")
}
})
},
// 获取凭证下发记录
obtainVoucherIssuanceRecord() {
var AboutDevice = this.$store.state.roomAbout
var password = JSON.parse(this.viewRecordSelected.content).password || ''
var type = ''
if (this.viewRecordSelected.type == 11) {
type = 1
} else if (this.viewRecordSelected.type == 12) {
type = 2
} else if (this.viewRecordSelected.type == 13) {
type = 3
} else if (this.viewRecordSelected.type == 14) {
type = 4
}
if (this.recordFilterCondition.roomId) {
var t = {
roomIds: [this.recordFilterCondition.roomId],
lockType: 1
};
var data = {
q: JSON.stringify(t),
};
httpPost(data, this.$api.getDeviceItems).then((res) => {
if (res.success) {
var status = ''
if (this.recordFilterCondition.status == '') {
status = "0,1,702"
} else {
status = this.recordFilterCondition.status
}
if (res.data.list.length > 0) {
if (this.viewRecordSelected.type == 13 && (res.data.list[0].manufactureId == 201 || res.data.list[0].manufactureId == 221)) {
password = utils.cardFormatConversion(password)
}
}
var data6 = {
pageNum: this.currentPage1,
pageSize: this.pageSize1,
orderBy: "create_at desc",
q: JSON.stringify({
info: {
password: password
},
cardId: this.drawerRow.id,
deviceNum: res.data.list[0].deviceNum,
imei: this.recordFilterCondition.imei,
types: type || '0,1,2,3,4',
inStatus: status
}),
};
httpGet(data6, this.$api.getCertificates).then((res) => {
console.log("123123", res)
if (res.success) {
var certiflist = utils.zlib_unzip(res.data)
console.log(certiflist)
certiflist.map((li) => {
li.createAt = this.time(+new Date(li.createAt))
li['userTelephone'] = JSON.parse(li.content).userTelephone
li['operateMode'] = JSON.parse(li.content).operateMode
if (JSON.parse(li.content).fingerprintAlias) {
li.pzname = JSON.parse(li.content).pzname + "-" + JSON.parse(li.content)
.fingerprintAlias
} else {
li.pzname = JSON.parse(li.content).pzname
}
li['statusText'] = utils.statusCode(li.status)
var operateMode = JSON.parse(li.content).operateMode
if (li.status == 0) {
if (operateMode == 18 || operateMode == 15 || operateMode == 12 || operateMode == 9) {
li['statusText'] = '删除中'
} else if (operateMode == 17 || operateMode == 14 || operateMode == 11 ||
operateMode == 8) {
li['statusText'] = '修改中'
}
} else if (li.status == 702) {
if (operateMode == 18 || operateMode == 15 || operateMode == 12 || operateMode == 9) {
li['statusText'] = '删除失败'
} else if (operateMode == 17 || operateMode == 14 || operateMode == 11 ||
operateMode == 8) {
li['statusText'] = '修改失败'
}
}
li.password = JSON.parse(li.content).password
li['startTimeText'] = utils.formatTime(li.startTime)
li['endTimeText'] = utils.formatTime(li.endTime)
li['data'] = JSON.parse(li.content).password
if (li.type == 1) {
li['data'] = li.id
}
var resultArr = AboutDevice.filter(
(_item) => _item.imei == li.imei
)[0];
if (resultArr) {
li.roomId = resultArr.id;
li.roomName = resultArr.roomName;
} else {
li.roomId = "";
li.roomName = JSON.parse(li.content).roomName || "";
}
});
this.sendListRecords = certiflist
this.total1 = res.data.total
} else {
this.$message.error("获取失败")
}
})
} else {
this.$message.error("获取房间对应门锁信息失败")
}
})
} else {
var status = ''
if (this.recordFilterCondition.status == '') {
status = "0,1,702"
} else {
status = this.recordFilterCondition.status
}
var data6 = {}
if (this.viewRecordSelected.type == 11) {
password = utils.cardFormatConversion(password)
data6 = {
pageNum: this.currentPage1,
pageSize: this.pageSize1,
orderBy: "create_at desc",
q: JSON.stringify({
cardId: this.drawerRow.id,
info: {
pzname: JSON.parse(this.viewRecordSelected.content).pzname
},
deviceNum: this.recordFilterCondition.deviceNum,
types: '0,1,2,3,4',
imei: this.recordFilterCondition.imei,
inStatus: status,
type: type,
}),
};
} else if (this.viewRecordSelected.type == 13) {
password = utils.cardFormatConversion(password)
data6 = {
pageNum: this.currentPage1,
pageSize: this.pageSize1,
orderBy: "create_at desc",
q: JSON.stringify({
cardId: this.drawerRow.id,
info: {
pzname: JSON.parse(this.viewRecordSelected.content).pzname
},
deviceNum: this.recordFilterCondition.deviceNum,
types: type || '0,1,2,3,4',
imei: this.recordFilterCondition.imei,
inStatus: status,
}),
};
} else {
data6 = {
pageNum: this.currentPage1,
pageSize: this.pageSize1,
orderBy: "create_at desc",
q: JSON.stringify({
cardId: this.drawerRow.id,
info: {
password: password
},
deviceNum: this.recordFilterCondition.deviceNum,
types: type || '0,1,2,3,4',
imei: this.recordFilterCondition.imei,
inStatus: status,
}),
};
}
httpGet(data6, this.$api.getCertificates).then((res) => {
if (res.success) {
var certiflist = utils.zlib_unzip(res.data)
certiflist.map((li) => {
li.createAt = this.time(+new Date(li.createAt))
li['userTelephone'] = JSON.parse(li.content).userTelephone
li['operateMode'] = JSON.parse(li.content).operateMode
var operateMode = JSON.parse(li.content).operateMode
li['statusText'] = utils.statusCode(li.status)
if (li.status == 0) {
if (operateMode == 18 || operateMode == 15 || operateMode == 12 || operateMode == 9) {
li['statusText'] = '删除中'
} else if (operateMode == 17 || operateMode == 14 || operateMode == 11 || operateMode == 8) {
li['statusText'] = '修改中'
}
} else if (li.status == 702) {
if (operateMode == 18 || operateMode == 15 || operateMode == 12 || operateMode == 9) {
li['statusText'] = '删除失败'
} else if (operateMode == 17 || operateMode == 14 || operateMode == 11 || operateMode == 8) {
li['statusText'] = '修改失败'
}
} else if (li.status == 1) {
if (operateMode == 18 || operateMode == 15 || operateMode == 12 || operateMode == 9) {
li['statusText'] = '删除成功'
} else if (operateMode == 17 || operateMode == 14 || operateMode == 11 || operateMode == 8) {
li['statusText'] = '修改成功'
}
}
if (JSON.parse(li.content).fingerprintAlias) {
li.pzname = JSON.parse(li.content).pzname + "-" + JSON.parse(li.content).fingerprintAlias
} else {
li.pzname = JSON.parse(li.content).pzname
}
li.password = JSON.parse(li.content).password
li['startTimeText'] = utils.formatTime(li.startTime)
li['endTimeText'] = utils.formatTime(li.endTime)
li['data'] = JSON.parse(li.content).password
if (li.type == 1) {
li['data'] = li.id
}
var resultArr = AboutDevice.filter(
(_item) => _item.imei == li.imei
)[0];
if (resultArr) {
li.roomId = resultArr.id;
li.roomName = resultArr.roomName;
} else {
li.roomId = "";
li.roomName = JSON.parse(li.content).roomName || "";
}
});
this.sendListRecords = certiflist
this.total1 = res.data.total
} else {
this.$message.error("获取失败")
}
})
}
},
// 导出
exportfun() {
var q = {
type: "0",
};
var data = {
q: JSON.stringify(q),
fileName: "租客信息",
};
download(data, this.$api.exportCard).then((res) => {
const link = document.createElement("a");
let blob = new Blob([res], {
type: "application/vnd.ms-excel"
});
var objectUrl = URL.createObjectURL(blob);
link.href = objectUrl;
link.download = "租客信息.xlsx";
link.click();
URL.revokeObjectURL(objectUrl);
});
},
// 删除所有对应人员凭证
dellAllCertificate(row) {
var data6 = {
pageNum: 0,
pageSize: 0,
orderBy: "create_at desc",
q: {
cardId: row.id,
},
};
httpGet(data6, this.$api.getCertificates).then((res6) => {
if (res6.success) {
var ids = []
let data = utils.zlib_unzip(res6.data)
data.map(li => {
ids.push(li.id)
})
if (ids.length > 0) {
var data7 = {
ids: ids,
};
httpPost(data7, this.$api.deleteCertificates).then((res7) => {
if (res7.success) {
this.$message.success("成功删除人员对应凭证")
} else {
this.$message.error("删除人员对应凭证失败")
}
});
}
} else {
this.$message.error("删除人员对应凭证失败")
}
})
},
// 删除用户
deleteUser(row, roomtable) {
var selectkey = roomtable;
console.log()
if (selectkey.length > 0) {
selectkey.forEach((li, index) => {
var resultArr = this.AboutDevice.filter(
(_item) => _item.roomId == li
)[0];
if (resultArr) {
if (resultArr.imei) {
var roomName = this.zNodes.filter(item => li === item.id)
if (resultArr.manufactureId == 201 || resultArr.manufactureId == 221) {
var data = {
lockerId: resultArr.deviceNum,
imei: resultArr.imei,
lockerUserId: JSON.parse(row.info).userPassword,
keyId: JSON.parse(row.info).userPassword,
role: 0,
action: 2, //1--添加、2--删除、3--修改
order: 6203,
cardName: row.name,
roomName: roomName[0].name
}
ICINLocker.addUserToLock(data.lockerId, data.imei, data.lockerUserId, data
.role, data.action, data
.order, data.cardName, data.roomName, (callback) => {
if (callback.success) {
this.$message.success('下发成功')
this.dellAllCertificate(row)
} else {
this.$message.error(callback.msg)
}
})
} else if (resultArr.manufactureId == 101) {
var str1 = {
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
userTelephone: JSON.parse(row.info).userTelephone,
userPassword: JSON.parse(row.info).userPassword,
cardName: row.name,
roomName: roomName[0].name
};
ICINLocker.LDDeleteUser(str1.deviceNum, str1.imei, str1.userTelephone, str1
.userPassword, str1.cardName, str1.roomName, (callback) => {
if (callback.success) {
this.$message.success('下发成功')
this.dellAllCertificate(row)
} else {
this.$message.error(callback.msg)
}
})
}
}
} else {
this.dellAllCertificate(row)
}
});
} else {
this.dellAllCertificate(row)
}
},
// 多个删除
selectmoredel() {
var list = this.multipleSelection;
var idlist = [];
var that = this;
if (list.length == 0) {
this.$message.error("请勾选需要删除的数据");
} else {
this.$confirm("确定要删除吗?", "提示", {
type: "warning",
}).then(() => {
list.map((row) => {
var unbindCarddata = [];
this.screenRoom1(row.id, function (roomtable) {
var arr = []
roomtable.map((li) => {
var data = {
siteId: li.roomId,
cardId: row.id
};
arr.push(li.roomId)
unbindCarddata.push(data);
});
httpPost(unbindCarddata, that.$api.unbindCard).then((res) => {
var data = {
ids: [row.id]
};
httpPost(data, that.$api.deleteCard).then((res) => {
if (res.success) {
that.$message.success("删除成功");
that.deleteUser(row, arr);
that.getlist();
} else {
that.$message.error("删除失败");
}
});
});
})
});
});
}
},
// 触发搜索按钮
handleSearch() {
var q = {
// type: 0,
name: this.query.name,
number: this.query.number,
phone: this.query.phone,
};
var data = {
pageNum: 1,
pageSize: 10,
orderBy: "create_time desc",
q: JSON.stringify(q),
};
this.currentPage4 = 1
let roomAbout = this.$store.state.roomAbout
httpPost(data, this.$api.getlistNum).then((res1) => {
console.log(res1);
let para = [];
res1.data.list.map((li, index) => {
let userTelephone = JSON.parse(li.info) ? JSON.parse(li.info).userTelephone : ''
let str = {
imei: li.imei,
userTelephone: userTelephone,
password: "",
operateMode: 1,
};
para.push(str);
this.$store.commit("increment", 1);
li.status = 3;
li['rommNameText'] = this.screenRoomName(li.id)
});
// this.getallstatus(para);
console.log(res1.data.list);
this.userlist = res1.data.list;
this.total = res1.data.total;
});
},
// 获取人员列表
getlist() {
var q = {
// type: 0,
};
var data = {
pageNum: this.currentPage4,
pageSize: this.pageSize,
orderBy: "create_time desc",
q: JSON.stringify(q),
};
httpPost(data, this.$api.getlistNum).then((res1) => {
console.log(res1)
// res1.data.list.map((li, index) => {
// li['rommNameText'] = this.screenRoomName(li.id)
// });
let para = [];
res1.data.list.map((li, index) => {
let userTelephone = JSON.parse(li.info) ? JSON.parse(li.info).userTelephone : ''
let str = {
imei: li.imei,
userTelephone: userTelephone,
password: "",
operateMode: 1,
};
para.push(str);
this.$store.commit("increment", 1);
li.status = 3;
li['rommNameText'] = this.screenRoomName(li.id)
});
this.userlist = res1.data.list;
this.total = res1.data.total;
});
},
screenRoomName(id) {
let roomAbout = this.$store.state.roomAbout
var arr = ''
roomAbout.map(lt => {
if (id == lt.cardId) {
var name = utils.findIndexArray(this.roomlistZNodes, lt.roomId, [])
if (name) {
var path = name.join('/')
arr += path + '、'
}
}
})
return arr
},
// 查询和人员相关的房间
getAboutRoom() {
let data = {
orderBy: "create_time desc",
pageNum: 0,
pageSize: 0,
q: JSON.stringify({
name: '',
number: '',
cardId: ''
})
}
let data1 = []
httpPost(data, this.$api.getlistNum).then((res) => {
console.log("123", res);
if (res.success) {
res.data.list.map(li => {
data1.push(li.id)
})
let data2 = {
cardIds: data1
}
httpPost(data2, this.$api.onlyTenant).then((res1) => {
console.log(res1);
this.$store.commit("getAboutRoom", res1.data.list);
this.getlist();
});
}
})
},
getEnterprise() {
httpGet("", this.$api.getEnterprise).then((res) => {
res.data.list.map(li => {
li['pid'] = li.parentId
li['label'] = li.name
li['value'] = li.id
})
var array = utils.uniqueArray(res.data.list, "id");
var roomlistZNodes = ztreeToElementTree2(array, []);
this.enterpriseListOption = roomlistZNodes
this.enterpriselist = res.data.list
});
},
// 获取绑定所有房间
getalllist() {
var data = {};
httpGet(data, this.$api.getSiteList).then((res) => {
this.zNodes = JSON.parse(JSON.stringify(res.data.list.list));
var zNodes = JSON.parse(JSON.stringify(res.data.list.list));
var array = utils.uniqueArray(zNodes, "id");
this.roomlistZNodes = ztreeToElementTree2(array, []);
});
},
// 获取卡统计
getcardstatus() {
var data = {
cardState: 0,
};
httpPost(data, this.$api.countStatus).then((res) => {
res.data.map((li) => {
if (li.value == 1) {
this.normal = li.total;
} else if (li.value == 2) {
this.lose = li.total;
} else if (li.value == 3) {
this.frozen = li.total;
}
});
});
},
// 查询和房间相关的设备
getAboutDevice() {
let data = {
orderBy: "create_time desc",
pageNum: 0,
pageSize: 0,
q: JSON.stringify({
name: '',
number: '',
cardId: ''
})
}
let data1 = []
httpPost(data, this.$api.getlistNum).then((res) => {
console.log(res);
if (res.success) {
res.data.list.map(li => {
data1.push(li.id)
})
let data2 = {
cardIds: data1
}
httpPost(data2, this.$api.onlyTenant).then((res1) => {
// this.$store.commit("getAboutRoom", res.data.list);
// this.getlist();
let data3 = []
if (res1.success) {
res1.data.list.map(li => {
data3.push(li.roomId)
})
let data4 = {
ids: data3
}
httpPost(data4, this.$api.onlySiteDevice).then((res) => {
this.AboutDevice = res.data.list;
this.$store.commit("getAboutDevice", res.data.list);
});
}
});
}
})
},
credentialSearchReset() {
this.credentialSearch = {
deviceNum: '',
imei: '',
status: '',
roomId: '',
type: ''
}
},
selectTenantId(e) {
localStorage.setItem('tenantId', e)
this.reload()
},
// 续住保存
continuationManagementSave() {
console.log(this.roomtable, this.drawerRow)
this.$confirm("是否续住", "提示", {
type: "warning",
}).then(() => {
if (this.continuationManagementDate.time == '') {
this.$message.error("请选择时间范围")
return
}
var endTime = new Date(this.continuationManagementDate.time[1]).getTime()
var startTime = new Date(this.continuationManagementDate.time[0]).getTime()
var passwordEndTime = moment(endTime).format("YYYYMMDDHHmmss");
var passwordStartTime = moment(startTime).format("YYYYMMDDHHmmss");
this.roomtable.map(li => {
var resultArr = this.AboutDevice.filter(
(_item) => _item.roomId == li.roomId
)[0];
var roomName = this.zNodes.filter(item => li.roomId === item.id)
if (resultArr) {
if (resultArr.manufactureId == 101) {
var userTelephone = JSON.parse(this.drawerRow.info).userTelephone;
var userPassword = JSON.parse(this.drawerRow.info).userPassword;
resultArr.roomName = roomName[0].name
var data = {
deviceNum: resultArr.deviceNum,
imei: resultArr.imei,
userTelephone: userTelephone,
userPassword: userPassword,
password: userPassword,
operateMode: 2,
order: 6202,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
cardName: this.drawerRow.name,
roomName: resultArr.roomName
}
ICINLocker.LDAddUser(data.deviceNum, data.imei, data.userTelephone, data
.userPassword, data
.password, passwordStartTime, passwordEndTime, data.operateMode,
data.order, data.cardName,
data.roomName, false, (callback) => {
if (callback.success) {
var data = {
pageNum: 0,
pageSize: 0,
orderBy: "create_at desc",
q: {
cardId: this.drawerRow.id,
deviceNum: resultArr.deviceNum
},
};
var unbind = [{
siteId: this.drawerRow.id,
cardId: resultArr.roomId
}];
httpPost(unbind, this.$api.unbindCard).then((res) => {
var data1 = [{
cardId: this.drawerRow.id,
siteId: resultArr.roomId,
startTime: this
.continuationManagementDate
.time[0],
endTime: this
.continuationManagementDate
.time[1]
}];
httpPost(data1, this.$api.bindCard).then((
res) => {
});
})
httpGet(data, this.$api.getCertificates).then((res) => {
let data = utils.zlib_unzip(res.data)
data.map(lt => {
utils.putCarfid(resultArr, lt,
endTime, startTime)
})
})
} else {
this.$message.error("修改失败")
}
})
} else if (resultArr.manufactureId == 201 || resultArr.manufactureId == 221) {
resultArr.roomName = roomName[0].name
var unbind = [{
siteId: this.drawerRow.id,
cardId: resultArr.roomId
}];
httpPost(unbind, this.$api.unbindCard).then((res) => {
var data1 = [{
cardId: this.drawerRow.id,
siteId: resultArr.roomId,
startTime: this.continuationManagementDate.time[0],
endTime: this.continuationManagementDate.time[1]
}];
httpPost(data1, this.$api.bindCard).then((res) => {
});
})
var data = {
pageNum: 0,
pageSize: 0,
orderBy: "create_at desc",
q: {
cardId: this.drawerRow.id,
deviceNum: resultArr.deviceNum
},
};
httpGet(data, this.$api.getCertificates).then((res) => {
let data = utils.zlib_unzip(res.data)
data.map(lt => {
utils.putCarfidzg(resultArr, lt, endTime,
startTime)
})
})
}
}
})
})
},
// 续住返回
continuationManagementBack() {
this.activeName = 1
this.roomstatus1 = true;
},
// 续住管理
continuationManagement(index, row) {
this.activeName = index;
this.drawerRow = row;
this.voucher.username = row.name;
this.personname = row.name
this.getAboutDevice1();
this.screenRoom(row.id); //根据id筛选有关房源
this.getItems(row.siteId);
// this.getOperates(row.id);
this.getcertificate();
this.drawer = true
this.activeName = 2;
},
// 选择房间跳转下发凭证
issueVoucher() {
this.activeName = 1;
},
addBindRoom() {
this.activeName = 0;
},
// 房源搜索
searchTable() {
this.roomtable.map(li => {
})
},
// 选择房源,下发凭证
sendVoucher() {
var SelectedListbind = this.SelectedList
var roomAbout = this.$store.state.roomAbout
var infostr = JSON.parse(this.drawerRow.info);
var fjid = [];
if (this.value2[0] == '' || this.value2[1] == '') {
this.$message.error("请选择开始结束时间")
return false;
}
if (SelectedListbind.length != 0) {
SelectedListbind.forEach((li) => {
var resultArr = this.AboutDevice.filter(
(_item) => _item.roomId == li
)[0];
if (resultArr) {
if (resultArr.imei) {
if (resultArr.manufactureId == 201 || resultArr.manufactureId == 221) {
var room = roomAbout.filter(item => item.roomId == resultArr.roomId)[0]
resultArr.roomName = room.roomName
this.putCarfidzg(resultArr, this.multipleSelection2);
} else if (resultArr.manufactureId == 101) {
var room = roomAbout.filter(item => item.roomId == resultArr.roomId)[0]
resultArr.roomName = room.roomName
this.putCarfid(resultArr, this.multipleSelection2);
} else if (resultArr.manufactureId == 1201) {
var room = roomAbout.filter(item => item.roomId == resultArr.roomId)[0]
resultArr.roomName = room.roomName
this.putCarfidLwj(resultArr, this.multipleSelection2);
}
}
} else {
this.$message.error("该房间未绑定门锁")
}
});
} else {
this.$message.error("请选择要添加的房间")
}
},
getTypeSort(data, type) {
var num = 1
data.map(li => {
if (li.type == type) {
num++
}
})
return num
},
// 点击查看已绑房间
backTop() {
this.drawer = false
},
// 选择绑定房间弹窗
bindRoomTop() {
this.bindRoomStatus = true
},
getSelectedTab(ids) {
return new Promise((resolve, reject) => {
var selected_tab = [];
var selected = [];
var zNodes = this.zNodes
ids.map(function (item) {
selected_tab = zNodes.filter(function (obj) {
return obj.id == item
});
selected.push(Object.assign({}, ...selected_tab))
})
resolve(selected)
})
},
bindRoomTop1(index, row) {
this.multipleSelection2 = row
this.bindRoomStatus1 = true
let startTime = ''
let endTime = '';
if (JSON.stringify(row.startTime).length == 10) {
startTime = new Date(row.startTime * 1000)
} else {
startTime = new Date(row.startTime)
}
if (JSON.stringify(row.endTime).length == 10) {
endTime = new Date(row.endTime * 1000)
} else {
endTime = new Date(row.endTime)
}
this.value2 = [startTime, endTime]
this.dateRange = [startTime, endTime]
let ids = []
let arr = []
this.roomtable.map(li => {
ids.push(li.roomId)
let tt = this.findParentIds(this.bindRoomlist, li.roomId)
arr.push(...tt)
})
console.log(row, arr)
let treeId = ids.concat([...new Set(arr)])
this.getSelectedTab(treeId).then((res) => {
console.log(res);
if (res.length > 0) {
this.roomlist = []
var array = utils.uniqueArray(res, "id");
console.log(array);
this.roomlist = this.ztreeToElementTree(array, []);
console.log(this.roomlist);
} else {
this.roomlist = []
}
})
},
findParentIds(dataSource, nodeId) {
const parentIds = []; // 用于存储所有父节点ID的数组
// 定义一个递归函数,用于遍历整棵树并查找子节点的所有父节点
function traverse(node, nodeId) {
if (node.id === nodeId) { // 如果当前节点的ID等于子节点的ID,则表示已经找到了子节点,可以开始向上查找父节点
return true; // 返回true表示已经找到了子节点
}
if (node.children) { // 如果当前节点有子节点,则继续遍历子节点
for (const childNode of node.children) {
if (traverse(childNode, nodeId)) { // 如果在子节点中找到了子节点的父节点,则将当前节点的ID添加到父节点ID数组中,并返回true表示已经找到了子节点
parentIds.push(node.id);
return true;
}
}
}
return false; // 如果当前节点不是子节点的父节点,则返回false
}
// 从根节点开始遍历整棵树,并调用递归函数查找子节点的所有父节点
for (const node of dataSource) {
if (traverse(node, nodeId)) { // 如果在当前节点的子树中找到了子节点的父节点,则直接退出循环
break;
}
}
return parentIds; // 返回所有父节点ID的数组
},
getallselectRoom() {
var ids = []
this.roomtable.map(li => {
ids.push(li.roomId)
})
var selected_tab = [];
var selected = [];
var zNodes = this.zNodes
ids.map(function (item) {
selected_tab = zNodes.filter(function (obj) {
return obj.id == item
});
selected.push(Object.assign({}, ...selected_tab))
})
if (selected.length > 0) {
var array = utils.uniqueArray(selected, "id");
this.roomlistVoucher = []
this.roomlistVoucher = this.ztreeToElementTree(array, []);
} else {
this.roomlistVoucher = []
}
},
checkNodeSearch(e) {
let selectRow = []
console.log(e)
e.map(li => {
selectRow.push(...li)
})
console.log(selectRow)
// this.bindSelectedList = selectRow
},
// 选择绑定房间返回的子级id
checkNode(e) {
let selectRow = []
e.map(li => {
let id = li[li.length - 1]
selectRow.push(id)
})
this.bindSelectedList = selectRow
this.getDeviceAllRoom()
},
getDeviceAllRoom() {
let obj = {
ids: this.bindSelectedList
}
if (obj.ids.length > 0) {
httpPost(obj, this.$api.onlySiteDevice).then((res) => {
this.AboutDevice = res.data.list;
this.$store.commit("getAboutDevice", res.data.list);
});
}
},
checkNode1(e) {
var selectRow = []
console.log(e)
e.map(li => {
selectRow.push(li[li.length - 1])
})
this.SelectedList = selectRow
console.log(this.SelectedList)
},
// 选择绑定房间返回的子级id
checkNode2(e) {
this.credentialSearch.roomId = e[e.length - 1]
},
checkEnterpriseList(e) {
this.$nextTick(() => {
var list = this.$refs['cascader'].getCheckedNodes()
this.checkEnterpriseNode = list
})
},
checkNodeRecord(e) {
this.recordFilterCondition.roomId = e[e.length - 1]
},
childNodesDeep(nodes, arr) {
if (nodes)
nodes.forEach((ele) => {
arr.push(ele.id);
if (ele.children) {
this.childNodesDeep(ele.children, arr);
}
});
},
checkNode3(e) {
var selectRow = []
e.map(li => {
selectRow.push(li[li.length - 1])
})
// var roomlist=this.roomlist
// selectRow = this.getChild(roomlist, e[e.length - 1], [])
this.SelectedListVoucher = selectRow
},
// 绑定房间
bindsave() {
let SelectedListbind = this.bindSelectedList
let infostr = ''//JSON.parse(this.drawerRow.info);
if (typeof (this.drawerRow.info) == 'object') {
infostr = this.drawerRow.info
} else if (typeof (this.drawerRow.info) == 'string') {
infostr = JSON.parse(this.drawerRow.info)
}
var fjid = [];
var _this = this
if (this.value2[0] == '' || this.value2[1] == '') {
this.$message.error("请选择开始结束时间")
return false;
}
if (SelectedListbind.length != 0) {
SelectedListbind.forEach((li, index) => {
var str = {
cardId: this.drawerRow.id,
siteId: li,
startTime: this.value2[0],
endTime: this.value2[1]
};
var resultArr = this.AboutDevice.filter(
(_item) => _item.roomId == li
)[0];
console.log(resultArr, SelectedListbind, this.AboutDevice)
var roomName = this.zNodes.filter(item => li === item.id)
if (resultArr) {
if (resultArr.imei) {
fjid.push(str);
if (resultArr.manufactureId == 201 || resultArr.manufactureId == 221) {
var data = {
lockerId: resultArr.deviceNum,
imei: resultArr.imei,
lockerUserId: infostr.userPassword,
keyId: infostr.userPassword,
role: 0,
action: 1,
order: 6226,
cardName: this.drawerRow.name,
roomName: roomName[0].name
};
ICINLocker.addUserToLock(data.lockerId, data.imei, data
.lockerUserId, data.role, data.action, data.order, data.cardName, data
.roomName, (
callback) => {
console.log(callback);
if (callback.success) {
var locakUserdata = {
deviceNum: resultArr.deviceNum,
imei: resultArr.imei,
cardId: this.drawerRow.id,
content: JSON.stringify(
data
), //operateMode:NFC-10、把人员添加到凭证-1
type: 26,
serial: callback.data.serialNumber,
startTime: moment(this.value2[0]).valueOf() / 1000,
endTime: moment(this.value2[1]).valueOf() / 1000,
}
utils.sendLockUser(locakUserdata, (callbackLOCK) => {
})
} else {
this.$message.error(callback.msg);
if (callback.code == 201016) {
httpPost(fjid, this.$api.bindCard).then((res) => {
if (res.success) {
this.bindRoomStatus = false
this.getcheckInList()
this.getAboutRoom();
setTimeout(() => {
_this.updateRoom();
}, 1000);
this.$message.success("用户门锁已存在")
} else {
this.$message.error("添加失败")
}
});
}
}
})
if ((SelectedListbind.length - 1) === index) {
httpPost(fjid, this.$api.bindCard).then((res) => {
if (res.success) {
this.bindRoomStatus = false
this.getAboutRoom();
this.getcheckInList()
setTimeout(() => {
_this.updateRoom();
}, 1000);
} else {
this.$message.error("添加失败")
}
});
}
} else if (resultArr.manufactureId == 101) {
var userstr = {
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
userTelephone: infostr.userTelephone,
userPassword: infostr.userPassword,
password: infostr.userPassword,
operateMode: 26,
order: 6226,
passwordStartTime: this.moment(this.value2[0]).format(
"YYYYMMDDHHmmss"),
passwordEndTime: this.moment(this.value2[1]).format("YYYYMMDDHHmmss"),
is: false,
cardName: this.drawerRow.name,
roomName: roomName[0].name
};
ICINLocker.LDAddUser(userstr.deviceNum, userstr.imei, userstr.userTelephone,
userstr.userPassword, userstr.password, userstr.passwordStartTime,
userstr.passwordEndTime, userstr.operateMode, userstr.order, userstr
.cardName, userstr.roomName, false, (callback) => {
if (callback.success) {
console.log(_this.value2)
var locakUserdata = {
deviceNum: resultArr.deviceNum,
imei: resultArr.imei,
cardId: this.drawerRow.id,
content: JSON.stringify(
userstr
), //operateMode:NFC-10、把人员添加到凭证-1
type: 26,
serial: callback.data.serialNumber,
startTime: moment(_this.value2[0]).valueOf() / 1000,
endTime: moment(_this.value2[1]).valueOf() / 1000,
}
utils.sendLockUser(locakUserdata, (callbackLOCK) => {
})
if ((SelectedListbind.length - 1) === index) {
httpPost(fjid, this.$api.bindCard).then((res) => {
if (res.success) {
this.bindRoomStatus = false
this.getAboutRoom();
this.getcheckInList()
setTimeout(() => {
_this.updateRoom();
}, 1000);
} else {
this.$message.error("添加失败")
}
});
} else {
this.$message.error(callback.msg);
}
} else {
this.$message.error("添加失败")
}
})
} else if (resultArr.manufactureId == 1201) {
if ((SelectedListbind.length - 1) === index) {
httpPost(fjid, this.$api.bindCard).then((res) => {
if (res.success) {
this.bindRoomStatus = false
this.getAboutRoom();
this.getcheckInList()
setTimeout(() => {
_this.updateRoom();
}, 1000);
} else {
this.$message.error("添加失败")
}
});
}
}
} else {
fjid.push(str);
if ((SelectedListbind.length - 1) === index) {
httpPost(fjid, this.$api.bindCard).then((res) => {
if (res.success) {
this.bindRoomStatus = false
this.getAboutRoom();
this.getcheckInList()
setTimeout(() => {
_this.updateRoom();
}, 1000);
} else {
this.$message.error("添加失败")
}
});
}
}
} else {
fjid.push(str);
if ((SelectedListbind.length - 1) === index) {
httpPost(fjid, this.$api.bindCard).then((res) => {
if (res.success) {
this.bindRoomStatus = false
this.getAboutRoom();
this.getcheckInList()
setTimeout(() => {
_this.updateRoom();
}, 1000);
} else {
this.$message.error("添加失败")
}
});
} else {
return this.$message.error("该房间未绑定门锁")
}
}
});
} else {
this.$message.error("请选择要添加的房间")
}
},
// 下发凭证
putCarfidzg(resultArr, row) {
var data = {};
var userTelephone = JSON.parse(row.content).userTelephone;
var userPassword = JSON.parse(row.content).userPassword;
var startTime = new Date(this.value2[0]).getTime() / 1000
var endTime = new Date(this.value2[1]).getTime() / 1000
var passwordStartTime = new Date(this.value2[0]).getTime() / 1000
var passwordEndTime = new Date(this.value2[1]).getTime() / 1000
// var passwordStartTime = JSON.stringify(row.startTime)
// var passwordEndTime = JSON.stringify(row.endTime)
// var sort=this.getTypeSort(this.roomtable1,row.type)
var pzname = JSON.parse(row.content).pzname || ''
if (passwordStartTime.length == 13) {
passwordStartTime = startTime / 1000
}
if (passwordEndTime.length == 13) {
passwordEndTime = endTime / 1000
}
if (row.type == 11) {
// if(pzname==''){
// pzname='指纹'+sort
// }
var fpId = new Date();
var fingerprint1 = JSON.parse(row.content).fingerprint;
var str = {
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
fingerprintAlias: JSON.parse(row.content).fingerprintAlias,
userTelephone: userTelephone,
userPassword: userPassword,
password: JSON.parse(row.content).password,
length: fingerprint1.length / 2,
fpTimeId: fpId.getTime(),
operateMode: 16,
type: 1,
order: 6216,
fingerprint: fingerprint1,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
pzname: (pzname ? pzname : ''),
cardName: row.name + '-' + (pzname ? pzname : ''),
roomName: resultArr.roomName
};
var data3 = {
lockerId: resultArr.deviceNum,
imei: resultArr.imei,
order: 6216,
lockerUserId: JSON.parse(this.drawerRow.info).userPassword,
keyId: JSON.parse(this.drawerRow.info).userPassword,
fingerType: 0,
file: fingerprint1,
cardName: row.name + '-' + (pzname ? pzname : ''),
roomName: resultArr.roomName,
startTime: passwordStartTime,
endTime: passwordEndTime
};
ICINLocker.addFingerPrints(data3.lockerId, data3.imei, data3.lockerUserId, data3.fingerType, data3
.file, data3.startTime, data3.endTime, data3.cardName, data3.roomName, (callback) => {
if (callback.success) {
var data = {
cardId: this.drawerRow.id,
deviceNum: resultArr.deviceNum,
imei: resultArr.imei,
content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
type: str.type,
serial: callback.data.serialNumber,
startTime: startTime,
endTime: endTime,
order: 6216
};
httpPost(data, this.$api.addCertificates).then((res) => {
this.bindRoomStatus1 = false
this.getcertificate(); //获取凭证
});
} else {
this.$message.error(callback.msg)
}
})
} else if (row.type == 12) {
if (JSON.parse(row.content).password.length != 16) {
this.$message.error("卡格式错误,请重新录入")
return
}
// if(pzname==''){
// pzname='身份证'+sort
// }
var str = {
imei: resultArr.imei,
userTelephone: userTelephone,
cardId: row.cardId,
userPassword: userPassword,
password: JSON.parse(row.content).password,
operateMode: 13,
order: 6213,
type: 2,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
pzname: pzname,
is: false,
cardName: row.name + '-' + (pzname ? pzname : ''),
roomName: resultArr.roomName
};
var data3 = {
lockerId: resultArr.deviceNum,
imei: resultArr.imei,
lockerUserId: userPassword,
keyId: userPassword,
action: 1,
taskStatus: 1,
order: 6213,
startTime: passwordStartTime,
endTime: passwordEndTime,
cardType: 36,
cardName: row.name + '-' + (pzname ? pzname : ''),
roomName: resultArr.roomName,
cardNo: JSON.parse(row.content).password
};
ICINLocker.RfCardRegister(data3.lockerId, data3.imei, data3.keyId, data3.action, data3.taskStatus,
data3.cardNo, data3.cardType, data3.startTime, data3.endTime, data3.order, data3.cardName, data3.roomName,
(callback) => {
if (callback.success) {
var data = {
cardId: this.drawerRow.id,
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
type: str.type,
serial: callback.data.serialNumber,
startTime: startTime,
endTime: endTime,
};
httpPost(data, this.$api.addCertificates).then((res) => {
this.bindRoomStatus1 = false
this.getcertificate(); //获取凭证
});
} else {
this.$message.error(callback.msg)
}
})
} else if (row.type == 13) {
var password = ""
if (JSON.parse(row.content).password.length == 8) {
password = utils.cardFormatConversion(JSON.parse(row.content).password)
password = password + '00000000'
} else if (JSON.parse(row.content).password.length == 16) {
password = JSON.parse(row.content).password
} else {
this.$message.error("卡格式错误,请重新录入")
return
}
// if(pzname==''){
// pzname='NFC'+sort
// }
var str = {
imei: resultArr.imei,
userTelephone: userTelephone,
cardId: row.cardId,
userPassword: userPassword,
password: password,
operateMode: 10,
type: 3,
order: 6210,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
pzname: pzname,
is: false,
cardName: row.name + '-' + (pzname ? pzname : ''),
roomName: resultArr.roomName
};
var data3 = {
lockerId: resultArr.deviceNum,
lockerUserId: userPassword,
keyId: userPassword,
imei: resultArr.imei,
action: 1,
taskStatus: 1,
order: 6210,
startTime: passwordStartTime,
endTime: passwordEndTime,
cardType: 50,
cardName: row.name + '-' + (pzname ? pzname : ''),
roomName: resultArr.roomName,
cardNo: password
};
ICINLocker.RfCardRegister(data3.lockerId, data3.imei, data3.keyId, data3.action, data3.taskStatus,
data3.cardNo, data3.cardType, data3.startTime,
data3.endTime, data3.order, data3.cardName, data3.roomName, (callback) => {
if (callback.success) {
var data = {
cardId: this.drawerRow.id,
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
type: str.type,
serial: callback.data.serialNumber,
startTime: startTime,
endTime: endTime,
};
httpPost(data, this.$api.addCertificates).then((res) => {
this.bindRoomStatus1 = false
this.getcertificate(); //获取凭证
});
} else {
this.$message.error(callback.msg)
}
})
} else if (row.type == 14) {
// if(pzname==''){
// pzname='密码'+sort
// }
str = {
imei: resultArr.imei,
userTelephone: userTelephone,
cardId: row.cardId,
userPassword: userPassword,
password: JSON.parse(row.content).password,
operateMode: 7,
order: 6207,
type: 4,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
pzname: pzname,
is: false,
cardName: row.name + '-' + (pzname ? pzname : ''),
roomName: resultArr.roomName
};
var data3 = {
lockerId: resultArr.deviceNum,
imei: resultArr.imei,
order: 6207,
passwordCount: 255,
lockerUserId: userPassword,
keyId: userPassword,
startTime: passwordStartTime,
endTime: passwordEndTime,
action: 1,
password: JSON.parse(row.content).password,
cardName: row.name + '-' + (pzname ? pzname : ''),
roomName: resultArr.roomName
};
ICINLocker.addForeverPassword(data3.lockerId, data3.imei, data3.keyId, data3.action, data3.password,
data3.passwordCount, data3.startTime, data3.endTime, data3.order, data3.cardName, data3
.roomName, (callback) => {
if (callback.success) {
var data = {
cardId: this.drawerRow.id,
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
type: str.type,
serial: callback.data.serialNumber,
startTime: startTime,
endTime: endTime,
};
httpPost(data, this.$api.addCertificates).then((res) => {
this.bindRoomStatus1 = false
this.getcertificate(); //获取凭证
});
} else {
this.$message.error(callback.msg)
}
})
}
},
putCarfidLwj(resultArr, row) {
var userTelephone = JSON.parse(row.content).userTelephone;
var userPassword = JSON.parse(row.content).userPassword;
var startTime = new Date(this.value2[0]).getTime() / 1000
var endTime = new Date(this.value2[1]).getTime() / 1000
var passwordStartTime = new Date(this.value2[0]).getTime() / 1000
var passwordEndTime = new Date(this.value2[1]).getTime() / 1000
var pzname = JSON.parse(row.content).pzname || ''
if (passwordStartTime.length == 13) {
passwordStartTime = startTime / 1000
}
if (passwordEndTime.length == 13) {
passwordEndTime = endTime / 1000
}
if (row.type == 11) {
var fpId = new Date();
var fingerprint1 = JSON.parse(row.content).fingerprint;
var str = {
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
fingerprintAlias: JSON.parse(row.content).fingerprintAlias,
userTelephone: userTelephone,
userPassword: userPassword,
password: JSON.parse(row.content).password,
length: fingerprint1.length / 2,
fpTimeId: fpId.getTime(),
operateMode: 16,
type: 1,
order: 6216,
fingerprint: fingerprint1,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
pzname: (pzname ? pzname : ''),
cardName: row.name + '-' + (pzname ? pzname : ''),
roomName: resultArr.roomName
};
let data = {
code: "lwj/fpOperate",
data: {
lockerId: resultArr.deviceNum,
lockerUserId: JSON.parse(row.content).userPassword,
action: 1,
fpData: fingerprint1,
startTime: startTime,
endTime: endTime,
operateMode: 16,
order: 6216,
cardName: row.name + '-' + (pzname ? pzname : ''),
roomName: resultArr.roomName
}
}
httpPost(data, this.$api.sendCommand).then(res => {
if (res.success) {
var data = {
cardId: this.drawerRow.id,
deviceNum: resultArr.deviceNum,
imei: resultArr.imei,
content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
type: str.type,
serial: res.data.serialNumber,
startTime: startTime,
endTime: endTime,
order: 6216
};
httpPost(data, this.$api.addCertificates).then((res) => {
this.bindRoomStatus1 = false
this.getcertificate(); //获取凭证
});
} else {
this.$message.error(res.msg)
}
})
} if (row.type == 13) {
var password = ""
if (JSON.parse(row.content).password.length == 8) {
password = utils.cardFormatConversion(JSON.parse(row.content).password)
password = password + '00000000'
} else if (JSON.parse(row.content).password.length == 16) {
password = JSON.parse(row.content).password
} else {
this.$message.error("卡格式错误,请重新录入")
return
}
let startTime = new Date(this.value2[0]).getTime() / 1000
let endTime = new Date(this.value2[1]).getTime() / 1000
let data = {
code: "lwj/cardOperate",
data: {
lockerId: resultArr.deviceNum,
lockerUserId: JSON.parse(row.content).userPassword,
action: 1,
cardNo: JSON.parse(row.content).password,
startTime: startTime,
endTime: endTime,
operateMode: 10,
order: 6210,
cardName: row.name + '-' + (pzname ? pzname : ''),
roomName: resultArr.roomName
}
}
let str = {
imei: resultArr.imei,
userTelephone: userTelephone,
cardId: row.cardId,
userPassword: userPassword,
password: JSON.parse(row.content).password,
operateMode: 10,
order: 6210,
type: 3,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
pzname: pzname,
is: false,
cardName: row.name + '-' + (pzname ? pzname : ''),
roomName: resultArr.roomName
};
httpPost(data, this.$api.sendCommand).then(res => {
if (res.success) {
var data = {
cardId: this.drawerRow.id,
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
type: str.type,
serial: res.data.serialNumber,
startTime: startTime,
endTime: endTime,
};
httpPost(data, this.$api.addCertificates).then((res) => {
this.bindRoomStatus1 = false
this.getcertificate(); //获取凭证
});
} else {
this.$message.error(callback.msg)
}
})
} else if (row.type == 14) {
if (JSON.parse(row.content).password == '') {
this.$message.error('密码不能为空')
} else {
let startTime = new Date(this.value2[0]).getTime() / 1000
let endTime = new Date(this.value2[1]).getTime() / 1000
let data = {
code: "lwj/passwordOperate",
data: {
lockerId: resultArr.deviceNum,
lockerUserId: JSON.parse(row.content).userPassword,
action: 1,
password: JSON.parse(row.content).password,
startTime: startTime,
endTime: endTime,
operateMode: 7,
order: 6207,
cardName: row.name + '-' + (pzname ? pzname : ''),
roomName: resultArr.roomName
}
}
let str = {
imei: resultArr.imei,
userTelephone: userTelephone,
cardId: row.cardId,
userPassword: userPassword,
password: JSON.parse(row.content).password,
operateMode: 7,
order: 6207,
type: 4,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
pzname: pzname,
is: false,
cardName: row.name + '-' + (pzname ? pzname : ''),
roomName: resultArr.roomName
};
httpPost(data, this.$api.sendCommand).then(res => {
if (res.success) {
var data = {
cardId: this.drawerRow.id,
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
type: str.type,
serial: res.data.serialNumber,
startTime: startTime,
endTime: endTime,
};
httpPost(data, this.$api.addCertificates).then((res) => {
this.bindRoomStatus1 = false
this.getcertificate(); //获取凭证
});
} else {
this.$message.error(callback.msg)
}
})
}
}
},
// 下发凭证
putCarfid(resultArr, row) {
var data = {};
var userTelephone = JSON.parse(row.content).userTelephone;
var userPassword = JSON.parse(row.content).userPassword;
var startTime = new Date(this.value2[0]).getTime()
var endTime = new Date(this.value2[1]).getTime()
var passwordEndTime = moment(endTime).format("YYYYMMDDHHmmss");
var passwordStartTime = moment(startTime).format("YYYYMMDDHHmmss");
// var sort=this.getTypeSort(this.roomtable1,row.type)
var pzname = JSON.parse(row.content).pzname || ''
if (row.type == 11) {
// if(pzname==''){
// pzname='指纹'+sort
// }
var fpId = new Date();
var fingerprint = JSON.parse(row.content).fingerprint;
// var array = fingerprint.split(",");
// var num = this.Bytes2Str(array);
// return
var str = {
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
fingerprintAlias: JSON.parse(row.content).fingerprintAlias,
userTelephone: userTelephone,
userPassword: userPassword,
password: JSON.parse(row.content).password,
length: fingerprint.length / 2,
fpTimeId: fpId.getTime(),
operateMode: 16,
type: 1,
order: 6216,
fingerprint: fingerprint,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
cardName: row.name + '-' + pzname,
roomName: resultArr.roomName,
pzname: pzname,
pass: false
};
ICINLocker.LDAddFingerPrints(str.deviceNum, str.imei, str.userTelephone, str.userPassword, str
.password, str.passwordStartTime, str.passwordEndTime, str.operateMode, str.order, str.length,
str.fpTimeId, str.fingerprint, str.cardName, str.roomName, str.pass, (callback) => {
if (callback.success) {
var datafid = {
deviceNum: resultArr.deviceNum,
imei: resultArr.imei,
cardId: this.drawerRow.id,
content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
type: str.type,
serial: callback.data.serialNumber,
startTime: startTime / 1000,
endTime: endTime / 1000,
};
httpPost(datafid, this.$api.addCertificates).then((res) => {
if (res.success) {
this.bindRoomStatus1 = false
this.$message.success("下发成功")
this.getcertificate(); //获取凭证
} else {
this.$message.error("下发失败")
}
});
} else {
this.$message.error(callback.msg)
}
})
return false
} else if (row.type == 12) {
// if(pzname==''){
// pzname='身份证'+sort
// }
data = {
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
userTelephone: userTelephone,
cardId: row.cardId,
userPassword: userPassword,
password: JSON.parse(row.content).password,
operateMode: 13,
order: 6213,
type: 2,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
is: false,
cardName: row.name + '-' + pzname,
roomName: resultArr.roomName,
pzname: pzname,
};
} else if (row.type == 13) {
// if(pzname==''){
// pzname='NFC'+sort
// }
data = {
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
userTelephone: userTelephone,
cardId: row.cardId,
userPassword: userPassword,
password: JSON.parse(row.content).password,
operateMode: 10,
order: 6210,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
is: false,
type: 3,
cardName: row.name + '-' + pzname,
roomName: resultArr.roomName,
pzname: pzname,
};
} else if (row.type == 14) {
// if(pzname==''){
// pzname='密码'+sort
// }
data = {
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
userTelephone: userTelephone,
cardId: row.cardId,
userPassword: userPassword,
password: JSON.parse(row.content).password,
operateMode: 7,
order: 6207,
type: 4,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
is: false,
cardName: row.name + '-' + pzname,
roomName: resultArr.roomName,
pzname: pzname,
pass: false
};
}
ICINLocker.LDRfCardRegister(data.deviceNum, data.imei, data.userTelephone, data.userPassword, data
.password, data
.passwordStartTime, data.passwordEndTime, data.operateMode, data.order, data.cardName, data
.roomName, data.pass, (
callback) => {
if (callback.success) {
var datafid = {
deviceNum: resultArr.deviceNum,
imei: resultArr.imei,
cardId: this.drawerRow.id,
content: JSON.stringify(data), //operateMode:NFC-10、把人员添加到凭证-1
type: data.type,
serial: callback.data.serialNumber,
startTime: startTime / 1000,
endTime: endTime / 1000,
};
httpPost(datafid, this.$api.addCertificates).then((res) => {
if (res.success) {
this.bindRoomStatus1 = false
this.$message.success("下发成功")
this.getcertificate(); //获取凭证
} else {
this.$message.error("下发失败")
}
});
} else {
this.$message.error(callback.msg)
}
})
},
// 添加房源后更新人员和房间关系
updateRoom() {
var array = this.returnScreenRoom(this.drawerRow.id);
var SelectedList = [],
roomtable = [], roomScreen = [];
array.map((li) => {
SelectedList.push(li.roomId);
var name = utils.findIndexArray(this.$store.state.zNodes, li.roomId, [])
var path = ''
if (name) {
path = name.join('/')
}
li.roomName = path
let result = this.checkInListing.filter(item => item.siteId == li.roomId)[0]
let deviceResult = this.allAboutDevice.filter(it => it.roomId == li.roomId)[0]
if (result) {
li['endTime'] = moment(result.endTime).format("YYYY-MM-DD HH:mm:ss") || ''
li['startTime'] = moment(result.startTime).format("YYYY-MM-DD HH:mm:ss") || ''
li['name'] = result.name
li.card = li.cardId
}
if (deviceResult) {
li['deviceNum'] = deviceResult.deviceNum
li['imei'] = deviceResult.imei
li['manufactureId'] = deviceResult.manufactureId
}
if (li.isRoom == 1) {
roomScreen.push(li)
}
roomtable.push(li);
});
console.log(roomScreen);
this.roomScreen = roomScreen
this.SelectedList = SelectedList;
this.selectkeyadd = SelectedList;
var list = roomtable.sort((pre, cur) => pre.siteId - cur.siteId)
this.roomtable = list;
this.roomstatus = !this.roomstatus;
this.addroomstatus = !this.addroomstatus;
this.$message.success("操作成功");
},
// 打开侧边栏
operation(index, row) {
this.activeName = index;
this.drawerRow = row;
this.bindroomstatus = true;
this.voucher.username = row.name;
this.drawer = true;
this.personname = row.name
this.getAboutDevice1();
var data = {
ids: [row.id]
}
httpPost(data, this.$api.getTenant).then(res => {
if (res.code == 200) {
this.checkInListing = res.data
if (res.data.length > 0) {
this.maxDateTime = res.data[0].endTime
this.minDateTime = res.data[0].startTime
this.value2 = [this.minDateTime, this.maxDateTime]
} else {
this.maxDateTime = ''
this.minDateTime = ''
this.value2 = ['', '']
}
setTimeout(() => {
this.screenRoom(row.id);
}, 500)
} else {
this.checkInListing = []
}
})
this.getItems(row.siteId);
// this.getOperates(row.id);
this.getcertificate();
},
getcheckInList() {
var data = {
ids: [this.drawerRow.id]
}
httpPost(data, this.$api.getTenant).then(res => {
console.log(res);
if (res.code == 200) {
this.checkInListing = res.data
} else {
this.checkInListing = []
}
})
},
getSearchRoomList() {
var ids = []
this.roomtable.map(li => {
ids.push(li.roomId)
})
var selected_tab = [];
var selected = [];
var zNodes = this.zNodes
ids.map(function (item) {
selected_tab = zNodes.filter(function (obj) {
return obj.id == item
});
selected.push(Object.assign({}, ...selected_tab))
})
if (selected.length > 0) {
var array = utils.uniqueArray(selected, "id");
this.roomlist2 = []
this.roomlist2 = this.ztreeToElementTree(array, []);
} else {
this.roomlis2 = []
}
},
// 凭证列表获取
getcertificate() {
if (this.credentialSearch.roomId) {
var t = {
roomIds: [this.credentialSearch.roomId],
lockType: 1
};
var data = {
q: JSON.stringify(t),
};
httpPost(data, this.$api.getDeviceItems).then((res) => {
if (res.success) {
var data = {
pageNum: 0,
pageSize: 0,
orderBy: "create_at desc",
q: {
cardId: this.drawerRow.id,
deviceNum: res.data.list[0].deviceNum,
imei: this.credentialSearch.imei,
status: this.credentialSearch.status,
type: this.credentialSearch.type,
types: "10,11,12,13,14"
},
};
this.getfilterAcquisition(data)
} else {
this.$message.error("获取房间对应门锁信息失败")
}
})
} else {
var data = {
pageNum: 0,
pageSize: 0,
orderBy: "create_at desc",
q: {
cardId: this.drawerRow.id,
deviceNum: this.credentialSearch.deviceNum,
imei: this.credentialSearch.imei,
status: this.credentialSearch.status,
// type: this.credentialSearch.type,
types: this.credentialSearch.type || "10,11,12,13,14"
},
};
this.getfilterAcquisition(data)
}
},
getfilterAcquisition(data) {
console.log(data)
var dataall = {
pageNum: 0,
pageSize: 0,
orderBy: "create_at desc",
q: {
cardId: this.drawerRow.id,
deviceNum: this.credentialSearch.deviceNum,
imei: this.credentialSearch.imei,
inStatus: "0,1,702",
types: "0,1,2,3,4"
},
}
httpGet(dataall, this.$api.getCertificates).then((resall) => {
if (resall.code == 200) {
var sendOn = utils.zlib_unzip(resall.data)
console.log(sendOn)
var sendstatus = true
if (resall.data.total == 0) {
sendstatus = false
}
httpGet(data, this.$api.getCertificates).then((res) => {
let certiflist = utils.zlib_unzip(res.data);
let AboutDevice = this.allAboutDevice;
console.log(certiflist)
certiflist.map((li) => {
li['color'] = '1'
var licontent = ''
var filterResult = ''
if (li.type == 11) {
licontent = JSON.parse(li.content).pzname
filterResult = sendOn.filter(item => JSON.parse(item.content).pzname == licontent)
} else if (li.type == 13) {
// licontent=utils.cardFormatConversion(JSON.parse(li.content).password)
licontent = JSON.parse(li.content).pzname
filterResult = sendOn.filter(item => JSON.parse(item.content).pzname == licontent)
} else {
licontent = JSON.parse(li.content).password
filterResult = sendOn.filter(item => JSON.parse(item.content).password == licontent)
}
if (sendstatus && filterResult && filterResult.length > 0) {
var statusOne = filterResult.some(item => item.status == 0)
var statusTwo = filterResult.some(item => item.status == 1)
var statusThree = filterResult.some(item => item.status == 702)
if (statusOne) {
li['color'] = '0'
} else if (!statusOne && !statusThree && statusTwo) {
li['color'] = '1'
} else if (!statusOne && statusThree) {
li['color'] = '702'
} else {
li['color'] = '999'
}
}
li.createAt = this.time(+new Date(li.createAt));
li['userTelephone'] = JSON.parse(li.content).userTelephone;
li.pzname = JSON.parse(li.content).pzname;
li.password = JSON.parse(li.content).password;
li['startTimeText'] = utils.formatTime(li.startTime)
li['fingerprintAlias'] = JSON.parse(li.content).fingerprintAlias || ''
li['endTimeText'] = utils.formatTime(li.endTime)
li['data'] = JSON.parse(li.content).password
if (li.type == 1) {
li['data'] = li.id
}
if (li.pzname) {
var statusif = li.pzname.indexOf('蓝牙')
if (statusif) {
li['DeletePermissions'] = true
} else {
if (li.type != 11) {
li['DeletePermissions'] = true
} else {
li['DeletePermissions'] = false
}
}
} else {
li['DeletePermissions'] = true
}
});
this.roomtable1 = certiflist;
this.total1 = res.data.total;
});
}
})
},
// 筛选和这个人员有关的房源
screenRoom(id) {
console.log("调用");
var roomAbout = this.$store.state.roomAbout;
var SelectedList = [],
roomtable = [], roomScreen = [];
roomAbout.map((li) => {
var name = utils.findIndexArray(this.$store.state.zNodes, li.roomId, [])
var path = ''
if (name) {
path = name.join('/')
}
li.roomName = path
if (li.cardId == id) {
if (li.layout != null) {
SelectedList.push(li.roomId);
}
let result = this.checkInListing.filter(item => item.siteId == li.roomId)[0]
let deviceResult = this.allAboutDevice.filter(it => it.roomId == li.roomId)[0]
if (result) {
li['endTime'] = moment(result.endTime).format("YYYY-MM-DD HH:mm:ss") || ''
li['startTime'] = moment(result.startTime).format("YYYY-MM-DD HH:mm:ss") || ''
li['name'] = result.name
li['id'] = result.id
li.card = li.cardId
}
if (deviceResult) {
li['deviceNum'] = deviceResult.deviceNum
li['imei'] = deviceResult.imei
li['manufactureId'] = deviceResult.manufactureId
}
if (li.isRoom == 1) {
roomScreen.push(li)
}
roomtable.push(li);
}
});
this.roomtablestatus = false;
if (this.activeName == 0) {
var data = JSON.parse(JSON.stringify(this.zNodes))
// var zNodes = utils.filterObj(data, SelectedList)
var zNodes = data
var array = utils.uniqueArray(zNodes, "id");
console.log(array);
var bindRoomlist = this.ztreeToElementTree(array, []);
this.bindRoomlist = bindRoomlist
} else if (this.activeName == 1) {
var data = JSON.parse(JSON.stringify(this.zNodes))
var array = utils.uniqueArray(data, "id");
this.bindRoomlist = this.ztreeToElementTree(array, []);
// this.bindRoomlist = this.roomlist
}
var list = roomtable.sort((pre, cur) => pre.siteId - cur.siteId)
console.log(list);
this.getSearchRoomList()
this.$nextTick(function () {
this.roomtable = list;
this.SelectedList = SelectedList;
this.roomtablestatus = true;
this.roomScreen = roomScreen
});
},
ztreeToElementTree(data, config) {
var id = 'id' // 定义ztree数据存储id(自身的id)的key值,可以自定义但一般都是id、pid这种
var pid = 'pid' // 定义ztree数据存储pid(父id)的key值
var children = 'children' // 定义生成的element tree存储子节点的key,可以在element中规定defaultProps: {children: 'children'}
var idMap = {} // 将原始数据转化为以id为key的map
var elementTree = [] // 输出的element tree数据
data.forEach(item => {
item['value'] = item.id
item['label'] = item.name
idMap[item.id] = item
})
data.forEach(item => {
// debugger
if (idMap[item.pid] != idMap[item.id] && idMap[item.pid]) { // 该item项有爸爸,放到对应的父节点下
!idMap[item.pid].hasOwnProperty(children) && (idMap[item.pid][children] = [])
idMap[item.pid][children].push(item)
} else { // 根节点
elementTree.push(item)
}
});
console.log(elementTree);
return elementTree
},
// 删除操作
handleDelete(index, row) {
this.drawerRow = row
var that = this
// 二次确认删除
this.$confirm("确定要删除吗?", "提示", {
type: "warning",
}).then(() => {
var unbindCarddata = [];
this.screenRoom1(row.id, function (roomtable) {
var arr = []
roomtable.map((li) => {
var data = {
siteId: li.roomId,
cardId: row.id
};
arr.push(li.roomId)
unbindCarddata.push(data);
});
if (roomtable.length > 0) {
that.$confirm("是否先退租已入住房间?", "提示", {
type: "warning",
}).then(() => {
console.log(roomtable)
roomtable.map((li, index) => {
that.deleteRoomfun(index, li)
})
})
} else {
httpPost(unbindCarddata, that.$api.unbindCard).then((res) => {
var data = {
ids: [row.id]
};
httpPost(data, that.$api.deleteCard).then((res) => {
if (res.success) {
that.$message.success("删除成功");
that.deleteUser(row, arr);
that.getlist();
} else {
that.$message.error("删除失败");
}
});
});
}
})
});
},
//添加
handleSearch1() {
this.modify = true;
this.editVisiblelist = true;
},
// 保存编辑
saveEdit() {
// 添加人员的凭证保存
var documentType = this.documentType;
var str = {};
console.log(this.form)
if (this.form.name == "" || this.form.enterpriseId === "" || this.form.number == "" || this.form.type === "") {
this.$message.error("请填写完整信息");
} else if (IdentityCodeValid(this.form.number)) {
this.$message.error("请填写正确身份证号");
} else if (!utils.verificationPhone(this.form.phone)) {
this.$message.error("请填写正确手机号");
} else {
let phone = this.form.phone
let infostr = {
userTelephone: phone,
userPassword: phone.substring(phone.length - 6, phone.length),
userId: phone.substring(phone.length - 6, phone.length),
keyId: phone.substring(phone.length - 6, phone.length)
};
var data = {
cardId: this.form.cardId,
cardState: 1,
info: JSON.stringify(infostr),
name: this.form.name,
number: this.form.number,
phone: this.form.phone,
sex: parseInt(this.form.sex),
enterpriseId: this.form.enterpriseId,
type: this.form.type,
};
var drawerRowid = ''
RequestSet.addPeople(data, (callback) => {
if (callback.success) {
this.editVisiblelist = false;
let dataprise = []
this.checkEnterpriseNode.map(li => {
var obj = {
itemId: callback.data,
orderId: li.value,
}
dataprise.push(obj)
})
if (dataprise.length > 0) {
httpPost(dataprise, this.$api.personBindEnterprise).then(res => {
})
}
let ids = {
ids: [callback.data]
}
httpPost(ids, this.$api.createkeyCard).then(res => {
})
this.getAboutRoom();
this.getlist();
} else {
this.getlist();
}
})
if (this.WhetherToGreatAnAccount) {
var enterpriseName = this.enterpriselist.filter(item => item.id == this.form.enterpriseId)[0]
if (enterpriseName) {
var addform = {
username: this.form.number,
phone: this.form.phone,
password: '123456',
userType: 3,
identity: 3,
tenantId: this.$store.state.tenantId,
enterpriseName: enterpriseName.name,
enterpriseId: this.form.enterpriseId
}
httpPost(addform, this.$api.addUser).then((res3) => {
if (res3.success) {
this.$message.success("创建账号成功")
} else {
this.$message.error("创建账号失败")
}
})
} else {
this.$message.error("请选择所属部门")
}
}
}
},
// 录入凭证
bindsave1() {
let documentType = this.documentType;
let str = {};
let cardName = this.drawerRow.name,
pzname = '';
if (documentType == '请选择') {
this.$message.error("请选择凭证类型")
return false;
}
if (this.value2[0] == '' || this.value2[1] == '') {
this.$message.error("请选择开始结束时间")
return false;
}
console.log(this.value2)
let sort = this.getTypeSort(this.roomtable1, documentType)
pzname = this.voucher.pzname || ''
if (documentType == 11 && this.voucher.fingerprintAlias == '') {
this.$message.error("请选择指纹别名");
return false
}
if (documentType == 10) {
this.$message.error("人脸暂未开放");
return
} else if (documentType == 11) {
var fingerprint = localStorage.getItem("fingerprint");
var indexofstr = fingerprint.indexOf(',')
if (indexofstr != -1) {
var array = fingerprint.split(",");
var num = this.Bytes2Str(array);
fingerprint = num
}
if (pzname == '') {
pzname = '指纹' + sort
}
str = {
username: this.voucher.username,
pzname: pzname,
userTelephone: JSON.parse(this.drawerRow.info).userTelephone,
userPassword: JSON.parse(this.drawerRow.info).userPassword,
keyId: JSON.parse(this.drawerRow.info).keyId || '',
userId: JSON.parse(this.drawerRow.info).userId || '',
fingerprintAlias: this.voucher.fingerprintAlias,
password: "",
passwordStartTime: moment(this.value2[0]).format('YYYYMMDDHHmmss'),
passwordEndTime: moment(this.value2[1]).format('YYYYMMDDHHmmss'),
operateMode: 16,
order: 6216,
fingerprint: fingerprint,
};
let data = {
cardId: this.drawerRow.id,
content: JSON.stringify(str),
type: documentType,
startTime: parseInt(moment(this.value2[0]).valueOf() / 1000),
endTime: parseInt(moment(this.value2[1]).valueOf() / 1000),
};
httpPost(data, this.$api.addCertificates).then((res) => {
this.$message.success('下发成功')
this.roomstatus1 = true;
this.getcertificate(); //获取凭证
});
return false;
} else if (documentType == 12) {
var arr2 = ''
if (this.voucher.idcard.length == 16) {
arr2 = this.voucher.idcard
} else if (this.voucher.idcard.length == 0) {
this.$message.error("请输入身份证")
return false
} else {
arr2 = dec2hex(this.voucher.idcard);
}
if (pzname == '') {
pzname = '身份证' + sort
}
str = {
username: this.voucher.username,
pzname: pzname,
userTelephone: JSON.parse(this.drawerRow.info).userTelephone,
userPassword: JSON.parse(this.drawerRow.info).userPassword,
keyId: JSON.parse(this.drawerRow.info).keyId || '',
userId: JSON.parse(this.drawerRow.info).userId || '',
operateMode: 13,
order: 6213,
password: arr2.toUpperCase(), //this.voucher.idcard,
passwordStartTime: moment(this.value2[0]).format('YYYYMMDDHHmmss'),
passwordEndTime: moment(this.value2[1]).format('YYYYMMDDHHmmss'),
is: false,
};
} else if (documentType == 13) {
var nfc = "";
if (this.voucher.nfc.length == 8) {
nfc = this.voucher.nfc
} else if (this.voucher.nfc.length == 0) {
this.$message.error("请输入NFC")
return false
} else {
var array3 = dec2hex(this.voucher.nfc);
var arr4 = group(array3, 2)
arr4.map((li) => {
nfc += li;
});
}
if (pzname == '') {
pzname = 'NFC' + sort
}
if (this.regularCard) {
nfc = nfc + 'AA55'
}
str = {
username: this.voucher.username,
pzname: pzname,
operateMode: 10,
order: 6210,
userTelephone: JSON.parse(this.drawerRow.info).userTelephone,
userPassword: JSON.parse(this.drawerRow.info).userPassword,
keyId: JSON.parse(this.drawerRow.info).keyId || '',
userId: JSON.parse(this.drawerRow.info).userId || '',
password: nfc.toUpperCase(), //this.voucher.nfc,
passwordStartTime: moment(this.value2[0]).format('YYYYMMDDHHmmss'),
passwordEndTime: moment(this.value2[1]).format('YYYYMMDDHHmmss'),
is: false
};
} else if (documentType == 14) {
if (this.voucher.password.length != 6) {
this.$message.error("密码长度为6位")
return false
} else if (this.voucher.password.length == 0) {
this.$message.error("请输入密码")
return false
}
if (pzname == '') {
pzname = '密码' + sort
}
str = {
username: this.voucher.username,
pzname: pzname,
// imei: this.deviceList[0].imei,
password: this.voucher.password,
userTelephone: JSON.parse(this.drawerRow.info).userTelephone,
userPassword: JSON.parse(this.drawerRow.info).userPassword,
keyId: JSON.parse(this.drawerRow.info).keyId || '',
userId: JSON.parse(this.drawerRow.info).userId || '',
operateMode: 7,
order: 6207,
passwordStartTime: moment(this.value2[0]).format('YYYYMMDDHHmmss'),
passwordEndTime: moment(this.value2[1]).format('YYYYMMDDHHmmss'),
is: false,
};
}
var data = {
cardId: this.drawerRow.id,
content: JSON.stringify(str),
type: documentType,
startTime: moment(this.value2[0]).valueOf() / 1000,
endTime: moment(this.value2[1]).valueOf() / 1000
};
httpPost(data, this.$api.addCertificates).then((res) => {
this.$message.success('添加成功')
this.roomstatus1 = true;
this.getcertificate();
});
},
// 重新下发凭证
Issue(index, row) {
var data = {};
var userTelephone = JSON.parse(row.content).userTelephone;
var userPassword = JSON.parse(row.content).userPassword;
var passwordEndTime = JSON.parse(row.content).passwordEndTime;
var passwordStartTime = JSON.parse(row.content).passwordStartTime;
var q = {
deviceNum: row.deviceNum,
lockType: 1
// imei: row.imei
};
var data = {
q: JSON.stringify(q),
pageNum: 1,
pageSize: 10,
};
this.$confirm("确定要重新下发吗?", "提示", {
type: "warning",
}).then(() => {
httpPost(data, this.$api.getDeviceItems).then((res) => {
if (res.data.list.length > 0) {
if (res.data.list[0].manufactureId == 201 || res.data.list[0].manufactureId == 221) {
if (row.type == 1) {
var fpId = new Date();
var fingerprint = JSON.parse(row.content).fingerprint;
var pwd = JSON.parse(row.content).userPassword
var startTime = JSON.stringify(row.startTime)
var endTime = JSON.stringify(row.endTime)
if (startTime.length == 13) {
startTime = Number(row.startTime / 1000)
}
if (endTime.length == 13) {
endTime = Number(row.endTime / 1000)
}
ICINLocker.addFingerPrints(row.deviceNum, row.imei, pwd, 0,
fingerprint, startTime,
endTime, (callback) => {
if (callback.success) {
var str1 = JSON.parse(row.content);
str1.fpTimeId = callback.serialNumber;
var updatedata = {
id: row.id,
content: JSON.stringify(str1),
serial: callback.serialNumber,
};
httpPost(updatedata, this.$api.updateCertificates)
.then(
(res2) => {
}
);
this.obtainVoucherIssuanceRecord()
this.$message.success(callback.msg)
} else {
this.$message.error(callback.msg)
}
})
} else if (row.type == 2) {
var pwd = JSON.parse(row.content).password
var userid = JSON.parse(row.content).userPassword
if (pwd.length != 16) {
this.$message.error("卡格式错误,请重新录入")
return
}
var startTime = JSON.stringify(row.startTime)
var endTime = JSON.stringify(row.endTime)
if (startTime.length == 13) {
startTime = Number(row.startTime / 1000)
}
if (endTime.length == 13) {
endTime = Number(row.endTime / 1000)
}
ICINLocker.RfCardRegister(row.deviceNum, row.imei, userid, 1, 1, pwd,
36,
startTime, endTime, 6210, (callback) => {
if (callback.success) {
var updatedata = {
id: row.id,
serial: callback.serialNumber,
};
httpPost(updatedata, this.$api.updateCertificates)
.then((
res) => {
});
this.$message.success(callback.msg)
this.obtainVoucherIssuanceRecord()
} else {
this.$message.error(callback.msg)
this.obtainVoucherIssuanceRecord()
}
})
} else if (row.type == 3) {
var pwd = JSON.parse(row.content).password
var userid = JSON.parse(row.content).userPassword
if (pwd.length != 8) {
this.$message.error("卡格式错误,请重新录入")
return
}
pwd = pwd + '00000000'
var startTime = JSON.stringify(row.startTime)
var endTime = JSON.stringify(row.endTime)
if (startTime.length == 13) {
startTime = Number(row.startTime / 1000)
}
if (endTime.length == 13) {
endTime = Number(row.endTime / 1000)
}
ICINLocker.RfCardRegister(row.deviceNum, row.imei, userid, 1, 1, pwd,
50,
startTime, endTime, 6210, (callback) => {
if (callback.success) {
var updatedata = {
id: row.id,
serial: callback.serialNumber,
};
httpPost(updatedata, this.$api.updateCertificates)
.then((
res) => {
});
this.$message.success(callback.msg)
this.obtainVoucherIssuanceRecord()
} else {
this.$message.error(callback.msg)
this.obtainVoucherIssuanceRecord()
}
})
} else if (row.type == 4) {
var pwd = JSON.parse(row.content).password
var userid = JSON.parse(row.content).userPassword
var startTime = JSON.stringify(row.startTime)
var endTime = JSON.stringify(row.endTime)
if (startTime.length == 13) {
startTime = Number(row.startTime / 1000)
}
if (endTime.length == 13) {
endTime = Number(row.endTime / 1000)
}
ICINLocker.addForeverPassword(row.deviceNum, row.imei, userid, 1, pwd,
255,
startTime, endTime, 6207, (callback) => {
if (callback.success) {
var updatedata = {
id: row.id,
serial: callback.serialNumber,
};
httpPost(updatedata, this.$api.updateCertificates)
.then((
res) => {
});
this.$message.success(callback.msg)
this.obtainVoucherIssuanceRecord()
} else {
this.$message.error(callback.msg)
this.obtainVoucherIssuanceRecord()
}
})
}
} else if (res.data.list[0].manufactureId == 101) {
if (row.type == 1) {
var fpId = new Date();
var fingerprint = JSON.parse(row.content).fingerprint;
var str = {
imei: row.imei,
deviceNum: row.deviceNum,
userTelephone: userTelephone,
userPassword: userPassword,
password: JSON.parse(row.content).password,
length: fingerprint.length / 2,
fpTimeId: fpId.getTime(),
operateMode: 16,
order: 6216,
fingerprint: fingerprint,
fingerprintStartTime: passwordStartTime,
fingerprintEndTime: passwordEndTime,
};
httpPost(str, this.$api.fingerprintTransfer).then((res1) => {
if (res1.success) {
var str1 = JSON.parse(row.content);
str1.fpTimeId = str.fpTimeId;
var updatedata = {
id: row.id,
content: JSON.stringify(str1),
serial: res1.data.serialNumber,
};
httpPost(updatedata, this.$api.updateCertificates)
.then(
(res2) => {
}
);
this.$message.success("下发成功");
this.obtainVoucherIssuanceRecord()
} else {
this.$message.error("下发失败");
this.obtainVoucherIssuanceRecord()
}
});
this.$message.success("操作成功");
return false;
} else if (row.type == 2) {
data = {
imei: row.imei,
deviceNum: row.deviceNum,
userTelephone: userTelephone,
cardId: row.cardId,
userPassword: userPassword,
password: JSON.parse(row.content).password,
operateMode: 13,
order: 6213,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
is: false,
};
} else if (row.type == 3) {
data = {
imei: row.imei,
deviceNum: row.deviceNum,
userTelephone: userTelephone,
cardId: row.cardId,
userPassword: userPassword,
password: JSON.parse(row.content).password,
operateMode: 10,
order: 6210,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
is: false,
};
} else if (row.type == 4) {
data = {
imei: row.imei,
deviceNum: row.deviceNum,
userTelephone: userTelephone,
cardId: row.cardId,
userPassword: userPassword,
password: JSON.parse(row.content).password,
operateMode: 7,
order: 6207,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
is: false,
};
}
httpPost(data, this.$api.getDeviceOperateUserInfo).then((res) => {
if (res.success) {
var updatedata = {
id: row.id,
serial: res.data.serialNumber,
};
httpPost(updatedata, this.$api.updateCertificates).then((
res) => {
});
this.$message.success("下发成功");
this.obtainVoucherIssuanceRecord()
} else {
this.$message.error("下发失败");
this.obtainVoucherIssuanceRecord()
}
});
}
} else {
this.$message.error("未发现这个设备")
}
})
})
},
// 解除绑定
UnbindFun(index, row) {
this.$confirm('是否只解除平台关系', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
var data = [{
siteId: row.roomId,
cardId: this.drawerRow.id,
},];
httpPost(data, this.$api.unbindCard).then((res) => {
if (res.success) {
this.getAboutRoom()
setTimeout(() => {
this.updateRoom()
}, 500)
this.screenRoom(this.drawerRow.id);
this.$message.success("解绑成功")
} else {
this.$message.error("解绑失败")
}
})
})
},
// 下载模板
workbook2blob(workbook) {
// 生成excel的配置项
var wopts = {
// 要生成的文件类型
bookType: 'xlsx',
// // 是否生成Shared String Table,官方解释是,如果开启生成速度会下降,但在低版本IOS设备上有更好的兼容性
bookSST: false,
type: 'binary'
}
var wbout = XLSX.write(workbook, wopts)
// 将字符串转ArrayBuffer
function s2ab(s) {
var buf = new ArrayBuffer(s.length)
var view = new Uint8Array(buf)
for (var i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xff
return buf
}
let buf = s2ab(wbout)
var blob = new Blob([buf], {
type: 'application/octet-stream'
})
return blob
},
// 将blob对象 创建bloburl,然后用a标签实现弹出下载框
openDownloadDialog(blob, fileName) {
if (typeof blob === 'object' && blob instanceof Blob) {
blob = URL.createObjectURL(blob) // 创建blob地址
}
var aLink = document.createElement('a')
aLink.href = blob
// HTML5新增的属性,指定保存文件名,可以不要后缀,注意,有时候 file:///模式下不会生效
aLink.download = fileName || ''
var event
if (window.MouseEvent) event = new MouseEvent('click')
// 移动端
else {
event = document.createEvent('MouseEvents')
event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
}
aLink.dispatchEvent(event)
},
exportBtn() {
this.exportExcel()
},
exportExcel() {
let sheet1data = [
['人员名称', '房间ID', '房间名称', '学工号', '卡号', '电话(为11位手机号码)', '性别(1为男,2为女)', '开锁方式(3为NFC,4为密码)',
'内容(NFC为8位16进制物理卡号、密码为6位数字密码)'
]
]
var sheet1 = XLSX.utils.json_to_sheet(sheet1data, {
skipHeader: true,
})
// 创建一个新的空的workbook
var wb = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(wb, sheet1, '人员导入模板')
// XLSX.utils.book_append_sheet(wb, sheet2, '行政部')
// XLSX.utils.book_append_sheet(wb, sheet3, '前端部')
const workbookBlob = this.workbook2blob(wb)
this.openDownloadDialog(workbookBlob, '人员导入模板.xlsx')
},
hexStringToBuffer(hex) {
let buffer = new ArrayBuffer(hex.length / 2);
let byteStream = new Uint8Array(buffer);
let i = 0;
while (hex.length >= 2) {
var x = parseInt(hex.substring(0, 2), 16);
hex = hex.substring(2, hex.length);
byteStream[i++] = x;
}
return byteStream;
},
// 采集指纹
addfir() {
let _this = this
this.$refs.myChild.addFingerprintFun(0x8014, function (data) {
localStorage.setItem('fingerprint', data)
_this.localFingerprint = data
})
},
async getFingerData() {
let _this = this
await this.$refs.myGetFinger.DetectFinger()
await this.$refs.myGetFinger.getFingerData('', function (data) {
console.log(data)
localStorage.setItem('fingerprint', data.template)
_this.localFingerprint = data.template
})
},
setVoucherNfc(data) {
if (data.cardType == 50) {
var nfc = ""
var str = data.cardNo.substr(0, 8)
var arr4 = group(str, 2).reverse();
arr4.map((li) => {
nfc += li;
});
this.voucher.nfc = nfc.toUpperCase()
console.log(this.voucher.nfc)
} else if (data.cardType == 36) {
this.voucher.idcard = data.cardNo.toUpperCase()
}
},
writeNfc() {
var _this = this
this.$refs.myChild.writeCard(0x8011, function (data) {
if (data.status == 0) {
console.log(data)
} else {
console.log(data)
_this.$message.error("写卡错误,请检查读卡器是否正常!")
}
})
},
addNfc() {
var _this = this
this.$refs.myChild.cardFun(0x8010, function (data) {
if (data.status == 0) {
console.log(data)
_this.setVoucherNfc(data)
} else {
_this.$message.error("读卡错误,请检查读卡器是否正常!")
}
})
},
// input视图刷新
changesr(e) {
this.$forceUpdate();
},
// 加入信息库
addInformationBase(index, row) {
var info = JSON.parse(row.content);
var obj = {},
content = {},
arr = [];
content["type"] = row.type;
content["order"] = info.order;
content["cardId"] = info.cardId;
content["pzname"] = info.pzname;
if (row.type == 1) {
content["content"] = info.fingerprint;
} else {
content["content"] = info.password;
}
content["operateMode"] = info.operateMode;
content["userPassword"] = info.userPassword;
content["userTelephone"] = info.userTelephone;
content["length"] = info.length;
obj.cardId = this.drawerRow.id;
obj.content = JSON.stringify(content);
arr.push(obj);
var data = {
list: arr,
};
httpPost(data, this.$api.addMark).then((res) => {
if (res.success) {
this.$message.success("操作成功");
}
});
},
//多选删除房间数据
selectRoomdelete(val) {
this.selectRoomdeletelist = val;
},
// 清理房间
qlfj() {
var info = JSON.parse(this.drawerRow.info);
var info1 = {
roomIds: [],
userPassword: info.userPassword,
userTelephone: info.userTelephone,
};
var data1 = {
id: this.drawerRow.id,
info: JSON.stringify(info1),
};
httpPost(data1, this.$api.updateCard).then((res) => {
});
},
// 退租
rentWithdrawal(index, row) {
this.batchRenewalList = [row]
this.batchLeaseback()
},
// 删除房间
deleteRoomfun(index, row) {
var that = this
var resultArr = this.AboutDevice.filter((_item) => _item.roomId == row.roomId)[0];
console.log(resultArr, this.drawerRow.id)
if (resultArr) {
RequestSet.unbindPeopleAndRooms(this.drawerRow.id, resultArr.imei, (callback) => {
if (callback.success) {
let dataOne = utils.zlib_unzip(callback.data)
if (dataOne.length > 0) {
var data = dataOne[0]
if (data.status == 0) {
that.$message.error("该房间正在下发此用户,不能删除!")
} else if (data.status == 1) {
that.deleteRelationshipBetweenPersonnelAndRoom(index, row)
that.getcheckInList()
that.updateRoom()
} else if (data.status == 703) {
that.deleteRelationshipBetweenPersonnelAndRoom(index, row)
that.getcheckInList()
} else {
that.deleteRelationshipBetweenPersonnelAndRoom(index, row)
that.updateRoom()
}
} else {
that.deleteRelationshipBetweenPersonnelAndRoom(index, row)
that.getcheckInList()
that.updateRoom()
}
} else {
that.deleteRelationshipBetweenPersonnelAndRoom(index, row)
that.getcheckInList()
that.updateRoom()
}
})
} else {
that.deleteRelationshipBetweenPersonnelAndRoom(index, row)
that.getcheckInList()
that.updateRoom()
}
},
deleteRelationshipBetweenPersonnelAndRoom(index, row) {
var info = JSON.parse(this.drawerRow.info);
var data = [{
siteId: row.roomId,
cardId: this.drawerRow.id,
},];
httpPost(data, this.$api.unbindCard).then((res) => {
if (res.success) {
var array = this.roomtable,
SelectedList = [],
roomtable = [];
this.roomtable.map((item, Index) => {
if (item.roomId == row.roomId) {
array.splice(Index, 1);
}
});
array.map((li) => {
SelectedList.push(li.roomId);
});
this.getcheckInList()
this.getAboutRoom()
setTimeout(() => {
this.updateRoom()
}, 500)
// this.roomtablestatus = false
this.selectRoom = false
this.$nextTick(function () {
this.SelectedList = SelectedList;
this.roomtable = roomtable;
this.selectRoom = true
// this.roomtablestatus = true
});
var resultArr = this.AboutDevice.filter(
(_item) => _item.roomId == row.roomId
)[0];
if (resultArr) {
if (resultArr.imei) {
if (resultArr.manufactureId == 201 || resultArr.manufactureId == 221) {
var data = {
lockerId: resultArr.deviceNum,
imei: resultArr.imei,
lockerUserId: info.userPassword,
keyId: info.userPassword,
role: 0,
action: 2, //1--添加、2--删除、3--修改
order: 6203,
cardName: this.drawerRow.name,
roomName: resultArr.roomName
}
httpPost(data, this.$api.ZGduserOperation).then(res => {
if (res.success) {
this.$message.success('删除用户成功')
} else {
this.$message.error(res.msg)
}
})
} else if (resultArr.manufactureId == 101) {
var str = {
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
userTelephone: info.userTelephone,
userPassword: info.userPassword,
operateMode: 3,
order: 6203,
password: "20210816",
cardName: this.drawerRow.name,
roomName: resultArr.roomName,
is: false,
};
httpPost(str, this.$api.getDeviceOperateUserInfo).then(
(res1) => {
if (res1.success) {
this.$message.success("删除用户成功");
} else {
this.$message.error(res1.msg);
}
}
);
}
}
}
this.screenRoom(this.drawerRow.id);
this.$message.success("解绑房间成功");
}
});
},
getRandomNumber(n) {
var arr = new Array(n); //用于存放随机数
var randomNumber = ""; //存放随机数
for (i = 0; i < arr.length; i++) arr[i] = parseInt(Math.random() * 10);
var flag = 0;
for (i = 0; i < arr.length - 1; i++) {
for (j = i + 1; j < arr.length; j++) {
if (arr[i] == arr[j]) {
flag = 1;
break;
}
}
if (flag) break;
}
for (var i = 0; i < arr.length; i++) {
randomNumber += arr[i];
}
return randomNumber;
},
// 修改凭证
modifyCraiFun() {
var that = this;
var row = this.modifyrow;
var content = JSON.parse(row.content);
var passwordStartTime = moment(this.value2[0].getTime()).format('YYYYMMDDHHmmss')
var passwordEndTime = moment(this.value2[1].getTime()).format('YYYYMMDDHHmmss')
content.pzname = that.certificatesContent.pzname
content.passwordStartTime = passwordStartTime
content.passwordEndTime = passwordEndTime
var updatedata = {
id: row.id,
content: JSON.stringify(content),
startTime: this.value2[0].getTime() / 1000,
endTime: this.value2[1].getTime() / 1000
};
httpPost(updatedata, that.$api.updateCertificates)
.then((res2) => {
that.getcertificate();
that.certificatestatus = false;
});
},
modifyCrai(index, row) {
this.modifyrow = row;
var content = JSON.parse(row.content);
this.documentType1 = row.type;
this.certificatesContent.username = content.username;
this.certificatesContent.pzname = content.pzname;
this.certificatesContent.password = content.password;
var passwordStartTime = '',
passwordEndTime = ''
if (row.startTime && row.endTime) {
var str1 = JSON.stringify(row.startTime)
var str2 = JSON.stringify(row.endTime)
if (str1.length == 13 && str2.length == 13) {
passwordStartTime = moment(row.startTime).format('YYYY-MM-DD HH:mm:ss')
passwordEndTime = moment(row.endTime).format('YYYY-MM-DD HH:mm:ss')
} else if (str1.length == 10 && str2.length == 10) {
passwordStartTime = moment(row.startTime * 1000).format('YYYY-MM-DD HH:mm:ss')
passwordEndTime = moment(row.endTime * 1000).format('YYYY-MM-DD HH:mm:ss')
}
} else if (!row.deviceNum.indexOf('yxwl')) {
passwordStartTime = this.insertStr(content.endTime, "-");
passwordEndTime = this.insertStr(content.passwordEndTime, "-");
}
this.modifyStatus = false;
this.$nextTick(function () {
this.modifyvalue2[0] = passwordStartTime;
this.modifyvalue2[1] = passwordEndTime;
this.modifyStatus = true;
});
this.certificatestatus = true;
},
insertStr(soure, newStr) {
return (
soure.slice(0, 4) +
newStr +
soure.slice(4, 6) +
newStr +
soure.slice(6, 8) +
" " +
soure.slice(8, 10) +
":" +
soure.slice(10, 12) +
":" +
soure.slice(12, 14)
);
},
//所选房源
handleCheckChange() {
this.selectkey = this.$refs.tree.getCheckedKeys();
},
// 房源添加
handleCheckChangeadd() {
this.selectkeyadd = this.$refs.tree2.getCheckedKeys();
},
//所选房源
handleCheckChange1() {
this.selectkey1 = this.$refs.tree1.getCheckedKeys();
},
markFun(e) {
var info = this.tableData[e];
this.documentType = info.type;
if (info.type == 1) {
localStorage.setItem("fingerprint", info.content);
} else if (info.type == 2) {
this.voucher.idcard = info.content;
} else if (info.type == 3) {
this.voucher.nfc = info.content;
} else if (info.type == 4) {
this.voucher.password = info.content;
}
},
// 获取信息库
getOperates(id) {
// var data = {
// q: JSON.stringify({
// cardId: id,
// }),
// };
// httpGet(data, this.$api.getMark).then((res) => {
// var array = [];
// res.data.map((li) => {
// var str = JSON.parse(li.content);
// str.id = li.id;
// str.cardId = li.cardId;
// array.push(str);
// });
// this.tableData = array;
// });
},
// 人脸图片上传功能
handleRemove(file) {
console.log(file);
},
handlePictureCardPreview(file) {
this.dialogImageUrl = file.url;
this.dialogVisible1 = true;
},
handleDownload(file) {
console.log(file);
},
selectCheck(e) {
if (e == "左手大拇指") {
this.fingerprintId = 0;
} else if (e == "左手食指") {
this.fingerprintId = 1;
} else if (e == "右手大拇指") {
this.fingerprintId = 2;
} else if (e == "右手食指") {
this.fingerprintId = 3;
}
},
// 分页
handleSizeChange1(val) {
this.pageSize1 = val
this.obtainVoucherIssuanceRecord();
},
handleCurrentChange1(val) {
this.currentPage1 = val
this.obtainVoucherIssuanceRecord();
},
getlistNum1(val, size) {
var dataall = {
pageNum: 0,
pageSize: 0,
orderBy: "create_at desc",
q: {
cardId: this.drawerRow.id,
deviceNum: this.credentialSearch.deviceNum,
imei: this.credentialSearch.imei,
inStatus: "0,1,702",
types: "0,1,2,3,4"
},
}
httpGet(dataall, this.$api.getCertificates).then((resall) => {
if (resall.code == 200) {
var sendOn = utils.zlib_unzip(resall.data)
var sendstatus = true
if (resall.data.total == 0) {
sendstatus = false
}
var data = {
pageNum: this.currentPage1,
pageSize: this.pageSize1,
orderBy: "create_at desc",
q: {
cardId: this.drawerRow.id,
type: '1,2,3,4'
},
};
httpGet(data, this.$api.getCertificates).then((res) => {
var certiflist = utils.zlib_unzip(res.data);
var AboutDevice = this.allAboutDevice;
certiflist.map((li) => {
li['color'] = '1'
var licontent = JSON.parse(li.content).password
var filterResult = sendOn.filter(item => JSON.parse(item.content).password == licontent)
if (sendstatus && filterResult && filterResult.length > 0) {
var statusOne = filterResult.some(item => item.status == 0)
var statusTwo = filterResult.some(item => item.status == 1)
var statusThree = filterResult.some(item => item.status == 702)
if (statusOne) {
li['color'] = '0'
} else if (!statusOne && !statusThree && statusTwo) {
li['color'] = '1'
} else if (!statusOne && statusThree) {
li['color'] = '702'
} else {
li['color'] = '999'
}
}
li.createAt = this.time(+new Date(li.createAt));
li.userTelephone = JSON.parse(li.content).userTelephone;
li.pzname = JSON.parse(li.content).pzname;
li['startTimeText'] = utils.formatTime(li.startTime)
li['endTimeText'] = utils.formatTime(li.endTime)
li['data'] = JSON.parse(li.content).password
if (li.type == 1) {
li['data'] = li.id
}
if (li.pzname) {
var statusif = li.pzname.indexOf('蓝牙') || -1
if (statusif) {
li['DeletePermissions'] = true
} else {
if (li.type != 11) {
li['DeletePermissions'] = true
} else {
li['DeletePermissions'] = false
}
}
} else {
li['DeletePermissions'] = false
}
});
var array = utils.uniqueArray(certiflist, "data");
this.roomtable1 = certiflist;
this.total1 = res.data.total;
});
}
})
},
// 获取指纹id
getfiId(row, callback) {
var content = JSON.parse(row.content);
var data = {
q: JSON.stringify({
serial: row.serial,
}),
pageNum: 1,
pageSize: 10,
};
httpPost(data, this.$api.getDeviceResult).then((res) => {
let datalist = utils.zlib_unzip(res.data)
callback(datalist);
});
},
// 获取指纹id
getfiId1(row, callback) {
var data = {
q: JSON.stringify({
serial: row.serial
}),
pageNum: 1,
pageSize: 10,
};
httpPost(data, this.$api.getDeviceResult).then((res) => {
let datalist = utils.zlib_unzip(res.data)
callback(datalist);
});
},
// 批量删除凭证
deleAll() {
// console.log(this.multipleSelection4)
// return
var multipleSelection4 = this.multipleSelection4
this.$confirm("确定要删除吗?", "提示", {
type: "warning",
}).then(() => {
multipleSelection4.map((li, index) => {
this.deletefun2(index, li)
})
});
},
// 删除凭证操作
deletefun2(index, row) {
// 二次确认删除
var ids = this.roomtable;
var that = this;
var str = {};
var q = {
deviceNum: row.deviceNum,
imei: row.imei,
lockType: 1
};
var data = {
q: JSON.stringify(q),
pageNum: 1,
pageSize: 10,
};
httpPost(data, this.$api.getDeviceItems).then((res) => {
if (res.data.list.length > 0) {
var cardName = row.name + '-' + JSON.parse(row.content).pzname
if (res.data.list[0].manufactureId == 201 || res.data.list[0].manufactureId == 221) {
if (row.type == 1) {
this.getfiId1(row, function (data) {
if (data.length > 0) {
ICINLocker.delFingerPrints(row.deviceNum, row.imei,
JSON.parse(row.content).userPassword, 2, data[
0].face, 0, row.startTime, row.endTime, cardName, res
.data.list[0].roomName, (
callback) => {
if (callback.success) {
var content = JSON.parse(row.content)
content.operateMode = 18
var updatedata = {
id: row.id,
status: 0,
content: JSON.stringify(content),
// serial: callback.data.serialNumber,
};
httpPost(updatedata, that.$api.updateCertificates).then((res) => {
});
that.$message.success("删除成功!");
} else {
that.$message.error(callback.msg)
}
})
} else {
that.$message.success("未找到对应锁上凭证记录");
}
})
} else if (row.type == 2) {
this.getfiId1(row, function (data) {
if (data.length > 0) {
if (JSON.parse(row.content).password.length != 16) {
this.$confirm("卡格式错误,请重新录入", "提示", {
type: "warning",
})
.then(() => {
})
} else {
ICINLocker.delCardRegister(row.deviceNum, row.imei,
JSON.parse(row.content).userPassword, 2, 1,
JSON.parse(row.content).password, 36, row
.startTime, row.endTime, 6212, data[0]
.face, cardName, res.data.list[0].roomName, (
callback) => {
if (callback.success) {
var content = JSON.parse(row.content)
content.operateMode = 15
var updatedata = {
id: row.id,
status: 0,
content: JSON.stringify(content),
// serial: callback.data.serialNumber,
};
httpPost(updatedata, that.$api.updateCertificates).then((res) => {
});
that.$message.success("删除成功!");
} else {
that.$message.error(callback.msg)
}
})
}
} else {
that.$message.success("未找到对应锁上凭证记录");
}
})
} else if (row.type == 3) {
this.getfiId1(row, function (data) {
console.log(data)
if (data.length > 0) {
if (JSON.parse(row.content).password.length != 8) {
this.$confirm("卡格式错误,是否删除重新录入", "提示", {
type: "warning",
})
.then(() => {
var data = {
ids: [row.id],
};
httpPost(data, that.$api
.deleteCertificates).then((
res) => {
if (res.success) {
that.$message.success(
"删除成功!");
that.getcertificate();
}
});
})
} else {
ICINLocker.delCardRegister(row.deviceNum, row.imei,
JSON.parse(row.content).userPassword, 2, 1,
JSON.parse(row.content).password, 50, row
.startTime, row.endTime, 6212, data[0]
.face, cardName, res.data.list[0].roomName, (
callback) => {
if (callback.success) {
var content = JSON.parse(row.content)
content.operateMode = 12
var updatedata = {
id: row.id,
status: 0,
content: JSON.stringify(content),
// serial: callback.data.serialNumber,
};
httpPost(updatedata, that.$api.updateCertificates).then((res) => {
});
that.$message.success("删除成功!");
} else {
that.$message.error(callback.msg)
}
})
}
} else {
that.$message.success("未找到对应锁上凭证记录");
}
})
} else if (row.type == 4) {
this.getfiId1(row, function (data) {
if (data.length > 0) {
ICINLocker.delForeverPassword(row.deviceNum, row.imei,
JSON.parse(row.content).userPassword, 2, JSON
.parse(row.content).password, 255, row
.startTime, row.endTime, 6209, data[0].face, cardName, res
.data.list[0].roomName, (
callback) => {
if (callback.success) {
var content = JSON.parse(row.content)
content.operateMode = 9
var updatedata = {
id: row.id,
status: 0,
content: JSON.stringify(content),
// serial: callback.data.serialNumber,
};
httpPost(updatedata, that.$api.updateCertificates).then((res) => {
});
that.$message.success("删除成功!");
} else {
that.$message.error(callback.msg)
}
})
} else {
that.$message.success("未找到对应锁上凭证记录");
}
})
}
} else if (res.data.list[0].manufactureId == 101) {
if (row.type == 1) {
this.getfiId(row, function (data) {
if (data.length > 0) {
var fpid = "";
if (data[0].face) {
fpid = data[0].face.toString(16);
if (fpid.length != 2) {
fpid = "0" + fpid;
}
} else {
if (data[0].face == 0) {
fpid = data[0].face.toString(16);
fpid = "0" + fpid;
}
}
str = {
imei: row.imei,
deviceNum: row.deviceNum,
userTelephone: JSON.parse(row.content).userTelephone,
operateMode: 18,
order: 6218,
password: fpid,
userPassword: JSON.parse(row.content).userPassword,
is: false,
passwordStartTime: JSON.parse(row.content)
.passwordStartTime,
passwordEndTime: JSON.parse(row.content).passwordEndTime,
cardName: cardName,
roomName: res.data.list[0].roomName
};
if (JSON.parse(row.content).pass) {
str['pass'] = true
} else {
str['pass'] = false
}
httpPost(str, that.$api.getDeviceOperateUserInfo).then(
(res1) => {
if (res1.success) {
var content = JSON.parse(row.content)
content.operateMode = str.operateMode
var updatedata = {
id: row.id,
status: 0,
content: JSON.stringify(content),
// serial: res1.data.serialNumber,
};
httpPost(updatedata, that.$api.updateCertificates).then((res) => {
});
that.$message.success("删除成功!");
}
});
} else {
that.$message.success("未找到对应锁上凭证记录");
}
});
return false;
} else if (row.type == 2) {
str = {
imei: row.imei,
deviceNum: row.deviceNum,
userTelephone: JSON.parse(row.content).userTelephone,
operateMode: 15,
order: 6215,
password: JSON.parse(row.content).password,
userPassword: JSON.parse(row.content).userPassword,
is: false,
passwordStartTime: JSON.parse(row.content).passwordStartTime,
passwordEndTime: JSON.parse(row.content).passwordEndTime,
cardName: cardName,
roomName: res.data.list[0].roomName
};
} else if (row.type == 3) {
str = {
imei: row.imei,
deviceNum: row.deviceNum,
userTelephone: JSON.parse(row.content).userTelephone,
operateMode: 12,
order: 6212,
password: JSON.parse(row.content).password,
userPassword: JSON.parse(row.content).userPassword,
is: false,
passwordStartTime: JSON.parse(row.content).passwordStartTime,
passwordEndTime: JSON.parse(row.content).passwordEndTime,
cardName: cardName,
roomName: res.data.list[0].roomName
};
} else if (row.type == 4) {
str = {
imei: row.imei,
deviceNum: row.deviceNum,
userTelephone: JSON.parse(row.content).userTelephone,
operateMode: 9,
order: 6209,
userPassword: JSON.parse(row.content).userPassword,
password: JSON.parse(row.content).password,
is: false,
passwordStartTime: JSON.parse(row.content).passwordStartTime,
passwordEndTime: JSON.parse(row.content).passwordEndTime,
cardName: cardName,
roomName: res.data.list[0].roomName
};
}
if (JSON.parse(row.content).pass) {
str['pass'] = true
} else {
str['pass'] = false
}
httpPost(str, that.$api.getDeviceOperateUserInfo).then((res1) => {
if (res1.success) {
var content = JSON.parse(row.content)
content.operateMode = str.operateMode
var updatedata = {
id: row.id,
status: 0,
content: JSON.stringify(content),
// serial: res1.data.serialNumber,
};
httpPost(updatedata, that.$api.updateCertificates).then((res) => {
});
that.$message.success("删除成功!");
}
});
}
} else {
// var data = {
// ids: [row.id],
// };
// httpPost(data, that.$api.deleteCertificates).then((
// res) => {
// if (res.success) {
// that.$message.success("删除成功!");
// that.getcertificate();
// }
// });
that.$message.error("未找到锁上对应凭证ID");
}
})
},
deletefun1(index, row) {
var that = this
this.$confirm("此操作将删除凭证记录,请确认!", "提示", {
type: "warning",
}).then(() => {
let pzid = []
pzid.push(row.id)
if (row.type == 11) {
var pzname = JSON.parse(row.content).pzname
var data6 = {
pageNum: 1,
pageSize: 10,
orderBy: "create_at desc",
q: JSON.stringify({
info: {
pzname: pzname
},
cardId: this.drawerRow.id,
inStatus: "0,1,702",
type: 1
}),
};
httpGet(data6, this.$api.getCertificates).then((res) => {
let dataOne = utils.zlib_unzip(res.data)
if (dataOne.length > 0) {
this.$message.error("请先删除锁上凭证")
} else {
var data = {
ids: pzid,
};
httpPost(data, that.$api
.deleteCertificates).then((
res) => {
if (res.success) {
that.$message.success("删除成功!");
that.getcertificate();
}
});
}
})
} else {
var password = JSON.parse(row.content).password
var data6 = {
pageNum: 1,
pageSize: 10,
orderBy: "create_at desc",
q: JSON.stringify({
info: {
password: password
},
cardId: this.drawerRow.id,
inStatus: "0,1,702",
types: "0,1,2,3,4"
}),
};
httpGet(data6, this.$api.getCertificates).then((res) => {
let dataOne = utils.zlib_unzip(res.data)
if (dataOne.length > 0) {
this.$message.error("请先删除锁上凭证")
} else {
var data = {
ids: pzid,
};
httpPost(data, that.$api
.deleteCertificates).then((
res) => {
if (res.success) {
that.$message.success(
"删除成功!");
that.getcertificate();
}
});
}
})
}
})
},
getArrDifference(arr1, arr2) {
return arr1.concat(arr2).filter(function (v, i, arr) {
return arr.indexOf(v) === arr.lastIndexOf(v);
});
},
bindsave2() {
var SelectedList = [];
this.roomtable.map((li) => {
SelectedList.push(li.roomId);
});
this.SelectedList = SelectedList;
this.addroomstatus = !this.addroomstatus;
},
putCarfid1(resultArr, row) {
var data = {};
var userTelephone = JSON.parse(row.content).userTelephone;
var userPassword = JSON.parse(row.content).userPassword;
var passwordEndTime = JSON.parse(row.content).passwordEndTime;
var passwordStartTime = JSON.parse(row.content).passwordStartTime;
if (row.type == 1) {
var fpId = new Date();
var fingerprint = JSON.parse(row.content).fingerprint;
var str = {
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
userTelephone: userTelephone,
userPassword: userPassword,
password: JSON.parse(row.content).password,
length: fingerprint.length / 2,
fpTimeId: fpId.getTime(),
operateMode: 16,
order: 6216,
fingerprint: fingerprint,
fingerprintStartTime: passwordStartTime,
fingerprintEndTime: passwordEndTime,
};
httpPost(str, this.$api.fingerprintTransfer).then((res1) => {
var updatedata = {
id: row.id,
serial: res1.data.serialNumber,
};
httpPost(updatedata, that.$api.updateCertificates).then((res2) => {
});
});
return false;
} else if (row.type == 2) {
data = {
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
userTelephone: userTelephone,
cardId: row.cardId,
userPassword: userPassword,
password: JSON.parse(row.content).password,
operateMode: 13,
order: 6213,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
is: false,
};
} else if (row.type == 3) {
data = {
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
userTelephone: userTelephone,
cardId: row.cardId,
userPassword: userPassword,
password: JSON.parse(row.content).password,
operateMode: 10,
order: 6210,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
is: false,
};
} else if (row.type == 4) {
data = {
imei: resultArr.imei,
deviceNum: resultArr.deviceNum,
userTelephone: userTelephone,
cardId: row.cardId,
userPassword: userPassword,
password: JSON.parse(row.content).password,
operateMode: 7,
order: 6207,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
is: false,
};
}
httpPost(data, this.$api.getDeviceOperateUserInfo).then((res1) => {
if (res1.success) {
var updatedata = {
id: row.id,
serial: res1.data.serialNumber,
};
httpPost(updatedata, that.$api.updateCertificates).then((res2) => {
});
}
});
},
// 转换标准时间
getbztime(time) {
var d = new Date(time);
var mon =
d.getMonth() + 1 < 10 ? "0" + (d.getMonth() + 1) : d.getMonth() + 1;
var day = d.getDate() < 10 ? "0" + d.getDate() : d.getDate();
var hour = d.getDate() < 10 ? "0" + d.getDate() : d.getDate();
var min = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
var secon = d.getSeconds() < 10 ? "0" + d.getSeconds() : d.getSeconds();
var datetime =
d.getFullYear() +
"" +
mon +
"" +
day +
"" +
hour +
"" +
min +
"" +
secon;
return datetime;
},
time(time = +new Date()) {
var date = new Date(time + 8 * 3600 * 1000); // 增加8小时
return date.toJSON().substr(0, 19).replace("T", " ");
},
Bytes2Str(arrBytes) {
var str = "";
for (var i = 0; i < arrBytes.length; i++) {
var tmp;
var num = parseInt(arrBytes[i]);
if (num < 0) {
//此处填坑,当byte因为符合位导致数值为负时候,需要对数据进行处理
tmp = (255 + num + 1).toString(16);
} else {
tmp = num.toString(16);
}
if (tmp.length == 1) {
tmp = "0" + tmp;
}
if (i > 0) {
str += "" + tmp;
} else {
str += tmp;
}
}
return str;
},
// 选择绑定房间
onClick(evt, treeId, treeNode) {
// 点击事件
this.treedata = treeNode;
this.getItems(treeNode.id);
this.getlist();
},
getItems(id) {
if (id) {
var t = {
roomIds: [id],
lockType: 1
};
var data = {
q: JSON.stringify(t),
};
httpPost(data, this.$api.getDeviceItems).then((res) => {
if (res.data.list.length == 0) {
// this.$message.error("该房间还未绑定门锁");
// this.bindroomstatus = false;
} else {
this.deviceList = res.data.list;
}
});
} else {
this.bindroomstatus = false;
// this.$message({
// message: "该人员还未绑定房间",
// type: "error",
// customClass: "zZindex",
// });
}
},
// tabs标签页切换
handleClick(tab, event) {
},
// 侧边栏添加绑定房间
bindroom() {
this.roomstatus = !this.roomstatus;
this.addroomstatus = true;
},
addroom() {
var array = this.roomtable,
SelectedList = []
array.map((li) => {
SelectedList.push(li.roomId);
});
console.log(SelectedList)
this.SelectedList = SelectedList
this.roomstatus = !this.roomstatus;
this.addroomstatus = false;
},
bindroom1() {
this.roomstatus1 = !this.roomstatus1;
var nfc = ''
var arr2 = dec2hex(this.drawerRow.cardId);
var arr4 = group(arr2, 2).reverse()
arr4.map((li) => {
nfc += li;
});
if (nfc.length != 8) {
this.voucher.nfc = ""
} else {
this.voucher.nfc = nfc.toUpperCase()
}
},
// 关闭侧边栏
handleClose() {
this.drawer = false;
this.drawerVisible = false
this.personname = ''
},
screenRoom1(id, callback) {
// httpGet("", this.$api.onlyTenant).then((res) => {
// var roomAbout = res.data.list;
// var roomtable = [];
// roomAbout.map((li) => {
// if (li.cardId == id) {
// roomtable.push(li);
// }
// });
// callback(roomtable)
// });
var roomAbout = this.$store.state.roomAbout;
var roomtable = [];
roomAbout.map((li) => {
var name = utils.findIndexArray(this.$store.state.zNodes, li.roomId, [])
var path = ''
if (name) {
path = name.join('/')
}
li.roomName = path
if (li.cardId == id) {
roomtable.push(li);
}
});
console.log(roomtable)
callback(roomtable)
},
returnScreenRoom(id) {
var roomAbout = this.$store.state.roomAbout;
var SelectedList = [],
roomtable = [];
roomAbout.map((li) => {
var name = utils.findIndexArray(this.$store.state.zNodes, li.roomId, [])
var path = ''
if (name) {
path = name.join('/')
}
li.roomName = path
if (li.cardId == id) {
if (li.layout) {
SelectedList.push(li.roomId);
}
let result = this.checkInListing.filter(item => item.siteId == li.roomId)[0]
let deviceResult = this.allAboutDevice.filter(it => it.roomId == li.roomId)[0]
if (result) {
li['endTime'] = moment(result.endTime).format("YYYY-MM-DD HH:mm:ss") || ''
li['startTime'] = moment(result.startTime).format("YYYY-MM-DD HH:mm:ss") || ''
li['name'] = result.name
li.card = li.cardId
}
if (deviceResult) {
li['deviceNum'] = deviceResult.deviceNum
li['imei'] = deviceResult.imei
li['manufactureId'] = deviceResult.manufactureId
}
roomtable.push(li);
}
});
return roomtable;
// this.roomtable=roomtable
},
getAboutDevice1() {
var data = {
pageNum: 0,
pageSize: 0,
q: JSON.stringify({
lockType: 1
})
};
httpPost(data, this.$api.getDeviceItems).then((res) => {
this.allAboutDevice = res.data.list;
});
},
oninput(e) {
var str = Number(e).toString(2);
var str1 = Number(str);
var str3 = Number(str1).toString(16);
},
downloadItem(url) {
axios.get(url, {
responseType: "blob"
}).then(({
data
}) => {
let blob = new Blob([data], {
type: "application/vnd.ms-excel"
});
let link = document.createElement("a");
link.href = window.URL.createObjectURL(blob);
link.download = url.split("/").pop();
// for IE
if (navigator.msSaveBlob) {
navigator.msSaveBlob(blob, "SPU_templateV1.1.xlsx");
}
link.click().catch(error => {
console.error(error);
});
});
},
getallstatus(para) {
var data3 = {
code: "operateUserInfo/status",
data: {
para: para,
},
};
var userlistquery = this.userlistquery;
httpPost(data3, this.$api.sendCommand).then((res4) => {
this.userlistquery1 = res4.data;
});
},
activeiconfun(t) {
this.activeiconfont = t;
},
handleSizeChange(val) {
// console.log(`每页 ${val} 条`);
this.getlistNum(0, val);
},
handleCurrentChange(val) {
// console.log(`当前页: ${val}`);
this.getlistNum(val, 10);
this.$store.commit("increment", val);
},
// 分页
handleSizeChange2(val) {
this.pageSize2 = val
this.getlistNum2(0, val);
},
handleCurrentChange2(val) {
this.currentPage2 = val
// console.log(`当前页: ${val}`);
this.getlistNum2(val, 10);
},
getlistNum2(val, size) {
var data = {
pageNum: this.currentPage2,
pageSize: this.pageSize2,
orderBy: "create_at desc",
q: {
cardId: this.drawerRow.id,
},
};
httpGet(data, this.$api.getCertificates).then((res) => {
var certiflist = utils.zlib_unzip(res.data)
var AboutDevice = this.allAboutDevice;
certiflist.map((li) => {
li.createAt = this.time(+new Date(li.createAt));
li.userTelephone = JSON.parse(li.content).userTelephone;
li.pzname = JSON.parse(li.content).pzname;
li['statusText'] = utils.statusCode(li.status)
li['startTimeText'] = utils.formatTime(li.startTime)
li['endTimeText'] = utils.formatTime(li.endTime)
var resultArr = AboutDevice.filter(
(_item) => _item.imei == li.imei
)[0];
if (resultArr) {
li.roomId = resultArr.id;
li.roomName = resultArr.roomName;
} else {
li.roomId = "";
li.roomName = "";
}
});
this.roomtable2 = certiflist;
this.total2 = res.data.total;
});
},
getlistNum(val, size) {
var q = {
// type: 0,
name: this.query.name,
};
var data = {
pageNum: val,
pageSize: size,
orderBy: "create_time desc",
q: JSON.stringify(q),
};
let roomAbout = this.$store.state.roomAbout
httpPost(data, this.$api.getlistNum).then((res1) => {
if (res1.success) {
// let para = [];
// res1.data.list.map((li, index) => {
// let userTelephone = JSON.parse(li.info) ? JSON.parse(li.info).userTelephone : ''
// let str = {
// imei: li.imei,
// userTelephone: userTelephone,
// password: "",
// operateMode: 1,
// };
// para.push(str);
// li.status = 3;
// li['rommNameText'] = this.screenRoomName(li.id)
// });
let para = [];
res1.data.list.map((li, index) => {
let userTelephone = JSON.parse(li.info) ? JSON.parse(li.info).userTelephone : ''
let str = {
imei: li.imei,
userTelephone: userTelephone,
password: "",
operateMode: 1,
};
para.push(str);
this.$store.commit("increment", 1);
li.status = 3;
li['rommNameText'] = this.screenRoomName(li.id)
});
// this.getallstatus(para);
this.userlist = res1.data.list;
this.total = res1.data.total;
this.currentPage4 = val
this.pageSize = size
} else {
this.$message.error(res1.message)
}
});
},
handleChange(value) {
console.log(value);
},
//批量上传
batchUpload() {
this.uploadkj = true;
},
batchUploadpl() {
let data = []
this.userlist.map(li => {
data.push(li.id)
})
console.log(data)
let ids = {
ids: data
}
httpPost(ids, this.$api.createkeyCard).then(res => {
})
},
checkSameData(arr, str) {
var _arr = [],
_t = [],
// 临时的变量
_tmp;
// 按照特定的参数将数组排序将具有相同值得排在一起
arr = arr.sort(function (a, b) {
var s = a[str],
t = b[str];
return s < t ? -1 : 1;
});
if (arr.length) {
_tmp = arr[0][str];
}
// console.log( arr );
// 将相同类别的对象添加到统一个数组
for (var i in arr) {
if (arr[i][str] === _tmp) {
_t.push(arr[i]);
} else {
_tmp = arr[i][str];
_arr.push(_t);
_t = [arr[i]];
}
}
// 将最后的内容推出新数组
_arr.push(_t);
return _arr;
},
//批量上传确认
batchUploadfun() {
var that = this;
var array = this.checkSameData(this.userlist1, "phone");
var arrlist = []
this.batchCredentialList = []
array.map(li => {
arrlist.push(li[0])
})
if (this.value3) {
var data = {
list: arrlist,
};
httpPost(data, this.$api.infoImport).then((res) => {
if (res.success) {
arrlist.map((li, index) => {
this.getperson(li, function (data) {
li.id = data.id;
array[index].map(lt => {
lt['personId'] = data.id
})
let screeningList = RequestSet.deWeight(array[index], 'type', 'modeContent')
let passwordSum = 0,
nfcSum = 0;
screeningList.map(li => {
var operateMode = '',
order = '',
pzname = '',
type = ''
if (li.mode == 4) {
operateMode = 7
order = 6207
type = 14
var num = RequestSet.getCertificatesNum(data.id, 14, 1, '') || 0
pzname = '密码' + (num + passwordSum)
passwordSum++
} else if (li.mode == 3) {
operateMode = 10
order = 6210
type = 13
var num = RequestSet.getCertificatesNum(data.id, 13, 1, '') || 0
pzname = 'NFC' + (num + nfcSum)
nfcSum++
}
var str = {
userTelephone: JSON.parse(li.info).userTelephone,
userPassword: JSON.parse(li.info).userPassword,
password: li.modeContent,
operateMode: operateMode,
order: order,
passwordStartTime: moment(that.value3[0].getTime()).format('YYYYMMDDHHmmss'),
passwordEndTime: moment(that.value3[1].getTime()).format('YYYYMMDDHHmmss'),
cardName: data.name,
pzname: pzname,
pass: false
};
var datafidOne = {
cardId: data.id,
content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
type: type,
startTime: that.value3[0].getTime() / 1000,
endTime: that.value3[1].getTime() / 1000,
};
that.batchCredentialList.push(datafidOne)
httpPost(datafidOne, that.$api.addCertificates).then((res) => {
if (res.success) {
that.$message.success("添加成功")
} else {
that.$message.error("添加失败")
}
});
})
setTimeout(() => {
that.bindsaveFun(array[index]);
}, 500)
});
});
this.getlist();
this.uploadkj = false;
} else {
this.$message.error('导入失败')
}
});
} else {
this.$message.error("请选择开始结束时间")
}
},
//查询人员
getperson(li, callback) {
var data = {
orderBy: "create_time desc",
q: JSON.stringify({
cardId: li.cardId,
}),
};
let roomAbout = this.$store.state.roomAbout
httpPost(data, this.$api.getlistNum).then((res) => {
callback(res.data.list[0]);
});
},
// 绑定房间
bindsaveFun(list) {
var array = this.checkSameData(list, "siteId");
array.map((drawerRow, index) => {
this.sendUserlock(drawerRow[0])
setTimeout(this.sendUservoucher(drawerRow), 1000)
})
},
getCertificatesName(id, type, content, callback) {
this.batchCredentialList.map(li => {
var info = JSON.parse(li.content)
if (li.cardId == id && li.type == type && info.password == content) {
var pzname = info.pzname
callback(pzname)
}
})
},
sendUservoucher(voucherlist) {
voucherlist.map(drawerRow => {
setTimeout(() => {
var credentialName = ''
if (drawerRow.mode == 2) {
this.getCertificatesName(drawerRow.personId, 12, drawerRow.modeContent, (callback) => {
credentialName = callback
console.log(credentialName)
this.sendVoucherMethods(drawerRow, credentialName)
})
} else if (drawerRow.mode == 3) {
this.getCertificatesName(drawerRow.personId, 13, drawerRow.modeContent, (callback) => {
credentialName = callback
console.log(credentialName)
this.sendVoucherMethods(drawerRow, credentialName)
})
} else if (drawerRow.mode == 4) {
this.getCertificatesName(drawerRow.personId, 14, drawerRow.modeContent, (callback) => {
credentialName = callback
this.sendVoucherMethods(drawerRow, credentialName)
})
}
}, 1000)
})
},
sendVoucherMethods(drawerRow, credentialName) {
var info = JSON.parse(drawerRow.info);
var data = [{
cardId: drawerRow.personId,
siteId: drawerRow.siteId,
startTime: this.value3[0],
endTime: this.value3[1]
},];
var setid = {
pageNum: 1,
pageSize: 10,
q: JSON.stringify({
roomIds: [drawerRow.siteId],
lockType: 1
}),
};
httpPost(setid, this.$api.getDeviceItems).then((res) => {
var timeMantissa = moment().format('xx')
var mantissa = timeMantissa.substr(timeMantissa.length - 4,
timeMantissa.length - 1)
if (res.data.list.length > 0) {
var IMEI = res.data.list[0].imei
var DeviceNumRow = res.data.list[0]
if (DeviceNumRow.manufactureId == 201 || DeviceNumRow.manufactureId == 221) {
var startTime = this.value3[0].getTime() / 1000
var endTime = this.value3[1].getTime() / 1000
if (drawerRow.mode == 4) {
var pwd = drawerRow.modeContent
var userid = info.userPassword
var str = {
username: drawerRow.name,
pzname: credentialName,
imei: IMEI,
userTelephone: info.userTelephone,
userPassword: info.userPassword,
operateMode: 7,
order: 6207,
password: JSON.stringify(pwd),
passwordStartTime: startTime,
passwordEndTime: endTime,
is: false,
};
if (JSON.stringify(pwd).length != 6) {
this.$message.error("密码格式错误")
return
}
var cardName = drawerRow.name + '-' + credentialName
ICINLocker.addForeverPassword(DeviceNumRow.deviceNum, IMEI,
userid, 1,
pwd, 255, startTime, endTime, 6207, cardName,
DeviceNumRow.roomName, (
callback1) => {
if (callback1.success) {
var data = {
deviceNum: DeviceNumRow.deviceNum,
imei: IMEI,
cardId: drawerRow.personId,
content: JSON.stringify(
str
), //operateMode:NFC-10、把人员添加到凭证-1
type: drawerRow.mode,
serial: callback1.data
.serialNumber,
startTime: this.value3[0]
.getTime() / 1000,
endTime: this.value3[1]
.getTime() / 1000,
};
httpPost(data, this.$api
.addCertificates).then((
res) => {
});
this.$message.success("下发成功")
} else {
this.$message.error(callback1.msg)
}
})
} else if (drawerRow.mode == 3) {
var userid = info.userPassword
var cardNo = utils.cardFormatConversion(drawerRow.modeContent.toUpperCase())
if (cardNo.length == 8) {
cardNo = cardNo + '00000000'
} else if (cardNo.length != 16) {
cardNo = cardNo.padEnd(16, '0')
}
var str = {
username: drawerRow.name,
pzname: credentialName,
imei: IMEI,
userTelephone: info.userTelephone,
userPassword: info.userPassword,
operateMode: 10,
order: 6210,
password: cardNo,
passwordStartTime: startTime,
passwordEndTime: endTime,
is: false,
};
if (cardNo.length != 8) {
this.$message.error("NFC格式错误")
return
}
var cardName = drawerRow.name + '-' + credentialName
ICINLocker.RfCardRegister(DeviceNumRow.deviceNum,
IMEI, userid, 1, 1, cardNo,
50, startTime, endTime, 6210, cardName, DeviceNumRow
.roomName, (callback1) => {
if (callback1.success) {
var data = {
deviceNum: DeviceNumRow.deviceNum,
imei: IMEI,
cardId: drawerRow.personId,
content: JSON.stringify(
str
), //operateMode:NFC-10、把人员添加到凭证-1
type: drawerRow.mode,
serial: callback1.data
.serialNumber,
startTime: this.value3[0]
.getTime() / 1000,
endTime: this.value3[1]
.getTime() / 1000,
};
httpPost(data, this.$api
.addCertificates).then((
res) => {
});
this.$message.success("下发成功")
} else {
this.$message.error(callback1.msg)
}
})
} else if (drawerRow.mode == 2) {
var userid = info.userPassword
var cardNo = reverse(drawerRow.modeContent)
.toUpperCase()
var str = {
username: drawerRow.name,
pzname: credentialName,
imei: DeviceNumRow.imei,
userTelephone: info.userTelephone,
userPassword: info.userPassword,
operateMode: 13,
order: 6213,
password: cardNo,
passwordStartTime: startTime,
passwordEndTime: endTime,
is: false,
};
if (cardNo.length != 16) {
this.$message.error("身份证格式错误")
return
}
var cardName = drawerRow.name + '-' + credentialName
ICINLocker.RfCardRegister(DeviceNumRow.deviceNum,
IMEI, userid, 1, 1, cardNo,
36, startTime, endTime, 6213, cardName, DeviceNumRow
.roomName, (callback1) => {
if (callback1.success) {
var data = {
deviceNum: DeviceNumRow.deviceNum,
imei: IMEI,
cardId: drawerRow.personId,
content: JSON.stringify(
str
), //operateMode:NFC-10、把人员添加到凭证-1
type: drawerRow.mode,
serial: callback1.data
.serialNumber,
startTime: this.value3[0]
.getTime() / 1000,
endTime: this.value3[1]
.getTime() / 1000,
};
httpPost(data, this.$api
.addCertificates).then((
res) => {
});
this.$message.success("下发成功")
} else {
this.$message.error(callback1.msg)
}
})
} else {
this.$message.error("批量不支持指纹")
}
} else if (DeviceNumRow.manufactureId == 101) {
var passwordStartTime = moment(this.value3[0].getTime()).format('YYYYMMDDHHmmss')
var passwordEndTime = moment(this.value3[1].getTime()).format('YYYYMMDDHHmmss')
var str = {}
if (drawerRow.mode == 2) {
var arr2 = drawerRow.modeContent
str = {
username: drawerRow.name,
imei: IMEI,
pzname: credentialName,
userTelephone: info.userTelephone,
userPassword: info.userPassword,
operateMode: 13,
order: 6213,
password: arr2.toUpperCase(),
passwordStartTime: moment(this.value3[0].getTime())
.format('YYYYMMDDHHmmss'),
passwordEndTime: moment(this.value3[1].getTime())
.format('YYYYMMDDHHmmss'),
is: false,
};
if (arr2.length != 16) {
this.$message.error("身份证格式错误");
return false;
}
} else if (drawerRow.mode == 3) {
var array3 = drawerRow.modeContent
str = {
username: drawerRow.name,
imei: IMEI,
pzname: credentialName,
operateMode: 10,
order: 6210,
userTelephone: info.userTelephone,
userPassword: info.userPassword,
password: array3.toUpperCase(),
passwordStartTime: moment(this.value3[0].getTime())
.format('YYYYMMDDHHmmss'),
passwordEndTime: moment(this.value3[1].getTime())
.format('YYYYMMDDHHmmss'),
is: false,
};
if (array3.length != 8) {
this.$message.error("NFC格式错误");
return false;
}
} else if (drawerRow.mode == 4) {
var password = JSON.stringify(drawerRow.modeContent)
str = {
username: drawerRow.name,
imei: IMEI,
password: password,
pzname: credentialName,
userTelephone: info.userTelephone,
userPassword: info.userPassword,
operateMode: 7,
order: 6207,
passwordStartTime: moment(this.value3[0].getTime())
.format('YYYYMMDDHHmmss'),
passwordEndTime: moment(this.value3[1].getTime())
.format('YYYYMMDDHHmmss'),
is: false,
};
if (password.length != 6) {
this.$message.error("密码格式错误");
return false;
}
}
str['cardName'] = drawerRow.name + '-' + str.pzname,
str['roomName'] = DeviceNumRow.roomName,
httpPost(str, this.$api.getDeviceOperateUserInfo).then(
(res1) => {
if (res1.success) {
var data = {
deviceNum: DeviceNumRow.deviceNum,
imei: IMEI,
cardId: drawerRow.personId,
content: JSON.stringify(
str
), //operateMode:NFC-10、把人员添加到凭证-1
type: drawerRow.mode,
serial: res1.data.serialNumber,
startTime: this.value3[0]
.getTime() / 1000,
endTime: this.value3[1].getTime() / 1000,
};
httpPost(data, this.$api.addCertificates)
.then((res) => {
});
} else {
this.$message.error(res1.msg)
}
}
);
}
} else {
this.$message.error(drawerRow.siteName + "该房间未找到对应门锁")
}
})
},
sendUserlock(drawerRow) {
var info = JSON.parse(drawerRow.info);
var data = [{
cardId: drawerRow.personId,
siteId: drawerRow.siteId,
startTime: this.value3[0],
endTime: this.value3[1]
},];
var setid = {
pageNum: 1,
pageSize: 10,
q: JSON.stringify({
roomIds: [drawerRow.siteId],
lockType: 1
}),
};
httpPost(setid, this.$api.getDeviceItems).then((res) => {
if (res.data.list.length > 0) {
var timeMantissa = moment().format('xx')
var mantissa = timeMantissa.substr(timeMantissa.length - 4, timeMantissa.length - 1)
var IMEI = res.data.list[0].imei
var DeviceNumRow = res.data.list[0]
if (DeviceNumRow.manufactureId == 201 || DeviceNumRow.manufactureId == 221) {
ICINLocker.addUserToLock(DeviceNumRow.deviceNum, IMEI, info.userPassword, 0, 1,
6226, drawerRow.name, DeviceNumRow.roomName, (callback) => {
if (callback.success) {
var userstr = {
lockerId: DeviceNumRow.deviceNum,
imei: IMEI,
lockerUserId: info.userPassword,
keyId: info.userPassword,
role: 0,
action: 1,
order: 6226,
cardName: drawerRow.name,
roomName: DeviceNumRow.roomName
};
var locakUserdata = {
deviceNum: DeviceNumRow.deviceNum,
imei: IMEI,
cardId: drawerRow.personId,
content: JSON.stringify(
userstr
), //operateMode:NFC-10、把人员添加到凭证-1
type: 26,
serial: callback.data.serialNumber,
startTime: this.value3[0].getTime() / 1000,
endTime: this.value3[1].getTime() / 1000,
}
utils.sendLockUser(locakUserdata, (callbackLOCK) => {
})
httpPost(data, this.$api.bindCard).then((res1) => {
if (res1.success) {
this.$message.success("绑定成功")
this.getAboutRoom()
} else {
this.$message.error(res2.message)
}
})
} else {
this.$message.error(callback.msg)
}
})
} else if (DeviceNumRow.manufactureId == 101) {
var passwordStartTime = moment(this.value3[0].getTime()).format('YYYYMMDDHHmmss')
var passwordEndTime = moment(this.value3[1].getTime()).format('YYYYMMDDHHmmss')
var str1 = {
imei: IMEI,
deviceNum: DeviceNumRow.deviceNum,
userTelephone: info.userTelephone,
// cardId:this.personInfo.cardId,
userPassword: info.userPassword,
password: info.userPassword,
operateMode: 26,
order: 6226,
passwordStartTime: passwordStartTime,
passwordEndTime: passwordEndTime,
is: false,
cardName: drawerRow.name,
roomName: DeviceNumRow.roomName,
};
httpPost(str1, this.$api.getDeviceOperateUserInfo).then((res2) => {
if (res2.success) {
var userstr = {
lockerId: DeviceNumRow.deviceNum,
imei: IMEI,
lockerUserId: info.userPassword,
keyId: info.userPassword,
role: 0,
action: 1,
order: 6226,
cardName: drawerRow.name,
roomName: DeviceNumRow.roomName
};
var locakUserdata = {
deviceNum: DeviceNumRow.deviceNum,
imei: IMEI,
cardId: drawerRow.personId,
content: JSON.stringify(
userstr
), //operateMode:NFC-10、把人员添加到凭证-1
type: 26,
serial: res2.data.serialNumber,
startTime: this.value3[0].getTime() / 1000,
endTime: this.value3[1].getTime() / 1000,
}
utils.sendLockUser(locakUserdata, (callbackLOCK) => {
})
httpPost(data, this.$api.bindCard).then((res1) => {
if (res1.success) {
this.$message.success("绑定成功")
this.getAboutRoom()
} else {
this.$message.error(res2.message)
}
})
} else {
this.$message.error(res2.message)
}
});
}
} else {
this.$message.error(drawerRow.siteName + "该房间未找到对应门锁")
}
});
},
// 多选操作
handleSelectionChange(val) {
this.multipleSelection = val;
},
// 新增房源,选择凭证
handleSelectionChange2(val) {
this.multipleSelection2 = val;
},
handleSelectionChange3(val) {
this.multipleSelection3 = val;
},
handleSelectionChange4(val) {
this.multipleSelection4 = val;
},
handleSelectionChange1(val) {
this.multipleSelection1 = val;
},
delAllSelection() {
const length = this.multipleSelection.length;
let str = "";
this.delList = this.delList.concat(this.multipleSelection);
for (let i = 0; i < length; i++) {
str += this.multipleSelection[i].name + " ";
}
this.$message.error(`删除了${str}`);
this.multipleSelection = [];
},
// 编辑操作
handleEdit(index, row) {
this.modify = false;
this.idx = index;
this.form = row;
this.editVisiblelist = true;
var data = [{
itemId: row.id,
}]
httpPost(data, this.$api.getPersonBindEnterprise).then(res => {
if (res.code == 200) {
var list = []
res.data.map(li => {
list.push(li.enterpriseId)
})
this.defaultEnterpriseId = list
this.defaultEnterpriseIdBack = res.data
}
})
},
// 子组件触发修改
handleEdit1(row) {
this.modify = false;
this.form = row;
this.editVisiblelist = true;
},
// 重置from
resetFrom() {
this.form = {
sex: 1,
number: "",
name: "",
phone: "",
cardId: "",
cardState: 1,
};
},
modifyEdit() {
var data = {
id: this.form.id,
cardId: this.form.cardId,
cardState: this.form.cardState,
name: this.form.name,
number: this.form.number,
phone: this.form.phone,
sex: parseInt(this.form.sex),
enterpriseId: this.form.enterpriseId,
type: this.form.type,
};
if (this.form.key) {
var rowInfo = JSON.parse(this.form.info)
var rqTime = moment().format("X")
rowInfo.loginKey = setCode("MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCXKHkNKieiGOTjXZJ0lFBjhRCa\nZTaAebTIfB9nnnVmNVIp//yCfyFXSlxbAj58CQwCVhwy109ROYf3BcsQNMZz7Djo\n8a5V0JThNye4ihxLiYLawLRjb2y2/IhzV0/JZiFtaM83xUt0tbqTKxD00Up7dy8c\n9OXc0h//0uQSraf6JwIDAQAB", this.form.key)
data.info = JSON.stringify(rowInfo)
}
httpPost(data, this.$api.updateCard).then((res) => {
if (this.defaultEnterpriseIdBack.length > 0) {
let arr = []
this.defaultEnterpriseIdBack.map(li => {
var obj = {
itemId: li.cardId,
orderId: li.enterpriseId,
}
arr.push(obj)
})
httpPost(arr, this.$api.personUnBindEnterprise).then(res => {
if (res.code == 200) {
let dataprise = []
this.checkEnterpriseNode.map(li => {
var obj = {
itemId: this.form.id,
orderId: li.value,
}
dataprise.push(obj)
})
httpPost(dataprise, this.$api.personBindEnterprise).then(res => {
})
}
})
} else {
if (this.checkEnterpriseNode.length > 0) {
let dataprise = []
this.checkEnterpriseNode.map(li => {
var obj = {
itemId: this.form.id,
orderId: li.value,
}
dataprise.push(obj)
})
httpPost(dataprise, this.$api.personBindEnterprise).then(res => {
})
}
}
this.editVisiblelist = false;
this.getlist();
this.$store.commit("increment", 1);
});
},
// 分页导航
handlePageChange(val) {
this.$set(this.query, "pageIndex", val);
this.getData();
},
btnClick() {
document.querySelector(".input-file").click();
},
exportData(event) {
if (!event.currentTarget.files.length) {
return;
}
const that = this;
// 拿取文件对象
var f = event.currentTarget.files[0];
// 用FileReader来读取
var reader = new FileReader();
// 重写FileReader上的readAsBinaryString方法
FileReader.prototype.readAsBinaryString = function (f) {
var binary = "";
var wb; // 读取完成的数据
var outdata; // 你需要的数据
var reader = new FileReader();
reader.onload = function (e) {
// 读取成Uint8Array,再转换为Unicode编码(Unicode占两个字节)
var bytes = new Uint8Array(reader.result);
var length = bytes.byteLength;
for (var i = 0; i < length; i++) {
binary += String.fromCharCode(bytes[i]);
}
// 接下来就是xlsx了,具体可看api
wb = XLSX.read(binary, {
type: "binary",
});
outdata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
// 自定义方法向父组件传递数据
console.log(outdata)
var userInfo = localStorage.getItem('info')
let arr = [];
outdata.map((li, index) => {
var obj = {};
obj.name = li["人员名称"];
obj.siteId = li["房间ID"];
obj.siteName = li["房间名称"];
obj.number = li["学工号"];
obj.cardId = li["卡号"];
obj.phone = li["电话(为11位手机号码)"];
obj.sex = li["性别(1为男,2为女)"];
obj.mode = li["开锁方式(3为NFC,4为密码)"];
obj.modeContent = li["内容(NFC为8位16进制物理卡号、密码为6位数字密码)"];
obj.id = li["id"];
obj.cardState = '1';
obj.enterpriseId = JSON.parse(userInfo).enterpriseId;
obj.type = 0;
var phone = JSON.stringify(obj.phone);
obj.phone = phone
obj.siteId = JSON.stringify(obj.siteId)
var str = {
userPassword: phone.substr(phone.length - 6, phone.length - 1),
userTelephone: phone,
};
obj.info = JSON.stringify(str);
if (obj.sex == "男") {
obj.sex = 1;
} else if (obj.sex == "女") {
obj.sex = 2;
}
if (obj.mode == "密码") {
obj.mode = 4;
} else if (obj.mode == "NFC") {
obj.mode = 3;
} else if (obj.mode == "身份证") {
obj.mode = 2;
}
if (obj.cardState == "正常") {
obj.cardState = 1;
} else if (obj.cardState == "挂失") {
obj.cardState = 2;
} else if (obj.cardState == "挂失冻结") {
obj.cardState = 3;
} else if (obj.cardState == "冻结") {
obj.cardState = 4;
} else if (obj.cardState == "预开户") {
obj.cardState = 5;
} else if (obj.cardState == "过期") {
obj.cardState = 6;
}
arr.push(obj);
});
console.log(arr);
that.userlist1statu = false;
that.$nextTick(() => {
that.userlist1 = arr;
that.userlist1statu = true;
});
};
reader.readAsArrayBuffer(f);
};
reader.readAsBinaryString(f);
},
},
};
</script>
<style scoped>
.el-dialog .el-input__inner.el-date-editor--datetimerange {
width: 100%;
}
/* .handle-box .handle-input:last-child {
display: inline-block;
} */
.handle-input {
/* width: 3rem; */
/* display: inline-block; */
margin-bottom: 10px;
}
.mr10 {
margin-right: 10px;
}
.marginb20 {
margin-bottom: 20px;
}
.contentc {
display: flex;
align-items: center;
}
.cardrelative::before {
content: " ";
position: absolute;
top: 50%;
left: 0;
transform: translateY(-50%);
width: 8px;
height: 57px;
}
.aftercolor1::before {
background: #f2827c;
}
.aftercolor2::before {
background: #ffd791;
}
.aftercolor3::before {
background: #90d09e;
}
.aftercolor4::before {
background: #73cde2;
}
.aftercolor5::before {
background: #128bf1;
top: 40px;
transform: none;
}
.contentc .contenttitle {
font-size: 16px;
color: #333;
line-height: 30px;
margin-left: 10px;
}
.contentc .contentnum {
font-size: 35px;
color: #333;
line-height: 35px;
margin-left: 30px;
}
.cardrelative {
position: relative;
}
.cardrelative .pzimg {
position: absolute;
max-width: 100%;
bottom: -15px;
right: 0;
}
.paddcontent {
padding: 14px 0;
}
.contentc1 {
display: block;
}
.contentleft {
width: 48%;
box-sizing: border-box;
margin-left: 30px;
display: inline-block;
vertical-align: top;
}
.pieChart {
width: 50%;
height: 200px;
display: inline-block;
vertical-align: top;
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.pieChart .schart {
height: 100%;
}
.heightbt {
height: 220px;
}
.contentleft .contenttitle {
display: inline-block;
}
.contentleft .contentnum {
display: inline-block;
}
.contentleft>ul {
box-sizing: border-box;
margin-left: 30px;
}
.contentul li {
display: flex;
align-items: center;
line-height: 40px;
position: relative;
color: #333333;
}
.contentul li::before {
content: "●";
position: absolute;
top: 50%;
left: -20px;
transform: translateY(-50%);
color: #128bf1;
}
.contentul li>span {
width: 50%;
}
.userlist {
justify-content: space-between;
display: flex;
flex-direction: row;
flex-wrap: wrap;
position: relative;
margin-top: 20px;
}
/* .userlist::after{
content: '';
flex: auto;
} */
.userlist .userli {
display: inline-block;
box-sizing: border-box;
overflow: hidden;
}
.userlist .ko {
height: 0;
overflow: hidden;
padding: 0;
width: 264px;
}
.paging {
margin-top: 30px;
text-align: center;
}
.add {
width: 264px;
height: 276px;
cursor: pointer;
}
.add .adddiv {
margin-top: 50px;
background: #fff;
border-radius: 6px;
box-shadow: 0px 0px 9px 0px rgba(6, 6, 6, 0.06);
height: 226px;
position: relative;
display: flex;
align-items: center;
justify-content: center;
}
.add .adddiv img {
max-width: 100%;
}
.switchiconfont {
position: absolute;
top: 0;
left: 0;
background: #fff;
color: #333;
display: flex;
}
.switchiconfont .iconfont {
font-size: 16px;
padding: 4px 6px;
border: 1px solid #dcdfe6;
cursor: pointer;
}
.switchiconfont .active {
color: #fff;
cursor: pointer;
background: #FA8E00;
border: 1px solid #FA8E00;
}
.nulldiv {
text-align: center;
color: #999;
font-size: 16px;
font-weight: 400;
}
.nullimg {
margin: 30px auto;
max-width: 300px;
}
.tablelist {
position: relative;
padding-top: 40px;
margin-top: 20px;
}
.adddbtn {
display: inline-block;
position: absolute;
top: 0;
left: 75px;
}
.upload-demo {
display: inline-block;
}
.upload-demo>>>.el-upload--text {
display: inline;
}
.input-file {
display: none;
}
.rltable {
box-sizing: border-box;
margin: 0 20px;
}
.ztree {
/* height: 500px; */
overflow-y: auto;
}
.temporary {
margin-top: 20px;
}
.roomcontent {
margin-top: 50px;
}
.roomcontent .roomconli {
display: inline-block;
cursor: pointer;
position: relative;
}
.taball {
width: 100%;
margin-top: 50px;
}
.button-list {
position: absolute;
width: 300px;
height: 160px;
background: rgba(0, 0, 0, 0.5);
top: 0;
left: 20px;
border-radius: 10px;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-sizing: border-box;
box-sizing: border-box;
padding: 0 10px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-line-pack: center;
align-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
display: none;
}
.button-list div {
/* width: 55px; */
padding: 0 20px;
height: 25px;
background: rgba(0, 0, 0, 0.4);
border-radius: 13px;
margin: 0 5px 10px;
font-size: 14px;
font-family: Microsoft YaHei;
font-weight: 700;
color: #dedede;
cursor: pointer;
text-align: center;
line-height: 25px;
}
.roomcontent .roomconli:hover .button-list {
display: flex;
}
.roomcontentheight {
height: 600px;
overflow-y: auto;
}
.zZindex {
z-index: 999999 !important;
}
.rltable>>>.sleect-option {
z-index: 99 !important;
}
.tableoverflowHidden {
overflow: hidden;
}
.seleectOption {
width: 100px;
}
.operationclass>>>.el-drawer__header span {
font-size: 20px !important;
}
.SearchInput {
display: inline-block;
width: 2rem;
}
.tablebutton .el-button {
padding: 0;
}
.tablelist .el-table th>.cell {
text-align: center;
font-size: 14px;
}
.tablelist>>>.el-table .cell {
text-align: center;
font-size: 14px;
}
.tablelist .el-table__row .el-table__cell {
padding: 10px 0;
}
.widthRem5 {
/* display: inline-block; */
width: 5rem;
}
.selectoptionClass {
display: inline-block;
margin-bottom: 10px;
}
/deep/ .table .wait-row {
background: #fdf6ec;
}
/deep/ .table .warning-row {
background: #fef0f0;
}
/deep/ .table .success-row {
background: #f0f9eb;
}
.adddbtn .el-button+.el-button,
.adddbtn .el-checkbox.is-bordered+.el-checkbox.is-bordered {
margin-left: 0;
}
@media only screen and (max-width: 1024px) {
.adddbtn {
left: 70px;
}
}
</style>