Browse Source

user

master
maochaoying 2 years ago
parent
commit
01498fa27e
  1. 8
      .env
  2. 40
      src/components/Setting/components/User.vue
  3. 131
      src/components/dialogs/PermissionModal.vue
  4. 4
      src/mock/command.js

8
.env

@ -1,5 +1,5 @@
# VITE_BASE_WS1_URL=ws://192.168.8.10:19001/
# VITE_BASE_WS2_URL=ws://192.168.8.10:19002/
VITE_BASE_WS1_URL=ws://192.168.8.10:19001/
VITE_BASE_WS2_URL=ws://192.168.8.10:19002/
VITE_BASE_WS1_URL=ws://127.0.0.1:19001/
VITE_BASE_WS2_URL=ws://127.0.0.1:19002/
# VITE_BASE_WS1_URL=ws://127.0.0.1:19001/
# VITE_BASE_WS2_URL=ws://127.0.0.1:19002/

40
src/components/Setting/components/User.vue

@ -102,11 +102,11 @@
删除用户 删除用户
</div> </div>
<div <div
v-if="item.uid != 'admin'"
class="common_btn mb style-btn" class="common_btn mb style-btn"
v-if="item.permission_level == 3"
@click="showUserModal(`${item.uid} 设置为管理员`, item.id, 2)"
@click="updatePer(item.id, item.permission_level)"
> >
设为管理员
修改权限
</div> </div>
<div class="btn style-btn" @click="showUpdatePassword(item.uid)"> <div class="btn style-btn" @click="showUpdatePassword(item.uid)">
修改密码 修改密码
@ -147,6 +147,12 @@
:input="newUserPassword" :input="newUserPassword"
/> />
</div> </div>
<PermissionModal
v-if="logVisible"
:hiddenLogVisible="hiddenLogVisible"
:changeLogVal="changeLogVal"
:logVal="logVal"
/>
</div> </div>
</template> </template>
@ -155,6 +161,7 @@ import { ref, onMounted } from 'vue'
import UserModal from 'cpns/dialogs/UserModal' import UserModal from 'cpns/dialogs/UserModal'
import SimpleKeyboard from 'cpns/SimpleKeyboard' import SimpleKeyboard from 'cpns/SimpleKeyboard'
import Eye from '@/assets/img/login/eye.png' import Eye from '@/assets/img/login/eye.png'
import PermissionModal from 'cpns/dialogs/PermissionModal'
import Open from '@/assets/img/login/open.png' import Open from '@/assets/img/login/open.png'
import { useUserStore, useWebSocketStore } from '@/store' import { useUserStore, useWebSocketStore } from '@/store'
import { import {
@ -176,6 +183,14 @@ const hideKeyBoard = () => {
showkeyboard.value = false showkeyboard.value = false
} }
const logVisible = ref(false)
const logVal = ref('3')
const updatePer = (uid, permission_level) => {
logVal.value = permission_level + ''
currDelUserId.value = uid
logVisible.value = true
}
const hideKeyBoard2 = () => { const hideKeyBoard2 = () => {
showkeyboard2.value = false showkeyboard2.value = false
} }
@ -183,6 +198,20 @@ const hideKeyBoard3 = () => {
showkeyboard3.value = false showkeyboard3.value = false
} }
const changeLogVal = val => {
logVal.value = val
logVisible.value = false
//
webSocketStore.sendCommandMsg(
updateUserPermissionLevelJSON(currDelUserId.value, val),
)
webSocketStore.sendCommandMsg(getAllUserJSON)
}
const hiddenLogVisible = () => {
logVisible.value = false
}
const showAddPasswordKey = () => { const showAddPasswordKey = () => {
showkeyboard3.value = false showkeyboard3.value = false
showkeyboard2.value = true showkeyboard2.value = true
@ -236,6 +265,7 @@ const updateUserPassword = () => {
arr[0]?.passwd, arr[0]?.passwd,
), ),
) )
changePasswordVisible.value = false
} }
} }
@ -299,10 +329,6 @@ const handleOk = () => {
// //
webSocketStore.sendCommandMsg(delUserJSON(currDelUserId.value)) webSocketStore.sendCommandMsg(delUserJSON(currDelUserId.value))
} else { } else {
//
webSocketStore.sendCommandMsg(
updateUserPermissionLevelJSON(currDelUserId.value),
)
} }
getAllUser() getAllUser()
} }

131
src/components/dialogs/PermissionModal.vue

@ -0,0 +1,131 @@
<template>
<div class="permission_dialog_container">
<div class="modal_content">
<p class="title">选择用户权限</p>
<div class="log_select">
<van-picker
:columns="columns"
:show-toolbar="false"
visible-option-num="3"
option-height="42"
v-model="selectedValues"
/>
</div>
<div class="ok_btn style-btn" @click="chooseLog">确定</div>
<svg
class="close"
@click="handleClickClose"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
fill="none"
version="1.1"
width="13.06049919128418"
height="13.062000274658203"
viewBox="0 0 13.06049919128418 13.062000274658203"
>
<g>
<path
d="M6.531,7.5915L12,13.062L13.0605,12.0015L7.5915,6.531L13.0605,1.062L12,3.57628e-7L6.531,5.4705L1.062,0L0,1.062L5.4705,6.531L0,12L1.062,13.062L6.531,7.5915Z"
fill="#323233"
fill-opacity="1"
/>
</g>
</svg>
</div>
</div>
</template>
<script setup>
import { ref, watch } from 'vue'
const props = defineProps({
changeLogVal: {
type: Function,
},
logVal: {
type: String,
},
hiddenLogVisible: {
type: Function,
},
})
const columns = ref([
{ text: '维护员', value: '1' },
{ text: '管理员', value: '2' },
{ text: '用户', value: '3' },
])
const chooseLog = () => {
props.changeLogVal(selectedValues.value[0])
}
const handleClickClose = () => {
props.hiddenLogVisible()
}
const selectedValues = ref(['3'])
watch(() => {
selectedValues.value = [props.logVal]
})
</script>
<style lang="scss" scoped>
.permission_dialog_container {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 2;
display: flex;
align-items: center;
justify-content: center;
.modal_content {
width: 476px;
height: 407px;
border-radius: 16px;
background: #ffffff;
box-sizing: border-box;
padding: 45px 68px 62px 68px;
display: flex;
flex-direction: column;
align-items: center;
position: relative;
.close {
position: absolute;
right: 24px;
top: 18px;
}
.title {
font-family: Source Han Sans CN;
font-size: 22px;
font-weight: normal;
letter-spacing: 0.04em;
color: #000000;
margin-bottom: 39px;
}
.log_select {
width: 340px;
height: 113px;
overflow: hidden;
margin-bottom: 48px;
}
.ok_btn {
width: 340px;
height: 68px;
border-radius: 8px;
background: #06518b;
display: flex;
align-items: center;
justify-content: center;
font-family: Source Han Sans CN;
font-size: 23px;
font-weight: 350;
letter-spacing: 0em;
color: #ffffff;
}
}
}
</style>

4
src/mock/command.js

@ -204,12 +204,12 @@ export const delUserJSON = id => {
} }
} }
export const updateUserPermissionLevelJSON = id => {
export const updateUserPermissionLevelJSON = (id, permission_level) => {
return { return {
command: 'updateUserPermissionLevel', command: 'updateUserPermissionLevel',
messageId: 'updateUserPermissionLevel', messageId: 'updateUserPermissionLevel',
id, id,
permission_level: 0,
permission_level,
} }
} }

Loading…
Cancel
Save