158 lines
4.0 KiB
Vue
158 lines
4.0 KiB
Vue
<template>
|
||
<view>
|
||
<view v-if="info">
|
||
<view class="item">
|
||
<view class="item-title">姓名</view>
|
||
<view class="item-content">{{ info.keyName }}</view>
|
||
</view>
|
||
<view class="item" style="margin-top: 2rpx">
|
||
<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>
|
||
</view>
|
||
<view class="item" style="margin-top: 20rpx">
|
||
<view class="item-title">接受者</view>
|
||
<view class="item-content">{{ info.username }}</view>
|
||
</view>
|
||
<view class="item" style="margin-top: 2rpx">
|
||
<view class="item-title">添加者</view>
|
||
<view class="item-content">{{ info.senderUsername }}</view>
|
||
</view>
|
||
<view class="item" style="margin-top: 2rpx">
|
||
<view class="item-title">发送时间</view>
|
||
<view class="item-content">{{ timeFormat(info.sendDate, 'yyyy-mm-dd h:M') }}</view>
|
||
</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>
|
||
</view>
|
||
<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>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { getCurrentInstance, ref } from 'vue'
|
||
import { onLoad } from '@dcloudio/uni-app'
|
||
import { timeFormat } from 'uview-plus'
|
||
import { deleteKeyRequest } from '@/api/key'
|
||
import { useBasicStore } from '@/stores/basic'
|
||
|
||
const instance = getCurrentInstance().proxy
|
||
const eventChannel = instance.getOpenerEventChannel()
|
||
|
||
const $basic = useBasicStore()
|
||
|
||
const info = ref(null)
|
||
|
||
const showModal = ref(false)
|
||
const checked = ref(false)
|
||
|
||
onLoad(options => {
|
||
if (options.info) {
|
||
info.value = JSON.parse(options.info)
|
||
console.log(info.value)
|
||
}
|
||
})
|
||
|
||
const toRecordList = async () => {
|
||
$basic.routeJump({
|
||
name: 'typeRecordList',
|
||
params: {
|
||
name: info.value.keyName,
|
||
key: 'keyId',
|
||
id: info.value.keyId
|
||
}
|
||
})
|
||
}
|
||
|
||
const confirmModal = async () => {
|
||
uni.showLoading({
|
||
title: '删除中',
|
||
mask: true
|
||
})
|
||
const { code } = await deleteKeyRequest({
|
||
keyId: info.value.keyId,
|
||
includeUnderlings: checked.value ? 1 : 0
|
||
})
|
||
showModal.value = false
|
||
if (code === 0) {
|
||
eventChannel.emit('refresherList', {})
|
||
uni.hideLoading()
|
||
$basic.backAndToast('删除成功')
|
||
} else {
|
||
uni.hideLoading()
|
||
uni.showToast({
|
||
title: 'message',
|
||
icon: 'none'
|
||
})
|
||
}
|
||
}
|
||
const cancelModal = () => {
|
||
showModal.value = false
|
||
checked.value = false
|
||
}
|
||
|
||
const changeRadio = () => {
|
||
checked.value = !checked.value
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
page {
|
||
background-color: $uni-bg-color-grey;
|
||
}
|
||
</style>
|
||
|
||
<style lang="scss" scoped>
|
||
.item-title {
|
||
width: 350rpx;
|
||
}
|
||
|
||
.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;
|
||
}
|
||
|
||
.button {
|
||
margin: 32rpx;
|
||
width: 686rpx;
|
||
height: 88rpx;
|
||
background-color: #df282d;
|
||
color: white;
|
||
text-align: center;
|
||
line-height: 88rpx;
|
||
border-radius: 44rpx;
|
||
font-weight: bold;
|
||
}
|
||
</style>
|