2024-08-28 16:55:11 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<view>
|
|
|
|
|
|
<view class="item">
|
2024-09-26 17:40:44 +08:00
|
|
|
|
<view class="item-title" style="width: 350rpx">姓名</view>
|
2024-09-02 17:18:14 +08:00
|
|
|
|
<view class="item-content">{{ currentKeyInfo.keyName }}</view>
|
2024-08-28 16:55:11 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<view class="item" style="margin-top: 2rpx">
|
|
|
|
|
|
<view class="item-title">有效期</view>
|
|
|
|
|
|
<view v-if="currentKeyInfo.keyType === 1">永久</view>
|
2024-09-02 17:18:14 +08:00
|
|
|
|
<view v-else-if="currentKeyInfo.keyType === 3">单次</view>
|
2024-09-02 17:52:55 +08:00
|
|
|
|
<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>
|
2024-08-28 16:55:11 +08:00
|
|
|
|
<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>
|
|
|
|
|
|
</view>
|
2024-09-02 17:52:55 +08:00
|
|
|
|
<view v-if="currentKeyInfo.keyType === 4" class="item" style="margin-top: 2rpx">
|
|
|
|
|
|
<view class="item-title">有效日</view>
|
|
|
|
|
|
<view class="item-content">{{ convertWeekDaysToChineseString(currentKeyInfo.weekDays) }}</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="item" v-if="currentKeyInfo.keyType === 4" style="margin-top: 2rpx">
|
|
|
|
|
|
<view class="item-title">有效时间</view>
|
|
|
|
|
|
<view class="item-content">
|
2024-09-03 17:48:26 +08:00
|
|
|
|
{{ timeFormat(currentKeyInfo.startDate, 'h:M') }}~{{ timeFormat(currentKeyInfo.endDate, 'h:M') }}
|
2024-09-02 17:52:55 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
2024-08-28 16:55:11 +08:00
|
|
|
|
<view class="item" style="margin-top: 20rpx">
|
|
|
|
|
|
<view class="item-title">接收者</view>
|
|
|
|
|
|
<view class="item-content">{{ currentKeyInfo.username }}</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="item" style="margin-top: 2rpx">
|
|
|
|
|
|
<view class="item-title">发送人</view>
|
|
|
|
|
|
<view class="item-content">{{ 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>
|
2024-09-26 17:40:44 +08:00
|
|
|
|
<view class="button" @click="deleteKey">删除</view>
|
2024-09-04 10:36:33 +08:00
|
|
|
|
<up-modal :show="showModal" title="是否删除授权管理员钥匙?" :showCancelButton="true" width="600rpx" @cancel="cancelModal"
|
|
|
|
|
|
@confirm="confirmModal">
|
|
|
|
|
|
<view class="slot-content" @click="changeRadio">
|
|
|
|
|
|
<view style="display: flex;align-items: center;">
|
|
|
|
|
|
<radio :checked="checked"></radio>
|
|
|
|
|
|
<view>同时删除其发送的所有钥匙,钥匙删除后不能恢复</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</up-modal>
|
2024-08-28 16:55:11 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2024-08-29 14:42:16 +08:00
|
|
|
|
import { mapActions, mapState } from 'pinia'
|
2024-08-28 16:55:11 +08:00
|
|
|
|
import { useLockStore } from '@/stores/lock'
|
|
|
|
|
|
import { timeFormat } from 'uview-plus'
|
2024-08-29 14:42:16 +08:00
|
|
|
|
import { deleteKeyRequest } from '@/api/key'
|
2024-08-29 17:40:41 +08:00
|
|
|
|
import { useBasicStore } from '@/stores/basic'
|
2024-08-28 16:55:11 +08:00
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
data () {
|
2024-09-04 10:36:33 +08:00
|
|
|
|
return {
|
|
|
|
|
|
showModal: false,
|
|
|
|
|
|
checked: false
|
|
|
|
|
|
}
|
2024-08-28 16:55:11 +08:00
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
2024-08-29 14:42:16 +08:00
|
|
|
|
...mapState(useLockStore, ['currentKeyInfo', 'keySearch']),
|
2024-08-28 16:55:11 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2024-08-29 14:42:16 +08:00
|
|
|
|
timeFormat,
|
2024-09-03 17:48:26 +08:00
|
|
|
|
...mapActions(useLockStore, ['updateKeySearch', 'getKeyList', 'convertWeekDaysToChineseString']),
|
2024-08-29 17:40:41 +08:00
|
|
|
|
...mapActions(useBasicStore, ['backAndToast']),
|
2024-09-04 10:36:33 +08:00
|
|
|
|
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'
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2024-08-29 14:42:16 +08:00
|
|
|
|
async deleteKey () {
|
|
|
|
|
|
const that = this
|
2024-09-04 10:36:33 +08:00
|
|
|
|
if(that.currentKeyInfo.keyRight === 1) {
|
|
|
|
|
|
that.showModal = true
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2024-08-29 14:42:16 +08:00
|
|
|
|
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)
|
2024-08-29 17:40:41 +08:00
|
|
|
|
that.backAndToast('删除成功')
|
2024-08-29 14:42:16 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
uni.hideLoading()
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: message,
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2024-09-02 17:52:55 +08:00
|
|
|
|
}
|
2024-08-28 16:55:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
|
page {
|
|
|
|
|
|
background-color: $uni-bg-color-grey;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
.item {
|
|
|
|
|
|
padding: 24rpx 32rpx;
|
|
|
|
|
|
background-color: #FFFFFF;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.tips {
|
|
|
|
|
|
padding: 24rpx 32rpx;
|
|
|
|
|
|
font-size: 24rpx;
|
|
|
|
|
|
color: #999999;
|
|
|
|
|
|
}
|
2024-08-29 14:42:16 +08:00
|
|
|
|
|
|
|
|
|
|
.button {
|
|
|
|
|
|
margin: 32rpx;
|
|
|
|
|
|
width: 686rpx;
|
|
|
|
|
|
height: 88rpx;
|
|
|
|
|
|
background-color: #df282d;
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
line-height: 88rpx;
|
|
|
|
|
|
border-radius: 44rpx;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
}
|
2024-08-28 16:55:11 +08:00
|
|
|
|
</style>
|