| | |
| | | </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> |
| | |
| | | </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> |
| | |
| | | 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) => { |
| | |
| | | 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(''); |
| | |
| | | |
| | | }); |
| | | |
| | | 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; |
| | |
| | | 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') { |
| | |
| | | } |
| | | 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) |
| | | } |
| | |
| | | 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) |
| | |
| | | empno: '', |
| | | post: '', |
| | | duty: '', |
| | | idNo: '' |
| | | idNo: '', |
| | | createId: null, |
| | | createBy: '', |
| | | userType: null |
| | | } |
| | | superRef.value.clearValidate(); |
| | | superRef.value.resetFields() |
| | |
| | | } |
| | | |
| | | |
| | | 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) |
| | | } |
| | | } |
| | | |
| | | |
| | | |