211 lines
6.0 KiB
Vue
211 lines
6.0 KiB
Vue
<template>
|
|
<view>
|
|
<view v-if="info">
|
|
<view class="item">
|
|
<view class="item-title">遥控号</view>
|
|
<view class="item-content">{{ info.remoteNumber }}</view>
|
|
</view>
|
|
<view class="item" style="margin-top: 2rpx" @click="() => $refs.modalInput.open()">
|
|
<view class="item-title">姓名</view>
|
|
<view class="flex items-center">
|
|
<view class="item-content mr-2 max-w-550 break-all">{{ info.remoteName }}</view>
|
|
<up-icon name="arrow-right"></up-icon>
|
|
</view>
|
|
</view>
|
|
<view class="item" style="margin-top: 2rpx" @click="updateTime">
|
|
<view class="item-title">有效期</view>
|
|
<view class="flex items-center">
|
|
<view v-if="info.remoteType === 1" class="mr-2">永久</view>
|
|
<view v-else-if="info.remoteType === 2" class="mr-2 w-400 text-right">
|
|
<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 v-else class="mr-2">
|
|
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd') }}</view>
|
|
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd') }}</view>
|
|
</view>
|
|
<up-icon name="arrow-right"></up-icon>
|
|
</view>
|
|
</view>
|
|
<view class="item" style="margin-top: 2rpx" v-if="info.remoteType === 4" @click="updateTime">
|
|
<view class="item-title">有效日</view>
|
|
<view class="flex items-center">
|
|
<view class="item-content mr-2">{{
|
|
$lock.convertWeekDaysToChineseString(info.weekDay)
|
|
}}</view>
|
|
<up-icon name="arrow-right"></up-icon>
|
|
</view>
|
|
</view>
|
|
<view class="item" style="margin-top: 2rpx" v-if="info.remoteType === 4" @click="updateTime">
|
|
<view class="item-title">有效时间</view>
|
|
<view class="flex items-center">
|
|
<view class="item-content mr-2">
|
|
{{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }}
|
|
</view>
|
|
<up-icon name="arrow-right"></up-icon>
|
|
</view>
|
|
</view>
|
|
<view class="item" style="margin-top: 20rpx">
|
|
<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.createDate, '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="deletePassword">删除</view>
|
|
<ModalInput
|
|
ref="modalInput"
|
|
title="请输入姓名"
|
|
:autoClose="false"
|
|
placeholder="请输入姓名"
|
|
:value="info.remoteName"
|
|
@confirm="changeName"
|
|
/>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { getCurrentInstance, ref } from 'vue'
|
|
import { onLoad } from '@dcloudio/uni-app'
|
|
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)
|
|
console.log(info.value)
|
|
}
|
|
})
|
|
|
|
const toRecordList = async () => {
|
|
$basic.routeJump({
|
|
name: 'typeRecordList',
|
|
params: {
|
|
name: info.value.remoteName,
|
|
key: 'remoteId',
|
|
id: info.value.remoteId
|
|
}
|
|
})
|
|
}
|
|
|
|
const deletePassword = async () => {
|
|
eventChannel.emit('delete', {})
|
|
}
|
|
</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>
|