Browse Source

修复用户bug

# Conflicts:
#	components.d.ts
#	src/pages/Index/Index.vue
#	src/pages/Index/components/Setting/UpdatePinModal.vue
#	src/utils/getServerInfo.ts

# Conflicts:
#	components.d.ts
#	src/pages/Index/Index.vue
#	src/pages/Index/Settings/NavBar.vue
#	src/pages/Index/components/Setting/UpdatePinModal.vue
#	src/utils/getServerInfo.ts
relver
LiLongLong 7 months ago
committed by zhangjiming
parent
commit
bb297b7bb6
  1. 4
      src/assets/close.svg
  2. 3
      src/assets/init.svg
  3. 3
      src/assets/logout.svg
  4. 132
      src/pages/Index/Index.vue
  5. 20
      src/pages/Index/Settings/NavBar.vue
  6. 52
      src/pages/Index/Settings/Users.vue
  7. 14
      src/pages/Index/components/Consumables/Warn/InitWarn.vue
  8. 4
      src/pages/Index/components/Setting/EnterPinModal.vue
  9. 8
      src/pages/Index/components/Setting/UpdatePinModal.vue
  10. 2
      src/services/Index/user-manage.ts
  11. 11
      src/services/Login/login.ts

4
src/assets/close.svg

@ -0,0 +1,4 @@
<svg width="29" height="31" viewBox="0 0 29 31" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.4941 0H16.0626V17.8477H12.4941V0Z" fill="#5C5C5C"/>
<path d="M22.4878 4.28516L19.991 6.78424C22.8432 8.74503 24.9843 12.1384 24.9843 16.0622C24.9843 21.9524 20.1663 26.7701 14.2764 26.7701C8.38909 26.7701 3.56844 21.9523 3.56844 16.0622C3.56844 12.1384 5.71222 8.74503 8.74479 6.96225L6.06774 4.2852C2.49657 6.96225 0 11.2443 0 16.0623C0 23.9182 6.42578 30.3413 14.2764 30.3413C22.1296 30.3413 28.5554 23.9182 28.5554 16.0623C28.5554 11.2443 26.0561 6.9622 22.4878 4.28516Z" fill="#5C5C5C"/>
</svg>

3
src/assets/init.svg

@ -0,0 +1,3 @@
<svg width="28" height="32" viewBox="0 0 28 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18.175 0.148589L11.3519 5.24831C11.2557 5.31963 11.177 5.41332 11.1222 5.52183C11.0674 5.63033 11.0381 5.75062 11.0365 5.87301C11.0365 6.12289 11.1573 6.34839 11.3519 6.49771L18.1514 11.5974C18.2612 11.6823 18.3915 11.7343 18.5279 11.7477C18.6644 11.7612 18.8018 11.7355 18.9251 11.6736C19.0462 11.6098 19.1484 11.5135 19.2211 11.3947C19.2937 11.2759 19.334 11.1391 19.3377 10.9986V8.14937C21.0544 9.18271 22.451 10.7002 23.3639 12.5243C24.2768 14.3484 24.6683 16.4036 24.4926 18.4494C24.3793 19.8744 23.9937 21.262 23.358 22.5318C22.7223 23.8016 21.8492 24.9283 20.7893 25.8468C19.7318 26.7728 18.5071 27.4728 17.1861 27.9061C15.8652 28.3395 14.4742 28.4977 13.0937 28.3715C11.7147 28.255 10.3718 27.857 9.14242 27.2006C7.9131 26.5441 6.82181 25.6423 5.93166 24.5471C5.03536 23.4555 4.35769 22.1907 3.93799 20.8262C3.5183 19.4616 3.36495 18.0245 3.48683 16.5981C3.71183 13.7687 5.00773 11.1453 7.09292 9.29822C7.26515 9.14446 7.40623 8.95698 7.50805 8.74659C7.60986 8.53619 7.67039 8.30704 7.68615 8.07234C7.7019 7.83765 7.67257 7.60205 7.59984 7.37913C7.52711 7.15621 7.41243 6.95038 7.2624 6.7735C7.11332 6.59551 6.93169 6.44973 6.72795 6.34454C6.52422 6.23935 6.30238 6.17682 6.0752 6.16053C5.84802 6.14425 5.61997 6.17454 5.40414 6.24966C5.18831 6.32478 4.98897 6.44326 4.81756 6.59828C2.04262 9.09047 0.327314 12.6113 0.0421991 16.4002C-0.242916 20.1891 0.925049 23.9419 3.29378 26.8478C5.68654 29.7812 9.10595 31.615 12.8034 31.9475C16.5011 32.2737 20.173 31.0697 23.0131 28.6C25.8533 26.1302 27.6298 22.5964 27.9528 18.7739C28 18.3473 28 17.9481 28 17.5245C28 14.1237 26.8623 10.8508 24.7093 8.22555C23.2667 6.45084 21.4318 5.06166 19.3598 4.17564V0.774817C19.3595 0.633942 19.3209 0.495996 19.2485 0.37667C19.176 0.257345 19.0727 0.161428 18.9501 0.0998316C18.831 0.0269432 18.6935 -0.00736884 18.5553 0.00132188C18.4172 0.0100126 18.2847 0.0613073 18.175 0.148589Z" fill="#555656"/>
</svg>

