From fee5aa62e333a767853f0318401094928f0bb4da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E9=B9=8F?= Date: Thu, 13 Feb 2025 18:53:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8C=87=E7=BA=B9=E3=80=81?= =?UTF-8?q?=E9=81=A5=E6=8E=A7=E3=80=81=E4=BA=BA=E8=84=B8=E3=80=81=E6=8E=8C?= =?UTF-8?q?=E9=9D=99=E8=84=89=E4=BF=A1=E6=81=AF=E4=BF=AE=E6=94=B9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/face.js | 18 ++ api/fingerprint.js | 18 ++ api/palmVein.js | 18 ++ api/remote.js | 18 ++ pages/bindFace/bindFace.vue | 4 +- pages/bindFingerprint/bindFingerprint.vue | 2 + pages/bindPalmVein/bindPalmVein.vue | 2 + pages/bindRemote/bindRemote.vue | 2 + pages/cycleDate/cycleDate.vue | 94 ++++++-- pages/faceDetail/faceDetail.vue | 133 +++++++++-- pages/faceList/faceList.vue | 6 + pages/fingerprintDetail/fingerprintDetail.vue | 213 ++++++++++++++++-- pages/fingerprintList/fingerprintList.vue | 6 + pages/palmVeinDetail/palmVeinDetail.vue | 212 +++++++++++++++-- pages/palmVeinList/palmVeinList.vue | 6 + pages/remoteDetail/remoteDetail.vue | 115 ++++++++-- pages/remoteList/remoteList.vue | 6 + pages/temporaryDate/temporaryDate.vue | 73 +++++- 18 files changed, 858 insertions(+), 88 deletions(-) diff --git a/api/face.js b/api/face.js index 7b9cf69..7bc0e16 100644 --- a/api/face.js +++ b/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 + }) +} diff --git a/api/fingerprint.js b/api/fingerprint.js index 3876683..3eeff52 100644 --- a/api/fingerprint.js +++ b/api/fingerprint.js @@ -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 + }) +} diff --git a/api/palmVein.js b/api/palmVein.js index 83e1327..0e64818 100644 --- a/api/palmVein.js +++ b/api/palmVein.js @@ -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 + }) +} diff --git a/api/remote.js b/api/remote.js index fe2bc64..850c25e 100644 --- a/api/remote.js +++ b/api/remote.js @@ -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 + }) +} diff --git a/pages/bindFace/bindFace.vue b/pages/bindFace/bindFace.vue index 08d3322..cd25ba4 100644 --- a/pages/bindFace/bindFace.vue +++ b/pages/bindFace/bindFace.vue @@ -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) { diff --git a/pages/bindFingerprint/bindFingerprint.vue b/pages/bindFingerprint/bindFingerprint.vue index 317cc3a..fb20e38 100644 --- a/pages/bindFingerprint/bindFingerprint.vue +++ b/pages/bindFingerprint/bindFingerprint.vue @@ -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), diff --git a/pages/bindPalmVein/bindPalmVein.vue b/pages/bindPalmVein/bindPalmVein.vue index e2da53e..d272254 100644 --- a/pages/bindPalmVein/bindPalmVein.vue +++ b/pages/bindPalmVein/bindPalmVein.vue @@ -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), diff --git a/pages/bindRemote/bindRemote.vue b/pages/bindRemote/bindRemote.vue index 0fc4009..3e9c442 100644 --- a/pages/bindRemote/bindRemote.vue +++ b/pages/bindRemote/bindRemote.vue @@ -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, diff --git a/pages/cycleDate/cycleDate.vue b/pages/cycleDate/cycleDate.vue index b2774f9..ea31b8c 100644 --- a/pages/cycleDate/cycleDate.vue +++ b/pages/cycleDate/cycleDate.vue @@ -141,6 +141,10 @@ 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' const instance = getCurrentInstance().proxy const eventChannel = instance.getOpenerEventChannel() @@ -168,6 +172,8 @@ const defaultStartDate = ref(0) const defaultEndDate = ref(0) + const pending = ref(false) + const list = ['一', '二', '三', '四', '五', '六', '日'] const canSubmit = computed(() => { @@ -184,6 +190,11 @@ if (options.info) { 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 @@ -247,6 +258,10 @@ } }) } else { + if (pending.value) { + return + } + pending.value = true uni.showLoading({ title: '更新中' }) @@ -268,19 +283,71 @@ endTime: endTimeText.value }) if (code === 0) { - const { code, message } = 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 - }) + 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 (code === 0) { + if (data.code === 0) { eventChannel.emit('refresh', {}) $basic.backAndToast('更新成功') uni.showToast({ @@ -289,11 +356,12 @@ }) } else { uni.showToast({ - title: message, + title: data.message, icon: 'none' }) } } else { + pending.value = false uni.hideLoading() uni.showToast({ title: '操作失败,请重试', diff --git a/pages/faceDetail/faceDetail.vue b/pages/faceDetail/faceDetail.vue index df2e70c..f134e6f 100644 --- a/pages/faceDetail/faceDetail.vue +++ b/pages/faceDetail/faceDetail.vue @@ -5,30 +5,44 @@ 人脸号 {{ info.faceNumber }} - + 姓名 - {{ info.faceName }} + + {{ info.faceName }} + + - + 有效期 - 永久 - - {{ 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') }} + + 永久 + + {{ 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') }} + + - + 有效日 - {{ $lock.convertWeekDaysToChineseString(info.weekDay) }} + + {{ + $lock.convertWeekDaysToChineseString(info.weekDay) + }} + + - + 有效时间 - - {{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }} + + + {{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }} + + @@ -39,11 +53,30 @@ 添加时间 {{ timeFormat(info.createDate, 'yyyy-mm-dd h:M') }} + + + 是否为管理员 + + 操作记录 删除 + @@ -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) diff --git a/pages/faceList/faceList.vue b/pages/faceList/faceList.vue index fa65ee1..fd466a4 100644 --- a/pages/faceList/faceList.vue +++ b/pages/faceList/faceList.vue @@ -354,6 +354,12 @@ events: { delete() { deleteItem({ ...item, back: true }) + }, + refresherList() { + pageNo.value = 1 + getList({ + pageNo: pageNo.value + }) } } }) diff --git a/pages/fingerprintDetail/fingerprintDetail.vue b/pages/fingerprintDetail/fingerprintDetail.vue index 4e3ad61..dd98602 100644 --- a/pages/fingerprintDetail/fingerprintDetail.vue +++ b/pages/fingerprintDetail/fingerprintDetail.vue @@ -5,30 +5,54 @@ 指纹号 {{ info.fingerprintNumber }} - + 姓名 - {{ info.fingerprintName }} + + {{ info.fingerprintName }} + + - + 有效期 - 永久 - - {{ 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') }} + + 永久 + + {{ 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') }} + + - + 有效日 - {{ $lock.convertWeekDaysToChineseString(info.weekDay) }} + + {{ + $lock.convertWeekDaysToChineseString(info.weekDay) + }} + + - + 有效时间 - - {{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }} + + + {{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }} + + @@ -39,11 +63,40 @@ 添加时间 {{ timeFormat(info.createDate, 'yyyy-mm-dd h:M') }} + + + 胁迫指纹 + + + + 是否为管理员 + + 操作记录 删除 + @@ -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', diff --git a/pages/fingerprintList/fingerprintList.vue b/pages/fingerprintList/fingerprintList.vue index df9a781..2c4b910 100644 --- a/pages/fingerprintList/fingerprintList.vue +++ b/pages/fingerprintList/fingerprintList.vue @@ -353,6 +353,12 @@ events: { delete() { deleteItem({ ...item, back: true }) + }, + refresherList() { + pageNo.value = 1 + getList({ + pageNo: pageNo.value + }) } } }) diff --git a/pages/palmVeinDetail/palmVeinDetail.vue b/pages/palmVeinDetail/palmVeinDetail.vue index e68de89..e3f3332 100644 --- a/pages/palmVeinDetail/palmVeinDetail.vue +++ b/pages/palmVeinDetail/palmVeinDetail.vue @@ -5,30 +5,54 @@ 掌静脉号 {{ info.palmVeinNumber }} - + 姓名 - {{ info.palmVeinName }} + + {{ info.palmVeinName }} + + - + 有效期 - 永久 - - {{ 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') }} + + 永久 + + {{ 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') }} + + - + 有效日 - {{ $lock.convertWeekDaysToChineseString(info.weekDay) }} + + {{ + $lock.convertWeekDaysToChineseString(info.weekDay) + }} + + - + 有效时间 - - {{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }} + + + {{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }} + + @@ -39,11 +63,40 @@ 添加时间 {{ timeFormat(info.createDate, 'yyyy-mm-dd h:M') }} + + + 胁迫掌静脉 + + + + 是否为管理员 + + 操作记录 删除 + @@ -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) diff --git a/pages/palmVeinList/palmVeinList.vue b/pages/palmVeinList/palmVeinList.vue index 9f409f0..d7164fb 100644 --- a/pages/palmVeinList/palmVeinList.vue +++ b/pages/palmVeinList/palmVeinList.vue @@ -358,6 +358,12 @@ events: { delete() { deleteItem({ ...item, back: true }) + }, + refresherList() { + pageNo.value = 1 + getList({ + pageNo: pageNo.value + }) } } }) diff --git a/pages/remoteDetail/remoteDetail.vue b/pages/remoteDetail/remoteDetail.vue index ca9b62f..722efad 100644 --- a/pages/remoteDetail/remoteDetail.vue +++ b/pages/remoteDetail/remoteDetail.vue @@ -5,30 +5,44 @@ 遥控号 {{ info.remoteNumber }} - + 姓名 - {{ info.remoteName }} + + {{ info.remoteName }} + + - + 有效期 - 永久 - - {{ 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') }} + + 永久 + + {{ 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') }} + + - + 有效日 - {{ $lock.convertWeekDaysToChineseString(info.weekDay) }} + + {{ + $lock.convertWeekDaysToChineseString(info.weekDay) + }} + + - + 有效时间 - - {{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }} + + + {{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }} + + @@ -44,6 +58,14 @@ 删除 + @@ -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) diff --git a/pages/remoteList/remoteList.vue b/pages/remoteList/remoteList.vue index 7470f29..ed6ab92 100644 --- a/pages/remoteList/remoteList.vue +++ b/pages/remoteList/remoteList.vue @@ -356,6 +356,12 @@ events: { delete() { deleteItem({ ...item, back: true }) + }, + refresherList() { + pageNo.value = 1 + getList({ + pageNo: pageNo.value + }) } } }) diff --git a/pages/temporaryDate/temporaryDate.vue b/pages/temporaryDate/temporaryDate.vue index fdc9fc4..4347601 100644 --- a/pages/temporaryDate/temporaryDate.vue +++ b/pages/temporaryDate/temporaryDate.vue @@ -74,6 +74,10 @@ 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' const instance = getCurrentInstance().proxy const eventChannel = instance.getOpenerEventChannel() @@ -93,6 +97,8 @@ const defaultStartDate = ref(0) const defaultEndDate = ref(0) + const pending = ref(false) + const canSubmit = computed(() => { return startDate.value && endDate.value }) @@ -123,6 +129,12 @@ return } + if (pending.value) { + return + } + + pending.value = true + uni.showLoading({ title: '更新中' }) @@ -142,16 +154,56 @@ endDate: endDate.value }) if (code === 0) { - const { code, message } = await updateCardRequest({ - lockId: $bluetooth.currentLockInfo.lockId, - cardId: info.value.cardId, - cardType: 2, - startDate: startDate.value, - endDate: endDate.value, - changeType: 1 - }) + 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() - if (code === 0) { + pending.value = false + if (data.code === 0) { eventChannel.emit('refresh', {}) $basic.backAndToast('更新成功') uni.showToast({ @@ -160,11 +212,12 @@ }) } else { uni.showToast({ - title: message, + title: data.message, icon: 'none' }) } } else { + pending.value = false uni.hideLoading() uni.showToast({ title: '操作失败,请重试',