| | |
| | | :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 !== '修改密码'"> |
| | |
| | | <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 |
| | | v-if="state.isAdmin" |
| | | v-model="state.form.companyName" |
| | | filterable |
| | | :disabled="disabled || state.title =='编辑'" |
| | | remote |
| | | @change="selectValue" |
| | | reserve-keyword |
| | |
| | | :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"--> |
| | |
| | | <!-- :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="name" |
| | | :methods="getUser"> |
| | | </scorllSelect> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer v-if="state.title !='查看'"> |
| | |
| | | password: '', |
| | | confirmPassword: '', |
| | | username: '', |
| | | userType: 0, |
| | | userType: null, |
| | | sex: 0, |
| | | companyId: null, |
| | | parentId: null |
| | |
| | | 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: [ |
| | |
| | | cloading:false, |
| | | totlePage: 0, |
| | | userParam: {}, |
| | | isAdmin: false |
| | | isAdmin: false, |
| | | currentUserType: null |
| | | |
| | | }) |
| | | const UisMounted = ref(false); |
| | |
| | | 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'){ |
| | |
| | | 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 = '无上级账号' |
| | |
| | | |
| | | const finshed = ref(false) |
| | | const loading = ref(false) |
| | | |
| | | const getCompanyList = async (val)=>{ |
| | | if(val != ""){ |
| | | loading.value = true; |
| | |
| | | } |
| | | const changeType = () => { |
| | | state.companyList = []; |
| | | 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 ){ |
| | | 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 = () => { |
| | |
| | | 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; |
| | |
| | | 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'); |
| | | } |
| | | } |
| | | }) |
| | | } |