3
src/assets/logout.svg

@ -0,0 +1,3 @@
<svg width="29" height="31" viewBox="0 0 29 31" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M29 15.5019V29.2128C29 30.1999 28.1231 31 27.0364 31H17.2261C16.1432 31 15.2626 30.1999 15.2626 29.2128C15.2626 28.2257 16.1394 27.4255 17.2261 27.4255H25.0729V3.57448H17.2224C16.1394 3.57448 15.2588 2.77433 15.2588 1.78724C15.2588 0.800145 16.1357 0 17.2224 0H27.0364C28.1194 0 29 0.800145 29 1.78724V15.5019ZM0.61455 14.2082C0.236076 14.5372 0 15.0121 0 15.5393C0 16.0702 0.236076 16.5413 0.61455 16.8703L6.81251 22.2321C7.14227 22.5162 7.5807 22.692 8.0566 22.692C9.08335 22.692 9.91524 21.8881 9.91524 20.901C9.91524 20.3738 9.67541 19.8989 9.29694 19.5736L6.70009 17.3265H17.9793C19.0061 17.3265 19.838 16.5264 19.838 15.5393C19.838 14.5522 19.0061 13.752 17.9793 13.752H6.70759L9.30443 11.5049C9.68291 11.1796 9.92273 10.701 9.92273 10.1738C9.92273 9.18671 9.08709 8.38656 8.06409 8.38656C7.58444 8.38656 7.14976 8.55856 6.82 8.84646L0.61455 14.2082Z" fill="#5C5C5C"/>
</svg>

132
src/pages/Index/Index.vue

