锁设置页显示电子钥匙起止时间

This commit is contained in:
范鹏 2024-09-03 17:48:26 +08:00
parent 1a42b7ed25
commit 41efe3ed47
3 changed files with 55 additions and 18 deletions

View File

@ -24,7 +24,7 @@
<view class="item" v-if="currentKeyInfo.keyType === 4" style="margin-top: 2rpx"> <view class="item" v-if="currentKeyInfo.keyType === 4" style="margin-top: 2rpx">
<view class="item-title">有效时间</view> <view class="item-title">有效时间</view>
<view class="item-content"> <view class="item-content">
{{ timeFormat(currentKeyInfo.startDate, 'h:M') }}-{{ timeFormat(currentKeyInfo.endDate, 'h:M') }} {{ timeFormat(currentKeyInfo.startDate, 'h:M') }}{{ timeFormat(currentKeyInfo.endDate, 'h:M') }}
</view> </view>
</view> </view>
<view class="item" style="margin-top: 20rpx"> <view class="item" style="margin-top: 20rpx">
@ -59,7 +59,7 @@ export default {
}, },
methods: { methods: {
timeFormat, timeFormat,
...mapActions(useLockStore, ['updateKeySearch', 'getKeyList']), ...mapActions(useLockStore, ['updateKeySearch', 'getKeyList', 'convertWeekDaysToChineseString']),
...mapActions(useBasicStore, ['backAndToast']), ...mapActions(useBasicStore, ['backAndToast']),
async deleteKey () { async deleteKey () {
const that = this const that = this
@ -93,21 +93,6 @@ export default {
} }
} }
}) })
},
convertWeekDaysToChineseString(weekDays) {
const dayMap = {
1: '一',
2: '二',
3: '三',
4: '四',
5: '五',
6: '六',
7: '日'
}
const chineseWeekDays = weekDays.map(day => dayMap[day])
return chineseWeekDays.join('')
} }
} }
} }

View File

@ -7,6 +7,7 @@
<view class="info">{{currentLockInfo.lockAlias}}</view> <view class="info">{{currentLockInfo.lockAlias}}</view>
</view> </view>
</view> </view>
<view class="view-line"></view>
<view class="view-button"> <view class="view-button">
<view>锁编号</view> <view>锁编号</view>
<view class="view-button" style="padding: 0"> <view class="view-button" style="padding: 0">
@ -37,6 +38,40 @@
</view> </view>
</view> </view>
</view> </view>
<view class="view" v-if="currentLockInfo.keyType === 2 || currentLockInfo.keyType === 4">
<view v-if="currentLockInfo.keyType === 2">
<view class="view-button">
<view>有效期</view>
<view class="view-button" style="padding: 0">
<view class="info">{{ timeFormat(currentLockInfo.startDate, 'yyyy-mm-dd h:M') }}{{
timeFormat(currentLockInfo.endDate, 'yyyy-mm-dd h:M') }}</view>
</view>
</view>
</view>
<view v-if="currentLockInfo.keyType === 4">
<view class="view-button">
<view>有效期</view>
<view class="view-button" style="padding: 0">
<view class="info">{{ timeFormat(currentLockInfo.startDate, 'yyyy-mm-dd') }}{{ timeFormat(currentLockInfo.endDate, 'yyyy-mm-dd') }}</view>
</view>
</view>
<view class="view-line"></view>
<view class="view-button">
<view>有效日</view>
<view class="view-button" style="padding: 0">
<view class="info">{{ convertWeekDaysToChineseString(currentLockInfo.weekDays) }}</view>
</view>
</view>
<view class="view-line"></view>
<view class="view-button">
<view>有效时间</view>
<view class="view-button" style="padding: 0">
<view class="info">{{ timeFormat(currentLockInfo.startDate, 'h:M') }}{{
timeFormat(currentLockInfo.endDate, 'h:M') }}</view>
</view>
</view>
</view>
</view>
<view class="button-logout" @click="deleteLock">删除</view> <view class="button-logout" @click="deleteLock">删除</view>
<up-modal :show="showModal" title="是否删除授权管理员钥匙?" :showCancelButton="true" width="600rpx" @cancel="cancelModal" <up-modal :show="showModal" title="是否删除授权管理员钥匙?" :showCancelButton="true" width="600rpx" @cancel="cancelModal"
@confirm="confirmModal"> @confirm="confirmModal">
@ -59,6 +94,7 @@ import { useLockStore } from '@/stores/lock'
import { updateLockSettingRequest } from '@/api/lockSetting' import { updateLockSettingRequest } from '@/api/lockSetting'
import { deleteKeyRequest } from '@/api/key' import { deleteKeyRequest } from '@/api/key'
import { useBasicStore } from '@/stores/basic' import { useBasicStore } from '@/stores/basic'
import { timeFormat } from 'uview-plus'
export default { export default {
data () { data () {
@ -77,8 +113,9 @@ export default {
this.unlockApp = this.currentLockInfo.lockSetting.appUnlockOnline this.unlockApp = this.currentLockInfo.lockSetting.appUnlockOnline
}, },
methods: { methods: {
timeFormat,
...mapActions(useBluetoothStore, ['resetDevice', 'updateCurrentLockInfo']), ...mapActions(useBluetoothStore, ['resetDevice', 'updateCurrentLockInfo']),
...mapActions(useLockStore, ['getLockList', 'updateLockSearch']), ...mapActions(useLockStore, ['getLockList', 'updateLockSearch', 'convertWeekDaysToChineseString']),
...mapActions(useBasicStore, ['backAndToast']), ...mapActions(useBasicStore, ['backAndToast']),
changeRadio() { changeRadio() {
this.checked = !this.checked this.checked = !this.checked

View File

@ -51,6 +51,21 @@ export const useLockStore = defineStore('lock', {
} }
}, },
actions: { actions: {
convertWeekDaysToChineseString(weekDays) {
const dayMap = {
1: '一',
2: '二',
3: '三',
4: '四',
5: '五',
6: '六',
7: '日'
}
const chineseWeekDays = weekDays.map(day => dayMap[day])
return chineseWeekDays.join('')
},
updateLockSearch(search) { updateLockSearch(search) {
this.lockSearch = search this.lockSearch = search
}, },