diff --git a/pages/keyDetail/keyDetail.vue b/pages/keyDetail/keyDetail.vue index 9d4752b..b5c4035 100644 --- a/pages/keyDetail/keyDetail.vue +++ b/pages/keyDetail/keyDetail.vue @@ -40,6 +40,15 @@ {{ timeFormat(currentKeyInfo.sendDate, 'yyyy-mm-dd h:M') }} 删除钥匙 + + + + + 同时删除其发送的所有钥匙,钥匙删除后不能恢复 + + + @@ -52,7 +61,10 @@ import { useBasicStore } from '@/stores/basic' export default { data () { - return {} + return { + showModal: false, + checked: false + } }, computed: { ...mapState(useLockStore, ['currentKeyInfo', 'keySearch']), @@ -61,8 +73,46 @@ export default { timeFormat, ...mapActions(useLockStore, ['updateKeySearch', 'getKeyList', 'convertWeekDaysToChineseString']), ...mapActions(useBasicStore, ['backAndToast']), + 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, + pageNo: 1 + }) + that.getKeyList(that.keySearch) + uni.hideLoading() + that.backAndToast('删除成功') + } else { + uni.hideLoading() + uni.showToast({ + title: 'message', + icon: 'none' + }) + } + }, async deleteKey () { const that = this + if(that.currentKeyInfo.keyRight === 1) { + that.showModal = true + return + } uni.showModal({ title: '提示', content: '确定要删除该钥匙', diff --git a/pages/keyList/keyList.vue b/pages/keyList/keyList.vue index 5fe1e34..5faa250 100644 --- a/pages/keyList/keyList.vue +++ b/pages/keyList/keyList.vue @@ -20,8 +20,11 @@ - + {{ key.keyName }} + + {{ getKeyStatus(key.keyStatus) }} @@ -39,6 +42,15 @@ 重置钥匙 发送钥匙 + + + + + 同时删除其发送的所有钥匙,钥匙删除后不能恢复 + + + @@ -54,6 +66,8 @@ import { deleteKeyRequest, resetKeyRequest } from '@/api/key' export default { data () { return { + showModal: false, + checked: false, deviceInfo: null, refresherTriggered: false, requestFinished: false, @@ -62,7 +76,8 @@ export default { style: { backgroundColor: '#f56c6c' } - }] + }], + deleteKeyId: '' } }, computed: { @@ -87,6 +102,43 @@ export default { methods: { ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']), ...mapActions(useLockStore, ['getKeyList', 'updateCurrentKeyInfo', 'updateKeySearch', 'getKeyStatus']), + changeRadio() { + this.checked = !this.checked + }, + async confirmModal() { + uni.showLoading({ + title: '删除中', + mask: true + }) + const that = this + const { code } = await deleteKeyRequest({ + keyId: that.deleteKeyId, + includeUnderlings: that.checked ? 1 : 0 + }) + that.showModal = false + if(code === 0) { + that.updateKeySearch({ + ...that.keySearch, + pageNo: 1 + }) + that.getKeyList(that.keySearch) + uni.hideLoading() + uni.showToast({ + title: '删除成功', + icon: 'none' + }) + } else { + uni.hideLoading() + uni.showToast({ + title: 'message', + icon: 'none' + }) + } + }, + cancelModal() { + this.showModal = false + this.checked = false + }, toKeyDetail(key) { this.updateCurrentKeyInfo(key) this.routeJump({ @@ -98,6 +150,11 @@ export default { const that = this let index = this.keyList.findIndex(item => item.keyId === key.keyId) that.$refs.swipeItem[index].closeHandler() + if(data.keyRight === 1) { + this.deleteKeyId = key.keyId + this.showModal = true + return + } uni.showModal({ title: '提示', content: '确定要删除该钥匙', @@ -274,6 +331,7 @@ page { width: 574rpx; .key-right-top { + max-width: 450rpx; font-size: 32rpx; font-weight: bold; padding-bottom: 6rpx; @@ -282,6 +340,13 @@ page { text-overflow: ellipsis; } + .key-admin { + margin-top: 8rpx; + margin-left: 10rpx; + width: 25rpx; + height: 25rpx; + } + .key-right-bottom { font-size: 24rpx; color: #999999; @@ -289,6 +354,7 @@ page { } .key-status { + margin-top: 4rpx; margin-left: auto; font-size: 26rpx; color: #63b8af; diff --git a/pages/setting/setting.vue b/pages/setting/setting.vue index f4e9b99..5ebb714 100644 --- a/pages/setting/setting.vue +++ b/pages/setting/setting.vue @@ -134,6 +134,7 @@ export default { keyId: that.keyId, includeUnderlings: that.checked ? 1 : 0 }) + that.showModal = false if(code === 0) { uni.hideLoading() that.updateLockSearch({ diff --git a/static/images/icon_admin.png b/static/images/icon_admin.png new file mode 100755 index 0000000..d2a83cf Binary files /dev/null and b/static/images/icon_admin.png differ diff --git a/static/images/icon_remote_unlock.png b/static/images/icon_remote_unlock.png new file mode 100755 index 0000000..87ac084 Binary files /dev/null and b/static/images/icon_remote_unlock.png differ diff --git a/stores/lock.js b/stores/lock.js index 996d90f..27b541a 100644 --- a/stores/lock.js +++ b/stores/lock.js @@ -45,7 +45,7 @@ export const useLockStore = defineStore('lock', { searchStr: '', endDate: '0', startDate: '0', - keyStatus: [110401,110402,110412], + keyStatus: [110401, 110402, 110412, 110405, 110403], keyRight: 0 }, } @@ -93,10 +93,14 @@ export const useLockStore = defineStore('lock', { getKeyStatus(keyStatus) { if(keyStatus === 110401) { return '正常' + } else if(keyStatus === 110403) { + return '未生效' } else if(keyStatus === 110402) { return '待接收' } else if(keyStatus === 110412) { return '已过期' + } else if(keyStatus === 110405) { + return '已冻结' } else { return '' }