From ff46cc24356b2cd2f23ab3cd7892e61b682d2b8c Mon Sep 17 00:00:00 2001
From: 祖安之光 <11848914+light-of-zuan@user.noreply.gitee.com>
Date: Mon, 11 May 2026 10:03:42 +0800
Subject: [PATCH] 主线提交
---
src/views/onlineEducation/systemManage/user/components/userDialog.vue | 202 +++++++++++++++++++++++++++++++++++++-------------
1 files changed, 149 insertions(+), 53 deletions(-)
diff --git a/src/views/onlineEducation/systemManage/user/components/userDialog.vue b/src/views/onlineEducation/systemManage/user/components/userDialog.vue
index aa3512e..59f2a98 100644
--- a/src/views/onlineEducation/systemManage/user/components/userDialog.vue
+++ b/src/views/onlineEducation/systemManage/user/components/userDialog.vue
@@ -5,6 +5,8 @@
:title="state.title"
width="700px"
:before-close="handleClose"
+ :close-on-press-escape="false"
+ :close-on-click-modal="false"
>
<el-form :model="state.form" size="default" ref="superRef" :rules="state.formRules" label-width="150px" >
<el-form-item label="用户名:" prop="username" v-if="state.title !== '修改密码'">
@@ -28,20 +30,31 @@
<el-form-item label="手机号:" prop="phone" v-if="state.title !== '修改密码'" >
<el-input v-model.trim="state.form.phone" :maxlength="11" :disabled="disabled" placeholder="请输入手机号"></el-input>
</el-form-item>
- <el-form-item label="用户类型:" v-if="state.title !== '修改密码'">
- <el-radio-group v-model="state.form.userType" :disabled="disabled" @change="changeType">
- <el-radio :label="0" v-if="state.isAdmin">管理员</el-radio>
- <el-radio :label="1" v-if="state.isAdmin">企业级</el-radio>
- <el-radio :label="2" v-if="!state.isAdmin">部门级</el-radio>
+ <el-form-item label="用户类型:" v-if="state.title !== '修改密码'" prop="userType">
+ <el-radio-group v-model="state.form.userType" :disabled="disabled" @change="changeType" v-if="state.title == '新增'">
+ <el-radio :label="0" v-if="state.currentUserType == 0">管理员</el-radio>
+ <el-radio :label="1" v-if="state.currentUserType == 0 ">企业级</el-radio>
+ <el-radio :label="2" v-if="state.currentUserType == 1 ">部门级</el-radio>
<el-radio :label="3" v-if="!state.isAdmin">车间(岗位)级</el-radio>
- <el-radio :label="4" v-if="state.isAdmin">其他</el-radio>
+ <el-radio :label="4" v-if="state.currentUserType == 0">其他</el-radio>
</el-radio-group>
+ <span v-else-if="state.title == '查看'">{{state.currentUserType === 0 ? '管理员' : state.currentUserType === 1 ? '企业级' : state.currentUserType === 2 ? '部门级' : state.currentUserType === 3 ? '车间级' :'其他'}}</span>
+ <span v-else-if="state.title == '编辑'">{{state.form.userType === 0 ? '管理员' : state.form.userType === 1 ? '企业级' : state.form.userType === 2 ? '部门级' : state.form.userType === 3 ? '车间级' :'其他'}}</span>
+ <!-- <el-radio-group v-model="state.form.userType" :disabled="disabled" @change="changeType" v-else-if="state.title == '编辑'">-->
+<!-- <el-radio :label="0" v-if="state.currentUserType == 0">管理员</el-radio>-->
+<!-- <el-radio :label="1" >企业级</el-radio>-->
+<!-- <el-radio :label="2" >部门级</el-radio>-->
+<!-- <el-radio :label="3" >车间(岗位)级</el-radio>-->
+<!-- <el-radio :label="4" >其他</el-radio>-->
+<!-- </el-radio-group>-->
</el-form-item>
- <el-form-item label="选择上级企业:" prop="companyName" v-if="state.title !== '修改密码' && state.form.userType !== 0">
+ <el-form-item label="所属企业:" prop="companyName" v-if="state.title !== '修改密码' && showCompany">
<el-select
+ clearable
v-if="state.isAdmin"
v-model="state.form.companyName"
filterable
+ :disabled="disabled || state.title =='编辑'"
remote
@change="selectValue"
reserve-keyword
@@ -58,6 +71,7 @@
:value="item.name"
/>
</el-select>
+ <el-input v-else disabled style="width: 45%" v-model="state.form.companyName"></el-input>
<!-- <el-select-->
<!-- v-if="state.isAdmin"-->
<!-- v-model="state.form.companyName"-->
@@ -75,21 +89,23 @@
<!-- :value="item.name"-->
<!-- />-->
<!-- </el-select>-->
- <el-input v-else disabled style="width: 45%" v-model="state.form.companyName"></el-input>
- <scorllSelect
- :disabled="disabled"
- ref="scrollRef"
- v-if="UisMounted && (state.form.userType === 2 || state.form.userType === 3)"
- v-model="state.form.parentName"
- @getval = "getSelectUser"
- placeholder="请选择"
- clearable
- style="width: 45%;margin-left: 10px"
- filterable
- remote
- searchKey="name"
- :methods="getUser">
- </scorllSelect>
+
+
+ </el-form-item>
+ <el-form-item label="所属上级账号:" prop="companyName" v-if="showChild">
+ <scorllSelect
+ :disabled="disabled || state.title =='编辑'"
+ ref="scrollRef"
+ v-model="state.form.parentName"
+ @getval = "getSelectUser"
+ placeholder="请选择"
+ clearable
+ style="width: 45%;"
+ filterable
+ remote
+ searchKey="username"
+ :methods="getUser">
+ </scorllSelect>
</el-form-item>
</el-form>
<template #footer v-if="state.title !='查看'">
@@ -197,7 +213,7 @@
password: '',
confirmPassword: '',
username: '',
- userType: 0,
+ userType: null,
sex: 0,
companyId: null,
parentId: null
@@ -209,6 +225,7 @@
password: [{ required: true, validator: validatePwd, trigger: 'blur' }],
confirmPassword: [{ required: true, validator: equalToPassword, trigger: 'blur' }],
phone: [{ required: true, validator: validateUserPhone, trigger: 'blur' }],
+ userType: [{ required: true, message: '请选择用户类型', trigger: 'blur' }],
},
companyList: [],
userList: [
@@ -221,7 +238,8 @@
cloading:false,
totlePage: 0,
userParam: {},
- isAdmin: false
+ isAdmin: false,
+ currentUserType: null
})
const UisMounted = ref(false);
@@ -229,25 +247,26 @@
UisMounted.value = true;
});
-
+const showCompany = ref(false)
+const showChild = ref(false)
const disabled = ref(false);
+const userInfo = ref()
const openDialog = async (type, value) => {
- const userInfo = JSON.parse(Cookies.get('userInfo'))
- console.log("userInfo",userInfo)
- if(userInfo.userType === 0){
+ userInfo.value = JSON.parse(Cookies.get('userInfo'))
+ console.log("userInfo",userInfo.value)
+ state.currentUserType = userInfo.value.userType
+ if(state.currentUserType === 0){
state.isAdmin = true;
- state.form.userType = 0;
}else {
state.isAdmin = false;
- state.form.companyId = userInfo.companyId;
- state.form.companyName = userInfo.companyName;
- state.form.userType = 1;
+ state.form.companyId = userInfo.value.companyId;
+ state.form.companyName = userInfo.value.companyName;
}
if(type !== 'view' && type !== 'pwd'){
- if(state.isAdmin){
- // await getCompanyList('open')
- }
+ // if(state.isAdmin){
+ // await getCompanyList("")
+ // }
}
state.title = type === 'add' ? '新增' : type ==='edit' ? '编辑' : type ==='pwd' ? '修改密码' : '查看' ;
if(type === 'edit' || type === 'view') {
@@ -258,7 +277,14 @@
const res = await getUserById(value.id);
if(res.code === 200){
state.form = res.data
- if(res.data.userType === 2|| res.data.userType === 3){
+ if(res.data.userType === 3){
+ showCompany.value = true;
+ showChild.value = true
+ }else if(res.data.userType === 2 || res.data.userType === 1 || res.data.userType === 4){
+ showCompany.value = true;
+ showChild.value = false;
+ }
+ if(res.data.userType === 3){
if(!res.data.parentId){
state.form.parentId = ''
state.form.parentName = '无上级账号'
@@ -272,18 +298,33 @@
dialogVisible.value = true
if(type === 'edit' && state.form && (state.form.userType === 2||state.form.userType === 3)){
await nextTick(() => {
- doGetUser()
+ // doGetUser()
})
}
}
const finshed = ref(false)
const loading = ref(false)
+
const getCompanyList = async (val)=>{
if(val != ""){
loading.value = true;
const queryParams = {
name: val
+ }
+ const res = await getCompany(queryParams)
+ if (res.code == 200) {
+ loading.value = false;
+ state.companyList = res.data.list
+
+ } else {
+ ElMessage.warning(res.message)
+ }
+ }else {
+ loading.value = true;
+ const queryParams = {
+ pageNum: 1,
+ pageSize: 10
}
const res = await getCompany(queryParams)
if (res.code == 200) {
@@ -342,7 +383,20 @@
}else if(state.title == '编辑'){
const {confirmPassword,...data} = state.form
data.password = Base64.encode(data.password)
- const res = await editUser(data)
+ const param = {
+ name: data.name,
+ sex:data.sex,
+ phone: data.phone,
+ id:data.id,
+ companyId: data.companyId,
+ userType:data.userType,
+ username:data.username,
+ password: data.password,
+ parentId: data.parentId
+
+ }
+
+ const res = await editUser(param)
if(res.code == 200){
ElMessage.success(res.message)
emit('getList')
@@ -372,21 +426,68 @@
}
scrollRef.value.getList(param,'change');
}
-const changeType = () => {
+const changeType = async (val) => {
state.companyList = [];
- if(state.isAdmin){
- state.form.companyId = null;
- state.form.companyName = '';
+ if(state.isAdmin && val !=0){
+ await getCompanyList("")
}
state.form.parentId = null;
state.form.parentName = '';
- if(state.form.userType === 2 || state.form.userType === 3 ){
+ state.form.companyId = null;
+ state.form.companyName = '';
+ //当前是管理员级用户
+ if(state.currentUserType === 0){
+ if(state.form.userType === 0){
+ showCompany.value = false;
+ showChild.value = false;
+ }else {
+ showCompany.value = true;
+ showChild.value = false;
+ }
+ }
+ //当前是企业级/其他用户选择部门
+ if((state.currentUserType === 1 && state.form.userType === 2) || (state.currentUserType === 4 && state.form.userType === 2)){
+ state.form.parentId = userInfo.value.id;
+ state.form.companyName = userInfo.value.companyName
+ state.form.companyId = userInfo.value.companyId;
+ showChild.value = false;
+ showCompany.value = true;
+
+ } //当前是企业级/其他用户选择车间
+ else if((state.currentUserType === 1 && state.form.userType === 3) || (state.currentUserType === 4 && state.form.userType === 3)){
+ state.form.companyName = userInfo.value.companyName
+ state.form.companyId = userInfo.value.companyId;
+ showCompany.value = true;
+ showChild.value = true;
const param = {
- userType: state.form.userType-1,
+ userType: 2,
companyId: state.form.companyId,
}
- scrollRef.value.getList(param,'change');
+ nextTick(() => {
+ scrollRef.value.getList(param,'change');
+ })
}
+ //当前是部门级选择车间
+ if((state.currentUserType === 2 && state.form.userType === 3)){
+ state.form.parentId = userInfo.value.id;
+ state.form.companyName = userInfo.value.companyName
+ state.form.companyId = userInfo.value.companyId;
+ showCompany.value = true;
+ showChild.value = false;
+ }
+ // if(state.isAdmin){
+ // state.form.companyId = null;
+ // state.form.companyName = '';
+ // }
+ // state.form.parentId = null;
+ // state.form.parentName = '';
+ // if(state.form.userType === 2 || state.form.userType === 3 ){
+ // const param = {
+ // userType: state.form.userType-1,
+ // companyId: state.form.companyId,
+ // }
+ // scrollRef.value.getList(param,'change');
+ // }
}
const handleClose = () => {
@@ -397,11 +498,13 @@
password: '',
confirmPassword: '',
username: '',
- userType: 0,
+ userType: null,
sex: 0,
companyId: null,
parentId: null
}
+ showCompany.value = false;
+ showChild.value = false;
state.userList = [];
state.companyList = [];
state.pageNum = 1;
@@ -427,13 +530,6 @@
state.companyList.forEach(item => {
if(item.name === val){
state.form.companyId = item.id
- if(state.form.userType === 2 || state.form.userType === 3 ){
- const param = {
- userType: state.form.userType-1,
- companyId: state.form.companyId,
- }
- scrollRef.value.getList(param,'change');
- }
}
})
}
--
Gitblit v1.9.2