Merge branch 'fanpeng' into 'develop'
完成卡信息修改功能 See merge request StarlockTeam/wx-starlock!20
This commit is contained in:
commit
274cef3d76
18
api/card.js
18
api/card.js
@ -37,3 +37,21 @@ export function addCardRequest(data) {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 更新卡片
|
||||
export function updateCardRequest(data) {
|
||||
return request({
|
||||
url: '/identityCard/update',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 卡详情
|
||||
export function getCardRequest(data) {
|
||||
return request({
|
||||
url: '/identityCard/detail',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
18
api/face.js
18
api/face.js
@ -46,3 +46,21 @@ export function addFaceRequest(data) {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 更新人脸
|
||||
export function updateFaceRequest(data) {
|
||||
return request({
|
||||
url: '/face/update',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 人脸详情
|
||||
export function getFaceRequest(data) {
|
||||
return request({
|
||||
url: '/face/detail',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
@ -37,3 +37,21 @@ export function addFingerprintRequest(data) {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 更新指纹
|
||||
export function updateFingerprintRequest(data) {
|
||||
return request({
|
||||
url: '/fingerprint/changePeriod',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 指纹详情
|
||||
export function getFingerprintRequest(data) {
|
||||
return request({
|
||||
url: '/fingerprint/detail',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
27
api/key.js
27
api/key.js
@ -55,3 +55,30 @@ export function getUserNoListRequest(data) {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改电子钥匙名称
|
||||
export function updateKeyNameRequest(data) {
|
||||
return request({
|
||||
url: '/key/modifyKeyNameForAdmin',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改电子钥匙有效期
|
||||
export function updateKeyDateRequest(data) {
|
||||
return request({
|
||||
url: '/key/updateKeyDate',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 获取电子钥匙详情
|
||||
export function getKeyRequest(data) {
|
||||
return request({
|
||||
url: '/key/detail',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
@ -37,3 +37,30 @@ export function deletePsaawordRequest(data) {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 创建自定义密码
|
||||
export function addCustomPasswordRequest(data) {
|
||||
return request({
|
||||
url: '/keyboardPwd/add',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 更新密码
|
||||
export function updatePasswordRequest(data) {
|
||||
return request({
|
||||
url: '/keyboardPwd/update',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 获取密码详情
|
||||
export function getPasswordRequest(data) {
|
||||
return request({
|
||||
url: '/keyboardPwd/detail',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
@ -46,3 +46,21 @@ export function addPalmVeinRequest(data) {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 更新掌纹
|
||||
export function updatePalmVeinRequest(data) {
|
||||
return request({
|
||||
url: '/palmVein/update',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 掌纹详情
|
||||
export function getPalmVeinRequest(data) {
|
||||
return request({
|
||||
url: '/palmVein/detail',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
@ -46,3 +46,21 @@ export function addRemoteRequest(data) {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 更新远程
|
||||
export function updateRemoteRequest(data) {
|
||||
return request({
|
||||
url: '/remote/update',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 远程详情
|
||||
export function getRemoteRequest(data) {
|
||||
return request({
|
||||
url: '/remote/detail',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
@ -4,10 +4,11 @@
|
||||
<view class="name-text">{{ title }}</view>
|
||||
<input
|
||||
:value="value"
|
||||
:type="type"
|
||||
class="name-input"
|
||||
:placeholder="placeholder"
|
||||
placeholder-class="placeholder-class"
|
||||
maxlength="50"
|
||||
:maxlength="maxlength"
|
||||
@input="changeInput"
|
||||
/>
|
||||
</view>
|
||||
@ -20,7 +21,15 @@
|
||||
props: {
|
||||
title: String,
|
||||
placeholder: String,
|
||||
value: String
|
||||
value: String,
|
||||
maxlength: {
|
||||
type: Number,
|
||||
default: 50
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
default: 'text'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
changeInput(e) {
|
||||
|
||||
76
components/ModalInput/ModalInput.vue
Normal file
76
components/ModalInput/ModalInput.vue
Normal file
@ -0,0 +1,76 @@
|
||||
<template>
|
||||
<view>
|
||||
<up-popup :show="show" mode="center" round="32rpx" @close="close" :safeAreaInsetBottom="false">
|
||||
<view class="bg-#f3f3f3 rounded-2xl">
|
||||
<view class="py-4 text-center font-bold text-lg">{{ title }}</view>
|
||||
<view class="px-4">
|
||||
<input
|
||||
class="bg-white border-none outline-none rounded-md h-80 w-450 text-base px-4"
|
||||
placeholder-class="text-base line-height-[80rpx]"
|
||||
:focus="show"
|
||||
:placeholder="placeholder"
|
||||
:value="text"
|
||||
:maxlength="maxlength"
|
||||
:type="type"
|
||||
@change="change"
|
||||
/>
|
||||
</view>
|
||||
<view
|
||||
class="flex justify-between items-center border-t-solid border-t-2 text-base font-bold border-t-gray-200 mt-4 text-#63b8af"
|
||||
>
|
||||
<view
|
||||
@click="close"
|
||||
class="text-center border-r-solid border-r-2 border-e-gray-200 w-50% box-border py-2"
|
||||
>取消</view
|
||||
>
|
||||
<view @click="confirm" class="text-center w-50% py-2">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</up-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const show = ref(false)
|
||||
const text = ref('')
|
||||
|
||||
const props = defineProps({
|
||||
title: { type: String, default: '请输入' },
|
||||
placeholder: { type: String, default: '请输入' },
|
||||
value: { type: String, default: '' },
|
||||
autoClose: { type: Boolean, default: true },
|
||||
maxlength: { type: Number, default: 50 },
|
||||
type: { type: String, default: 'text' }
|
||||
})
|
||||
|
||||
const emits = defineEmits(['confirm'])
|
||||
|
||||
const open = () => {
|
||||
text.value = props.value
|
||||
show.value = true
|
||||
}
|
||||
|
||||
const close = () => {
|
||||
show.value = false
|
||||
}
|
||||
|
||||
const change = e => {
|
||||
text.value = e.target.value
|
||||
}
|
||||
|
||||
const confirm = () => {
|
||||
emits('confirm', text.value)
|
||||
if (props.autoClose) {
|
||||
show.value = false
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
close
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
@ -330,6 +330,13 @@
|
||||
"navigationBarTitleText": "有效期",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/temporaryDate/temporaryDate",
|
||||
"style": {
|
||||
"navigationBarTitleText": "修改有效期",
|
||||
"disableScroll": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
|
||||
@ -1,16 +1,26 @@
|
||||
<template>
|
||||
<view>
|
||||
<view v-if="info">
|
||||
<view class="item">
|
||||
<view class="item" @click="() => $refs.modalInput.open()">
|
||||
<view class="item-title">姓名</view>
|
||||
<view class="item-content">{{ info.keyName }}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ info.keyName }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item" style="margin-top: 2rpx" @click="updateTime">
|
||||
<view class="item-title">有效期</view>
|
||||
<view v-if="info.keyType === 1">永久</view>
|
||||
<view v-else>
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view class="flex items-center">
|
||||
<view v-if="info.keyType === 1" class="mr-2">永久</view>
|
||||
<view v-else-if="info.keyType === 2" class="mr-2 w-400 text-right">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<view v-else class="mr-2">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd') }}</view>
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx">
|
||||
@ -25,11 +35,29 @@
|
||||
<view class="item-title">发送时间</view>
|
||||
<view class="item-content">{{ timeFormat(info.sendDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<view class="item !py-2" style="margin-top: 20rpx">
|
||||
<view class="item-title">仅管理自己创建的用户</view>
|
||||
<switch
|
||||
:checked="info.isOnlyManageSelf"
|
||||
class="transform-scale-90"
|
||||
@click="changeManageSelf"
|
||||
:disabled="true"
|
||||
color="#002ce5"
|
||||
/>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||
<view class="item-title">操作记录</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="button" @click="showModal = true">删除</view>
|
||||
<ModalInput
|
||||
ref="modalInput"
|
||||
title="请输入姓名"
|
||||
:autoClose="false"
|
||||
placeholder="请输入姓名"
|
||||
:value="info.keyName"
|
||||
@confirm="changeName"
|
||||
/>
|
||||
</view>
|
||||
<up-modal
|
||||
:show="showModal"
|
||||
@ -53,19 +81,62 @@
|
||||
import { getCurrentInstance, ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { deleteKeyRequest } from '@/api/key'
|
||||
import {
|
||||
deleteKeyRequest,
|
||||
getKeyRequest,
|
||||
updateKeyDateRequest,
|
||||
updateKeyNameRequest
|
||||
} from '@/api/key'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
const $basic = useBasicStore()
|
||||
const $bluetooth = useBluetoothStore()
|
||||
|
||||
const info = ref(null)
|
||||
|
||||
const showModal = ref(false)
|
||||
const checked = ref(false)
|
||||
|
||||
const modalInput = ref(null)
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
const changeName = async name => {
|
||||
if (!name) {
|
||||
uni.showToast({
|
||||
title: '请输入姓名',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
const { code, message } = await updateKeyNameRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyId: info.value.keyId,
|
||||
keyNameForAdmin: name
|
||||
})
|
||||
pending.value = false
|
||||
if (code === 0) {
|
||||
modalInput.value.close()
|
||||
eventChannel.emit('refresherList', {})
|
||||
info.value.keyName = name
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
onLoad(options => {
|
||||
if (options.info) {
|
||||
info.value = JSON.parse(options.info)
|
||||
@ -73,6 +144,59 @@
|
||||
}
|
||||
})
|
||||
|
||||
const changeManageSelf = async () => {
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
uni.showLoading({
|
||||
title: '更新中'
|
||||
})
|
||||
const { code, message } = await updateKeyDateRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyId: info.value.keyId,
|
||||
keyType: info.value.keyType,
|
||||
startDate: info.value.startDate,
|
||||
endDate: info.value.endDate,
|
||||
isOnlyManageSelf: info.value.isOnlyManageSelf === 1 ? 0 : 1
|
||||
})
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
if (code === 0) {
|
||||
info.value.isOnlyManageSelf = info.value.isOnlyManageSelf === 1 ? 0 : 1
|
||||
eventChannel.emit('refresherList', {})
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const updateTime = () => {
|
||||
$basic.routeJump({
|
||||
name: 'temporaryDate',
|
||||
params: {
|
||||
info: JSON.stringify({ ...info.value, type: 'key' })
|
||||
},
|
||||
events: {
|
||||
refresh() {
|
||||
eventChannel.emit('refresherList', {})
|
||||
getKeyRequest({
|
||||
keyId: info.value.keyId
|
||||
}).then(res => {
|
||||
info.value = {
|
||||
...res.data,
|
||||
keyId: info.value.keyId
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const toRecordList = async () => {
|
||||
$basic.routeJump({
|
||||
name: 'typeRecordList',
|
||||
|
||||
@ -59,6 +59,8 @@
|
||||
cardUserNo: String(data.cardNumber),
|
||||
cardType: params.cardType,
|
||||
addType: 1,
|
||||
startTime: params.startDate,
|
||||
endTime: params.endDate,
|
||||
weekDay: params.weekDays,
|
||||
cardRight: params.isAdmin,
|
||||
isCoerced: params.isForce === 1 ? 2 : 1
|
||||
|
||||
@ -53,13 +53,15 @@
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
startDate: params.value.startDate,
|
||||
endDate: params.value.endDate,
|
||||
startTime: params.value.startDate,
|
||||
endTime: params.value.endDate,
|
||||
faceName: params.value.faceName,
|
||||
faceNumber: String(data.faceNumber),
|
||||
faceUserNo: String(data.faceNumber),
|
||||
faceType: params.value.faceType,
|
||||
addType: 1,
|
||||
weekDay: params.value.weekDays,
|
||||
fingerRight: params.value.isAdmin,
|
||||
faceRight: params.value.isAdmin,
|
||||
isCoerced: params.value.isForce === 1 ? 2 : 1
|
||||
})
|
||||
if (code === 0) {
|
||||
|
||||
@ -58,6 +58,8 @@
|
||||
startDate: params.startDate,
|
||||
endDate: params.endDate,
|
||||
weekDay: params.weekDays,
|
||||
startTime: params.startDate,
|
||||
endTime: params.endDate,
|
||||
fingerprintName: params.fingerprintName,
|
||||
fingerprintNumber: String(data.fingerprintNumber),
|
||||
fingerprintUserNo: String(data.fingerprintNumber),
|
||||
|
||||
@ -51,6 +51,8 @@
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
startDate: params.startDate,
|
||||
endDate: params.endDate,
|
||||
startTime: params.startDate,
|
||||
endTime: params.endDate,
|
||||
palmVeinName: params.palmVeinName,
|
||||
palmVeinNumber: String(data.palmVeinNumber),
|
||||
palmVeinUserNo: String(data.palmVeinNumber),
|
||||
|
||||
@ -55,6 +55,8 @@
|
||||
startDate: params.startDate,
|
||||
endDate: params.endDate,
|
||||
remoteName: params.remoteName,
|
||||
startTime: params.startDate,
|
||||
endTime: params.endDate,
|
||||
remoteNumber: String(data.remoteNumber),
|
||||
remoteUserNo: String(data.remoteNumber),
|
||||
remoteType: params.remoteType,
|
||||
|
||||
@ -5,30 +5,44 @@
|
||||
<view class="item-title">卡号</view>
|
||||
<view class="item-content">{{ info.cardNumber }}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item" style="margin-top: 2rpx" @click="() => $refs.modalInput.open()">
|
||||
<view class="item-title">姓名</view>
|
||||
<view class="item-content">{{ info.cardName }}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ info.cardName }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item" style="margin-top: 2rpx" @click="updateTime">
|
||||
<view class="item-title">有效期</view>
|
||||
<view v-if="info.cardType === 1">永久</view>
|
||||
<view v-else-if="info.cardType === 2">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="flex items-center">
|
||||
<view v-if="info.cardType === 1" class="mr-2">永久</view>
|
||||
<view v-else-if="info.cardType === 2" class="mr-2 w-400 text-right">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<view v-else class="mr-2">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd') }}</view>
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.cardType === 4">
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.cardType === 4" @click="updateTime">
|
||||
<view class="item-title">有效日</view>
|
||||
<view class="item-content">{{ $lock.convertWeekDaysToChineseString(info.weekDay) }}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{
|
||||
$lock.convertWeekDaysToChineseString(info.weekDay)
|
||||
}}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.cardType === 4">
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.cardType === 4" @click="updateTime">
|
||||
<view class="item-title">有效时间</view>
|
||||
<view class="item-content">
|
||||
{{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }}
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">
|
||||
{{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }}
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx">
|
||||
@ -39,11 +53,39 @@
|
||||
<view class="item-title">添加时间</view>
|
||||
<view class="item-content">{{ timeFormat(info.createDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<view class="item !py-2" style="margin-top: 20rpx">
|
||||
<view class="item-title">胁迫卡</view>
|
||||
<switch
|
||||
:checked="info.isCoerced === 2"
|
||||
class="transform-scale-90"
|
||||
@click="changeCoerced"
|
||||
:disabled="true"
|
||||
color="#002ce5"
|
||||
/>
|
||||
</view>
|
||||
<view class="item !py-2" style="margin-top: 2rpx">
|
||||
<view class="item-title">是否为管理员</view>
|
||||
<switch
|
||||
@click="disabled"
|
||||
:checked="info.cardRight"
|
||||
class="transform-scale-90"
|
||||
:disabled="true"
|
||||
color="#002ce5"
|
||||
/>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||
<view class="item-title">操作记录</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="button" @click="deletePassword">删除</view>
|
||||
<ModalInput
|
||||
ref="modalInput"
|
||||
title="请输入姓名"
|
||||
:autoClose="false"
|
||||
placeholder="请输入姓名"
|
||||
:value="info.cardName"
|
||||
@confirm="changeName"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@ -54,19 +96,27 @@
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { getCardRequest, updateCardRequest } from '@/api/card'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
const $lock = useLockStore()
|
||||
const $basic = useBasicStore()
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $user = useUserStore()
|
||||
|
||||
const info = ref(null)
|
||||
|
||||
const modalInput = ref(null)
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
onLoad(options => {
|
||||
if (options.info) {
|
||||
info.value = JSON.parse(options.info)
|
||||
console.log(info.value)
|
||||
}
|
||||
})
|
||||
|
||||
@ -81,6 +131,121 @@
|
||||
})
|
||||
}
|
||||
|
||||
const disabled = () => {
|
||||
uni.showToast({
|
||||
title: '暂不支持修改',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
const updateTime = () => {
|
||||
$basic.routeJump({
|
||||
name: info.value.cardType === 1 || info.value.cardType === 2 ? 'temporaryDate' : 'cycleDate',
|
||||
params: {
|
||||
info: JSON.stringify({ ...info.value, type: 'card' })
|
||||
},
|
||||
events: {
|
||||
refresh() {
|
||||
eventChannel.emit('refresherList', {})
|
||||
getCardRequest({
|
||||
cardId: info.value.cardId
|
||||
}).then(res => {
|
||||
info.value = res.data
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const changeName = async name => {
|
||||
if (!name) {
|
||||
uni.showToast({
|
||||
title: '请输入姓名',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
const { code, message } = await updateCardRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
cardId: info.value.cardId,
|
||||
cardType: info.value.cardType,
|
||||
cardName: name,
|
||||
changeType: 1
|
||||
})
|
||||
pending.value = false
|
||||
if (code === 0) {
|
||||
modalInput.value.close()
|
||||
eventChannel.emit('refresherList', {})
|
||||
info.value.cardName = name
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const changeCoerced = async () => {
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
uni.showLoading({
|
||||
title: '更新中'
|
||||
})
|
||||
const { code } = await $bluetooth.registerAuthentication({
|
||||
type: 'card',
|
||||
operate: 1,
|
||||
isAdmin: info.value.isAdmin,
|
||||
isForce: info.value.isCoerced === 2 ? 0 : 1,
|
||||
isRound: info.value.cardType === 4 ? 1 : 0,
|
||||
weekDays: info.value.weekDay,
|
||||
no: info.value.cardNumber,
|
||||
userCountLimit: 0xffff,
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
startDate: info.value.startDate,
|
||||
endDate: info.value.endDate,
|
||||
startTime: info.value.cardType === 4 ? timeFormat(info.value.startDate, 'h:M') : '00:00',
|
||||
endTime: info.value.cardType === 4 ? timeFormat(info.value.endDate, 'h:M') : '00:00'
|
||||
})
|
||||
if (code === 0) {
|
||||
const { code, message } = await updateCardRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
cardId: info.value.cardId,
|
||||
cardType: info.value.cardType,
|
||||
isCoerced: info.value.isCoerced === 2 ? 1 : 2,
|
||||
changeType: 1
|
||||
})
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
if (code === 0) {
|
||||
info.value.isCoerced = info.value.isCoerced === 2 ? 1 : 2
|
||||
eventChannel.emit('refresherList', {})
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '操作失败,请重试',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const deletePassword = async () => {
|
||||
eventChannel.emit('delete', {})
|
||||
}
|
||||
|
||||
@ -353,6 +353,12 @@
|
||||
events: {
|
||||
delete() {
|
||||
deleteItem({ ...item, back: true })
|
||||
},
|
||||
refresherList() {
|
||||
pageNo.value = 1
|
||||
getList({
|
||||
pageNo: pageNo.value
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -196,7 +196,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
|
||||
if (type === 'temporary' && temporaryStartTime.value >= temporaryEndTime.value) {
|
||||
uni.showToast({
|
||||
title: '失效时间要大于生效时间',
|
||||
icon: 'none'
|
||||
|
||||
@ -228,7 +228,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
|
||||
if (type === 'temporary' && temporaryStartTime.value >= temporaryEndTime.value) {
|
||||
uni.showToast({
|
||||
title: '失效时间要大于生效时间',
|
||||
icon: 'none'
|
||||
|
||||
@ -200,7 +200,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
|
||||
if (type === 'temporary' && temporaryStartTime.value >= temporaryEndTime.value) {
|
||||
uni.showToast({
|
||||
title: '失效时间要大于生效时间',
|
||||
icon: 'none'
|
||||
|
||||
@ -228,7 +228,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
|
||||
if (type === 'temporary' && temporaryStartTime.value >= temporaryEndTime.value) {
|
||||
uni.showToast({
|
||||
title: '失效时间要大于生效时间',
|
||||
icon: 'none'
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
:list="tabs"
|
||||
lineWidth="40rpx"
|
||||
lineHeight="5rpx"
|
||||
:current="currnetIndex"
|
||||
:current="current"
|
||||
lineColor="#63b8af"
|
||||
@click="clickTab"
|
||||
:inactiveStyle="{ color: '#a3a3a3', fontSize: '32rpx', fontWeight: 'bold' }"
|
||||
@ -19,7 +19,7 @@
|
||||
:list="tabs"
|
||||
:autoplay="false"
|
||||
:circular="true"
|
||||
:current="currnetIndex"
|
||||
:current="current"
|
||||
@change="changeSwiper"
|
||||
>
|
||||
<swiper-item>
|
||||
@ -27,13 +27,13 @@
|
||||
:value="permanentAccount"
|
||||
title="接收者"
|
||||
placeholder="请输入手机号或邮箱"
|
||||
@change-input="changePermanentAccountInput"
|
||||
@change-input="changeAccount('permanent', $event)"
|
||||
></LockInput>
|
||||
<LockInput
|
||||
:value="permanentName"
|
||||
title="姓名"
|
||||
placeholder="请输入姓名"
|
||||
@change-input="changePermanentNameInput"
|
||||
@change-input="changeName('permanent', $event)"
|
||||
></LockInput>
|
||||
<view class="text" style="margin-top: 40rpx">接收者可使用此小程序开关锁</view>
|
||||
<view class="text" style="margin-bottom: 50rpx"
|
||||
@ -41,30 +41,30 @@
|
||||
>
|
||||
<view class="button" @click="createKey('permanent')">发送</view>
|
||||
</swiper-item>
|
||||
<swiper-item :style="{ height: deviceInfo.windowHeight - 44 + 'px' }">
|
||||
<swiper-item>
|
||||
<LockInput
|
||||
:value="temporaryAccount"
|
||||
title="接收者"
|
||||
placeholder="请输入手机号或邮箱"
|
||||
@change-input="changeTemporaryAccountInput"
|
||||
@change-input="changeAccount('temporary', $event)"
|
||||
></LockInput>
|
||||
<LockInput
|
||||
:value="temporaryName"
|
||||
title="姓名"
|
||||
placeholder="请输入姓名"
|
||||
@change-input="changeTemporaryNameInput"
|
||||
@change-input="changeName('temporary', $event)"
|
||||
></LockInput>
|
||||
<view style="margin-top: 20rpx">
|
||||
<LockDatetimePicker
|
||||
title="生效时间"
|
||||
:value="temporaryValidTime"
|
||||
:value="startDate"
|
||||
:minDate="minDate"
|
||||
@change-time="changeTemporaryValidTime"
|
||||
:maxDate="maxDate"
|
||||
></LockDatetimePicker>
|
||||
<LockDatetimePicker
|
||||
title="失效时间"
|
||||
:value="temporaryInvalidTime"
|
||||
:value="endDate"
|
||||
:minDate="minDate"
|
||||
@change-time="changeTemporaryInvalidTime"
|
||||
:maxDate="maxDate"
|
||||
@ -76,6 +76,41 @@
|
||||
>
|
||||
<view class="button" @click="createKey('temporary')">发送</view>
|
||||
</swiper-item>
|
||||
<swiper-item>
|
||||
<LockInput
|
||||
:value="singleAccount"
|
||||
title="接收者"
|
||||
placeholder="请输入手机号或邮箱"
|
||||
@change-input="changeAccount('single', $event)"
|
||||
></LockInput>
|
||||
<LockInput
|
||||
:value="singleName"
|
||||
title="姓名"
|
||||
placeholder="请输入姓名"
|
||||
@change-input="changeName('single', $event)"
|
||||
></LockInput>
|
||||
<view class="text mt-5 mb-50rpx">单次钥匙有效期为1小时,只能使用一次</view>
|
||||
<view class="button" @click="createKey('single')">发送</view>
|
||||
</swiper-item>
|
||||
<swiper-item>
|
||||
<LockInput
|
||||
:value="cycleAccount"
|
||||
title="接收者"
|
||||
placeholder="请输入手机号或邮箱"
|
||||
@change-input="changeAccount('cycle', $event)"
|
||||
></LockInput>
|
||||
<LockInput
|
||||
:value="cycleName"
|
||||
title="姓名"
|
||||
placeholder="请输入姓名"
|
||||
@change-input="changeName('cycle', $event)"
|
||||
></LockInput>
|
||||
<view style="margin-top: 20rpx">
|
||||
<LockCycle @change="changeCycle"></LockCycle>
|
||||
</view>
|
||||
<view class="text mt-5 mb-50rpx">接收者可以在有效期内的固定时间段里,不限次数使用</view>
|
||||
<view class="button" @click="createKey('cycle')">发送</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
</view>
|
||||
</template>
|
||||
@ -103,17 +138,30 @@
|
||||
},
|
||||
{
|
||||
name: '限时'
|
||||
},
|
||||
{
|
||||
name: '单次'
|
||||
},
|
||||
{
|
||||
name: '循环'
|
||||
}
|
||||
],
|
||||
permanentName: '',
|
||||
permanentAccount: '',
|
||||
temporaryName: '',
|
||||
temporaryAccount: '',
|
||||
temporaryValidTime: Number(new Date()),
|
||||
temporaryInvalidTime: Number(new Date()),
|
||||
startDate: Number(new Date()),
|
||||
endDate: Number(new Date()),
|
||||
singleName: '',
|
||||
singleAccount: '',
|
||||
cycleName: '',
|
||||
cycleAccount: '',
|
||||
cycleStartTime: null,
|
||||
cycleEndTime: null,
|
||||
weekDays: [],
|
||||
minDate: Number(new Date()),
|
||||
maxDate: Number(4133951940000),
|
||||
currnetIndex: 0,
|
||||
current: 0,
|
||||
deviceInfo: null,
|
||||
pending: false
|
||||
}
|
||||
@ -124,24 +172,24 @@
|
||||
},
|
||||
async onLoad() {
|
||||
this.deviceInfo = await this.getDeviceInfo()
|
||||
// this.temporaryInvalidTime = this.setTime()
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useBasicStore, ['getDeviceInfo', 'backAndToast', 'getNetworkType']),
|
||||
...mapActions(useLockStore, ['getKeyList', 'updateKeySearch']),
|
||||
setTime() {
|
||||
const now = new Date()
|
||||
now.setMinutes(0, 0, 0)
|
||||
now.setDate(now.getDate() + 3)
|
||||
|
||||
return now.getTime()
|
||||
changeCycle(data) {
|
||||
this.cycleStartTime = data.startDate
|
||||
this.cycleEndTime = data.endDate
|
||||
this.weekDays = data.weekDays
|
||||
},
|
||||
async createKey(type, createUser = false) {
|
||||
if (
|
||||
(type === 'temporary' &&
|
||||
!(test.email(this.temporaryAccount) || test.mobile(this.temporaryAccount))) ||
|
||||
(type === 'permanent' &&
|
||||
!(test.email(this.permanentAccount) || test.mobile(this.permanentAccount)))
|
||||
!(test.email(this.permanentAccount) || test.mobile(this.permanentAccount))) ||
|
||||
(type === 'single' &&
|
||||
!(test.email(this.singleAccount) || test.mobile(this.singleAccount))) ||
|
||||
(type === 'cycle' && !(test.email(this.cycleAccount) || test.mobile(this.cycleAccount)))
|
||||
) {
|
||||
uni.showToast({
|
||||
title: '请输入格式正确的手机号或邮箱',
|
||||
@ -150,7 +198,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'temporary' && this.temporaryValidTime >= this.temporaryInvalidTime) {
|
||||
if (type === 'temporary' && this.startDate >= this.endDate) {
|
||||
uni.showToast({
|
||||
title: '失效时间必须大于生效时间',
|
||||
icon: 'none'
|
||||
@ -158,6 +206,14 @@
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'cycle' && this.weekDays.length === 0) {
|
||||
uni.showToast({
|
||||
title: '请选择有效期',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const netWork = await this.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
@ -183,16 +239,31 @@
|
||||
}
|
||||
if (type === 'temporary') {
|
||||
params.keyNameForAdmin = this.temporaryName
|
||||
params.endDate = this.temporaryInvalidTime.toString()
|
||||
params.endDate = this.endDate.toString()
|
||||
params.keyType = '2'
|
||||
params.receiverUsername = this.temporaryAccount
|
||||
params.startDate = this.temporaryValidTime.toString()
|
||||
} else {
|
||||
params.startDate = this.startDate.toString()
|
||||
} else if (type === 'permanent') {
|
||||
params.keyNameForAdmin = this.permanentName
|
||||
params.startDate = new Date().getTime().toString()
|
||||
params.endDate = '0'
|
||||
params.keyType = '1'
|
||||
params.receiverUsername = this.permanentAccount
|
||||
} else if (type === 'single') {
|
||||
params.keyNameForAdmin = this.singleName
|
||||
params.startDate = new Date().getTime().toString()
|
||||
params.endDate = '0'
|
||||
params.keyType = '3'
|
||||
params.receiverUsername = this.singleAccount
|
||||
} else if (type === 'cycle') {
|
||||
params.keyNameForAdmin = this.cycleName
|
||||
params.startDate = this.cycleStartTime
|
||||
params.endDate = this.cycleEndTime
|
||||
params.keyType = '4'
|
||||
params.receiverUsername = this.cycleAccount
|
||||
params.weekDays = this.weekDays
|
||||
params.startTime = this.cycleStartTime
|
||||
params.endTime = this.cycleEndTime
|
||||
}
|
||||
const { code, message } = await createKeyRequest(params)
|
||||
if (code === 0) {
|
||||
@ -222,29 +293,39 @@
|
||||
}
|
||||
this.pending = false
|
||||
},
|
||||
changePermanentAccountInput(e) {
|
||||
this.permanentAccount = e
|
||||
changeAccount(type, e) {
|
||||
if (type === 'permanent') {
|
||||
this.permanentAccount = e
|
||||
} else if (type === 'temporary') {
|
||||
this.temporaryAccount = e
|
||||
} else if (type === 'single') {
|
||||
this.singleAccount = e
|
||||
} else if (type === 'cycle') {
|
||||
this.cycleAccount = e
|
||||
}
|
||||
},
|
||||
changePermanentNameInput(e) {
|
||||
this.permanentName = e
|
||||
},
|
||||
changeTemporaryNameInput(e) {
|
||||
this.temporaryName = e
|
||||
},
|
||||
changeTemporaryAccountInput(e) {
|
||||
this.temporaryAccount = e
|
||||
changeName(type, e) {
|
||||
if (type === 'permanent') {
|
||||
this.permanentName = e
|
||||
} else if (type === 'temporary') {
|
||||
this.temporaryName = e
|
||||
} else if (type === 'single') {
|
||||
this.singleName = e
|
||||
} else if (type === 'cycle') {
|
||||
this.cycleName = e
|
||||
}
|
||||
},
|
||||
changeTemporaryValidTime(e) {
|
||||
this.temporaryValidTime = e
|
||||
this.startDate = e
|
||||
},
|
||||
changeTemporaryInvalidTime(e) {
|
||||
this.temporaryInvalidTime = e
|
||||
this.endDate = e
|
||||
},
|
||||
clickTab(data) {
|
||||
this.currnetIndex = data.index
|
||||
this.current = data.index
|
||||
},
|
||||
changeSwiper(e) {
|
||||
this.currnetIndex = e.detail.current
|
||||
this.current = e.detail.current
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
|
||||
if (type === 'temporary' && temporaryStartTime.value >= temporaryEndTime.value) {
|
||||
uni.showToast({
|
||||
title: '失效时间要大于生效时间',
|
||||
icon: 'none'
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
:list="tabs"
|
||||
lineWidth="40rpx"
|
||||
lineHeight="5rpx"
|
||||
:current="currnetIndex"
|
||||
:current="currentIndex"
|
||||
lineColor="#63b8af"
|
||||
@click="clickTab"
|
||||
:inactiveStyle="{ color: '#a3a3a3', fontSize: '32rpx', fontWeight: 'bold' }"
|
||||
@ -19,7 +19,7 @@
|
||||
:list="tabs"
|
||||
:autoplay="false"
|
||||
:circular="true"
|
||||
:current="currnetIndex"
|
||||
:current="currentIndex"
|
||||
@change="changeSwiper"
|
||||
>
|
||||
<swiper-item>
|
||||
@ -27,17 +27,17 @@
|
||||
:value="permanentName"
|
||||
title="姓名"
|
||||
placeholder="请给密码命名"
|
||||
@change-input="changePermanentInput"
|
||||
@change-input="changeName('permanent', $event)"
|
||||
></LockInput>
|
||||
<view class="text">{{ text }}</view>
|
||||
<view class="button" @click="createPassword('permanent')">获取密码</view>
|
||||
</swiper-item>
|
||||
<swiper-item :style="{ height: deviceInfo.windowHeight - 44 + 'px' }">
|
||||
<swiper-item>
|
||||
<LockInput
|
||||
:value="temporaryName"
|
||||
title="姓名"
|
||||
placeholder="请给密码命名"
|
||||
@change-input="changeTemporaryInput"
|
||||
@change-input="changeName('temporary', $event)"
|
||||
></LockInput>
|
||||
<view style="margin-top: 20rpx">
|
||||
<LockDateHourPicker
|
||||
@ -52,142 +52,428 @@
|
||||
<view class="text">{{ text }}</view>
|
||||
<view class="button" @click="createPassword('temporary')">获取密码</view>
|
||||
</swiper-item>
|
||||
<swiper-item>
|
||||
<LockInput
|
||||
:value="singleName"
|
||||
title="姓名"
|
||||
placeholder="请给密码命名"
|
||||
@change-input="changeName('single', $event)"
|
||||
></LockInput>
|
||||
<view class="text">密码有效期为6个小时,只能使用一次</view>
|
||||
<view class="button" @click="createPassword('single')">获取密码</view>
|
||||
</swiper-item>
|
||||
<swiper-item>
|
||||
<LockInput
|
||||
:value="customName"
|
||||
title="姓名"
|
||||
placeholder="请给密码命名"
|
||||
@change-input="changeName('custom', $event)"
|
||||
></LockInput>
|
||||
<LockInput
|
||||
:value="customPassword"
|
||||
title="密码"
|
||||
placeholder="请输入6-9位数字"
|
||||
:maxlength="9"
|
||||
type="number"
|
||||
@change-input="changePassword('custom', $event)"
|
||||
></LockInput>
|
||||
<view class="mt-3 border-b-2 border-b-solid border-b-gray-200">
|
||||
<LockSwitch
|
||||
:value="customPermanent"
|
||||
title="永久"
|
||||
@change="changePermanent('custom', $event)"
|
||||
></LockSwitch>
|
||||
</view>
|
||||
<view v-if="!customPermanent" class="border-b-2 border-b-solid border-b-gray-200">
|
||||
<LockDatetimePicker
|
||||
title="生效时间"
|
||||
:value="customStartTime"
|
||||
@change-time="changeDate('customStartTime', $event)"
|
||||
></LockDatetimePicker>
|
||||
</view>
|
||||
<view v-if="!customPermanent">
|
||||
<LockDatetimePicker
|
||||
title="失效时间"
|
||||
:value="customEndTime"
|
||||
@change-time="changeDate('customEndTime', $event)"
|
||||
></LockDatetimePicker>
|
||||
</view>
|
||||
<view class="mt-3">
|
||||
<LockSwitch
|
||||
:value="customAdmin"
|
||||
title="是否为管理员"
|
||||
@change="changeAdmin('custom', $event)"
|
||||
></LockSwitch>
|
||||
</view>
|
||||
<view class="text">
|
||||
手动输入6-9位数字作为密码。可在锁旁边通过手机蓝牙添加,也可通过网关远程添加
|
||||
</view>
|
||||
<view class="button" @click="createPassword('custom')">获取密码</view>
|
||||
</swiper-item>
|
||||
<swiper-item>
|
||||
<LockInput
|
||||
:value="cycleName"
|
||||
title="姓名"
|
||||
placeholder="请给密码命名"
|
||||
@change-input="changeName('cycle', $event)"
|
||||
></LockInput>
|
||||
<view style="margin-top: 20rpx" class="border-b-2 border-b-solid border-b-gray-200">
|
||||
<view
|
||||
@click="showCycle = true"
|
||||
class="flex items-center bg-white font-bold text-base h-100 w-full"
|
||||
>
|
||||
<view class="w-168 ml-4 leading-[100rpx]">有效日</view>
|
||||
<view class="ml-a mr-2 flex items-center">
|
||||
<view class="mr-2 text-right w-[518rpx] h-100 leading-[100rpx]"
|
||||
>{{ cycleOptions[0][defaultIndex].name }}
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="border-b-2 border-b-solid border-b-gray-200">
|
||||
<view
|
||||
@click="showHoursStart = true"
|
||||
class="flex items-center bg-white font-bold text-base h-100 w-full"
|
||||
>
|
||||
<view class="w-168 ml-4 leading-[100rpx]">生效时间</view>
|
||||
<view class="ml-a mr-2 flex items-center">
|
||||
<view class="mr-2 text-right w-[518rpx] h-100 leading-[100rpx]"
|
||||
>{{ hoursStart }}:00
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<view
|
||||
@click="showHoursEnd = true"
|
||||
class="flex items-center bg-white font-bold text-base h-100 w-full"
|
||||
>
|
||||
<view class="w-168 ml-4 leading-[100rpx]">失效时间</view>
|
||||
<view class="ml-a mr-2 flex items-center">
|
||||
<view class="mr-2 text-right w-[518rpx] h-100 leading-[100rpx]">
|
||||
{{ hoursEnd }}:00</view
|
||||
>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="text">{{ text }}</view>
|
||||
<view class="button" @click="createPassword('cycle')">获取密码</view>
|
||||
</swiper-item>
|
||||
<swiper-item>
|
||||
<LockInput
|
||||
:value="emptyName"
|
||||
title="姓名"
|
||||
placeholder="请给密码命名"
|
||||
@change-input="changeName('empty', $event)"
|
||||
></LockInput>
|
||||
<view class="text">
|
||||
<view>清空密码当日23:59前有效</view>
|
||||
<view>
|
||||
清空内容1:当日0点前生成的所有密码(当日0点后生成的密码,不受清空密码影响,可继续使用)
|
||||
</view>
|
||||
<view>清空内容2:清空密码使用后,立即清除所有自定义密码(含使用过和未使用过的)</view>
|
||||
<view>如需彻底清除所有密码,请使用重置所有密码功能</view></view
|
||||
>
|
||||
<view class="button" @click="createPassword('empty')">获取密码</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<up-picker
|
||||
:show="showCycle"
|
||||
:columns="cycleOptions"
|
||||
keyName="name"
|
||||
:defaultIndex="[defaultIndex]"
|
||||
@close="showCycle = false"
|
||||
closeOnClickOverlay
|
||||
@cancel="showCycle = false"
|
||||
@confirm="selectCycle"
|
||||
></up-picker>
|
||||
<up-picker
|
||||
:show="showHoursStart"
|
||||
:columns="hours"
|
||||
:defaultIndex="[hoursStart]"
|
||||
closeOnClickOverlay
|
||||
@close="showHoursStart = false"
|
||||
@cancel="showHoursStart = false"
|
||||
@confirm="selectHours('start', $event)"
|
||||
></up-picker>
|
||||
<up-picker
|
||||
:show="showHoursEnd"
|
||||
:columns="hours"
|
||||
:defaultIndex="[hoursEnd]"
|
||||
closeOnClickOverlay
|
||||
@close="showHoursEnd = false"
|
||||
@cancel="showHoursEnd = false"
|
||||
@confirm="selectHours('end', $event)"
|
||||
></up-picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapState } from 'pinia'
|
||||
<script setup>
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import test from 'uview-plus/libs/function/test'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import LockInput from '@/components/LockInput/LockInput.vue'
|
||||
import LockDateHourPicker from '@/components/LockDateHourPicker/LockDateHourPicker.vue'
|
||||
import { createPsaawordRequest } from '@/api/keyboardPwd'
|
||||
import { addCustomPasswordRequest, createPsaawordRequest } from '@/api/keyboardPwd'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
LockInput,
|
||||
LockDateHourPicker
|
||||
const $lock = useLockStore()
|
||||
const $basic = useBasicStore()
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $user = useUserStore()
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
name: '永久'
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tabs: [
|
||||
{
|
||||
name: '永久'
|
||||
},
|
||||
{
|
||||
name: '限时'
|
||||
}
|
||||
],
|
||||
permanentName: '',
|
||||
temporaryName: '',
|
||||
temporaryTime: Number(new Date()),
|
||||
minDate: Number(new Date()),
|
||||
maxDate: Number(4133951940000),
|
||||
currnetIndex: 0,
|
||||
deviceInfo: null,
|
||||
pending: false,
|
||||
text: '密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。'
|
||||
{
|
||||
name: '限时'
|
||||
},
|
||||
{
|
||||
name: '单次'
|
||||
},
|
||||
{
|
||||
name: '自定义'
|
||||
},
|
||||
{
|
||||
name: '循环'
|
||||
},
|
||||
{
|
||||
name: '清空'
|
||||
}
|
||||
]
|
||||
const cycleOptions = ref([
|
||||
[
|
||||
{ type: 5, name: '周末' },
|
||||
{ type: 6, name: '每日' },
|
||||
{ type: 7, name: '工作日' },
|
||||
{ type: 8, name: '星期一' },
|
||||
{ type: 9, name: '星期二' },
|
||||
{ type: 10, name: '星期三' },
|
||||
{ type: 11, name: '星期四' },
|
||||
{ type: 12, name: '星期五' },
|
||||
{ type: 13, name: '星期六' },
|
||||
{ type: 14, name: '星期日' }
|
||||
]
|
||||
])
|
||||
const defaultIndex = ref(0)
|
||||
const showCycle = ref(false)
|
||||
const showHoursStart = ref(false)
|
||||
const showHoursEnd = ref(false)
|
||||
const hours = ref([Array.from({ length: 25 }, (v, k) => `${k}时`)])
|
||||
const permanentName = ref('')
|
||||
const temporaryName = ref('')
|
||||
const singleName = ref('')
|
||||
const customName = ref('')
|
||||
const cycleName = ref('')
|
||||
const emptyName = ref('')
|
||||
const temporaryTime = ref(Number(new Date()))
|
||||
const customPermanent = ref(true)
|
||||
const customStartTime = ref(0)
|
||||
const customEndTime = ref(0)
|
||||
const customAdmin = ref(false)
|
||||
const customPassword = ref('')
|
||||
const hoursStart = ref(0)
|
||||
const hoursEnd = ref(0)
|
||||
const minDate = ref(Number(new Date()))
|
||||
const maxDate = ref(Number(4133951940000))
|
||||
const currentIndex = ref(0)
|
||||
const deviceInfo = ref(null)
|
||||
const pending = ref(false)
|
||||
const text = ref(
|
||||
'密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。'
|
||||
)
|
||||
|
||||
onMounted(async () => {
|
||||
deviceInfo.value = await $basic.getDeviceInfo()
|
||||
temporaryTime.value = Number(getNextFullHour())
|
||||
hoursStart.value = Number(timeFormat(getNextFullHour(), 'h')) - 1
|
||||
hoursEnd.value = Number(timeFormat(getNextFullHour(), 'h'))
|
||||
minDate.value = Number(getNextFullHour())
|
||||
maxDate.value = Number(getFutureTimestamp())
|
||||
})
|
||||
|
||||
const changePassword = (type, e) => {
|
||||
if (type === 'custom') {
|
||||
customPassword.value = e
|
||||
}
|
||||
}
|
||||
|
||||
const selectCycle = e => {
|
||||
showCycle.value = false
|
||||
defaultIndex.value = e.indexs[0]
|
||||
}
|
||||
|
||||
const changePermanent = (type, e) => {
|
||||
if (type === 'custom') {
|
||||
customPermanent.value = e.detail.value
|
||||
if (customPermanent.value) {
|
||||
customStartTime.value = 0
|
||||
customEndTime.value = 0
|
||||
} else {
|
||||
customStartTime.value = new Date().getTime()
|
||||
customEndTime.value = new Date().getTime()
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(useBluetoothStore, ['currentLockInfo']),
|
||||
...mapState(useLockStore, ['passwordSearch'])
|
||||
},
|
||||
async onLoad() {
|
||||
this.deviceInfo = await this.getDeviceInfo()
|
||||
this.temporaryTime = Number(this.getNextFullHour())
|
||||
this.minDate = Number(this.getNextFullHour())
|
||||
this.maxDate = Number(this.getFutureTimestamp())
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useBasicStore, ['getDeviceInfo', 'backAndToast', 'getNetworkType']),
|
||||
...mapActions(useLockStore, ['getPasswordList', 'updatePasswordSearch']),
|
||||
getNextFullHour() {
|
||||
const now = new Date()
|
||||
const currentHour = now.getHours() + 1
|
||||
now.setHours(currentHour)
|
||||
now.setMinutes(0)
|
||||
now.setSeconds(0)
|
||||
now.setMilliseconds(0)
|
||||
}
|
||||
}
|
||||
|
||||
return now
|
||||
},
|
||||
getFutureTimestamp() {
|
||||
const currentDate = new Date()
|
||||
const changeAdmin = (type, e) => {
|
||||
if (type === 'custom') {
|
||||
customAdmin.value = e.detail.value
|
||||
}
|
||||
}
|
||||
|
||||
const year = currentDate.getFullYear()
|
||||
const month = currentDate.getMonth()
|
||||
const day = currentDate.getDate()
|
||||
const changeDate = (type, e) => {
|
||||
if (type === 'customStartTime') {
|
||||
customStartTime.value = e
|
||||
} else {
|
||||
customEndTime.value = e
|
||||
}
|
||||
}
|
||||
|
||||
const futureDate = new Date(year + 3, month, day, 23, 0, 0)
|
||||
const selectHours = (type, e) => {
|
||||
if (type === 'start') {
|
||||
showHoursStart.value = false
|
||||
hoursStart.value = e.indexs[0]
|
||||
} else {
|
||||
showHoursEnd.value = false
|
||||
hoursEnd.value = e.indexs[0]
|
||||
}
|
||||
}
|
||||
|
||||
return futureDate.getTime()
|
||||
},
|
||||
async createPassword(type) {
|
||||
const that = this
|
||||
if (
|
||||
(type === 'temporary' && this.temporaryName === '') ||
|
||||
(type === 'permanent' && this.permanentName === '')
|
||||
) {
|
||||
uni.showToast({
|
||||
title: '名称不能为空',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
const getNextFullHour = () => {
|
||||
const now = new Date()
|
||||
const currentHour = now.getHours() + 1
|
||||
now.setHours(currentHour)
|
||||
now.setMinutes(0)
|
||||
now.setSeconds(0)
|
||||
now.setMilliseconds(0)
|
||||
|
||||
const netWork = await this.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
return now
|
||||
}
|
||||
|
||||
if (this.pending) {
|
||||
return
|
||||
}
|
||||
this.pending = true
|
||||
const getFutureTimestamp = () => {
|
||||
const currentDate = new Date()
|
||||
|
||||
let params = {
|
||||
lockId: this.currentLockInfo.lockId,
|
||||
const year = currentDate.getFullYear()
|
||||
const month = currentDate.getMonth()
|
||||
const day = currentDate.getDate()
|
||||
|
||||
const futureDate = new Date(year + 3, month, day, 23, 0, 0)
|
||||
|
||||
return futureDate.getTime()
|
||||
}
|
||||
|
||||
const createPassword = async type => {
|
||||
if (
|
||||
(type === 'temporary' && temporaryName.value === '') ||
|
||||
(type === 'permanent' && permanentName.value === '') ||
|
||||
(type === 'single' && singleName.value === '') ||
|
||||
(type === 'cycle' && cycleName.value === '') ||
|
||||
(type === 'empty' && emptyName.value === '') ||
|
||||
(type === 'custom' && customName.value === '')
|
||||
) {
|
||||
uni.showToast({
|
||||
title: '名称不能为空',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'custom' && !test.rangeLength(customPassword.value, [6, 9])) {
|
||||
uni.showToast({
|
||||
title: '密码为6-9位纯数字',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (
|
||||
type === 'custom' &&
|
||||
customPermanent.value === false &&
|
||||
customStartTime.value >= customEndTime.value
|
||||
) {
|
||||
uni.showToast({
|
||||
title: '失效时间需晚于生效时间',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'cycle' && hoursStart.value >= hoursEnd.value) {
|
||||
uni.showToast({
|
||||
title: '失效时间需晚于生效时间',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
|
||||
if (pending.value) {
|
||||
return
|
||||
}
|
||||
pending.value = true
|
||||
|
||||
if (type === 'custom') {
|
||||
uni.showLoading({
|
||||
title: '生成中'
|
||||
})
|
||||
const params = {
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
pwdNo: 0,
|
||||
operate: 0,
|
||||
isAdmin: customAdmin.value ? 1 : 0,
|
||||
pwd: customPassword.value,
|
||||
userCountLimit: 0xffff,
|
||||
startTime: Math.floor(customStartTime.value / 1000),
|
||||
endTime: Math.floor(customEndTime.value / 1000)
|
||||
}
|
||||
const { code, data } = await $bluetooth.setLockPassword(params)
|
||||
if (code === 0 && data.status === 0) {
|
||||
console.log(1111, data)
|
||||
const { code: requestCode, message } = await addCustomPasswordRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
isCoerced: 2,
|
||||
pwdRight: 0
|
||||
}
|
||||
if (type === 'temporary') {
|
||||
params.keyboardPwdName = this.temporaryName
|
||||
params.keyboardPwdType = 3
|
||||
params.startDate = new Date().setHours(0, 0, 0, 0)
|
||||
params.endDate = this.temporaryTime
|
||||
params.hoursStart = 0
|
||||
params.hoursEnd = 0
|
||||
} else {
|
||||
params.startDate = 0
|
||||
params.endDate = 0
|
||||
params.keyboardPwdName = this.permanentName
|
||||
params.keyboardPwdType = 2
|
||||
params.hoursStart = 0
|
||||
params.hoursEnd = 0
|
||||
}
|
||||
const { code, data, message } = await createPsaawordRequest(params)
|
||||
if (code === 0) {
|
||||
addType: 1,
|
||||
pwdUserNo: data.no,
|
||||
pwdRight: customAdmin.value ? 1 : 0,
|
||||
keyboardPwdType: customPermanent.value ? 2 : 3,
|
||||
keyboardPwdName: customName.value,
|
||||
keyboardPwd: customPassword.value,
|
||||
startDate: customStartTime.value,
|
||||
endDate: customEndTime.value
|
||||
})
|
||||
uni.hideLoading()
|
||||
if (requestCode === 0) {
|
||||
uni.reportEvent('create_password', {})
|
||||
this.updatePasswordSearch({
|
||||
...this.passwordSearch,
|
||||
$lock.updatePasswordSearch({
|
||||
...$lock.passwordSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
this.getPasswordList(this.passwordSearch)
|
||||
$lock.getPasswordList($lock.passwordSearch)
|
||||
uni.showModal({
|
||||
title: '密码生成成功',
|
||||
content: `密码:${data.keyboardPwd}`,
|
||||
content: `密码:${customPassword.value}`,
|
||||
cancelText: '复制',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
uni.navigateBack()
|
||||
} else {
|
||||
uni.setClipboardData({
|
||||
data: data.keyboardPwd,
|
||||
data: customPassword.value,
|
||||
success: () => {
|
||||
that.backAndToast('复制成功')
|
||||
$basic.backAndToast('复制成功')
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -199,24 +485,144 @@
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
this.pending = false
|
||||
},
|
||||
changePermanentInput(e) {
|
||||
this.permanentName = e
|
||||
},
|
||||
changeTemporaryInput(e) {
|
||||
this.temporaryName = e
|
||||
},
|
||||
changeTemporaryTime(e) {
|
||||
this.temporaryTime = e
|
||||
},
|
||||
clickTab(data) {
|
||||
this.currnetIndex = data.index
|
||||
},
|
||||
changeSwiper(e) {
|
||||
this.currnetIndex = e.detail.current
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
if (data.status === 0xff) {
|
||||
uni.showToast({
|
||||
title: '创建失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfe) {
|
||||
uni.showToast({
|
||||
title: '管理员已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfd) {
|
||||
uni.showToast({
|
||||
title: '用户已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfc) {
|
||||
uni.showToast({
|
||||
title: '密码已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfb) {
|
||||
uni.showToast({
|
||||
title: '密码已存在',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '创建失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let params = {
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
isCoerced: 2,
|
||||
pwdRight: 0
|
||||
}
|
||||
if (type === 'temporary') {
|
||||
params.keyboardPwdName = temporaryName.value
|
||||
params.keyboardPwdType = 3
|
||||
params.startDate = new Date().setHours(0, 0, 0, 0)
|
||||
params.endDate = temporaryTime.value
|
||||
params.hoursStart = 0
|
||||
params.hoursEnd = 0
|
||||
} else if (type === 'permanent') {
|
||||
params.startDate = 0
|
||||
params.endDate = 0
|
||||
params.keyboardPwdName = permanentName.value
|
||||
params.keyboardPwdType = 2
|
||||
params.hoursStart = 0
|
||||
params.hoursEnd = 0
|
||||
} else if (type === 'single') {
|
||||
params.startDate = 0
|
||||
params.endDate = 0
|
||||
params.keyboardPwdName = singleName.value
|
||||
params.keyboardPwdType = 1
|
||||
params.hoursStart = 0
|
||||
params.hoursEnd = 0
|
||||
} else if (type === 'cycle') {
|
||||
params.startDate = new Date().getTime()
|
||||
params.endDate = new Date().getTime()
|
||||
params.keyboardPwdName = cycleName.value
|
||||
params.keyboardPwdType = cycleOptions.value[0][defaultIndex.value].type
|
||||
params.hoursStart = hoursStart.value
|
||||
params.hoursEnd = hoursEnd.value
|
||||
} else {
|
||||
params.startDate = 0
|
||||
params.endDate = 0
|
||||
params.keyboardPwdName = emptyName.value
|
||||
params.keyboardPwdType = 4
|
||||
params.hoursStart = 0
|
||||
params.hoursEnd = 0
|
||||
}
|
||||
const { code, data, message } = await createPsaawordRequest(params)
|
||||
if (code === 0) {
|
||||
uni.reportEvent('create_password', {})
|
||||
$lock.updatePasswordSearch({
|
||||
...$lock.passwordSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getPasswordList($lock.passwordSearch)
|
||||
uni.showModal({
|
||||
title: '密码生成成功',
|
||||
content: `密码:${data.keyboardPwd}`,
|
||||
cancelText: '复制',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
uni.navigateBack()
|
||||
} else {
|
||||
uni.setClipboardData({
|
||||
data: data.keyboardPwd,
|
||||
success: () => {
|
||||
$basic.backAndToast('复制成功')
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pending.value = false
|
||||
}
|
||||
|
||||
const changeName = (type, e) => {
|
||||
if (type === 'temporary') {
|
||||
temporaryName.value = e
|
||||
} else if (type === 'permanent') {
|
||||
permanentName.value = e
|
||||
} else if (type === 'single') {
|
||||
singleName.value = e
|
||||
} else if (type === 'cycle') {
|
||||
cycleName.value = e
|
||||
} else if (type === 'custom') {
|
||||
customName.value = e
|
||||
} else if (type === 'empty') {
|
||||
emptyName.value = e
|
||||
}
|
||||
}
|
||||
|
||||
const changeTemporaryTime = e => {
|
||||
temporaryTime.value = e
|
||||
}
|
||||
|
||||
const clickTab = data => {
|
||||
currentIndex.value = data.index
|
||||
}
|
||||
|
||||
const changeSwiper = e => {
|
||||
currentIndex.value = e.detail.current
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -176,7 +176,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
|
||||
if (type === 'temporary' && temporaryStartTime.value >= temporaryEndTime.value) {
|
||||
uni.showToast({
|
||||
title: '失效时间要大于生效时间',
|
||||
icon: 'none'
|
||||
|
||||
@ -137,10 +137,23 @@
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { computed, getCurrentInstance, ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { updateCardRequest } from '@/api/card'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { updateFingerprintRequest } from '@/api/fingerprint'
|
||||
import { updateRemoteRequest } from '@/api/remote'
|
||||
import { updatePalmVeinRequest } from '@/api/palmVein'
|
||||
import { updateFaceRequest } from '@/api/face'
|
||||
import { updateKeyDateRequest } from '@/api/key'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $user = useUserStore()
|
||||
const $basic = useBasicStore()
|
||||
|
||||
const showStartDate = ref(false)
|
||||
const showEndDate = ref(false)
|
||||
const showStartTime = ref(false)
|
||||
@ -150,6 +163,8 @@
|
||||
const endDate = ref(null)
|
||||
const weekDays = ref([])
|
||||
|
||||
const info = ref(null)
|
||||
|
||||
const startTimeText = ref(null)
|
||||
const endTimeText = ref(null)
|
||||
|
||||
@ -158,6 +173,8 @@
|
||||
const defaultStartDate = ref(0)
|
||||
const defaultEndDate = ref(0)
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
const list = ['一', '二', '三', '四', '五', '六', '日']
|
||||
|
||||
const canSubmit = computed(() => {
|
||||
@ -172,16 +189,24 @@
|
||||
|
||||
onLoad(options => {
|
||||
if (options.info) {
|
||||
const info = JSON.parse(options.info)
|
||||
if (info.startDate) {
|
||||
weekDays.value = info.weekDays
|
||||
startDate.value = info.startDate
|
||||
endDate.value = info.endDate
|
||||
const data = JSON.parse(options.info)
|
||||
info.value = data
|
||||
if (info.value.type) {
|
||||
uni.setNavigationBarTitle({
|
||||
title: '修改有效期'
|
||||
})
|
||||
}
|
||||
if (data.startDate) {
|
||||
weekDays.value = data.weekDays || data.weekDay
|
||||
startDate.value = data.startDate
|
||||
endDate.value = data.endDate
|
||||
|
||||
defaultStartDate.value = info.startDate
|
||||
defaultEndDate.value = info.endDate
|
||||
startTimeText.value = timeFormat(info.startDate, 'h:M')
|
||||
endTimeText.value = timeFormat(info.endDate, 'h:M')
|
||||
defaultStartDate.value = data.startDate
|
||||
defaultEndDate.value = data.endDate
|
||||
startTimeText.value = timeFormat(data.startDate, 'h:M')
|
||||
endTimeText.value = timeFormat(data.endDate, 'h:M')
|
||||
defaultStartTime.value = timeFormat(data.startDate, 'h:M')
|
||||
defaultEndTime.value = timeFormat(data.endDate, 'h:M')
|
||||
} else {
|
||||
defaultStartTime.value = timeFormat(new Date(), 'h:M')
|
||||
defaultEndTime.value = timeFormat(new Date(), 'h:M')
|
||||
@ -204,7 +229,7 @@
|
||||
return date1 - date2
|
||||
}
|
||||
|
||||
const save = () => {
|
||||
const save = async () => {
|
||||
if (!canSubmit.value) {
|
||||
return
|
||||
}
|
||||
@ -222,16 +247,156 @@
|
||||
})
|
||||
return
|
||||
}
|
||||
const data = {
|
||||
startDate: updateTime(startDate.value, startTimeText.value),
|
||||
endDate: updateTime(endDate.value, endTimeText.value),
|
||||
weekDays: weekDays.value.sort()
|
||||
}
|
||||
uni.navigateBack({
|
||||
success() {
|
||||
eventChannel.emit('change', data)
|
||||
if (!info.value.type) {
|
||||
const data = {
|
||||
startDate: updateTime(startDate.value, startTimeText.value),
|
||||
endDate: updateTime(endDate.value, endTimeText.value),
|
||||
weekDays: weekDays.value.sort()
|
||||
}
|
||||
})
|
||||
uni.navigateBack({
|
||||
success() {
|
||||
eventChannel.emit('change', data)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if (pending.value) {
|
||||
return
|
||||
}
|
||||
pending.value = true
|
||||
uni.showLoading({
|
||||
title: '更新中'
|
||||
})
|
||||
if (info.value.type === 'key') {
|
||||
const data = await updateKeyDateRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyId: info.value.keyId,
|
||||
keyType: 4,
|
||||
weekDays: weekDays.value.sort(),
|
||||
startDate: updateTime(startDate.value, startTimeText.value),
|
||||
endDate: updateTime(endDate.value, endTimeText.value),
|
||||
startTime: updateTime(startDate.value, startTimeText.value),
|
||||
endTime: updateTime(endDate.value, endTimeText.value)
|
||||
})
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
if (data.code === 0) {
|
||||
eventChannel.emit('refresh', {})
|
||||
$basic.backAndToast('更新成功')
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: data.message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
const { code } = await $bluetooth.registerAuthentication({
|
||||
type: info.value.type,
|
||||
operate: 1,
|
||||
isAdmin: info.value.type,
|
||||
isForce: info.value.isForce,
|
||||
isRound: 1,
|
||||
weekDays: weekDays.value.sort(),
|
||||
no: info.value[`${info.value.type}Number`],
|
||||
userCountLimit: 0xffff,
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
startDate: updateTime(startDate.value, startTimeText.value),
|
||||
endDate: updateTime(endDate.value, endTimeText.value),
|
||||
startTime: startTimeText.value,
|
||||
endTime: endTimeText.value
|
||||
})
|
||||
if (code === 0) {
|
||||
let data
|
||||
if (info.value.type === 'card') {
|
||||
data = await updateCardRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
cardId: info.value.cardId,
|
||||
cardType: 4,
|
||||
weekDay: weekDays.value.sort(),
|
||||
startDate: updateTime(startDate.value, startTimeText.value),
|
||||
endDate: updateTime(endDate.value, endTimeText.value),
|
||||
startTime: updateTime(startDate.value, startTimeText.value),
|
||||
endTime: updateTime(endDate.value, endTimeText.value),
|
||||
changeType: 1
|
||||
})
|
||||
} else if (info.value.type === 'fingerprint') {
|
||||
data = await updateFingerprintRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
fingerprintId: info.value.fingerprintId,
|
||||
fingerprintType: 4,
|
||||
weekDay: weekDays.value.sort(),
|
||||
startDate: updateTime(startDate.value, startTimeText.value),
|
||||
endDate: updateTime(endDate.value, endTimeText.value),
|
||||
startTime: updateTime(startDate.value, startTimeText.value),
|
||||
endTime: updateTime(endDate.value, endTimeText.value),
|
||||
changeType: 1
|
||||
})
|
||||
} else if (info.value.type === 'remote') {
|
||||
data = await updateRemoteRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
remoteId: info.value.remoteId,
|
||||
remoteType: 4,
|
||||
weekDay: weekDays.value.sort(),
|
||||
startDate: updateTime(startDate.value, startTimeText.value),
|
||||
endDate: updateTime(endDate.value, endTimeText.value),
|
||||
startTime: updateTime(startDate.value, startTimeText.value),
|
||||
endTime: updateTime(endDate.value, endTimeText.value),
|
||||
changeType: 1
|
||||
})
|
||||
} else if (info.value.type === 'face') {
|
||||
data = await updateFaceRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
faceId: info.value.faceId,
|
||||
faceType: 4,
|
||||
weekDay: weekDays.value.sort(),
|
||||
startDate: updateTime(startDate.value, startTimeText.value),
|
||||
endDate: updateTime(endDate.value, endTimeText.value),
|
||||
startTime: updateTime(startDate.value, startTimeText.value),
|
||||
endTime: updateTime(endDate.value, endTimeText.value),
|
||||
changeType: 1
|
||||
})
|
||||
} else if (info.value.type === 'palmVein') {
|
||||
data = await updatePalmVeinRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
palmVeinId: info.value.palmVeinId,
|
||||
palmVeinType: 4,
|
||||
weekDay: weekDays.value.sort(),
|
||||
startDate: updateTime(startDate.value, startTimeText.value),
|
||||
endDate: updateTime(endDate.value, endTimeText.value),
|
||||
startTime: updateTime(startDate.value, startTimeText.value),
|
||||
endTime: updateTime(endDate.value, endTimeText.value),
|
||||
changeType: 1
|
||||
})
|
||||
}
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
if (data.code === 0) {
|
||||
eventChannel.emit('refresh', {})
|
||||
$basic.backAndToast('更新成功')
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: data.message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '操作失败,请重试',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const updateTime = (datetime, timeStr) => {
|
||||
|
||||
@ -5,30 +5,44 @@
|
||||
<view class="item-title">人脸号</view>
|
||||
<view class="item-content">{{ info.faceNumber }}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item" style="margin-top: 2rpx" @click="() => $refs.modalInput.open()">
|
||||
<view class="item-title">姓名</view>
|
||||
<view class="item-content">{{ info.faceName }}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ info.faceName }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item" style="margin-top: 2rpx" @click="updateTime">
|
||||
<view class="item-title">有效期</view>
|
||||
<view v-if="info.faceType === 1">永久</view>
|
||||
<view v-else-if="info.faceType === 2">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="flex items-center">
|
||||
<view v-if="info.faceType === 1" class="mr-2">永久</view>
|
||||
<view v-else-if="info.faceType === 2" class="mr-2 w-400 text-right">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<view v-else class="mr-2">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd') }}</view>
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.faceType === 4">
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.faceType === 4" @click="updateTime">
|
||||
<view class="item-title">有效日</view>
|
||||
<view class="item-content">{{ $lock.convertWeekDaysToChineseString(info.weekDay) }}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{
|
||||
$lock.convertWeekDaysToChineseString(info.weekDay)
|
||||
}}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.faceType === 4">
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.faceType === 4" @click="updateTime">
|
||||
<view class="item-title">有效时间</view>
|
||||
<view class="item-content">
|
||||
{{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }}
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">
|
||||
{{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }}
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx">
|
||||
@ -39,11 +53,30 @@
|
||||
<view class="item-title">添加时间</view>
|
||||
<view class="item-content">{{ timeFormat(info.createDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
|
||||
<view class="item !py-2" style="margin-top: 20rpx">
|
||||
<view class="item-title">是否为管理员</view>
|
||||
<switch
|
||||
@click="disabled"
|
||||
:checked="info.faceRight"
|
||||
class="transform-scale-90"
|
||||
:disabled="true"
|
||||
color="#002ce5"
|
||||
/>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||
<view class="item-title">操作记录</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="button" @click="deletePassword">删除</view>
|
||||
<ModalInput
|
||||
ref="modalInput"
|
||||
title="请输入姓名"
|
||||
:autoClose="false"
|
||||
placeholder="请输入姓名"
|
||||
:value="info.faceName"
|
||||
@confirm="changeName"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@ -54,15 +87,83 @@
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { getFaceRequest, updateFaceRequest } from '@/api/face'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
const $lock = useLockStore()
|
||||
const $basic = useBasicStore()
|
||||
const $bluetooth = useBluetoothStore()
|
||||
|
||||
const info = ref(null)
|
||||
|
||||
const modalInput = ref(null)
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
const changeName = async name => {
|
||||
if (!name) {
|
||||
uni.showToast({
|
||||
title: '请输入姓名',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
const { code, message } = await updateFaceRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
faceId: info.value.faceId,
|
||||
faceType: info.value.faceType,
|
||||
faceName: name,
|
||||
changeType: 1
|
||||
})
|
||||
pending.value = false
|
||||
if (code === 0) {
|
||||
modalInput.value.close()
|
||||
eventChannel.emit('refresherList', {})
|
||||
info.value.faceName = name
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const updateTime = () => {
|
||||
$basic.routeJump({
|
||||
name: info.value.faceType === 1 || info.value.faceType === 2 ? 'temporaryDate' : 'cycleDate',
|
||||
params: {
|
||||
info: JSON.stringify({ ...info.value, type: 'face' })
|
||||
},
|
||||
events: {
|
||||
refresh() {
|
||||
eventChannel.emit('refresherList', {})
|
||||
getFaceRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
faceId: info.value.faceId
|
||||
}).then(res => {
|
||||
info.value = res.data
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const disabled = () => {
|
||||
uni.showToast({
|
||||
title: '暂不支持修改',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
onLoad(options => {
|
||||
if (options.info) {
|
||||
info.value = JSON.parse(options.info)
|
||||
|
||||
@ -354,6 +354,12 @@
|
||||
events: {
|
||||
delete() {
|
||||
deleteItem({ ...item, back: true })
|
||||
},
|
||||
refresherList() {
|
||||
pageNo.value = 1
|
||||
getList({
|
||||
pageNo: pageNo.value
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -5,30 +5,54 @@
|
||||
<view class="item-title">指纹号</view>
|
||||
<view class="item-content">{{ info.fingerprintNumber }}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item" style="margin-top: 2rpx" @click="() => $refs.modalInput.open()">
|
||||
<view class="item-title">姓名</view>
|
||||
<view class="item-content">{{ info.fingerprintName }}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ info.fingerprintName }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item" style="margin-top: 2rpx" @click="updateTime">
|
||||
<view class="item-title">有效期</view>
|
||||
<view v-if="info.fingerprintType === 1">永久</view>
|
||||
<view v-else-if="info.fingerprintType === 2">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="flex items-center">
|
||||
<view v-if="info.fingerprintType === 1" class="mr-2">永久</view>
|
||||
<view v-else-if="info.fingerprintType === 2" class="mr-2 w-400 text-right">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<view v-else class="mr-2">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd') }}</view>
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.fingerprintType === 4">
|
||||
<view
|
||||
class="item"
|
||||
style="margin-top: 2rpx"
|
||||
v-if="info.fingerprintType === 4"
|
||||
@click="updateTime"
|
||||
>
|
||||
<view class="item-title">有效日</view>
|
||||
<view class="item-content">{{ $lock.convertWeekDaysToChineseString(info.weekDay) }}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{
|
||||
$lock.convertWeekDaysToChineseString(info.weekDay)
|
||||
}}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.fingerprintType === 4">
|
||||
<view
|
||||
class="item"
|
||||
style="margin-top: 2rpx"
|
||||
v-if="info.fingerprintType === 4"
|
||||
@click="updateTime"
|
||||
>
|
||||
<view class="item-title">有效时间</view>
|
||||
<view class="item-content">
|
||||
{{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }}
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">
|
||||
{{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }}
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx">
|
||||
@ -39,11 +63,40 @@
|
||||
<view class="item-title">添加时间</view>
|
||||
<view class="item-content">{{ timeFormat(info.createDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
|
||||
<view class="item !py-2" style="margin-top: 20rpx">
|
||||
<view class="item-title">胁迫指纹</view>
|
||||
<switch
|
||||
:checked="info.isCoerced === 2"
|
||||
class="transform-scale-90"
|
||||
@click="changeCoerced"
|
||||
:disabled="true"
|
||||
color="#002ce5"
|
||||
/>
|
||||
</view>
|
||||
<view class="item !py-2" style="margin-top: 2rpx">
|
||||
<view class="item-title">是否为管理员</view>
|
||||
<switch
|
||||
@click="disabled"
|
||||
:checked="info.fingerRight"
|
||||
class="transform-scale-90"
|
||||
:disabled="true"
|
||||
color="#002ce5"
|
||||
/>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||
<view class="item-title">操作记录</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="button" @click="deletePassword">删除</view>
|
||||
<ModalInput
|
||||
ref="modalInput"
|
||||
title="请输入姓名"
|
||||
:autoClose="false"
|
||||
placeholder="请输入姓名"
|
||||
:value="info.fingerprintName"
|
||||
@confirm="changeName"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@ -54,6 +107,9 @@
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { getFingerprintRequest, updateFingerprintRequest } from '@/api/fingerprint'
|
||||
|
||||
const $basic = useBasicStore()
|
||||
|
||||
@ -61,9 +117,134 @@
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
const $lock = useLockStore()
|
||||
const $user = useUserStore()
|
||||
const $bluetooth = useBluetoothStore()
|
||||
|
||||
const info = ref(null)
|
||||
|
||||
const modalInput = ref(null)
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
const disabled = () => {
|
||||
uni.showToast({
|
||||
title: '暂不支持修改',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
const changeCoerced = async () => {
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
uni.showLoading({
|
||||
title: '更新中'
|
||||
})
|
||||
const { code } = await $bluetooth.registerAuthentication({
|
||||
type: 'fingerprint',
|
||||
operate: 1,
|
||||
isAdmin: info.value.isAdmin,
|
||||
isForce: info.value.isCoerced === 2 ? 0 : 1,
|
||||
isRound: info.value.fingerprintType === 4 ? 1 : 0,
|
||||
weekDays: info.value.weekDay,
|
||||
no: info.value.fingerprintNumber,
|
||||
userCountLimit: 0xffff,
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
startDate: info.value.startDate,
|
||||
endDate: info.value.endDate,
|
||||
startTime:
|
||||
info.value.fingerprintType === 4 ? timeFormat(info.value.startDate, 'h:M') : '00:00',
|
||||
endTime: info.value.fingerprintType === 4 ? timeFormat(info.value.endDate, 'h:M') : '00:00'
|
||||
})
|
||||
if (code === 0) {
|
||||
const { code, message } = await updateFingerprintRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
fingerprintId: info.value.fingerprintId,
|
||||
fingerprintType: info.value.fingerprintType,
|
||||
isCoerced: info.value.isCoerced === 2 ? 1 : 2,
|
||||
changeType: 1
|
||||
})
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
if (code === 0) {
|
||||
info.value.isCoerced = info.value.isCoerced === 2 ? 1 : 2
|
||||
eventChannel.emit('refresherList', {})
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '操作失败,请重试',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const changeName = async name => {
|
||||
if (!name) {
|
||||
uni.showToast({
|
||||
title: '请输入姓名',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
const { code, message } = await updateFingerprintRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
fingerprintId: info.value.fingerprintId,
|
||||
fingerprintType: info.value.fingerprintType,
|
||||
fingerprintName: name,
|
||||
changeType: 1
|
||||
})
|
||||
pending.value = false
|
||||
if (code === 0) {
|
||||
modalInput.value.close()
|
||||
eventChannel.emit('refresherList', {})
|
||||
info.value.fingerprintName = name
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const updateTime = () => {
|
||||
$basic.routeJump({
|
||||
name:
|
||||
info.value.fingerprintType === 1 || info.value.fingerprintType === 2
|
||||
? 'temporaryDate'
|
||||
: 'cycleDate',
|
||||
params: {
|
||||
info: JSON.stringify({ ...info.value, type: 'fingerprint' })
|
||||
},
|
||||
events: {
|
||||
refresh() {
|
||||
eventChannel.emit('refresherList', {})
|
||||
getFingerprintRequest({
|
||||
fingerprintId: info.value.fingerprintId
|
||||
}).then(res => {
|
||||
info.value = res.data
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const toRecordList = async () => {
|
||||
$basic.routeJump({
|
||||
name: 'typeRecordList',
|
||||
|
||||
@ -353,6 +353,12 @@
|
||||
events: {
|
||||
delete() {
|
||||
deleteItem({ ...item, back: true })
|
||||
},
|
||||
refresherList() {
|
||||
pageNo.value = 1
|
||||
getList({
|
||||
pageNo: pageNo.value
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -1,49 +1,89 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="item">
|
||||
<view class="item" @click="() => $refs.modalInput.open()">
|
||||
<view class="item-title" style="width: 350rpx">姓名</view>
|
||||
<view class="item-content">{{ currentKeyInfo.keyName }}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ $lock.currentKeyInfo.keyName }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item" style="margin-top: 2rpx" @click="updateTime">
|
||||
<view class="item-title">有效期</view>
|
||||
<view v-if="currentKeyInfo.keyType === 1">永久</view>
|
||||
<view v-else-if="currentKeyInfo.keyType === 3">单次</view>
|
||||
<view v-else-if="currentKeyInfo.keyType === 4">
|
||||
<view class="item-content">{{ timeFormat(currentKeyInfo.startDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="item-content">{{ timeFormat(currentKeyInfo.endDate, 'yyyy-mm-dd') }}</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
<view class="item-content">{{
|
||||
timeFormat(currentKeyInfo.startDate, 'yyyy-mm-dd h:M')
|
||||
}}</view>
|
||||
<view class="item-content">{{ timeFormat(currentKeyInfo.endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view class="flex items-center">
|
||||
<view v-if="$lock.currentKeyInfo.keyType === 1" class="mr-2">永久</view>
|
||||
<view v-else-if="$lock.currentKeyInfo.keyType === 3">单次</view>
|
||||
<view v-else-if="$lock.currentKeyInfo.keyType === 4" class="mr-2">
|
||||
<view class="item-content">{{
|
||||
timeFormat($lock.currentKeyInfo.startDate, 'yyyy-mm-dd')
|
||||
}}</view>
|
||||
<view class="item-content">{{
|
||||
timeFormat($lock.currentKeyInfo.endDate, 'yyyy-mm-dd')
|
||||
}}</view>
|
||||
</view>
|
||||
<view v-else class="mr-2">
|
||||
<view class="item-content">{{
|
||||
timeFormat($lock.currentKeyInfo.startDate, 'yyyy-mm-dd h:M')
|
||||
}}</view>
|
||||
<view class="item-content">{{
|
||||
timeFormat($lock.currentKeyInfo.endDate, 'yyyy-mm-dd h:M')
|
||||
}}</view>
|
||||
</view>
|
||||
<up-icon v-if="$lock.currentKeyInfo.keyType !== 3" name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="currentKeyInfo.keyType === 4" class="item" style="margin-top: 2rpx">
|
||||
<view
|
||||
v-if="$lock.currentKeyInfo.keyType === 4"
|
||||
class="item"
|
||||
style="margin-top: 2rpx"
|
||||
@click="updateTime"
|
||||
>
|
||||
<view class="item-title">有效日</view>
|
||||
<view class="item-content">{{
|
||||
convertWeekDaysToChineseString(currentKeyInfo.weekDays)
|
||||
}}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{
|
||||
$lock.convertWeekDaysToChineseString($lock.currentKeyInfo.weekDays)
|
||||
}}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" v-if="currentKeyInfo.keyType === 4" style="margin-top: 2rpx">
|
||||
<view
|
||||
class="item"
|
||||
v-if="$lock.currentKeyInfo.keyType === 4"
|
||||
style="margin-top: 2rpx"
|
||||
@click="updateTime"
|
||||
>
|
||||
<view class="item-title">有效时间</view>
|
||||
<view class="item-content">
|
||||
{{ timeFormat(currentKeyInfo.startDate, 'h:M') }}~{{
|
||||
timeFormat(currentKeyInfo.endDate, 'h:M')
|
||||
}}
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">
|
||||
{{ timeFormat($lock.currentKeyInfo.startDate, 'h:M') }}~{{
|
||||
timeFormat($lock.currentKeyInfo.endDate, 'h:M')
|
||||
}}</view
|
||||
>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx">
|
||||
<view class="item-title">接收者</view>
|
||||
<view class="item-content">{{ currentKeyInfo.username }}</view>
|
||||
<view class="item-content">{{ $lock.currentKeyInfo.username }}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item-title">发送人</view>
|
||||
<view class="item-content">{{ currentKeyInfo.senderUsername }}</view>
|
||||
<view class="item-content">{{ $lock.currentKeyInfo.senderUsername }}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item-title">发送时间</view>
|
||||
<view class="item-content">{{ timeFormat(currentKeyInfo.sendDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view class="item-content">{{
|
||||
timeFormat($lock.currentKeyInfo.sendDate, 'yyyy-mm-dd h:M')
|
||||
}}</view>
|
||||
</view>
|
||||
<view class="item !py-2" style="margin-top: 20rpx" v-if="$lock.currentKeyInfo.keyRight === 1">
|
||||
<view class="item-title">仅管理自己创建的用户</view>
|
||||
<switch
|
||||
:checked="$lock.currentKeyInfo.isOnlyManageSelf"
|
||||
class="transform-scale-90"
|
||||
@click="changeManageSelf"
|
||||
:disabled="true"
|
||||
color="#002ce5"
|
||||
/>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||
<view class="item-title">操作记录</view>
|
||||
@ -65,116 +105,231 @@
|
||||
</view>
|
||||
</view>
|
||||
</up-modal>
|
||||
<ModalInput
|
||||
ref="modalInput"
|
||||
title="请输入姓名"
|
||||
:autoClose="false"
|
||||
placeholder="请输入姓名"
|
||||
:value="$lock.currentKeyInfo.keyName"
|
||||
@confirm="changeName"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapState } from 'pinia'
|
||||
<script setup>
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { ref } from 'vue'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { deleteKeyRequest } from '@/api/key'
|
||||
import {
|
||||
deleteKeyRequest,
|
||||
getKeyRequest,
|
||||
updateKeyDateRequest,
|
||||
updateKeyNameRequest
|
||||
} from '@/api/key'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
showModal: false,
|
||||
checked: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(useLockStore, ['currentKeyInfo', 'keySearch'])
|
||||
},
|
||||
methods: {
|
||||
timeFormat,
|
||||
...mapActions(useLockStore, [
|
||||
'updateKeySearch',
|
||||
'getKeyList',
|
||||
'convertWeekDaysToChineseString'
|
||||
]),
|
||||
...mapActions(useBasicStore, ['backAndToast', 'routeJump']),
|
||||
async toRecordList() {
|
||||
this.routeJump({
|
||||
name: 'typeRecordList',
|
||||
params: {
|
||||
name: this.currentKeyInfo.keyName,
|
||||
key: 'keyId',
|
||||
id: this.currentKeyInfo.keyId
|
||||
}
|
||||
})
|
||||
const $lock = useLockStore()
|
||||
const $basic = useBasicStore()
|
||||
const $bluetooth = useBluetoothStore()
|
||||
|
||||
const showModal = ref(false)
|
||||
const checked = ref(false)
|
||||
|
||||
const modalInput = ref(null)
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
const changeManageSelf = async () => {
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
uni.showLoading({
|
||||
title: '更新中'
|
||||
})
|
||||
const { code, message } = await updateKeyDateRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyId: $lock.currentKeyInfo.keyId,
|
||||
keyType: $lock.currentKeyInfo.keyType,
|
||||
startDate: $lock.currentKeyInfo.startDate,
|
||||
endDate: $lock.currentKeyInfo.endDate,
|
||||
isOnlyManageSelf: $lock.currentKeyInfo.isOnlyManageSelf === 1 ? 0 : 1
|
||||
})
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
if (code === 0) {
|
||||
$lock.updateCurrentKeyInfo({
|
||||
...$lock.currentKeyInfo,
|
||||
isOnlyManageSelf: $lock.currentKeyInfo.isOnlyManageSelf === 1 ? 0 : 1
|
||||
})
|
||||
$lock.updateKeySearch({
|
||||
...$lock.keySearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getKeyList($lock.keySearch)
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const updateTime = () => {
|
||||
if ($lock.currentKeyInfo.keyType === 3) return
|
||||
$basic.routeJump({
|
||||
name:
|
||||
$lock.currentKeyInfo.keyType === 1 || $lock.currentKeyInfo.keyType === 2
|
||||
? 'temporaryDate'
|
||||
: 'cycleDate',
|
||||
params: {
|
||||
info: JSON.stringify({ ...$lock.currentKeyInfo, type: 'key' })
|
||||
},
|
||||
cancelModal() {
|
||||
this.showModal = false
|
||||
this.checked = false
|
||||
},
|
||||
changeRadio() {
|
||||
this.checked = !this.checked
|
||||
},
|
||||
async confirmModal() {
|
||||
uni.showLoading({
|
||||
title: '删除中',
|
||||
mask: true
|
||||
})
|
||||
const that = this
|
||||
const { code } = await deleteKeyRequest({
|
||||
keyId: that.currentKeyInfo.keyId,
|
||||
includeUnderlings: that.checked ? 1 : 0
|
||||
})
|
||||
that.showModal = false
|
||||
if (code === 0) {
|
||||
that.updateKeySearch({
|
||||
...that.keySearch,
|
||||
events: {
|
||||
refresh() {
|
||||
$lock.updateKeySearch({
|
||||
...$lock.keySearch,
|
||||
pageNo: 1
|
||||
})
|
||||
that.getKeyList(that.keySearch)
|
||||
uni.hideLoading()
|
||||
that.backAndToast('删除成功')
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: 'message',
|
||||
icon: 'none'
|
||||
$lock.getKeyList($lock.keySearch)
|
||||
getKeyRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyId: $lock.currentKeyInfo.keyId
|
||||
}).then(res => {
|
||||
$lock.updateCurrentKeyInfo({
|
||||
...res.data,
|
||||
keyId: $lock.currentKeyInfo.keyId
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
async deleteKey() {
|
||||
const that = this
|
||||
if (that.currentKeyInfo.keyRight === 1) {
|
||||
that.showModal = true
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该钥匙',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: '删除中',
|
||||
mask: true
|
||||
})
|
||||
const { code: requestCode, message } = await deleteKeyRequest({
|
||||
keyId: that.currentKeyInfo.keyId
|
||||
})
|
||||
if (requestCode === 0) {
|
||||
uni.hideLoading()
|
||||
that.updateKeySearch({
|
||||
...that.keySearch,
|
||||
pageNo: 1
|
||||
})
|
||||
await that.getKeyList(that.keySearch)
|
||||
that.backAndToast('删除成功')
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const changeName = async name => {
|
||||
if (!name) {
|
||||
uni.showToast({
|
||||
title: '请输入姓名',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
const { code, message } = await updateKeyNameRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyId: $lock.currentKeyInfo.keyId,
|
||||
keyNameForAdmin: name
|
||||
})
|
||||
pending.value = false
|
||||
if (code === 0) {
|
||||
modalInput.value.close()
|
||||
$lock.updateKeySearch({
|
||||
...$lock.keySearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getKeyList($lock.keySearch)
|
||||
$lock.updateCurrentKeyInfo({
|
||||
...$lock.currentKeyInfo,
|
||||
keyName: name
|
||||
})
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const toRecordList = () => {
|
||||
$basic.routeJump({
|
||||
name: 'typeRecordList',
|
||||
params: {
|
||||
name: $lock.currentKeyInfo.keyName,
|
||||
key: 'keyId',
|
||||
id: $lock.currentKeyInfo.keyId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const cancelModal = () => {
|
||||
showModal.value = false
|
||||
checked.value = false
|
||||
}
|
||||
|
||||
const changeRadio = () => {
|
||||
checked.value = !checked.value
|
||||
}
|
||||
|
||||
const confirmModal = async () => {
|
||||
uni.showLoading({
|
||||
title: '删除中',
|
||||
mask: true
|
||||
})
|
||||
const { code } = await deleteKeyRequest({
|
||||
keyId: $lock.currentKeyInfo.keyId,
|
||||
includeUnderlings: checked.value ? 1 : 0
|
||||
})
|
||||
showModal.value = false
|
||||
if (code === 0) {
|
||||
$lock.updateKeySearch({
|
||||
...$lock.keySearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getKeyList($lock.keySearch)
|
||||
uni.hideLoading()
|
||||
$basic.backAndToast('删除成功')
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: 'message',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const deleteKey = async () => {
|
||||
if ($lock.currentKeyInfo.keyRight === 1) {
|
||||
showModal.value = true
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该钥匙',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: '删除中',
|
||||
mask: true
|
||||
})
|
||||
const { code: requestCode, message } = await deleteKeyRequest({
|
||||
keyId: $lock.currentKeyInfo.keyId
|
||||
})
|
||||
if (requestCode === 0) {
|
||||
uni.hideLoading()
|
||||
$lock.updateKeySearch({
|
||||
...$lock.keySearch,
|
||||
pageNo: 1
|
||||
})
|
||||
await $lock.getKeyList($lock.keySearch)
|
||||
$lock.backAndToast('删除成功')
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -5,30 +5,54 @@
|
||||
<view class="item-title">掌静脉号</view>
|
||||
<view class="item-content">{{ info.palmVeinNumber }}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item" style="margin-top: 2rpx" @click="() => $refs.modalInput.open()">
|
||||
<view class="item-title">姓名</view>
|
||||
<view class="item-content">{{ info.palmVeinName }}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ info.palmVeinName }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item" style="margin-top: 2rpx" @click="updateTime">
|
||||
<view class="item-title">有效期</view>
|
||||
<view v-if="info.palmVeinType === 1">永久</view>
|
||||
<view v-else-if="info.palmVeinType === 2">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="flex items-center">
|
||||
<view v-if="info.palmVeinType === 1" class="mr-2">永久</view>
|
||||
<view v-else-if="info.palmVeinType === 2" class="mr-2 w-400 text-right">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<view v-else class="mr-2">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd') }}</view>
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.palmVeinType === 4">
|
||||
<view
|
||||
class="item"
|
||||
style="margin-top: 2rpx"
|
||||
v-if="info.palmVeinType === 4"
|
||||
@click="updateTime"
|
||||
>
|
||||
<view class="item-title">有效日</view>
|
||||
<view class="item-content">{{ $lock.convertWeekDaysToChineseString(info.weekDay) }}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{
|
||||
$lock.convertWeekDaysToChineseString(info.weekDay)
|
||||
}}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.palmVeinType === 4">
|
||||
<view
|
||||
class="item"
|
||||
style="margin-top: 2rpx"
|
||||
v-if="info.palmVeinType === 4"
|
||||
@click="updateTime"
|
||||
>
|
||||
<view class="item-title">有效时间</view>
|
||||
<view class="item-content">
|
||||
{{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }}
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">
|
||||
{{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }}
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx">
|
||||
@ -39,11 +63,40 @@
|
||||
<view class="item-title">添加时间</view>
|
||||
<view class="item-content">{{ timeFormat(info.createDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
|
||||
<view class="item !py-2" style="margin-top: 20rpx">
|
||||
<view class="item-title">胁迫掌静脉</view>
|
||||
<switch
|
||||
:checked="info.isCoerced === 2"
|
||||
class="transform-scale-90"
|
||||
@click="changeCoerced"
|
||||
:disabled="true"
|
||||
color="#002ce5"
|
||||
/>
|
||||
</view>
|
||||
<view class="item !py-2" style="margin-top: 2rpx">
|
||||
<view class="item-title">是否为管理员</view>
|
||||
<switch
|
||||
@click="disabled"
|
||||
:checked="info.palmVeinRight"
|
||||
class="transform-scale-90"
|
||||
:disabled="true"
|
||||
color="#002ce5"
|
||||
/>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||
<view class="item-title">操作记录</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="button" @click="deletePassword">删除</view>
|
||||
<ModalInput
|
||||
ref="modalInput"
|
||||
title="请输入姓名"
|
||||
:autoClose="false"
|
||||
placeholder="请输入姓名"
|
||||
:value="info.palmVeinName"
|
||||
@confirm="changeName"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@ -54,15 +107,142 @@
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { getPalmVeinRequest, updatePalmVeinRequest } from '@/api/palmVein'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
const $lock = useLockStore()
|
||||
const $basic = useBasicStore()
|
||||
const $user = useUserStore()
|
||||
const $bluetooth = useBluetoothStore()
|
||||
|
||||
const info = ref(null)
|
||||
|
||||
const modalInput = ref(null)
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
const changeCoerced = async () => {
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
uni.showLoading({
|
||||
title: '更新中'
|
||||
})
|
||||
const { code } = await $bluetooth.registerAuthentication({
|
||||
type: 'palmVein',
|
||||
operate: 1,
|
||||
isAdmin: info.value.isAdmin,
|
||||
isForce: info.value.isCoerced === 2 ? 0 : 1,
|
||||
isRound: info.value.palmVeinType === 4 ? 1 : 0,
|
||||
weekDays: info.value.weekDay,
|
||||
no: info.value.palmVeinNumber,
|
||||
userCountLimit: 0xffff,
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
startDate: info.value.startDate,
|
||||
endDate: info.value.endDate,
|
||||
startTime: info.value.palmVeinType === 4 ? timeFormat(info.value.startDate, 'h:M') : '00:00',
|
||||
endTime: info.value.palmVeinType === 4 ? timeFormat(info.value.endDate, 'h:M') : '00:00'
|
||||
})
|
||||
if (code === 0) {
|
||||
const { code, message } = await updatePalmVeinRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
palmVeinId: info.value.palmVeinId,
|
||||
palmVeinType: info.value.palmVeinType,
|
||||
isCoerced: info.value.isCoerced === 2 ? 1 : 2,
|
||||
changeType: 1
|
||||
})
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
if (code === 0) {
|
||||
info.value.isCoerced = info.value.isCoerced === 2 ? 1 : 2
|
||||
eventChannel.emit('refresherList', {})
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '操作失败,请重试',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const changeName = async name => {
|
||||
if (!name) {
|
||||
uni.showToast({
|
||||
title: '请输入姓名',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
const { code, message } = await updatePalmVeinRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
palmVeinId: info.value.palmVeinId,
|
||||
palmVeinType: info.value.palmVeinType,
|
||||
palmVeinName: name,
|
||||
changeType: 1
|
||||
})
|
||||
pending.value = false
|
||||
if (code === 0) {
|
||||
modalInput.value.close()
|
||||
eventChannel.emit('refresherList', {})
|
||||
info.value.palmVeinName = name
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const updateTime = () => {
|
||||
$basic.routeJump({
|
||||
name:
|
||||
info.value.palmVeinType === 1 || info.value.palmVeinType === 2
|
||||
? 'temporaryDate'
|
||||
: 'cycleDate',
|
||||
params: {
|
||||
info: JSON.stringify({ ...info.value, type: 'palmVein' })
|
||||
},
|
||||
events: {
|
||||
refresh() {
|
||||
eventChannel.emit('refresherList', {})
|
||||
getPalmVeinRequest({
|
||||
palmVeinId: info.value.palmVeinId
|
||||
}).then(res => {
|
||||
info.value = res.data
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const disabled = () => {
|
||||
uni.showToast({
|
||||
title: '暂不支持修改',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
onLoad(options => {
|
||||
if (options.info) {
|
||||
info.value = JSON.parse(options.info)
|
||||
|
||||
@ -358,6 +358,12 @@
|
||||
events: {
|
||||
delete() {
|
||||
deleteItem({ ...item, back: true })
|
||||
},
|
||||
refresherList() {
|
||||
pageNo.value = 1
|
||||
getList({
|
||||
pageNo: pageNo.value
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -1,141 +1,360 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="item">
|
||||
<view class="item" v-if="$lock.currentPasswordInfo.isCustom === 1">
|
||||
<view class="item-title">密码号</view>
|
||||
<view class="item-content">{{ $lock.currentPasswordInfo.pwdUserNo }}</view>
|
||||
</view>
|
||||
<view
|
||||
class="item"
|
||||
:style="{ marginTop: $lock.currentPasswordInfo.isCustom === 1 ? '2rpx' : '0' }"
|
||||
@click="() => $lock.currentPasswordInfo.isCustom === 1 && $refs.modalPassword.open()"
|
||||
>
|
||||
<view class="item-title">密码</view>
|
||||
<view class="item-content">{{ currentPasswordInfo.keyboardPwd }}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item-title">姓名</view>
|
||||
<view class="item-content">{{ currentPasswordInfo.keyboardPwdName }}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item-title">有效期</view>
|
||||
<view v-if="currentPasswordInfo.keyboardPwdType === 2">永久</view>
|
||||
<view v-else-if="currentPasswordInfo.keyboardPwdType <= 4">
|
||||
<view class="item-content">{{
|
||||
timeFormat(currentPasswordInfo.startDate, 'yyyy-mm-dd h:M')
|
||||
}}</view>
|
||||
<view class="item-content">{{
|
||||
timeFormat(currentPasswordInfo.endDate, 'yyyy-mm-dd h:M')
|
||||
}}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ $lock.currentPasswordInfo.keyboardPwd }}</view>
|
||||
<up-icon v-if="$lock.currentPasswordInfo.isCustom === 1" name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view v-else>
|
||||
{{ currentPasswordInfo.timeText.slice(0, -3) }}
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx" @click="() => $refs.modalInput.open()">
|
||||
<view class="item-title">姓名</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ $lock.currentPasswordInfo.keyboardPwdName }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx" @click="updateTime">
|
||||
<view class="item-title">有效期</view>
|
||||
<view class="flex items-center">
|
||||
<view class="mr-2">
|
||||
<view v-if="$lock.currentPasswordInfo.keyboardPwdType === 2">永久</view>
|
||||
<view v-else-if="$lock.currentPasswordInfo.keyboardPwdType <= 4">
|
||||
<view class="item-content">{{
|
||||
timeFormat($lock.currentPasswordInfo.startDate, 'yyyy-mm-dd h:M')
|
||||
}}</view>
|
||||
<view class="item-content">{{
|
||||
timeFormat($lock.currentPasswordInfo.endDate, 'yyyy-mm-dd h:M')
|
||||
}}</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
{{ $lock.currentPasswordInfo.timeText.slice(0, -3) }}
|
||||
</view>
|
||||
</view>
|
||||
<up-icon v-if="$lock.currentPasswordInfo.isCustom === 1" name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx">
|
||||
<view class="item-title">发送人</view>
|
||||
<view class="item-content">{{ currentPasswordInfo.senderUsername }}</view>
|
||||
<view class="item-content">{{ $lock.currentPasswordInfo.senderUsername }}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item-title">发送时间</view>
|
||||
<view class="item-content">{{
|
||||
timeFormat(currentPasswordInfo.sendDate, 'yyyy-mm-dd h:M')
|
||||
timeFormat($lock.currentPasswordInfo.sendDate, 'yyyy-mm-dd h:M')
|
||||
}}</view>
|
||||
</view>
|
||||
<view class="item !py-2" style="margin-top: 20rpx">
|
||||
<view class="item-title">是否为管理员</view>
|
||||
<switch
|
||||
@click="disabled"
|
||||
:checked="$lock.currentPasswordInfo.pwdRight"
|
||||
class="transform-scale-90"
|
||||
:disabled="true"
|
||||
color="#002ce5"
|
||||
/>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||
<view class="item-title">操作记录</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="button" @click="deletePassword">删除</view>
|
||||
<ModalInput
|
||||
ref="modalInput"
|
||||
title="请输入姓名"
|
||||
:autoClose="false"
|
||||
placeholder="请输入姓名"
|
||||
:value="$lock.currentPasswordInfo.keyboardPwdName"
|
||||
@confirm="changeName"
|
||||
/>
|
||||
<ModalInput
|
||||
ref="modalPassword"
|
||||
title="修改密码"
|
||||
:autoClose="false"
|
||||
:maxlength="9"
|
||||
type="number"
|
||||
placeholder="密码为6-9位数字"
|
||||
:value="$lock.currentPasswordInfo.keyboardPwd"
|
||||
@confirm="changePassword"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapState } from 'pinia'
|
||||
<script setup>
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { ref } from 'vue'
|
||||
import test from 'uview-plus/libs/function/test'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { deletePsaawordRequest } from '@/api/keyboardPwd'
|
||||
import {
|
||||
deletePsaawordRequest,
|
||||
getPasswordRequest,
|
||||
updatePasswordRequest
|
||||
} from '@/api/keyboardPwd'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
computed: {
|
||||
...mapState(useLockStore, ['currentPasswordInfo', 'passwordSearch']),
|
||||
...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']),
|
||||
...mapState(useUserStore, ['userInfo'])
|
||||
},
|
||||
methods: {
|
||||
timeFormat,
|
||||
...mapActions(useBluetoothStore, ['setLockPassword', 'closeBluetoothConnection']),
|
||||
...mapActions(useLockStore, ['updatePasswordSearch', 'getPasswordList']),
|
||||
...mapActions(useBasicStore, ['backAndToast', 'getNetworkType', 'routeJump']),
|
||||
async toRecordList() {
|
||||
this.routeJump({
|
||||
name: 'typeRecordList',
|
||||
params: {
|
||||
name: this.currentPasswordInfo.keyboardPwdName,
|
||||
key: 'keyboardPwdId',
|
||||
id: this.currentPasswordInfo.keyboardPwdId
|
||||
}
|
||||
})
|
||||
const $lock = useLockStore()
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $user = useUserStore()
|
||||
const $basic = useBasicStore()
|
||||
|
||||
const modalInput = ref(null)
|
||||
const modalPassword = ref(null)
|
||||
const pending = ref(false)
|
||||
|
||||
const disabled = () => {
|
||||
uni.showToast({
|
||||
title: '暂不支持修改',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
const updateTime = () => {
|
||||
if ($lock.currentPasswordInfo.isCustom !== 1) return
|
||||
$basic.routeJump({
|
||||
name: 'temporaryDate',
|
||||
params: {
|
||||
info: JSON.stringify({ ...$lock.currentPasswordInfo, type: 'password' })
|
||||
},
|
||||
async deletePassword() {
|
||||
const netWork = await this.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
events: {
|
||||
refresh() {
|
||||
$lock.updatePasswordSearch({
|
||||
...$lock.passwordSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getPasswordList($lock.passwordSearch)
|
||||
getPasswordRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyboardPwdId: $lock.currentPasswordInfo.keyboardPwdId
|
||||
}).then(res => {
|
||||
$lock.updateCurrentPasswordInfo({
|
||||
...$lock.currentPasswordInfo,
|
||||
...res.data,
|
||||
keyboardPwdType: res.data.type
|
||||
})
|
||||
})
|
||||
}
|
||||
const that = this
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该密码',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: '删除中',
|
||||
mask: true
|
||||
})
|
||||
const timestamp = parseInt(new Date().getTime() / 1000, 10)
|
||||
const { code } = await that.setLockPassword({
|
||||
keyId: that.keyId.toString(),
|
||||
uid: that.userInfo.uid.toString(),
|
||||
pwdNo: that.currentPasswordInfo.pwdUserNo,
|
||||
operate: 3,
|
||||
isAdmin: that.currentPasswordInfo.pwdRight,
|
||||
pwd: that.currentPasswordInfo.keyboardPwd,
|
||||
userCountLimit: 0xffff,
|
||||
startTime: timestamp,
|
||||
endTime: timestamp
|
||||
})
|
||||
that.closeBluetoothConnection()
|
||||
if (code === 0) {
|
||||
const { code: requestCode, message } = await deletePsaawordRequest({
|
||||
lockId: that.currentLockInfo.lockId,
|
||||
keyboardPwdId: that.currentPasswordInfo.keyboardPwdId,
|
||||
deleteType: 1
|
||||
})
|
||||
if (requestCode === 0) {
|
||||
uni.hideLoading()
|
||||
that.updatePasswordSearch({
|
||||
...that.passwordSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
that.getPasswordList(that.passwordSearch)
|
||||
that.backAndToast('删除成功')
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else if (code === -1) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '删除失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const changePassword = async password => {
|
||||
if (!test.rangeLength(password, [6, 9])) {
|
||||
uni.showToast({
|
||||
title: '密码为6-9位纯数字',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
|
||||
uni.showLoading({
|
||||
title: '更新中'
|
||||
})
|
||||
|
||||
const params = {
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
pwdNo: $lock.currentPasswordInfo.pwdUserNo,
|
||||
operate: 1,
|
||||
isAdmin: $lock.currentPasswordInfo.pwdRight,
|
||||
pwd: password,
|
||||
userCountLimit: 0xffff,
|
||||
startTime: Math.floor($lock.currentPasswordInfo.startDate / 1000),
|
||||
endTime: Math.floor($lock.currentPasswordInfo.endDate / 1000)
|
||||
}
|
||||
const { code, data } = await $bluetooth.setLockPassword(params)
|
||||
|
||||
if (code === 0) {
|
||||
const { code, message } = await updatePasswordRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyboardPwdId: $lock.currentPasswordInfo.keyboardPwdId,
|
||||
startDate: $lock.currentPasswordInfo.startDate,
|
||||
endDate: $lock.currentPasswordInfo.endDate,
|
||||
newKeyboardPwd: password,
|
||||
changeType: 1
|
||||
})
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
if (code === 0) {
|
||||
modalPassword.value.close()
|
||||
$lock.updateCurrentPasswordInfo({
|
||||
...$lock.currentPasswordInfo,
|
||||
keyboardPwd: password
|
||||
})
|
||||
$lock.updatePasswordSearch({
|
||||
...$lock.passwordSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getPasswordList($lock.passwordSearch)
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
if (data.status === 0xff) {
|
||||
uni.showToast({
|
||||
title: '更新失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfe) {
|
||||
uni.showToast({
|
||||
title: '管理员已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfd) {
|
||||
uni.showToast({
|
||||
title: '用户已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfc) {
|
||||
uni.showToast({
|
||||
title: '密码已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfb) {
|
||||
uni.showToast({
|
||||
title: '密码已存在',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '更新失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const changeName = async name => {
|
||||
if (!name) {
|
||||
uni.showToast({
|
||||
title: '请输入姓名',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
const { code, message } = await updatePasswordRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyboardPwdId: $lock.currentPasswordInfo.keyboardPwdId,
|
||||
startDate: $lock.currentPasswordInfo.startDate,
|
||||
endDate: $lock.currentPasswordInfo.endDate,
|
||||
keyboardPwdName: name,
|
||||
changeType: 1
|
||||
})
|
||||
pending.value = false
|
||||
if (code === 0) {
|
||||
modalInput.value.close()
|
||||
$lock.updateCurrentPasswordInfo({
|
||||
...$lock.currentPasswordInfo,
|
||||
keyboardPwdName: name
|
||||
})
|
||||
$lock.updatePasswordSearch({
|
||||
...$lock.passwordSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getPasswordList($lock.passwordSearch)
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const toRecordList = async () => {
|
||||
$basic.routeJump({
|
||||
name: 'typeRecordList',
|
||||
params: {
|
||||
name: $lock.currentPasswordInfo.keyboardPwdName,
|
||||
key: 'keyboardPwdId',
|
||||
id: $lock.currentPasswordInfo.keyboardPwdId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const deletePassword = async () => {
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该密码',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: '删除中',
|
||||
mask: true
|
||||
})
|
||||
const timestamp = parseInt(new Date().getTime() / 1000, 10)
|
||||
const { code } = await $bluetooth.setLockPassword({
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
pwdNo: $lock.currentPasswordInfo.pwdUserNo,
|
||||
operate: $lock.currentPasswordInfo.isCustom === 1 ? 2 : 3,
|
||||
isAdmin: $lock.currentPasswordInfo.pwdRight,
|
||||
pwd: $lock.currentPasswordInfo.keyboardPwd,
|
||||
userCountLimit: 0xffff,
|
||||
startTime: timestamp,
|
||||
endTime: timestamp
|
||||
})
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
if (code === 0) {
|
||||
const { code: requestCode, message } = await deletePsaawordRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyboardPwdId: $lock.currentPasswordInfo.keyboardPwdId,
|
||||
deleteType: 1
|
||||
})
|
||||
if (requestCode === 0) {
|
||||
uni.hideLoading()
|
||||
$lock.updatePasswordSearch({
|
||||
...$lock.passwordSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getPasswordList($lock.passwordSearch)
|
||||
$basic.backAndToast('删除成功')
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else if (code === -1) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '删除失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
@ -171,7 +171,7 @@
|
||||
keyId: that.keyId.toString(),
|
||||
uid: that.userInfo.uid.toString(),
|
||||
pwdNo: password.pwdUserNo,
|
||||
operate: 3,
|
||||
operate: password.isCustom === 1 ? 2 : 3,
|
||||
isAdmin: password.pwdRight,
|
||||
pwd: password.keyboardPwd,
|
||||
userCountLimit: 0xffff,
|
||||
@ -405,7 +405,7 @@
|
||||
}
|
||||
|
||||
.password-right-bottom {
|
||||
font-size: 24rpx;
|
||||
font-size: 23rpx;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,30 +5,44 @@
|
||||
<view class="item-title">遥控号</view>
|
||||
<view class="item-content">{{ info.remoteNumber }}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item" style="margin-top: 2rpx" @click="() => $refs.modalInput.open()">
|
||||
<view class="item-title">姓名</view>
|
||||
<view class="item-content">{{ info.remoteName }}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ info.remoteName }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item" style="margin-top: 2rpx" @click="updateTime">
|
||||
<view class="item-title">有效期</view>
|
||||
<view v-if="info.remoteType === 1">永久</view>
|
||||
<view v-else-if="info.remoteType === 2">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="flex items-center">
|
||||
<view v-if="info.remoteType === 1" class="mr-2">永久</view>
|
||||
<view v-else-if="info.remoteType === 2" class="mr-2 w-400 text-right">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<view v-else class="mr-2">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd') }}</view>
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.remoteType === 4">
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.remoteType === 4" @click="updateTime">
|
||||
<view class="item-title">有效日</view>
|
||||
<view class="item-content">{{ $lock.convertWeekDaysToChineseString(info.weekDay) }}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{
|
||||
$lock.convertWeekDaysToChineseString(info.weekDay)
|
||||
}}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.remoteType === 4">
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.remoteType === 4" @click="updateTime">
|
||||
<view class="item-title">有效时间</view>
|
||||
<view class="item-content">
|
||||
{{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }}
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">
|
||||
{{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }}
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx">
|
||||
@ -44,6 +58,14 @@
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="button" @click="deletePassword">删除</view>
|
||||
<ModalInput
|
||||
ref="modalInput"
|
||||
title="请输入姓名"
|
||||
:autoClose="false"
|
||||
placeholder="请输入姓名"
|
||||
:value="info.remoteName"
|
||||
@confirm="changeName"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@ -54,15 +76,76 @@
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { getRemoteRequest, updateRemoteRequest } from '@/api/remote'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
const $lock = useLockStore()
|
||||
const $basic = useBasicStore()
|
||||
const $bluetooth = useBluetoothStore()
|
||||
|
||||
const info = ref(null)
|
||||
|
||||
const modalInput = ref(null)
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
const changeName = async name => {
|
||||
if (!name) {
|
||||
uni.showToast({
|
||||
title: '请输入姓名',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
const { code, message } = await updateRemoteRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
remoteId: info.value.remoteId,
|
||||
remoteType: info.value.remoteType,
|
||||
remoteName: name,
|
||||
changeType: 1
|
||||
})
|
||||
pending.value = false
|
||||
if (code === 0) {
|
||||
modalInput.value.close()
|
||||
eventChannel.emit('refresherList', {})
|
||||
info.value.remoteName = name
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const updateTime = () => {
|
||||
$basic.routeJump({
|
||||
name:
|
||||
info.value.remoteType === 1 || info.value.remoteType === 2 ? 'temporaryDate' : 'cycleDate',
|
||||
params: {
|
||||
info: JSON.stringify({ ...info.value, type: 'remote' })
|
||||
},
|
||||
events: {
|
||||
refresh() {
|
||||
eventChannel.emit('refresherList', {})
|
||||
getRemoteRequest({
|
||||
remoteId: info.value.remoteId
|
||||
}).then(res => {
|
||||
info.value = res.data
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onLoad(options => {
|
||||
if (options.info) {
|
||||
info.value = JSON.parse(options.info)
|
||||
|
||||
@ -356,6 +356,12 @@
|
||||
events: {
|
||||
delete() {
|
||||
deleteItem({ ...item, back: true })
|
||||
},
|
||||
refresherList() {
|
||||
pageNo.value = 1
|
||||
getList({
|
||||
pageNo: pageNo.value
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
334
pages/temporaryDate/temporaryDate.vue
Normal file
334
pages/temporaryDate/temporaryDate.vue
Normal file
@ -0,0 +1,334 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="font-bold text-base bg-white">
|
||||
<view class="border-b-solid border-b-1 border-b-gray-200" @click="showStartDate = true">
|
||||
<view class="mx-3 flex items-center h-100">
|
||||
<view class="w-168">生效时间</view>
|
||||
<view class="ml-a flex items-center">
|
||||
<view v-if="startDate" class="mr-2">
|
||||
<view>{{ timeFormat(startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<view class="mx-3 flex items-center h-100" @click="showEndDate = true">
|
||||
<view class="w-168">失效时间</view>
|
||||
<view class="ml-a flex items-center">
|
||||
<view v-if="endDate" class="mr-2">
|
||||
<view>{{ timeFormat(endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
:class="[
|
||||
canSubmit ? 'bg-[#5eb7ac]' : 'bg-[#9d9da3]',
|
||||
'mx-4',
|
||||
'h-100',
|
||||
'text-white',
|
||||
'text-center',
|
||||
'font-bold',
|
||||
'mt-4',
|
||||
'flex',
|
||||
'items-center',
|
||||
'justify-center'
|
||||
]"
|
||||
style="border-radius: 50rpx"
|
||||
@click="save"
|
||||
>保存</view
|
||||
>
|
||||
<up-datetime-picker
|
||||
:hasInput="false"
|
||||
:show="showStartDate"
|
||||
v-model="defaultStartDate"
|
||||
mode="datetime"
|
||||
closeOnClickOverlay
|
||||
:visibleItemCount="5"
|
||||
@close="showStartDate = false"
|
||||
@confirm="confirmDate('start', $event)"
|
||||
@cancel="showStartDate = false"
|
||||
></up-datetime-picker>
|
||||
<up-datetime-picker
|
||||
:hasInput="false"
|
||||
:show="showEndDate"
|
||||
v-model="defaultEndDate"
|
||||
mode="datetime"
|
||||
closeOnClickOverlay
|
||||
:visibleItemCount="5"
|
||||
@close="showEndDate = false"
|
||||
@confirm="confirmDate('end', $event)"
|
||||
@cancel="showEndDate = false"
|
||||
></up-datetime-picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { computed, getCurrentInstance, ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { updateCardRequest } from '@/api/card'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { updateFingerprintRequest } from '@/api/fingerprint'
|
||||
import { updateRemoteRequest } from '@/api/remote'
|
||||
import { updateFaceRequest } from '@/api/face'
|
||||
import { updatePalmVeinRequest } from '@/api/palmVein'
|
||||
import { updateKeyDateRequest } from '@/api/key'
|
||||
import { updatePasswordRequest } from '@/api/keyboardPwd'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $user = useUserStore()
|
||||
const $basic = useBasicStore()
|
||||
|
||||
const showStartDate = ref(false)
|
||||
const showEndDate = ref(false)
|
||||
|
||||
const info = ref(null)
|
||||
|
||||
const startDate = ref(null)
|
||||
const endDate = ref(null)
|
||||
|
||||
const defaultStartDate = ref(0)
|
||||
const defaultEndDate = ref(0)
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
const canSubmit = computed(() => {
|
||||
return startDate.value && endDate.value
|
||||
})
|
||||
|
||||
onLoad(options => {
|
||||
if (options.info) {
|
||||
const data = JSON.parse(options.info)
|
||||
if (data.startDate) {
|
||||
startDate.value = data.startDate
|
||||
endDate.value = data.endDate === 0 ? data.startDate + 24 * 60 * 60 * 1000 : data.endDate
|
||||
info.value = data
|
||||
defaultStartDate.value = data.startDate
|
||||
defaultEndDate.value =
|
||||
data.endDate === 0 ? data.startDate + 24 * 60 * 60 * 1000 : data.endDate
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const save = async () => {
|
||||
if (!canSubmit.value) {
|
||||
return
|
||||
}
|
||||
if (startDate.value >= endDate.value) {
|
||||
uni.showToast({
|
||||
title: '失效日期需晚于生效日期',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (pending.value) {
|
||||
return
|
||||
}
|
||||
|
||||
pending.value = true
|
||||
|
||||
uni.showLoading({
|
||||
title: '更新中'
|
||||
})
|
||||
if (info.value.type === 'password') {
|
||||
const params = {
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
pwdNo: info.value.pwdUserNo,
|
||||
operate: 1,
|
||||
isAdmin: info.value.pwdRight,
|
||||
pwd: info.value.keyboardPwd,
|
||||
userCountLimit: 0xffff,
|
||||
startTime: Math.floor(startDate.value / 1000),
|
||||
endTime: Math.floor(endDate.value / 1000)
|
||||
}
|
||||
const { code, data } = await $bluetooth.setLockPassword(params)
|
||||
|
||||
if (code === 0) {
|
||||
const { code, message } = await updatePasswordRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyboardPwdId: info.value.keyboardPwdId,
|
||||
startDate: startDate.value,
|
||||
endDate: endDate.value,
|
||||
keyboardPwdType: 3,
|
||||
changeType: 1
|
||||
})
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
if (code === 0) {
|
||||
eventChannel.emit('refresh', {})
|
||||
$basic.backAndToast('更新成功')
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
if (data.status === 0xff) {
|
||||
uni.showToast({
|
||||
title: '更新失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfe) {
|
||||
uni.showToast({
|
||||
title: '管理员已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfd) {
|
||||
uni.showToast({
|
||||
title: '用户已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfc) {
|
||||
uni.showToast({
|
||||
title: '密码已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfb) {
|
||||
uni.showToast({
|
||||
title: '密码已存在',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '更新失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
} else if (info.value.type === 'key') {
|
||||
const data = await updateKeyDateRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyId: info.value.keyId,
|
||||
keyType: 2,
|
||||
startDate: startDate.value,
|
||||
endDate: endDate.value
|
||||
})
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
if (data.code === 0) {
|
||||
eventChannel.emit('refresh', {})
|
||||
$basic.backAndToast('更新成功')
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: data.message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
const { code } = await $bluetooth.registerAuthentication({
|
||||
type: info.value.type,
|
||||
operate: 1,
|
||||
isAdmin: info.value.type,
|
||||
isForce: info.value.isForce,
|
||||
isRound: 0,
|
||||
weekDays: [],
|
||||
no: info.value[`${info.value.type}Number`],
|
||||
userCountLimit: 0xffff,
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
startDate: startDate.value,
|
||||
endDate: endDate.value
|
||||
})
|
||||
if (code === 0) {
|
||||
let data
|
||||
if (info.value.type === 'card') {
|
||||
data = await updateCardRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
cardId: info.value.cardId,
|
||||
cardType: 2,
|
||||
startDate: startDate.value,
|
||||
endDate: endDate.value,
|
||||
changeType: 1
|
||||
})
|
||||
} else if (info.value.type === 'fingerprint') {
|
||||
data = await updateFingerprintRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
fingerprintId: info.value.fingerprintId,
|
||||
fingerprintType: 2,
|
||||
startDate: startDate.value,
|
||||
endDate: endDate.value,
|
||||
changeType: 1
|
||||
})
|
||||
} else if (info.value.type === 'remote') {
|
||||
data = await updateRemoteRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
remoteId: info.value.remoteId,
|
||||
remoteType: 2,
|
||||
startDate: startDate.value,
|
||||
endDate: endDate.value,
|
||||
changeType: 1
|
||||
})
|
||||
} else if (info.value.type === 'face') {
|
||||
data = await updateFaceRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
faceId: info.value.faceId,
|
||||
faceType: 2,
|
||||
startDate: startDate.value,
|
||||
endDate: endDate.value,
|
||||
changeType: 1
|
||||
})
|
||||
} else if (info.value.type === 'palmVein') {
|
||||
data = await updatePalmVeinRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
palmVeinId: info.value.palmVeinId,
|
||||
palmVeinType: 2,
|
||||
startDate: startDate.value,
|
||||
endDate: endDate.value,
|
||||
changeType: 1
|
||||
})
|
||||
}
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
if (data.code === 0) {
|
||||
eventChannel.emit('refresh', {})
|
||||
$basic.backAndToast('更新成功')
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: data.message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '操作失败,请重试',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const confirmDate = (type, date) => {
|
||||
if (type === 'start') {
|
||||
startDate.value = date.value
|
||||
showStartDate.value = false
|
||||
} else {
|
||||
endDate.value = date.value
|
||||
showEndDate.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: $uni-bg-color-grey;
|
||||
}
|
||||
</style>
|
||||
@ -246,6 +246,11 @@ const pages = [
|
||||
name: 'cycleDate',
|
||||
path: '/pages/cycleDate/cycleDate',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'temporaryDate',
|
||||
path: '/pages/temporaryDate/temporaryDate',
|
||||
tabBar: false
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@ -336,9 +336,9 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
restoreCount: decrypted[134] * 256 + decrypted[135],
|
||||
restoreDate: this.arrayToTimestamp(decrypted.slice(136, 140)),
|
||||
icPartNo: that.uint8ArrayToString(decrypted.slice(140, 150)),
|
||||
indate: this.arrayToTimestamp(decrypted.slice(150, 154)),
|
||||
indate: this.arrayToTimestamp(decrypted.slice(150, 154)) * 1000,
|
||||
mac: that.uint8ArrayToString(decrypted.slice(154, 174)),
|
||||
timezoneOffset: new Date().getTimezoneOffset() * 60
|
||||
timezoneOffset: new Date().getTimezoneOffset() * -60
|
||||
}
|
||||
that.updateCurrentLockInfo({
|
||||
...that.currentLockInfo,
|
||||
@ -402,6 +402,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
characteristicValueCallback({
|
||||
code: decrypted[2],
|
||||
data: {
|
||||
no: decrypted[9] * 256 + decrypted[10],
|
||||
status: decrypted[11]
|
||||
}
|
||||
})
|
||||
|
||||
@ -196,7 +196,7 @@ export const useLockStore = defineStore('lock', {
|
||||
`${timeFormat(new Date(data.list[i].startDate), 'yyyy-mm-dd h:M')} 单次`
|
||||
} else if (data.list[i].keyboardPwdType === 2) {
|
||||
data.list[i].timeText =
|
||||
`${timeFormat(new Date(data.list[i].startDate), 'yyyy-mm-dd h:M')} 永久`
|
||||
`${timeFormat(new Date(data.list[i].created_at), 'yyyy-mm-dd h:M')} 永久`
|
||||
} else if (data.list[i].keyboardPwdType === 3) {
|
||||
data.list[i].timeText = `${data.list[i].validTimeStr} 限时`
|
||||
} else if (data.list[i].keyboardPwdType === 4) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user