diff --git a/api/key.js b/api/key.js
index 5733885..c3755c6 100644
--- a/api/key.js
+++ b/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
+ })
+}
diff --git a/pages/adminDetail/adminDetail.vue b/pages/adminDetail/adminDetail.vue
index d16d1c6..dce6b5b 100644
--- a/pages/adminDetail/adminDetail.vue
+++ b/pages/adminDetail/adminDetail.vue
@@ -1,16 +1,26 @@
-
+ $refs.modalInput.open()">
姓名
- {{ info.keyName }}
+
+ {{ info.keyName }}
+
+
-
+
有效期
- 永久
-
- {{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}
- {{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}
+
+ 永久
+
+ {{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}
+ {{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}
+
+
+ {{ timeFormat(info.startDate, 'yyyy-mm-dd') }}
+ {{ timeFormat(info.endDate, 'yyyy-mm-dd') }}
+
+
@@ -25,11 +35,29 @@
发送时间
{{ timeFormat(info.sendDate, 'yyyy-mm-dd h:M') }}
+
+ 仅管理自己创建的用户
+
+
操作记录
删除
+
{
+ 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,56 @@
}
})
+ 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
+ })
+ }
+ }
+ })
+ }
+
const toRecordList = async () => {
$basic.routeJump({
name: 'typeRecordList',
diff --git a/pages/cycleDate/cycleDate.vue b/pages/cycleDate/cycleDate.vue
index ea31b8c..ea47fc0 100644
--- a/pages/cycleDate/cycleDate.vue
+++ b/pages/cycleDate/cycleDate.vue
@@ -145,6 +145,7 @@
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()
@@ -265,88 +266,19 @@
uni.showLoading({
title: '更新中'
})
-
- 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
+ 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('更新成功')
@@ -361,12 +293,108 @@
})
}
} else {
- pending.value = false
- uni.hideLoading()
- uni.showToast({
- title: '操作失败,请重试',
- icon: 'none'
+ 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'
+ })
+ }
}
}
}
diff --git a/pages/keyDetail/keyDetail.vue b/pages/keyDetail/keyDetail.vue
index 131ceae..af8b5a7 100644
--- a/pages/keyDetail/keyDetail.vue
+++ b/pages/keyDetail/keyDetail.vue
@@ -1,49 +1,89 @@
-
+ $refs.modalInput.open()">
姓名
- {{ currentKeyInfo.keyName }}
+
+ {{ $lock.currentKeyInfo.keyName }}
+
+
-
+
有效期
- 永久
- 单次
-
- {{ timeFormat(currentKeyInfo.startDate, 'yyyy-mm-dd') }}
- {{ timeFormat(currentKeyInfo.endDate, 'yyyy-mm-dd') }}
-
-
- {{
- timeFormat(currentKeyInfo.startDate, 'yyyy-mm-dd h:M')
- }}
- {{ timeFormat(currentKeyInfo.endDate, 'yyyy-mm-dd h:M') }}
+
+ 永久
+ 单次
+
+ {{
+ timeFormat($lock.currentKeyInfo.startDate, 'yyyy-mm-dd')
+ }}
+ {{
+ timeFormat($lock.currentKeyInfo.endDate, 'yyyy-mm-dd')
+ }}
+
+
+ {{
+ timeFormat($lock.currentKeyInfo.startDate, 'yyyy-mm-dd h:M')
+ }}
+ {{
+ timeFormat($lock.currentKeyInfo.endDate, 'yyyy-mm-dd h:M')
+ }}
+
+
-
+
有效日
- {{
- convertWeekDaysToChineseString(currentKeyInfo.weekDays)
- }}
+
+ {{
+ $lock.convertWeekDaysToChineseString($lock.currentKeyInfo.weekDays)
+ }}
+
+
-
+
有效时间
-
- {{ timeFormat(currentKeyInfo.startDate, 'h:M') }}~{{
- timeFormat(currentKeyInfo.endDate, 'h:M')
- }}
+
+
+ {{ timeFormat($lock.currentKeyInfo.startDate, 'h:M') }}~{{
+ timeFormat($lock.currentKeyInfo.endDate, 'h:M')
+ }}
+
接收者
- {{ currentKeyInfo.username }}
+ {{ $lock.currentKeyInfo.username }}
发送人
- {{ currentKeyInfo.senderUsername }}
+ {{ $lock.currentKeyInfo.senderUsername }}
发送时间
- {{ timeFormat(currentKeyInfo.sendDate, 'yyyy-mm-dd h:M') }}
+ {{
+ timeFormat($lock.currentKeyInfo.sendDate, 'yyyy-mm-dd h:M')
+ }}
+
+
+ 仅管理自己创建的用户
+
操作记录
@@ -65,116 +105,228 @@
+
-
diff --git a/pages/temporaryDate/temporaryDate.vue b/pages/temporaryDate/temporaryDate.vue
index 4347601..16d2c3e 100644
--- a/pages/temporaryDate/temporaryDate.vue
+++ b/pages/temporaryDate/temporaryDate.vue
@@ -78,6 +78,7 @@
import { updateRemoteRequest } from '@/api/remote'
import { updateFaceRequest } from '@/api/face'
import { updatePalmVeinRequest } from '@/api/palmVein'
+ import { updateKeyDateRequest } from '@/api/key'
const instance = getCurrentInstance().proxy
const eventChannel = instance.getOpenerEventChannel()
@@ -108,12 +109,12 @@
const data = JSON.parse(options.info)
if (data.startDate) {
startDate.value = data.startDate
- endDate.value = data.endDate
+ endDate.value = data.endDate === 0 ? data.startDate + 24 * 60 * 60 * 1000 : data.endDate
info.value = data
defaultStartDate.value = data.startDate
- defaultEndDate.value = data.endDate
+ defaultEndDate.value =
+ data.endDate === 0 ? data.startDate + 24 * 60 * 60 * 1000 : data.endDate
}
- console.log(info.value)
}
})
@@ -139,68 +140,14 @@
title: '更新中'
})
- 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
- })
- }
+ 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) {
@@ -217,12 +164,91 @@
})
}
} else {
- pending.value = false
- uni.hideLoading()
- uni.showToast({
- title: '操作失败,请重试',
- icon: 'none'
+ 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'
+ })
+ }
}
}