@ -1,5 +1,11 @@
<template>
<div id="index-container">
<div class="loading-overlay" v-if="isLoading">
<div class="loading-content">
<div class="loading-spinner"></div>
<span class="loading-text">正在关机中...</span>
</div>
</div>
<el-header class="nav-bar">
<div class="logo">
<img src="@/assets/Index/logo.svg" alt="" width="150px" />
@ -78,9 +84,10 @@
<!-- 底部操作信息 -->
<el-footer class="footer-info">
<!-- <el-dropdown placement="top-start"> -->
<div class="user-card" @click="onClickLoginUser">
<img class="user-logo" src="@/assets/Index/user.svg" />
<el-dropdown placement="top-start" style="margin-left:-10px">
<div class="user-card">
<img class="user-logo" src="@/assets/Index/user.svg" />
<div class="user-name">
{{
deviceStore.contextState.loginFlag
@ -88,22 +95,30 @@
: '未登录'
}}
</div>
</div>
<!-- <template #dropdown>
<el-dropdown-menu>
</div>
<template #dropdown>
<el-dropdown-menu style="width:100px">
<el-dropdown-item >
<div @click="onInitDevice" style="display: flex;">
<img :src="InitSvg" alt="Icon" width="15" />
<div class="pd-5">初始化</div>
</div>
</el-dropdown-item>
<el-dropdown-item >
<div @click="onCloseDevice" style="display: flex;">
<img :src="CloseSvg" alt="Icon" width="15" />
<div class="pd-5">关机</div>
</div>
</el-dropdown-item>
<el-dropdown-item>
<img
class="user-logo"
src="@/assets/Index/user.svg"
height="30"
/>
<button class="logout" style="width: 100px" @click="onLogout">
退出
</button>
<div @click="onLogout" style="display: flex;">
<img :src="LogoutSvg" alt="Icon" width="15" />
<div class="pd-5">退出</div>
</div>
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown> -->
</el-dropdown>
<div class="equipment-status" @click="showRecentMsgDialog = true">
<div
@ -339,11 +354,16 @@ import type {
} from '../../websocket/socket'
import { getServerInfo } from '../../utils/getServerInfo'
import { eventBus } from '../../eventBus'
import { logout } from '@/services/Login/login'
import { logout, shutdown } from '@/services/Login/login'
import { useRunningStore } from '@/store/modules/running'
import { formatDate } from '@/utils/formDate'
import { eMessage } from './utils'
import InitSvg from '@/assets/init.svg'
import CloseSvg from '@/assets/close.svg'
import LogoutSvg from '@/assets/logout.svg'
const selectedTab = ref(sessionStorage.getItem('selectedTab') || '常规')
const lineWidth = ref(0)
const lineLeft = ref(0)
@ -489,6 +509,33 @@ const saveIdInfo = async () => {
idCardInserted.value = false
}
}
//
const onInitDevice = ()=> {
eventBus.emit('initDevice')
}
//
let isLoading = ref(false)
const onCloseDevice = ()=> {
// ElMessageBox.alert()
ElMessageBox.alert('请确认是否关机操作', '提示', {
confirmButtonText: '确定',
callback:async (action)=>{
console.log('action===', action)
if(action == 'confirm'){
//
isLoading.value = true;
//loading1sloading
setTimeout(async ()=>{
await shutdown()
isLoading.value = false;
},1000)
}
}
})
}
const showInitDeviceAlert = () => {
showModal.value = true
}
@ -720,8 +767,8 @@ const pollingInitState = async () => {
failMessage.value = {
title: '检测失败',
message:
infos && infos.length > 0
? infos.map((d: any) => d.name).join('\n')
infos && infos.length > 0
? infos.map((d: any) => d.name).join('\n')
: res.data.promopt.info,
}
showFailModal.value = true //
@ -1050,4 +1097,53 @@ watch(
font-size: 1.5rem;
}
}
.pd-5{
padding: 0 5px;
}
.loading-overlay {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: rgba(0, 0, 0, 0.7);
backdrop-filter: blur(4px);
display: flex;
justify-content: center;
align-items: center;
z-index: 9998;
}
.loading-content {
display: flex;
flex-direction: column;
align-items: center;
gap: 20px;
}
.loading-spinner {
width: 60px;
height: 60px;
border: 4px solid #f3f3f3;
border-top: 4px solid #4caf50;
border-radius: 50%;
animation: spin 1s linear infinite;
}
.loading-text {
color: white;
font-size: 24px;
font-weight: 500;
}
.loading-progress {
width: 300px;
height: 6px;
background: rgba(255, 255, 255, 0.2);
border-radius: 3px;
overflow: hidden;
}
</style>

20
src/pages/Index/Settings/NavBar.vue

