完成授权管理员相关功能
This commit is contained in:
parent
7b774f1e8b
commit
ba5d4f0bde
@ -1,7 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="bg-white">
|
<view class="bg-white">
|
||||||
<view class="name">
|
<view class="name">
|
||||||
<view class="name-text">{{ title }}</view>
|
<view class="flex items-center">
|
||||||
|
<view class="name-text mr-1">{{ title }}</view>
|
||||||
|
<up-icon
|
||||||
|
v-if="tip"
|
||||||
|
name="question-circle-fill"
|
||||||
|
color="#555555"
|
||||||
|
size="38"
|
||||||
|
@click="tipDialog"
|
||||||
|
></up-icon>
|
||||||
|
</view>
|
||||||
<switch :checked="checked" class="mr-4 transform-scale-90" @change="change" color="#002ce5" />
|
<switch :checked="checked" class="mr-4 transform-scale-90" @change="change" color="#002ce5" />
|
||||||
</view>
|
</view>
|
||||||
<view class="px-3 text-sm whitespace-pre-line pb-2" v-if="placeholder">{{ placeholder }}</view>
|
<view class="px-3 text-sm whitespace-pre-line pb-2" v-if="placeholder">{{ placeholder }}</view>
|
||||||
@ -16,16 +25,26 @@
|
|||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
title: String,
|
title: String,
|
||||||
placeholder: String,
|
placeholder: String,
|
||||||
value: Boolean
|
value: Boolean,
|
||||||
|
tip: String
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
checked.value = props.value
|
checked.value = props.value
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const emits = defineEmits(['change'])
|
||||||
|
|
||||||
const change = e => {
|
const change = e => {
|
||||||
console.log(111, e)
|
emits('change', e)
|
||||||
// this.$emit('changeInput', e.detail.value)
|
}
|
||||||
|
|
||||||
|
const tipDialog = () => {
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: props.tip,
|
||||||
|
showCancel: false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
21
pages.json
21
pages.json
@ -281,6 +281,27 @@
|
|||||||
"navigationBarTitleText": "添加掌静脉",
|
"navigationBarTitleText": "添加掌静脉",
|
||||||
"disableScroll": true
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/createAdmin/createAdmin",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "创建授权管理员",
|
||||||
|
"disableScroll": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/adminDetail/adminDetail",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "授权管理员详情",
|
||||||
|
"disableScroll": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/adminList/adminList",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "授权管理员",
|
||||||
|
"disableScroll": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"globalStyle": {
|
"globalStyle": {
|
||||||
|
|||||||
143
pages/adminDetail/adminDetail.vue
Normal file
143
pages/adminDetail/adminDetail.vue
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
<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="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 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>
|
||||||
399
pages/adminList/adminList.vue
Normal file
399
pages/adminList/adminList.vue
Normal file
@ -0,0 +1,399 @@
|
|||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<scroll-view
|
||||||
|
v-if="deviceInfo"
|
||||||
|
scroll-y="true"
|
||||||
|
:style="{ height: deviceInfo.screenHeight - deviceInfo.safeArea.top + 'px' }"
|
||||||
|
lower-threshold="100"
|
||||||
|
@refresherrefresh="refresherList"
|
||||||
|
:refresher-enabled="true"
|
||||||
|
@scrolltolower="nextPage"
|
||||||
|
:refresher-triggered="refresherTriggered"
|
||||||
|
>
|
||||||
|
<view class="search">
|
||||||
|
<up-search
|
||||||
|
shape="square"
|
||||||
|
:searchIconSize="48"
|
||||||
|
:inputStyle="{ fontSize: '32rpx' }"
|
||||||
|
:height="80"
|
||||||
|
placeholder="搜索"
|
||||||
|
:clearabled="false"
|
||||||
|
@change="changeSearch"
|
||||||
|
v-model="searchStr"
|
||||||
|
bgColor="#ffffff"
|
||||||
|
:showAction="false"
|
||||||
|
maxlength="50"
|
||||||
|
></up-search>
|
||||||
|
</view>
|
||||||
|
<view style="padding: 0 0 calc(env(safe-area-inset-bottom) + 250rpx) 0">
|
||||||
|
<view v-if="list.length === 0 && requestFinished">
|
||||||
|
<image
|
||||||
|
class="empty-list"
|
||||||
|
src="/static/images/background_empty_list.png"
|
||||||
|
mode="aspectFill"
|
||||||
|
></image>
|
||||||
|
<view class="empty-list-text">暂无数据</view>
|
||||||
|
</view>
|
||||||
|
<view v-else>
|
||||||
|
<up-swipe-action>
|
||||||
|
<up-swipe-action-item
|
||||||
|
ref="swipeItem"
|
||||||
|
:options="options"
|
||||||
|
v-for="item in list"
|
||||||
|
:key="item.keyboardPwdId"
|
||||||
|
:threshold="50"
|
||||||
|
@click="deleteItem(item)"
|
||||||
|
>
|
||||||
|
<view class="item" @click="toDetail(item)">
|
||||||
|
<image
|
||||||
|
class="item-left rounded-50%"
|
||||||
|
:src="item.headUrl === '' ? '/static/images/icon_user.png' : item.headUrl"
|
||||||
|
mode="aspectFill"
|
||||||
|
></image>
|
||||||
|
<view class="item-right">
|
||||||
|
<view style="display: flex; align-items: center">
|
||||||
|
<view class="item-right-top">{{ item.keyName }}</view>
|
||||||
|
<view class="status">
|
||||||
|
{{ $lock.getKeyStatus(item.keyStatus) }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="item-right-bottom">{{ item.timeText }}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="line"></view>
|
||||||
|
</up-swipe-action-item>
|
||||||
|
</up-swipe-action>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
<view class="button">
|
||||||
|
<view class="button-create" @click="toCreate">添加授权管理员</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 { onMounted, ref } from 'vue'
|
||||||
|
import { timeFormat } from 'uview-plus'
|
||||||
|
import { useBasicStore } from '@/stores/basic'
|
||||||
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||||
|
import { deleteKeyRequest, getKeyListRequest } from '@/api/key'
|
||||||
|
import { useLockStore } from '@/stores/lock'
|
||||||
|
|
||||||
|
const $basic = useBasicStore()
|
||||||
|
const $bluetooth = useBluetoothStore()
|
||||||
|
const $lock = useLockStore()
|
||||||
|
|
||||||
|
const swipeItem = ref(null)
|
||||||
|
|
||||||
|
const searchStr = ref('')
|
||||||
|
const list = ref([])
|
||||||
|
const pageNo = ref(1)
|
||||||
|
const pageSize = 50
|
||||||
|
const total = ref(0)
|
||||||
|
const lockId = ref(null)
|
||||||
|
|
||||||
|
const deviceInfo = ref(null)
|
||||||
|
const requestFinished = ref(false)
|
||||||
|
const refresherTriggered = ref(false)
|
||||||
|
const options = ref([
|
||||||
|
{
|
||||||
|
text: '删除',
|
||||||
|
style: {
|
||||||
|
backgroundColor: '#f56c6c'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
])
|
||||||
|
const showModal = ref(false)
|
||||||
|
const checked = ref(false)
|
||||||
|
const deleteData = ref(null)
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
uni.showLoading({
|
||||||
|
title: '加载中',
|
||||||
|
mask: true
|
||||||
|
})
|
||||||
|
deviceInfo.value = await $basic.getDeviceInfo()
|
||||||
|
lockId.value = $bluetooth.currentLockInfo.lockId
|
||||||
|
const { code, message } = await getList({
|
||||||
|
pageNo: pageNo.value
|
||||||
|
})
|
||||||
|
requestFinished.value = true
|
||||||
|
uni.hideLoading()
|
||||||
|
if (code !== 0) {
|
||||||
|
uni.showToast({
|
||||||
|
title: message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const confirmModal = async () => {
|
||||||
|
uni.showLoading({
|
||||||
|
title: '删除中',
|
||||||
|
mask: true
|
||||||
|
})
|
||||||
|
const { code } = await deleteKeyRequest({
|
||||||
|
keyId: deleteData.value.keyId,
|
||||||
|
includeUnderlings: checked.value ? 1 : 0
|
||||||
|
})
|
||||||
|
showModal.value = false
|
||||||
|
if (code === 0) {
|
||||||
|
pageNo.value = 1
|
||||||
|
getList({
|
||||||
|
pageNo: pageNo.value
|
||||||
|
})
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.showToast({
|
||||||
|
title: '删除成功',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.showToast({
|
||||||
|
title: 'message',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const cancelModal = () => {
|
||||||
|
showModal.value = false
|
||||||
|
checked.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
const changeRadio = () => {
|
||||||
|
checked.value = !checked.value
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteItem = async data => {
|
||||||
|
const index = list.value.findIndex(item => item.keyboardPwdId === data.keyboardPwdId)
|
||||||
|
swipeItem.value[index].closeHandler()
|
||||||
|
showModal.value = true
|
||||||
|
deleteData.value = data
|
||||||
|
}
|
||||||
|
|
||||||
|
const refresherList = async () => {
|
||||||
|
refresherTriggered.value = true
|
||||||
|
pageNo.value = 1
|
||||||
|
const { code, message } = await getList({
|
||||||
|
pageNo: pageNo.value,
|
||||||
|
searchStr: searchStr.value
|
||||||
|
})
|
||||||
|
if (code === 0) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '刷新成功',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
refresherTriggered.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
const nextPage = async () => {
|
||||||
|
if (total.value <= pageNo.value * pageSize) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const page = pageNo.value + 1
|
||||||
|
const params = {
|
||||||
|
searchStr: searchStr.value,
|
||||||
|
pageNo: page
|
||||||
|
}
|
||||||
|
const { code, message } = await getList(params)
|
||||||
|
if (code === 0) {
|
||||||
|
pageNo.value = page
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getList = async params => {
|
||||||
|
const { code, data, message } = await getKeyListRequest({
|
||||||
|
...params,
|
||||||
|
lockId: lockId.value,
|
||||||
|
keyRight: 1,
|
||||||
|
endDate: '0',
|
||||||
|
startDate: '0',
|
||||||
|
keyStatus: [110401, 110402, 110412, 110405, 110403],
|
||||||
|
pageSize
|
||||||
|
})
|
||||||
|
if (code === 0) {
|
||||||
|
total.value = data.total
|
||||||
|
for (let i = 0; i < data.list.length; i++) {
|
||||||
|
if (data.list[i].keyType === 1) {
|
||||||
|
data.list[i].timeText = timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') + ' 永久'
|
||||||
|
} else if (data.list[i].keyType === 2) {
|
||||||
|
data.list[i].timeText =
|
||||||
|
timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') +
|
||||||
|
' - ' +
|
||||||
|
timeFormat(data.list[i].endDate, 'yyyy-mm-dd hh:MM')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (params.pageNo === 1) {
|
||||||
|
list.value = data.list
|
||||||
|
} else {
|
||||||
|
list.value = list.value.concat(data.list)
|
||||||
|
}
|
||||||
|
return { code }
|
||||||
|
}
|
||||||
|
return { code, message }
|
||||||
|
}
|
||||||
|
|
||||||
|
const changeSearch = async data => {
|
||||||
|
pageNo.value = 1
|
||||||
|
const { code, message } = await getList({
|
||||||
|
searchStr: data,
|
||||||
|
pageNo: pageNo.value
|
||||||
|
})
|
||||||
|
if (code !== 0) {
|
||||||
|
uni.showToast({
|
||||||
|
title: message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const toCreate = () => {
|
||||||
|
$basic.routeJump({
|
||||||
|
name: 'createAdmin',
|
||||||
|
events: {
|
||||||
|
refresherList() {
|
||||||
|
pageNo.value = 1
|
||||||
|
getList({
|
||||||
|
pageNo: pageNo.value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const toDetail = item => {
|
||||||
|
$basic.routeJump({
|
||||||
|
name: 'adminDetail',
|
||||||
|
params: {
|
||||||
|
info: JSON.stringify(item)
|
||||||
|
},
|
||||||
|
events: {
|
||||||
|
refresherList() {
|
||||||
|
pageNo.value = 1
|
||||||
|
getList({
|
||||||
|
pageNo: pageNo.value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
page {
|
||||||
|
background-color: $uni-bg-color-grey;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.search {
|
||||||
|
padding: 32rpx;
|
||||||
|
width: 686rpx !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
position: fixed;
|
||||||
|
bottom: calc(env(safe-area-inset-bottom) + 20rpx);
|
||||||
|
font-weight: bold;
|
||||||
|
|
||||||
|
.button-create {
|
||||||
|
margin-left: 32rpx;
|
||||||
|
width: 686rpx;
|
||||||
|
height: 88rpx;
|
||||||
|
background-color: #63b8af;
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 88rpx;
|
||||||
|
border-radius: 44rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
background-color: #ffffff;
|
||||||
|
height: 120rpx;
|
||||||
|
width: 750rpx;
|
||||||
|
|
||||||
|
.item-left {
|
||||||
|
margin-left: 32rpx;
|
||||||
|
width: 80rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-right {
|
||||||
|
margin-right: 32rpx;
|
||||||
|
margin-left: 32rpx;
|
||||||
|
width: 574rpx;
|
||||||
|
|
||||||
|
.item-right-top {
|
||||||
|
max-width: 400rpx;
|
||||||
|
font-size: 32rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
padding-bottom: 6rpx;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-right-bottom {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #999999;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.line {
|
||||||
|
width: 100%;
|
||||||
|
height: 2rpx;
|
||||||
|
background: #ebebeb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-list {
|
||||||
|
width: 150rpx;
|
||||||
|
height: 150rpx;
|
||||||
|
margin: 300rpx auto 20rpx 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-list-text {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #999999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status {
|
||||||
|
margin-left: auto;
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #df282d;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
342
pages/createAdmin/createAdmin.vue
Normal file
342
pages/createAdmin/createAdmin.vue
Normal file
@ -0,0 +1,342 @@
|
|||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<view class="tabs">
|
||||||
|
<up-tabs
|
||||||
|
:list="tabs"
|
||||||
|
lineWidth="40rpx"
|
||||||
|
lineHeight="5rpx"
|
||||||
|
:current="currentIndex"
|
||||||
|
lineColor="#63b8af"
|
||||||
|
@click="clickTab"
|
||||||
|
:inactiveStyle="{ color: '#a3a3a3', fontSize: '32rpx', fontWeight: 'bold' }"
|
||||||
|
:activeStyle="{ color: '#63b8af', fontSize: '32rpx', fontWeight: 'bold' }"
|
||||||
|
>
|
||||||
|
</up-tabs>
|
||||||
|
</view>
|
||||||
|
<swiper
|
||||||
|
:style="{ height: deviceInfo.screenHeight - deviceInfo.safeArea.top - 44 + 'px' }"
|
||||||
|
v-if="deviceInfo"
|
||||||
|
:list="tabs"
|
||||||
|
:autoplay="false"
|
||||||
|
:circular="true"
|
||||||
|
:current="currentIndex"
|
||||||
|
@change="changeSwiper"
|
||||||
|
>
|
||||||
|
<swiper-item>
|
||||||
|
<LockInput
|
||||||
|
:value="permanentAccount"
|
||||||
|
title="接收者"
|
||||||
|
placeholder="请输入手机号或者邮箱"
|
||||||
|
@change-input="changeAccount('permanent', $event)"
|
||||||
|
></LockInput>
|
||||||
|
<LockInput
|
||||||
|
:value="permanentName"
|
||||||
|
title="姓名"
|
||||||
|
placeholder="请输入"
|
||||||
|
@change-input="changeName('permanent', $event)"
|
||||||
|
></LockInput>
|
||||||
|
<view class="mt-3">
|
||||||
|
<LockSwitch
|
||||||
|
:value="permanentManageSelf"
|
||||||
|
title="仅管理自己创建的用户"
|
||||||
|
:tip="tip"
|
||||||
|
@change="changeAdmin('permanent', $event)"
|
||||||
|
></LockSwitch>
|
||||||
|
</view>
|
||||||
|
<view class="button mt-5" @click="create('permanent')">发送</view>
|
||||||
|
</swiper-item>
|
||||||
|
<swiper-item :style="{ height: deviceInfo.windowHeight - 44 + 'px' }">
|
||||||
|
<LockInput
|
||||||
|
:value="temporaryAccount"
|
||||||
|
title="接收者"
|
||||||
|
placeholder="请输入手机号或者邮箱"
|
||||||
|
@change-input="changeAccount('permanent', $event)"
|
||||||
|
></LockInput>
|
||||||
|
<LockInput
|
||||||
|
:value="temporaryName"
|
||||||
|
title="姓名"
|
||||||
|
placeholder="请输入"
|
||||||
|
@change-input="changeName('permanent', $event)"
|
||||||
|
></LockInput>
|
||||||
|
<view class="mt-3">
|
||||||
|
<LockDatetimePicker
|
||||||
|
title="生效时间"
|
||||||
|
:value="temporaryStartTime"
|
||||||
|
:minDate="minDate"
|
||||||
|
:maxDate="maxDate"
|
||||||
|
type="datehour"
|
||||||
|
@change-time="changeDate('temporaryStartTime', $event)"
|
||||||
|
></LockDatetimePicker>
|
||||||
|
</view>
|
||||||
|
<view class="mt-3">
|
||||||
|
<LockDatetimePicker
|
||||||
|
title="失效时间"
|
||||||
|
:value="temporaryEndTime"
|
||||||
|
:minDate="minDate"
|
||||||
|
:maxDate="maxDate"
|
||||||
|
type="datehour"
|
||||||
|
@change-time="changeDate('temporaryEndTime', $event)"
|
||||||
|
></LockDatetimePicker>
|
||||||
|
</view>
|
||||||
|
<view class="mt-3">
|
||||||
|
<LockSwitch
|
||||||
|
:value="temporaryManageSelf"
|
||||||
|
title="仅管理自己创建的用户"
|
||||||
|
:tip="tip"
|
||||||
|
@change="changeAdmin('permanent', $event)"
|
||||||
|
></LockSwitch>
|
||||||
|
</view>
|
||||||
|
<view class="button mt-5" @click="create('temporary')">发送</view>
|
||||||
|
</swiper-item>
|
||||||
|
</swiper>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { getCurrentInstance, ref } from 'vue'
|
||||||
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
|
import test from 'uview-plus/libs/function/test'
|
||||||
|
import { useBasicStore } from '@/stores/basic'
|
||||||
|
import { createKeyRequest } from '@/api/key'
|
||||||
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||||
|
|
||||||
|
const instance = getCurrentInstance().proxy
|
||||||
|
const eventChannel = instance.getOpenerEventChannel()
|
||||||
|
|
||||||
|
const $basic = useBasicStore()
|
||||||
|
const $bluetooth = useBluetoothStore()
|
||||||
|
|
||||||
|
const tabs = [
|
||||||
|
{
|
||||||
|
name: '永久'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '限时'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
const permanentAccount = ref('')
|
||||||
|
const permanentName = ref('')
|
||||||
|
const permanentManageSelf = ref(false)
|
||||||
|
|
||||||
|
const temporaryAccount = ref('')
|
||||||
|
const temporaryName = ref('')
|
||||||
|
const temporaryStartTime = ref(Number(new Date()))
|
||||||
|
const temporaryEndTime = ref(Number(new Date()))
|
||||||
|
const temporaryManageSelf = ref(false)
|
||||||
|
|
||||||
|
const minDate = ref(Number(new Date()))
|
||||||
|
const maxDate = ref(Number(4133951940000))
|
||||||
|
const currentIndex = ref(0)
|
||||||
|
const deviceInfo = ref(null)
|
||||||
|
|
||||||
|
const tip = '授权管理员只能查看和管理自己下发的钥匙、密码等权限'
|
||||||
|
|
||||||
|
const pending = ref(false)
|
||||||
|
|
||||||
|
onLoad(async () => {
|
||||||
|
deviceInfo.value = await $basic.getDeviceInfo()
|
||||||
|
temporaryStartTime.value = setTime()
|
||||||
|
temporaryEndTime.value = setTime()
|
||||||
|
minDate.value = Number(getNextFullHour())
|
||||||
|
maxDate.value = Number(getFutureTimestamp())
|
||||||
|
})
|
||||||
|
|
||||||
|
const getNextFullHour = () => {
|
||||||
|
const now = new Date()
|
||||||
|
const currentHour = now.getHours()
|
||||||
|
now.setHours(currentHour)
|
||||||
|
now.setMinutes(0)
|
||||||
|
now.setSeconds(0)
|
||||||
|
now.setMilliseconds(0)
|
||||||
|
|
||||||
|
return now
|
||||||
|
}
|
||||||
|
|
||||||
|
const getFutureTimestamp = () => {
|
||||||
|
const currentDate = new Date()
|
||||||
|
|
||||||
|
const year = currentDate.getFullYear()
|
||||||
|
const month = currentDate.getMonth()
|
||||||
|
const day = currentDate.getDate()
|
||||||
|
|
||||||
|
const futureDate = new Date(year + 3, month, day, 23, 0, 0)
|
||||||
|
|
||||||
|
return futureDate.getTime()
|
||||||
|
}
|
||||||
|
|
||||||
|
const setTime = () => {
|
||||||
|
const now = new Date()
|
||||||
|
now.setMinutes(0, 0, 0)
|
||||||
|
|
||||||
|
return now.getTime()
|
||||||
|
}
|
||||||
|
|
||||||
|
const create = async (type, createUser = false) => {
|
||||||
|
if (
|
||||||
|
(type === 'temporary' && temporaryAccount.value === '') ||
|
||||||
|
(type === 'permanent' && permanentAccount.value === '')
|
||||||
|
) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '请输入接收者账号',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
(type === 'temporary' &&
|
||||||
|
!(test.email(temporaryAccount.value) || test.mobile(temporaryAccount.value))) ||
|
||||||
|
(type === 'permanent' &&
|
||||||
|
!(test.email(permanentAccount.value) || test.mobile(permanentAccount.value)))
|
||||||
|
) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '请输入格式正确的手机号或邮箱',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '失效时间要大于生效时间',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const netWork = await $basic.getNetworkType()
|
||||||
|
if (!netWork) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pending.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
pending.value = true
|
||||||
|
|
||||||
|
let params = {
|
||||||
|
faceAuthentication: '2',
|
||||||
|
isRemoteUnlock: '2',
|
||||||
|
lockId: $bluetooth.currentLockInfo.lockId,
|
||||||
|
keyRight: '1',
|
||||||
|
remarks: '',
|
||||||
|
countryCode: '86',
|
||||||
|
createUser: '0'
|
||||||
|
}
|
||||||
|
if (createUser) {
|
||||||
|
params.createUser = '1'
|
||||||
|
params.usernameType = test.mobile(temporaryAccount.value) ? '1' : '2'
|
||||||
|
}
|
||||||
|
if (type === 'temporary') {
|
||||||
|
params.keyNameForAdmin = temporaryName.value
|
||||||
|
params.endDate = temporaryEndTime.value.toString()
|
||||||
|
params.keyType = '2'
|
||||||
|
params.receiverUsername = temporaryAccount.value
|
||||||
|
params.startDate = temporaryStartTime.value.toString()
|
||||||
|
params.isOnlyManageSelf = temporaryManageSelf.value ? 1 : 0
|
||||||
|
} else {
|
||||||
|
params.keyNameForAdmin = permanentName.value
|
||||||
|
params.startDate = new Date().getTime().toString()
|
||||||
|
params.endDate = '0'
|
||||||
|
params.keyType = '1'
|
||||||
|
params.receiverUsername = permanentAccount.value
|
||||||
|
params.isOnlyManageSelf = permanentManageSelf.value ? 1 : 0
|
||||||
|
}
|
||||||
|
const { code, message } = await createKeyRequest(params)
|
||||||
|
if (code === 0) {
|
||||||
|
eventChannel.emit('refresherList', {})
|
||||||
|
$basic.backAndToast('添加成功')
|
||||||
|
} else if (code === 425) {
|
||||||
|
pending.value = false
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: `是否发送电子钥匙给未注册账号\n${params.receiverUsername}`,
|
||||||
|
success: async res => {
|
||||||
|
if (res.confirm) {
|
||||||
|
await create(type, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: message,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
pending.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
const changeName = (type, event) => {
|
||||||
|
if (type === 'permanent') {
|
||||||
|
permanentName.value = event
|
||||||
|
} else {
|
||||||
|
temporaryName.value = event
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const changeDate = (type, event) => {
|
||||||
|
if (type === 'temporaryStartTime') {
|
||||||
|
temporaryStartTime.value = event
|
||||||
|
} else {
|
||||||
|
temporaryEndTime.value = event
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const changeAdmin = (type, event) => {
|
||||||
|
if (type === 'permanent') {
|
||||||
|
permanentManageSelf.value = event.detail.value
|
||||||
|
} else {
|
||||||
|
temporaryManageSelf.value = event.detail.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const changeAccount = (type, event) => {
|
||||||
|
if (type === 'permanent') {
|
||||||
|
permanentAccount.value = event
|
||||||
|
} else {
|
||||||
|
temporaryAccount.value = event
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const clickTab = data => {
|
||||||
|
currentIndex.value = data.index
|
||||||
|
}
|
||||||
|
|
||||||
|
const changeSwiper = e => {
|
||||||
|
currentIndex.value = e.detail.current
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
page {
|
||||||
|
background-color: $uni-bg-color-grey;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.tabs {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
margin-top: 40rpx;
|
||||||
|
margin-bottom: 50rpx;
|
||||||
|
color: #262626;
|
||||||
|
font-size: 26rpx;
|
||||||
|
padding: 0 32rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
border-radius: 64rpx;
|
||||||
|
width: 686rpx;
|
||||||
|
margin-left: 32rpx;
|
||||||
|
height: 100rpx;
|
||||||
|
line-height: 100rpx;
|
||||||
|
text-align: center;
|
||||||
|
background-color: #63b8af;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 32rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -113,7 +113,11 @@
|
|||||||
<image class="menu-main-image" src="/static/images/icon_palm_vein.png"></image>
|
<image class="menu-main-image" src="/static/images/icon_palm_vein.png"></image>
|
||||||
<view>掌静脉</view>
|
<view>掌静脉</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="menu-main-view" @click="routeJump({ name: 'keyList' })">
|
<view
|
||||||
|
v-if="currentLockInfo.userType === 110301"
|
||||||
|
class="menu-main-view"
|
||||||
|
@click="routeJump({ name: 'adminList' })"
|
||||||
|
>
|
||||||
<image class="menu-main-image" src="/static/images/icon_admin_black.png"></image>
|
<image class="menu-main-image" src="/static/images/icon_admin_black.png"></image>
|
||||||
<view>授权管理员</view>
|
<view>授权管理员</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@ -211,6 +211,21 @@ const pages = [
|
|||||||
name: 'bindPalmVein',
|
name: 'bindPalmVein',
|
||||||
path: '/pages/bindPalmVein/bindPalmVein',
|
path: '/pages/bindPalmVein/bindPalmVein',
|
||||||
tabBar: false
|
tabBar: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'createAdmin',
|
||||||
|
path: '/pages/createAdmin/createAdmin',
|
||||||
|
tabBar: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'adminDetail',
|
||||||
|
path: '/pages/adminDetail/adminDetail',
|
||||||
|
tabBar: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'adminList',
|
||||||
|
path: '/pages/adminList/adminList',
|
||||||
|
tabBar: false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user