From ba5374383bbf3ecabf6f50f7aac34916d9f745e0 Mon Sep 17 00:00:00 2001
From: zhouwx <1175765986@qq.com>
Date: Sat, 14 Sep 2024 14:48:04 +0800
Subject: [PATCH] bug修改
---
src/views/onlineEducation/people/components/stuDialog.vue | 102 ++++++++++++++++++++++++++++++---
src/views/onlineEducation/people/index.vue | 8 +-
src/views/onlineEducation/systemManage/company/components/companyDialog.vue | 1
src/views/onlineEducation/systemManage/user/components/userDialog.vue | 17 +++++
4 files changed, 113 insertions(+), 15 deletions(-)
diff --git a/src/views/onlineEducation/people/components/stuDialog.vue b/src/views/onlineEducation/people/components/stuDialog.vue
index b27645e..8976689 100644
--- a/src/views/onlineEducation/people/components/stuDialog.vue
+++ b/src/views/onlineEducation/people/components/stuDialog.vue
@@ -22,7 +22,7 @@
</el-radio-group>
</el-form-item>
<el-form-item label="身份证号:" prop="idNo" v-if="state.title !== '修改密码'">
- <el-input v-model.trim="state.form.idNo" :disabled="disabled" placeholder="请输入身份证号" ></el-input>
+ <el-input v-model.trim="state.form.idNo" maxlength="18" :disabled="disabled" placeholder="请输入身份证号" ></el-input>
</el-form-item>
<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>
@@ -32,6 +32,28 @@
</el-form-item>
<el-form-item label="重复密码:" prop="confirmPassword" v-if="state.title == '新增' || state.title == '修改密码'">
<el-input v-model.trim="state.form.confirmPassword" type="password" show-password placeholder="请输入确认密码"></el-input>
+ </el-form-item>
+ <el-form-item label="所属部门账号:" prop="createBy" v-if="state.title !== '修改密码' && (currentUserType === 1 || currentUserType === 4)">
+ <el-select
+ clearable
+ v-model="state.form.createBy"
+ filterable
+ remote
+ @change="selectValue"
+ reserve-keyword
+ placeholder="请输入部门账号名称"
+ remote-show-suffix
+ :remote-method="getDeptUserList"
+ :loading="loading"
+ style="width: 100%"
+ >
+ <el-option
+ v-for="item in state.deptUserList"
+ :key="item.id"
+ :label="item.name"
+ :value="item.name"
+ />
+ </el-select>
</el-form-item>
<el-form-item label="工号:" prop="empno" v-if="state.title !== '修改密码'">
<el-input v-model.trim="state.form.empno" :disabled="disabled" placeholder="请输入工号" ></el-input>
@@ -63,11 +85,13 @@
import {Base64} from "js-base64"
import Cookies from "js-cookie";
import {addStudent, checkStuIdNo, checkStuPhone, editStudent} from "@/api/onlineEducation/student";
-
+import {getCompany} from "@/api/onlineEducation/company";
+import {getUser} from "@/api/onlineEducation/user";
const emit = defineEmits(["getList"]);
const dialogVisible = ref(false)
const superRef = ref(null)
const scrollRef = ref(null)
+
const equalToPassword = (rule, value, callback) => {
@@ -194,17 +218,23 @@
empno: '',
post: '',
duty: '',
- idNo: ''
+ idNo: '',
+ createId: null,
+ createBy: '',
+ userType: null
},
formRules:{
- name: [{ required: true, message: '请输入公司、部门或者车间岗位名称', trigger: 'blur' }],
+ name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
password: [{ required: true, validator: validatePwd, trigger: 'blur' }],
confirmPassword: [{ required: true, validator: equalToPassword, trigger: 'blur' }],
phone: [{ required: true, validator: validateUserPhone, trigger: 'blur' }],
idNo: [{ required: true, validator: validateIdNo, trigger: 'blur' }],
+ createBy: [{ required: true, message: '请输入所属部门名称', trigger: 'blur' }],
+
},
- isAdmin: false
+ isAdmin: false,
+ deptUserList: []
})
const startPhone = ref('');
@@ -215,10 +245,12 @@
});
+const currentUserType = ref(null)
const disabled = ref(false);
const openDialog = async (type, value) => {
const userInfo = JSON.parse(Cookies.get('userInfo'))
console.log("userInfo",userInfo)
+ currentUserType.value = userInfo.userType
if(userInfo.userType === 0){
state.isAdmin = true;
state.form.userType = 0;
@@ -226,7 +258,13 @@
state.isAdmin = false;
state.form.companyId = userInfo.companyId;
state.form.companyName = userInfo.companyName;
- state.form.userType = 1;
+ state.form.userType = userInfo.userType;
+ }
+ if(userInfo.userType === 1 || userInfo.userType === 4) {
+ await getDeptUserList("")
+ }else if(userInfo.userType === 2){
+ state.form.createId = userInfo.id
+ state.form.createBy = userInfo.name
}
state.title = type === 'add' ? '新增' : type ==='edit' ? '编辑' : type ==='pwd' ? '修改密码' : '查看' ;
if(type === 'edit' || type === 'view') {
@@ -235,7 +273,7 @@
}
startPhone.value = value.phone
startIdNo.value = value.idNo
- state.form = value
+ state.form = JSON.parse(JSON.stringify(value))
state.form.companyName = value.company.name;
console.log("ba",state.form)
}
@@ -260,8 +298,8 @@
ElMessage.warning(res.message)
}
}else if(state.title == '编辑'){
- const {id, name, phone, sex, companyId, empno, post, duty, idNo} = state.form
- const data = {id, name, phone, sex, companyId, empno, post, duty, idNo}
+ const {id, name, phone, sex, companyId, empno, post, duty, idNo,createId,createBy} = state.form
+ const data = {id, name, phone, sex, companyId, empno, post, duty, idNo,createId,createBy}
const res = await editStudent(data)
if(res.code == 200){
ElMessage.success(res.message)
@@ -297,7 +335,10 @@
empno: '',
post: '',
duty: '',
- idNo: ''
+ idNo: '',
+ createId: null,
+ createBy: '',
+ userType: null
}
superRef.value.clearValidate();
superRef.value.resetFields()
@@ -305,7 +346,48 @@
}
+const selectValue = (val) => {
+ // state.form.parentId = null;
+ // state.form.parentName = null;
+ state.deptUserList.forEach(item => {
+ if(item.name === val){
+ state.form.createId = item.id
+ }
+ })
+}
+const loading = ref(false)
+const getDeptUserList = async (val)=>{
+ let param = {}
+ if(val != ""){
+ param = {
+ name: val,
+ userType: 2,
+ companyId: state.form.companyId
+ }
+ }else {
+ param = {
+ pageNum: 1,
+ pageSize: 10,
+ userType: 2,
+ companyId: state.form.companyId
+ }
+ }
+ loading.value = true;
+ const res = await getUser(param)
+ if (res.code == 200) {
+ loading.value = false;
+ state.deptUserList = res.data.list.map(item => {
+ return {
+ ...item,
+ name: item.name + ' ('+ item.username +') '
+ }
+ })
+
+ } else {
+ ElMessage.warning(res.message)
+ }
+}
diff --git a/src/views/onlineEducation/people/index.vue b/src/views/onlineEducation/people/index.vue
index 2fa825f..91ccbc4 100644
--- a/src/views/onlineEducation/people/index.vue
+++ b/src/views/onlineEducation/people/index.vue
@@ -131,9 +131,11 @@
const openDialog = (type, value) => {
if(type == 'add' && data.isAdmin){
ElMessage.warning('监管部门请联系企业创建企业学员')
- }else if(userType.value !== 3 && (type == 'add' || type == 'edit')) {
- ElMessage.warning(' 只有车间级用户才能新增和编辑')
- } else{
+ }
+ // else if(userType.value !== 3 && (type == 'add' || type == 'edit')) {
+ // ElMessage.warning(' 只有车间级用户才能新增和编辑')
+ // }
+ else{
dialogRef.value.openDialog(type, value);
}
diff --git a/src/views/onlineEducation/systemManage/company/components/companyDialog.vue b/src/views/onlineEducation/systemManage/company/components/companyDialog.vue
index 047d46d..c42b43d 100644
--- a/src/views/onlineEducation/systemManage/company/components/companyDialog.vue
+++ b/src/views/onlineEducation/systemManage/company/components/companyDialog.vue
@@ -42,6 +42,7 @@
:disabled="title === '编辑'"
placeholder="请输入总课时"
v-model.trim="state.form.totalPeriod"
+ maxlength="10"
@input="state.form.totalPeriod = state.form.totalPeriod.replace(/[^0-9]/g,'')">
<template #append >分钟</template>
</el-input>
diff --git a/src/views/onlineEducation/systemManage/user/components/userDialog.vue b/src/views/onlineEducation/systemManage/user/components/userDialog.vue
index 3337214..59f2a98 100644
--- a/src/views/onlineEducation/systemManage/user/components/userDialog.vue
+++ b/src/views/onlineEducation/systemManage/user/components/userDialog.vue
@@ -298,7 +298,7 @@
dialogVisible.value = true
if(type === 'edit' && state.form && (state.form.userType === 2||state.form.userType === 3)){
await nextTick(() => {
- doGetUser()
+ // doGetUser()
})
}
}
@@ -383,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')
--
Gitblit v1.9.2