@ -3,7 +3,7 @@
<!-- 使用 router-link 实现每个导航项的路由切换 -->
<router-link v-for="(item, index) in navItems" :key="index" :to="item.route" class="nav-item-link"
active-class="active">
<div :class="['nav-item', { active: currentRoute === item.route }]" @click="setActive(index)">
<div :class="['nav-item', { active: currentRoute === item.route }]" v-if="userSetting(item.id)" @click="setActive(index)">
{{ item.label }}
</div>
</router-link>
@ -13,13 +13,13 @@
<script setup lang="ts">
import { ref, watch, nextTick } from 'vue'
import { useRoute, useRouter } from 'vue-router'
const userInfo = JSON.parse(sessionStorage.getItem('token') || '{}')
//
const navItems = [
{ label: '设备', route: '/index/setting/device' },
{ label: '用户管理', route: '/index/setting/users' },
{ label: '系统信息', route: '/index/setting/version' },
{ label: 'LIS', route: '/index/setting/lis' },
{id:1, label: '设备', route: '/index/setting/device' },
{id:2, label: '用户管理', route: '/index/setting/users' },
{id:3, label: '系统信息', route: '/index/setting/version' },
{id:4, label: 'LIS', route: '/index/setting/lis' },
]
const currentRoute = ref(navItems[0].route) //
@ -32,6 +32,14 @@ const setActive = async (index: number) => {
await nextTick() // DOM
}
const userSetting = (id)=>{
let userRole = userInfo.usrRole;
if(userRole !== 'Admin' && id == 2){
return false;
}
return true;
}
// sessionStorage
watch(route, (newRoute) => {
console.log('🚀 ~ newRoute:', newRoute)

52
src/pages/Index/Settings/Users.vue

@ -9,7 +9,7 @@
<div class="table-footer">
<el-button type="primary" @click="addUser">新增</el-button>
<el-button type="primary" @click="modifyPin">PIN</el-button>
<el-button type="primary" @click="modifyPin">修改密码</el-button>
<el-button type="danger" @click="deleteSelectedUsers">删除</el-button>
</div>
</div>
@ -49,6 +49,15 @@
<DelMessage v-if="confirmInsert" :visible="confirmInsert" icon="/src/assets/OK.svg" message="已成功添加新用户"
:username="newUser.account" @confirm="handleConfirmMsg" />
<InitWarn
v-if="isMoreSelected"
:visible="isMoreSelected"
title="提示"
:message="alertMessage"
confirmText="确认"
@confirm="isMoreSelected = false"
/>
</div>
</template>
@ -56,6 +65,8 @@
import type { User } from '../../../types/Index'
import { DelWarn, DelMessage, AddUserModal, EnterPinModal, UpdatePinModal } from '../components'
import { ref, onMounted, computed } from 'vue'
import { InitWarn } from '@/pages/Index/components/Consumables/Warn'
const userInfo = JSON.parse(sessionStorage.getItem('token') || '{}')
import {
getUserList,
deleteUser,
@ -109,6 +120,8 @@ const isPinModalVisible = ref(false)
const confirmInsert = ref(false)
const isChecked = ref(false)
const enterPinModal = ref(false)
const isMoreSelected = ref(false)
const alertMessage = ref('只能选择一条数据进行操作')
//
const isExist = ref(false)
//
@ -158,8 +171,10 @@ const modifyPin = async () => {
}
if(selectedUsers.value.length !== 1){
isMoreSelected.value = true;
return;
}
updateUser.value.id = selectedUsers.value[0].id
// updatePinModal.value = true
handleConfirmUpdatePin()
}
@ -170,6 +185,28 @@ const deleteSelectedUsers = () => {
isChecked.value = true
return
}
//
if(selectedUsers.value.length){
if(userInfo.isBuildIn){
isMoreSelected.value = true;
alertMessage.value = '此用户不可删除'
return;
}
let isSelf = false;
selectedUsers.value.forEach(item => {
//
if(item.id == userInfo.id || item.isBuiltInUser){
isSelf = true;
}
})
if(isSelf){
isMoreSelected.value = true;
alertMessage.value = '不可以删除此用户'
return;
}
}
delShowModal.value = true
}
//
@ -234,7 +271,7 @@ const handleUpdatePin = async () => {
const handleUpdatePwd= async () => {
if (selectedUsers.value.length !== 1) {
console.log('请选择一个用户来修改PIN码')
console.log('请选择一个用户来修改码')
return
}
@ -245,11 +282,11 @@ const handleUpdatePwd= async () => {
oldpasswd: user.oldpasswd,
})
if (response && response.success) {
} else {
console.log('修改用户权限失败')
}
return response;
}
//pin
@ -274,10 +311,15 @@ const updatePwdConfirm= (params:{password:string, oldpasswd: string}) => {
updatePinLoading.value = true
updateUser.value.password = params.password
updateUser.value.oldpasswd = params.oldpasswd
handleUpdatePwd().then(() => {
handleUpdatePwd().then((res) => {
updatePinLoading.value = false
updatePinModal.value = false
updatePinMsgModal.value = true
if (res && res.success) {
updatePinMsgModal.value = true
}else{
isMoreSelected.value = true;
alertMessage.value = '修改密码失败'
}
})
}

14
src/pages/Index/components/Consumables/Warn/InitWarn.vue

@ -3,7 +3,7 @@
<div v-if="visible" class="modal-overlay">
<div class="modal">
<!-- 图标部分 -->
<div class="modal-icon">
<div class="modal-icon" v-if="iconSrc">
<img :src="iconSrc" alt="Icon" class="icon" />
</div>
<div class="modal-content">
@ -12,11 +12,11 @@
<!-- 错误提示信息 -->
<p v-if="errorTip" class="modal-error">{{ errorTip }}</p>
</div>
<div class="modal-buttons">
<button v-if="cancelText" @click="onCancel" class="cancel-btn">{{ cancelText }}</button>
<button @click="onConfirm" class="confirm-btn">
<div class="modal-buttons" style="float:right">
<el-button style="width:100px;" v-if="cancelText" @click="onCancel" class="cancel-btn">{{ cancelText }}</el-button>
<el-button style="width:100px;" type="primary" @click="onConfirm" class="confirm-btn">
{{ confirmText }}
</button>
</el-button>
</div>
</div>
</div>
@ -58,7 +58,7 @@ const icons = import.meta.glob('/src/assets/**/*.svg')
onMounted(async () => {
const iconPath = `${props.icon}`
if (icons[iconPath]) {
if (icons[iconPath] && props.icon) {
// 使
const module = await icons[iconPath]()
iconSrc.value = (module as { default: string }).default
@ -163,6 +163,7 @@ const onConfirm = () => {
font-weight: bold;
cursor: pointer;
border: none;
height: 50px;
transition:
background-color 0.3s ease,
color 0.3s ease; //
@ -178,7 +179,6 @@ const onConfirm = () => {
}
.confirm-btn {
background-color: #ff4d4f;
color: #fff;
&:hover {

4
src/pages/Index/components/Setting/EnterPinModal.vue

@ -4,11 +4,11 @@
<div class="modal-container">
<div class="modal-header"></div>
<div class="modal-title">
<span class="title-text">请输入 PIN </span>
<span class="title-text">请输入</span>
</div>
<div class="modal-body">
<div class="input-container">
<input :type="isShowType?'text':'password'" v-model="pin" placeholder="输入PIN 码" @focus="showKeyboard()" class="pin-input" />
<input :type="isShowType?'text':'password'" v-model="pin" placeholder="输入码" @focus="showKeyboard()" class="pin-input" />
<el-icon class="pwd-view" @click="isShowType = !isShowType"><View /></el-icon>
</div>
</div>

8
src/pages/Index/components/Setting/UpdatePinModal.vue

@ -4,7 +4,7 @@
<div class="modal-container">
<div class="modal-header"></div>
<div class="modal-title">
<span class="title-text">请输入 PIN </span>
<span class="title-text">请输入</span>
</div>
<div class="modal-body">
<div class="input-container">
@ -12,7 +12,7 @@
<input
:type="showoldpasswd ? 'text' : 'password'"
v-model="oldpasswd"
placeholder="输入旧PIN码"
placeholder="输入旧码"
@focus="showKeyboard('oldpasswd')"
class="pin-input"
/>
@ -25,7 +25,7 @@
<input
:type="showPassword ? 'text' : 'password'"
v-model="password"
placeholder="输入新PIN 码"
placeholder="输入新码"
@focus="showKeyboard('password')"
class="pin-input"
/>
@ -38,7 +38,7 @@
<input
:type="showConfirmPassword ? 'text' : 'password'"
v-model="confirmPassword"
placeholder="输入确认新PIN 码"
placeholder="输入确认新码"
@focus="showKeyboard('confirmPassword')"
class="pin-input"
/>

2
src/services/Index/user-manage.ts

@ -13,7 +13,7 @@ export const changeUserAuth = async (params: any) => {
//修改用户密码
export const changeUserPassword = async (params: any) => {
try {
const res = await apiClient.post('/api/v1/app/Usr/modifyUsrPwd', params)
const res = await apiClient.post(`/api/v1/app/Usr/modifyUsrPwd?id=${params.id}&oldpasswd=${params.oldpasswd}&password=${params.password}`)
return res.data
} catch (error) {
console.log('修改用户密码时出错', error)

11
src/services/Login/login.ts

@ -22,3 +22,14 @@ export const logout = async () => {
console.log('退出登录时出错', error)
}
}
//关机
export const shutdown = async () => {
try {
const res = await apiClient.post('/api/v1/app/osCtrl/shutdown')
return res.data
} catch (error) {
console.log('关机时出错', error)
}
}
Loading…
Cancel
Save