Browse Source

user

master
maochaoying 2 years ago
parent
commit
162285699d
  1. 84
      src/components/Setting/components/User.vue
  2. 1
      src/components/dialogs/UserModal.vue

84
src/components/Setting/components/User.vue

@ -3,9 +3,15 @@
<div v-if="userFormVisible" class="add_user_form"> <div v-if="userFormVisible" class="add_user_form">
<p class="title">添加新用户</p> <p class="title">添加新用户</p>
<div class="form_wrap"> <div class="form_wrap">
<input v-model="newUserUserName" type="text" class="username_form" />
<input
v-model="newUserUserName"
@focus="showAddPasswordKey"
type="text"
class="username_form"
/>
<input <input
v-model="newUserPassword" v-model="newUserPassword"
@focus="showAddMewPasswordKey"
:type="showAddPassword ? 'text' : 'password'" :type="showAddPassword ? 'text' : 'password'"
class="password_form" class="password_form"
/> />
@ -14,8 +20,8 @@
class="eye" class="eye"
@click="handleAddPasswordShow" @click="handleAddPasswordShow"
/> />
<!-- <p class="username_tips">*用户名限制信息</p>
<p class="password_tips">*用户名限制信息</p> -->
<p class="username_tips">{{ `${addUserTips}` }}</p>
<!-- <p class="password_tips">*用户名限制信息</p> -->
</div> </div>
<div class="btns"> <div class="btns">
<div class="btn style-btn" @click="returnList">返回</div> <div class="btn style-btn" @click="returnList">返回</div>
@ -87,15 +93,15 @@
<div class="operator_wrap"> <div class="operator_wrap">
<div <div
class="common_btn style-btn" class="common_btn style-btn"
@click="showUserModal(`${item.uid} 用户删除`, item.uid, 1)"
v-if="item.permission_level == 3"
@click="showUserModal(`${item.uid} 用户删除`, item.id, 1)"
v-if="item.uid != 'admin'"
> >
删除用户 删除用户
</div> </div>
<div <div
class="common_btn mb style-btn" class="common_btn mb style-btn"
v-if="item.permission_level == 3" v-if="item.permission_level == 3"
@click="showUserModal(`${item.uid} 设置为管理员`, item.uid, 2)"
@click="showUserModal(`${item.uid} 设置为管理员`, item.id, 2)"
> >
设为管理员 设为管理员
</div> </div>
@ -122,6 +128,22 @@
:input="updateUserNewPassword" :input="updateUserNewPassword"
/> />
</div> </div>
<div class="key_wrap" v-if="showkeyboard2">
<SimpleKeyboard
:hideKeyBoard="hideKeyBoard2"
@onChange="onChange2"
:input="newUserUserName"
/>
</div>
<div class="key_wrap" v-if="showkeyboard3">
<SimpleKeyboard
:hideKeyBoard="hideKeyBoard3"
@onChange="onChange3"
:input="newUserPassword"
/>
</div>
</div> </div>
</template> </template>
@ -140,11 +162,29 @@ import {
getAllUserJSON, getAllUserJSON,
} from '@/mock/command' } from '@/mock/command'
const newUserUserName = ref('')
const newUserPassword = ref('')
const addUserTips = ref('')
const showkeyboard = ref(false) const showkeyboard = ref(false)
const showkeyboard2 = ref(false)
const showkeyboard3 = ref(false)
const hideKeyBoard = () => { const hideKeyBoard = () => {
showkeyboard.value = false showkeyboard.value = false
} }
const hideKeyBoard2 = () => {
showkeyboard2.value = false
}
const hideKeyBoard3 = () => {
showkeyboard3.value = false
}
const showAddPasswordKey = () => {
showkeyboard3.value = false
showkeyboard2.value = true
}
const showpasswordKey = () => { const showpasswordKey = () => {
showkeyboard.value = true showkeyboard.value = true
} }
@ -152,8 +192,18 @@ const onChange = a => {
updateUserNewPassword.value = a updateUserNewPassword.value = a
} }
const newUserUserName = ref('')
const newUserPassword = ref('')
const onChange3 = a => {
newUserPassword.value = a
}
const onChange2 = a => {
newUserUserName.value = a
}
const showAddMewPasswordKey = () => {
showkeyboard2.value = false
showkeyboard3.value = true
}
const userStore = useUserStore() const userStore = useUserStore()
const webSocketStore = useWebSocketStore() const webSocketStore = useWebSocketStore()
@ -215,6 +265,8 @@ onMounted(() => {
}) })
const returnList = () => { const returnList = () => {
showkeyboard2.value = false
showkeyboard3.value = false
userFormVisible.value = false userFormVisible.value = false
} }
@ -253,11 +305,26 @@ const handleOk = () => {
} }
const addNewUserFunc = () => { const addNewUserFunc = () => {
if (newUserUserName.value == '') {
addUserTips.value = '用户名不能为空'
return
}
// addUserTips
const arr = userStore.allUserList.filter(
item => item.uid == newUserUserName.value,
)
if (arr?.length > 0) {
addUserTips.value = '该用户名已存在'
return
}
showkeyboard2.value = false
showkeyboard3.value = false
webSocketStore.sendCommandMsg( webSocketStore.sendCommandMsg(
addUserJson(newUserUserName.value, newUserPassword.value), addUserJson(newUserUserName.value, newUserPassword.value),
) )
getAllUser() getAllUser()
returnList() returnList()
addUserTips.value = ''
} }
</script> </script>
@ -333,7 +400,6 @@ const addNewUserFunc = () => {
color: #06518b; color: #06518b;
} }
.mb { .mb {
margin: 0 16px;
} }
} }
} }

1
src/components/dialogs/UserModal.vue

@ -44,6 +44,7 @@ const props = defineProps({
const ok = () => { const ok = () => {
props.handleOk() props.handleOk()
props.hideUserModal()
} }
const handleCancel = () => { const handleCancel = () => {

Loading…
Cancel
Save