完成卡信息修改功能
This commit is contained in:
parent
ebcf510915
commit
8b8b3ccf0b
18
api/card.js
18
api/card.js
@ -37,3 +37,21 @@ export function addCardRequest(data) {
|
|||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新卡片
|
||||||
|
export function updateCardRequest(data) {
|
||||||
|
return request({
|
||||||
|
url: '/identityCard/update',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 卡详情
|
||||||
|
export function getCardRequest(data) {
|
||||||
|
return request({
|
||||||
|
url: '/identityCard/detail',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
72
components/ModalInput/ModalInput.vue
Normal file
72
components/ModalInput/ModalInput.vue
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<up-popup :show="show" mode="center" round="32rpx" @close="close" :safeAreaInsetBottom="false">
|
||||||
|
<view class="bg-#f3f3f3 rounded-2xl">
|
||||||
|
<view class="py-4 text-center font-bold text-lg">{{ title }}</view>
|
||||||
|
<view class="px-4">
|
||||||
|
<input
|
||||||
|
class="bg-white border-none outline-none rounded-md h-80 w-450 text-base px-4"
|
||||||
|
placeholder-class="text-base line-height-[80rpx]"
|
||||||
|
:focus="show"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
:value="text"
|
||||||
|
@change="change"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
class="flex justify-between items-center border-t-solid border-t-2 text-base font-bold border-t-gray-200 mt-4 text-#63b8af"
|
||||||
|
>
|
||||||
|
<view
|
||||||
|
@click="close"
|
||||||
|
class="text-center border-r-solid border-r-2 border-e-gray-200 w-50% box-border py-2"
|
||||||
|
>取消</view
|
||||||
|
>
|
||||||
|
<view @click="confirm" class="text-center w-50% py-2">确定</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</up-popup>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
const show = ref(false)
|
||||||
|
const text = ref('')
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
title: { type: String, default: '请输入' },
|
||||||
|
placeholder: { type: String, default: '请输入' },
|
||||||
|
value: { type: String, default: '' },
|
||||||
|
autoClose: { type: Boolean, default: true }
|
||||||
|
})
|
||||||
|
|
||||||
|
const emits = defineEmits(['confirm'])
|
||||||
|
|
||||||
|
const open = () => {
|
||||||
|
text.value = props.value
|
||||||
|
show.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const close = () => {
|
||||||
|
show.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
const change = e => {
|
||||||
|
text.value = e.target.value
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirm = () => {
|
||||||
|
emits('confirm', text.value)
|
||||||
|
if (props.autoClose) {
|
||||||
|
show.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
open,
|
||||||
|
close
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss"></style>
|
||||||
@ -330,6 +330,13 @@
|
|||||||
"navigationBarTitleText": "有效期",
|
"navigationBarTitleText": "有效期",
|
||||||
"disableScroll": true
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/temporaryDate/temporaryDate",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "修改有效期",
|
||||||
|
"disableScroll": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"globalStyle": {
|
"globalStyle": {
|
||||||
|
|||||||
@ -59,6 +59,8 @@
|
|||||||
cardUserNo: String(data.cardNumber),
|
cardUserNo: String(data.cardNumber),
|
||||||
cardType: params.cardType,
|
cardType: params.cardType,
|
||||||
addType: 1,
|
addType: 1,
|
||||||
|
startTime: params.startDate,
|
||||||
|
endTime: params.endDate,
|
||||||
weekDay: params.weekDays,
|
weekDay: params.weekDays,
|
||||||
cardRight: params.isAdmin,
|
cardRight: params.isAdmin,
|
||||||
isCoerced: params.isForce === 1 ? 2 : 1
|
isCoerced: params.isForce === 1 ? 2 : 1
|
||||||
|
|||||||
@ -5,30 +5,44 @@
|
|||||||
<view class="item-title">卡号</view>
|
<view class="item-title">卡号</view>
|
||||||
<view class="item-content">{{ info.cardNumber }}</view>
|
<view class="item-content">{{ info.cardNumber }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="item" style="margin-top: 2rpx">
|
<view class="item" style="margin-top: 2rpx" @click="() => $refs.modalInput.open()">
|
||||||
<view class="item-title">姓名</view>
|
<view class="item-title">姓名</view>
|
||||||
<view class="item-content">{{ info.cardName }}</view>
|
<view class="flex items-center">
|
||||||
|
<view class="item-content mr-2">{{ info.cardName }}</view>
|
||||||
|
<up-icon name="arrow-right"></up-icon>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="item" style="margin-top: 2rpx">
|
<view class="item" style="margin-top: 2rpx" @click="updateTime">
|
||||||
<view class="item-title">有效期</view>
|
<view class="item-title">有效期</view>
|
||||||
<view v-if="info.cardType === 1">永久</view>
|
<view class="flex items-center">
|
||||||
<view v-else-if="info.cardType === 2">
|
<view v-if="info.cardType === 1" class="mr-2">永久</view>
|
||||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
|
<view v-else-if="info.cardType === 2" class="mr-2 w-400 text-right">
|
||||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
|
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||||
</view>
|
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||||
<view v-else>
|
</view>
|
||||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd') }}</view>
|
<view v-else class="mr-2">
|
||||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd') }}</view>
|
<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>
|
</view>
|
||||||
<view class="item" style="margin-top: 2rpx" v-if="info.cardType === 4">
|
<view class="item" style="margin-top: 2rpx" v-if="info.cardType === 4" @click="updateTime">
|
||||||
<view class="item-title">有效日</view>
|
<view class="item-title">有效日</view>
|
||||||
<view class="item-content">{{ $lock.convertWeekDaysToChineseString(info.weekDay) }}</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>
|
||||||
<view class="item" style="margin-top: 2rpx" v-if="info.cardType === 4">
|
<view class="item" style="margin-top: 2rpx" v-if="info.cardType === 4" @click="updateTime">
|
||||||
<view class="item-title">有效时间</view>
|
<view class="item-title">有效时间</view>
|
||||||
<view class="item-content">
|
<view class="flex items-center">
|
||||||
{{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }}
|
<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>
|
</view>
|
||||||
<view class="item" style="margin-top: 20rpx">
|
<view class="item" style="margin-top: 20rpx">
|
||||||
@ -39,11 +53,39 @@
|
|||||||
<view class="item-title">添加时间</view>
|
<view class="item-title">添加时间</view>
|
||||||
<view class="item-content">{{ timeFormat(info.createDate, 'yyyy-mm-dd h:M') }}</view>
|
<view class="item-content">{{ timeFormat(info.createDate, 'yyyy-mm-dd h:M') }}</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="item !py-2" style="margin-top: 20rpx">
|
||||||
|
<view class="item-title">胁迫卡</view>
|
||||||
|
<switch
|
||||||
|
:checked="info.isCoerced === 2"
|
||||||
|
class="transform-scale-90"
|
||||||
|
@click="changeCoerced"
|
||||||
|
:disabled="true"
|
||||||
|
color="#002ce5"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<view class="item !py-2" style="margin-top: 2rpx">
|
||||||
|
<view class="item-title">是否为管理员</view>
|
||||||
|
<switch
|
||||||
|
@click="disabled"
|
||||||
|
:checked="info.cardRight"
|
||||||
|
class="transform-scale-90"
|
||||||
|
:disabled="true"
|
||||||
|
color="#002ce5"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||||
<view class="item-title">操作记录</view>
|
<view class="item-title">操作记录</view>
|
||||||
<up-icon name="arrow-right"></up-icon>
|
<up-icon name="arrow-right"></up-icon>
|
||||||
</view>
|
</view>
|
||||||
<view class="button" @click="deletePassword">删除</view>
|
<view class="button" @click="deletePassword">删除</view>
|
||||||
|
<ModalInput
|
||||||
|
ref="modalInput"
|
||||||
|
title="请输入姓名"
|
||||||
|
:autoClose="false"
|
||||||
|
placeholder="请输入姓名"
|
||||||
|
:value="info.cardName"
|
||||||
|
@confirm="changeName"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@ -54,19 +96,27 @@
|
|||||||
import { timeFormat } from 'uview-plus'
|
import { timeFormat } from 'uview-plus'
|
||||||
import { useLockStore } from '@/stores/lock'
|
import { useLockStore } from '@/stores/lock'
|
||||||
import { useBasicStore } from '@/stores/basic'
|
import { useBasicStore } from '@/stores/basic'
|
||||||
|
import { getCardRequest, updateCardRequest } from '@/api/card'
|
||||||
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||||
|
import { useUserStore } from '@/stores/user'
|
||||||
|
|
||||||
const instance = getCurrentInstance().proxy
|
const instance = getCurrentInstance().proxy
|
||||||
const eventChannel = instance.getOpenerEventChannel()
|
const eventChannel = instance.getOpenerEventChannel()
|
||||||
|
|
||||||
const $lock = useLockStore()
|
const $lock = useLockStore()
|
||||||
const $basic = useBasicStore()
|
const $basic = useBasicStore()
|
||||||
|
const $bluetooth = useBluetoothStore()
|
||||||
|
const $user = useUserStore()
|
||||||
|
|
||||||
const info = ref(null)
|
const info = ref(null)
|
||||||
|
|
||||||
|
const modalInput = ref(null)
|
||||||
|
|
||||||
|
const pending = ref(false)
|
||||||
|
|
||||||
onLoad(options => {
|
onLoad(options => {
|
||||||
if (options.info) {
|
if (options.info) {
|
||||||
info.value = JSON.parse(options.info)
|
info.value = JSON.parse(options.info)
|
||||||
console.log(info.value)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -81,6 +131,121 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const disabled = () => {
|
||||||
|
uni.showToast({
|
||||||
|
title: '暂不支持修改',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateTime = () => {
|
||||||
|
$basic.routeJump({
|
||||||
|
name: info.value.cardType === 1 || info.value.cardType === 2 ? 'temporaryDate' : 'cycleDate',
|
||||||
|
params: {
|
||||||
|
info: JSON.stringify({ ...info.value, type: 'card' })
|
||||||
|
},
|
||||||
|
events: {
|
||||||
|
refresh() {
|
||||||
|
eventChannel.emit('refresherList', {})
|
||||||
|
getCardRequest({
|
||||||
|
cardId: info.value.cardId
|
||||||
|
}).then(res => {
|
||||||
|
info.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const changeName = async name => {
|
||||||
|
if (!name) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '请输入姓名',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (pending.value) return
|
||||||
|
pending.value = true
|
||||||
|
const { code, message } = await updateCardRequest({
|
||||||
|
lockId: $bluetooth.currentLockInfo.lockId,
|
||||||
|
cardId: info.value.cardId,
|
||||||
|
cardType: info.value.cardType,
|
||||||
|
cardName: name,
|
||||||
|
changeType: 1
|
||||||
|
})
|
||||||
|
pending.value = false
|
||||||
|
if (code === 0) {
|
||||||
|
modalInput.value.close()
|
||||||
|
eventChannel.emit('refresherList', {})
|
||||||
|
info.value.cardName = name
|
||||||
|
uni.showToast({
|
||||||
|
title: '更新成功',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const changeCoerced = async () => {
|
||||||
|
if (pending.value) return
|
||||||
|
pending.value = true
|
||||||
|
uni.showLoading({
|
||||||
|
title: '更新中'
|
||||||
|
})
|
||||||
|
const { code } = await $bluetooth.registerAuthentication({
|
||||||
|
type: 'card',
|
||||||
|
operate: 1,
|
||||||
|
isAdmin: info.value.isAdmin,
|
||||||
|
isForce: info.value.isCoerced === 2 ? 0 : 1,
|
||||||
|
isRound: info.value.cardType === 4 ? 1 : 0,
|
||||||
|
weekDays: info.value.weekDay,
|
||||||
|
no: info.value.cardNumber,
|
||||||
|
userCountLimit: 0xffff,
|
||||||
|
keyId: $bluetooth.keyId.toString(),
|
||||||
|
uid: $user.userInfo.uid.toString(),
|
||||||
|
startDate: info.value.startDate,
|
||||||
|
endDate: info.value.endDate,
|
||||||
|
startTime: info.value.cardType === 4 ? timeFormat(info.value.startDate, 'h:M') : '00:00',
|
||||||
|
endTime: info.value.cardType === 4 ? timeFormat(info.value.endDate, 'h:M') : '00:00'
|
||||||
|
})
|
||||||
|
if (code === 0) {
|
||||||
|
const { code, message } = await updateCardRequest({
|
||||||
|
lockId: $bluetooth.currentLockInfo.lockId,
|
||||||
|
cardId: info.value.cardId,
|
||||||
|
cardType: info.value.cardType,
|
||||||
|
isCoerced: info.value.isCoerced === 2 ? 1 : 2,
|
||||||
|
changeType: 1
|
||||||
|
})
|
||||||
|
pending.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
if (code === 0) {
|
||||||
|
info.value.isCoerced = info.value.isCoerced === 2 ? 1 : 2
|
||||||
|
eventChannel.emit('refresherList', {})
|
||||||
|
uni.showToast({
|
||||||
|
title: '更新成功',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pending.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.showToast({
|
||||||
|
title: '操作失败,请重试',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const deletePassword = async () => {
|
const deletePassword = async () => {
|
||||||
eventChannel.emit('delete', {})
|
eventChannel.emit('delete', {})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -353,6 +353,12 @@
|
|||||||
events: {
|
events: {
|
||||||
delete() {
|
delete() {
|
||||||
deleteItem({ ...item, back: true })
|
deleteItem({ ...item, back: true })
|
||||||
|
},
|
||||||
|
refresherList() {
|
||||||
|
pageNo.value = 1
|
||||||
|
getList({
|
||||||
|
pageNo: pageNo.value
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -137,10 +137,18 @@
|
|||||||
import { timeFormat } from 'uview-plus'
|
import { timeFormat } from 'uview-plus'
|
||||||
import { computed, getCurrentInstance, ref } from 'vue'
|
import { computed, getCurrentInstance, ref } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
|
import { updateCardRequest } from '@/api/card'
|
||||||
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||||
|
import { useUserStore } from '@/stores/user'
|
||||||
|
import { useBasicStore } from '@/stores/basic'
|
||||||
|
|
||||||
const instance = getCurrentInstance().proxy
|
const instance = getCurrentInstance().proxy
|
||||||
const eventChannel = instance.getOpenerEventChannel()
|
const eventChannel = instance.getOpenerEventChannel()
|
||||||
|
|
||||||
|
const $bluetooth = useBluetoothStore()
|
||||||
|
const $user = useUserStore()
|
||||||
|
const $basic = useBasicStore()
|
||||||
|
|
||||||
const showStartDate = ref(false)
|
const showStartDate = ref(false)
|
||||||
const showEndDate = ref(false)
|
const showEndDate = ref(false)
|
||||||
const showStartTime = ref(false)
|
const showStartTime = ref(false)
|
||||||
@ -150,6 +158,8 @@
|
|||||||
const endDate = ref(null)
|
const endDate = ref(null)
|
||||||
const weekDays = ref([])
|
const weekDays = ref([])
|
||||||
|
|
||||||
|
const info = ref(null)
|
||||||
|
|
||||||
const startTimeText = ref(null)
|
const startTimeText = ref(null)
|
||||||
const endTimeText = ref(null)
|
const endTimeText = ref(null)
|
||||||
|
|
||||||
@ -172,16 +182,19 @@
|
|||||||
|
|
||||||
onLoad(options => {
|
onLoad(options => {
|
||||||
if (options.info) {
|
if (options.info) {
|
||||||
const info = JSON.parse(options.info)
|
const data = JSON.parse(options.info)
|
||||||
if (info.startDate) {
|
info.value = data
|
||||||
weekDays.value = info.weekDays
|
if (data.startDate) {
|
||||||
startDate.value = info.startDate
|
weekDays.value = data.weekDays || data.weekDay
|
||||||
endDate.value = info.endDate
|
startDate.value = data.startDate
|
||||||
|
endDate.value = data.endDate
|
||||||
|
|
||||||
defaultStartDate.value = info.startDate
|
defaultStartDate.value = data.startDate
|
||||||
defaultEndDate.value = info.endDate
|
defaultEndDate.value = data.endDate
|
||||||
startTimeText.value = timeFormat(info.startDate, 'h:M')
|
startTimeText.value = timeFormat(data.startDate, 'h:M')
|
||||||
endTimeText.value = timeFormat(info.endDate, 'h:M')
|
endTimeText.value = timeFormat(data.endDate, 'h:M')
|
||||||
|
defaultStartTime.value = timeFormat(data.startDate, 'h:M')
|
||||||
|
defaultEndTime.value = timeFormat(data.endDate, 'h:M')
|
||||||
} else {
|
} else {
|
||||||
defaultStartTime.value = timeFormat(new Date(), 'h:M')
|
defaultStartTime.value = timeFormat(new Date(), 'h:M')
|
||||||
defaultEndTime.value = timeFormat(new Date(), 'h:M')
|
defaultEndTime.value = timeFormat(new Date(), 'h:M')
|
||||||
@ -204,7 +217,7 @@
|
|||||||
return date1 - date2
|
return date1 - date2
|
||||||
}
|
}
|
||||||
|
|
||||||
const save = () => {
|
const save = async () => {
|
||||||
if (!canSubmit.value) {
|
if (!canSubmit.value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -222,16 +235,72 @@
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const data = {
|
if (!info.value.type) {
|
||||||
startDate: updateTime(startDate.value, startTimeText.value),
|
const data = {
|
||||||
endDate: updateTime(endDate.value, endTimeText.value),
|
startDate: updateTime(startDate.value, startTimeText.value),
|
||||||
weekDays: weekDays.value.sort()
|
endDate: updateTime(endDate.value, endTimeText.value),
|
||||||
}
|
weekDays: weekDays.value.sort()
|
||||||
uni.navigateBack({
|
|
||||||
success() {
|
|
||||||
eventChannel.emit('change', data)
|
|
||||||
}
|
}
|
||||||
})
|
uni.navigateBack({
|
||||||
|
success() {
|
||||||
|
eventChannel.emit('change', data)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.showLoading({
|
||||||
|
title: '更新中'
|
||||||
|
})
|
||||||
|
|
||||||
|
const { code } = await $bluetooth.registerAuthentication({
|
||||||
|
type: info.value.type,
|
||||||
|
operate: 1,
|
||||||
|
isAdmin: info.value.type,
|
||||||
|
isForce: info.value.isForce,
|
||||||
|
isRound: 1,
|
||||||
|
weekDays: weekDays.value.sort(),
|
||||||
|
no: info.value[`${info.value.type}Number`],
|
||||||
|
userCountLimit: 0xffff,
|
||||||
|
keyId: $bluetooth.keyId.toString(),
|
||||||
|
uid: $user.userInfo.uid.toString(),
|
||||||
|
startDate: updateTime(startDate.value, startTimeText.value),
|
||||||
|
endDate: updateTime(endDate.value, endTimeText.value),
|
||||||
|
startTime: startTimeText.value,
|
||||||
|
endTime: endTimeText.value
|
||||||
|
})
|
||||||
|
if (code === 0) {
|
||||||
|
const { code, message } = await updateCardRequest({
|
||||||
|
lockId: $bluetooth.currentLockInfo.lockId,
|
||||||
|
cardId: info.value.cardId,
|
||||||
|
cardType: 4,
|
||||||
|
weekDay: weekDays.value.sort(),
|
||||||
|
startDate: updateTime(startDate.value, startTimeText.value),
|
||||||
|
endDate: updateTime(endDate.value, endTimeText.value),
|
||||||
|
startTime: updateTime(startDate.value, startTimeText.value),
|
||||||
|
endTime: updateTime(endDate.value, endTimeText.value),
|
||||||
|
changeType: 1
|
||||||
|
})
|
||||||
|
uni.hideLoading()
|
||||||
|
if (code === 0) {
|
||||||
|
eventChannel.emit('refresh', {})
|
||||||
|
$basic.backAndToast('更新成功')
|
||||||
|
uni.showToast({
|
||||||
|
title: '更新成功',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.showToast({
|
||||||
|
title: '操作失败,请重试',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateTime = (datetime, timeStr) => {
|
const updateTime = (datetime, timeStr) => {
|
||||||
|
|||||||
191
pages/temporaryDate/temporaryDate.vue
Normal file
191
pages/temporaryDate/temporaryDate.vue
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<view class="font-bold text-base bg-white">
|
||||||
|
<view class="border-b-solid border-b-1 border-b-gray-200" @click="showStartDate = true">
|
||||||
|
<view class="mx-3 flex items-center h-100">
|
||||||
|
<view class="w-168">生效时间</view>
|
||||||
|
<view class="ml-a flex items-center">
|
||||||
|
<view v-if="startDate" class="mr-2">
|
||||||
|
<view>{{ timeFormat(startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||||
|
</view>
|
||||||
|
<up-icon name="arrow-right"></up-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<view class="mx-3 flex items-center h-100" @click="showEndDate = true">
|
||||||
|
<view class="w-168">失效时间</view>
|
||||||
|
<view class="ml-a flex items-center">
|
||||||
|
<view v-if="endDate" class="mr-2">
|
||||||
|
<view>{{ timeFormat(endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||||
|
</view>
|
||||||
|
<up-icon name="arrow-right"></up-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
:class="[
|
||||||
|
canSubmit ? 'bg-[#5eb7ac]' : 'bg-[#9d9da3]',
|
||||||
|
'mx-4',
|
||||||
|
'h-100',
|
||||||
|
'text-white',
|
||||||
|
'text-center',
|
||||||
|
'font-bold',
|
||||||
|
'mt-4',
|
||||||
|
'flex',
|
||||||
|
'items-center',
|
||||||
|
'justify-center'
|
||||||
|
]"
|
||||||
|
style="border-radius: 50rpx"
|
||||||
|
@click="save"
|
||||||
|
>保存</view
|
||||||
|
>
|
||||||
|
<up-datetime-picker
|
||||||
|
:hasInput="false"
|
||||||
|
:show="showStartDate"
|
||||||
|
v-model="defaultStartDate"
|
||||||
|
mode="datetime"
|
||||||
|
closeOnClickOverlay
|
||||||
|
:visibleItemCount="5"
|
||||||
|
@close="showStartDate = false"
|
||||||
|
@confirm="confirmDate('start', $event)"
|
||||||
|
@cancel="showStartDate = false"
|
||||||
|
></up-datetime-picker>
|
||||||
|
<up-datetime-picker
|
||||||
|
:hasInput="false"
|
||||||
|
:show="showEndDate"
|
||||||
|
v-model="defaultEndDate"
|
||||||
|
mode="datetime"
|
||||||
|
closeOnClickOverlay
|
||||||
|
:visibleItemCount="5"
|
||||||
|
@close="showEndDate = false"
|
||||||
|
@confirm="confirmDate('end', $event)"
|
||||||
|
@cancel="showEndDate = false"
|
||||||
|
></up-datetime-picker>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { timeFormat } from 'uview-plus'
|
||||||
|
import { computed, getCurrentInstance, ref } from 'vue'
|
||||||
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||||
|
import { useUserStore } from '@/stores/user'
|
||||||
|
import { updateCardRequest } from '@/api/card'
|
||||||
|
import { useBasicStore } from '@/stores/basic'
|
||||||
|
|
||||||
|
const instance = getCurrentInstance().proxy
|
||||||
|
const eventChannel = instance.getOpenerEventChannel()
|
||||||
|
|
||||||
|
const $bluetooth = useBluetoothStore()
|
||||||
|
const $user = useUserStore()
|
||||||
|
const $basic = useBasicStore()
|
||||||
|
|
||||||
|
const showStartDate = ref(false)
|
||||||
|
const showEndDate = ref(false)
|
||||||
|
|
||||||
|
const info = ref(null)
|
||||||
|
|
||||||
|
const startDate = ref(null)
|
||||||
|
const endDate = ref(null)
|
||||||
|
|
||||||
|
const defaultStartDate = ref(0)
|
||||||
|
const defaultEndDate = ref(0)
|
||||||
|
|
||||||
|
const canSubmit = computed(() => {
|
||||||
|
return startDate.value && endDate.value
|
||||||
|
})
|
||||||
|
|
||||||
|
onLoad(options => {
|
||||||
|
if (options.info) {
|
||||||
|
const data = JSON.parse(options.info)
|
||||||
|
if (data.startDate) {
|
||||||
|
startDate.value = data.startDate
|
||||||
|
endDate.value = data.endDate
|
||||||
|
info.value = data
|
||||||
|
defaultStartDate.value = data.startDate
|
||||||
|
defaultEndDate.value = data.endDate
|
||||||
|
}
|
||||||
|
console.log(info.value)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const save = async () => {
|
||||||
|
if (!canSubmit.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (startDate.value > endDate.value) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '失效日期需晚于生效日期',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.showLoading({
|
||||||
|
title: '更新中'
|
||||||
|
})
|
||||||
|
|
||||||
|
const { code } = await $bluetooth.registerAuthentication({
|
||||||
|
type: info.value.type,
|
||||||
|
operate: 1,
|
||||||
|
isAdmin: info.value.type,
|
||||||
|
isForce: info.value.isForce,
|
||||||
|
isRound: 0,
|
||||||
|
weekDays: [],
|
||||||
|
no: info.value[`${info.value.type}Number`],
|
||||||
|
userCountLimit: 0xffff,
|
||||||
|
keyId: $bluetooth.keyId.toString(),
|
||||||
|
uid: $user.userInfo.uid.toString(),
|
||||||
|
startDate: startDate.value,
|
||||||
|
endDate: endDate.value
|
||||||
|
})
|
||||||
|
if (code === 0) {
|
||||||
|
const { code, message } = await updateCardRequest({
|
||||||
|
lockId: $bluetooth.currentLockInfo.lockId,
|
||||||
|
cardId: info.value.cardId,
|
||||||
|
cardType: 2,
|
||||||
|
startDate: startDate.value,
|
||||||
|
endDate: endDate.value,
|
||||||
|
changeType: 1
|
||||||
|
})
|
||||||
|
uni.hideLoading()
|
||||||
|
if (code === 0) {
|
||||||
|
eventChannel.emit('refresh', {})
|
||||||
|
$basic.backAndToast('更新成功')
|
||||||
|
uni.showToast({
|
||||||
|
title: '更新成功',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.showToast({
|
||||||
|
title: '操作失败,请重试',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmDate = (type, date) => {
|
||||||
|
if (type === 'start') {
|
||||||
|
startDate.value = date.value
|
||||||
|
showStartDate.value = false
|
||||||
|
} else {
|
||||||
|
endDate.value = date.value
|
||||||
|
showEndDate.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
page {
|
||||||
|
background-color: $uni-bg-color-grey;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -246,6 +246,11 @@ const pages = [
|
|||||||
name: 'cycleDate',
|
name: 'cycleDate',
|
||||||
path: '/pages/cycleDate/cycleDate',
|
path: '/pages/cycleDate/cycleDate',
|
||||||
tabBar: false
|
tabBar: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'temporaryDate',
|
||||||
|
path: '/pages/temporaryDate/temporaryDate',
|
||||||
|
tabBar: false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user