| | |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="真实姓名" prop="realName"> |
| | | <el-input v-model.trim="userForm.realName" placeholder="请输入真实姓名" clearable></el-input> |
| | | <el-input v-model.trim="userForm.realName" :disabled="allDisabled" placeholder="请输入真实姓名" clearable></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="关联角色" prop="roleId"> |
| | | <el-select v-model="userForm.roleId" placeholder="请选择" clearable class="w100"> |
| | | <el-form-item label="关联角色" prop="roleIds"> |
| | | <el-select v-model="userForm.roleIds" placeholder="请选择" clearable class="w100" multiple :disabled="allDisabled"> |
| | | <el-option v-for="item in roleData" :key="item.roleId" :label="item.roleName" :value="item.roleId"> </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="部门" prop="depId"> |
| | | <el-cascader :options="departmentData" :props="{ emitPath: false, checkStrictly: true, value: 'depId', label: 'depName' }" placeholder="请选择部门" clearable class="w100" v-model="userForm.depId"> </el-cascader> |
| | | <el-cascader :options="departmentData" :props="{ emitPath: false, checkStrictly: true, value: 'depId', label: 'depName' }" placeholder="请选择部门" clearable class="w100" v-model="userForm.depId" :disabled="allDisabled"> </el-cascader> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="职务" prop="positionId"> |
| | | <el-select v-model="userForm.positionId" placeholder="请选择" clearable class="w100"> |
| | | <el-form-item label="职务" prop="positionIds"> |
| | | <el-select v-model="userForm.positionIds" placeholder="请选择" clearable class="w100" multiple :disabled="allDisabled"> |
| | | <el-option v-for="item in dutyData" :key="item.positionId" :label="item.positionName" :value="item.positionId"> </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="手机号" prop="phone"> |
| | | <el-input v-model.trim="userForm.phone" placeholder="请输入手机号" clearable></el-input> |
| | | <el-input v-model.trim="userForm.phone" placeholder="请输入手机号" clearable :disabled="allDisabled"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="身份证"> |
| | | <el-input v-model.trim="userForm.identify" placeholder="请输入身份证" clearable></el-input> |
| | | <el-input v-model.trim="userForm.identify" placeholder="请输入身份证" clearable :disabled="allDisabled"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="邮箱"> |
| | | <el-input v-model.trim="userForm.email" placeholder="请输入" clearable></el-input> |
| | | <el-input v-model.trim="userForm.email" placeholder="请输入" clearable :disabled="allDisabled"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="性别" prop="gender"> |
| | | <el-select v-model="userForm.gender" placeholder="请选择" clearable class="w100"> |
| | | <el-select v-model="userForm.gender" placeholder="请选择" clearable class="w100" :disabled="allDisabled"> |
| | | <el-option v-for="item in sexList" :key="item.id" :value="item.id" :label="item.name"> </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="账户过期" prop="expireTime"> |
| | | <el-date-picker v-model="userForm.expireTime" type="date" placeholder="请选择" class="w100"> </el-date-picker> |
| | | </el-form-item> |
| | | </el-col> |
| | | <!-- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">--> |
| | | <!-- <el-form-item label="账户过期" prop="expireTime">--> |
| | | <!-- <el-date-picker v-model="userForm.expireTime" type="date" placeholder="请选择" class="w100"> </el-date-picker>--> |
| | | <!-- </el-form-item>--> |
| | | <!-- </el-col>--> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20" v-if="!disabled"> |
| | | <el-form-item label="账户密码" prop="password"> |
| | | <el-input v-model.trim="userForm.password" placeholder="请输入" type="password" show-password> |
| | |
| | | </el-col> |
| | | <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> |
| | | <el-form-item label="用户类型" prop="type"> |
| | | <el-select v-model="userForm.type" placeholder="请选择" clearable class="w100"> |
| | | <el-select v-model="userForm.type" placeholder="请选择" clearable class="w100" :disabled="allDisabled"> |
| | | <el-option v-for="item in userTypeList.filter(item => userForm.type === 1 ? item.id === 1 : item.id !== 1)" :key="item.id" :label="item.name" :value="item.id"> </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | |
| | | <template #footer> |
| | | <span class="dialog-footer"> |
| | | <el-button @click="isShowUserDialog = !isShowUserDialog" size="default">取 消</el-button> |
| | | <el-button type="primary" v-throttle @click="onSubmit" size="default">确 定</el-button> |
| | | <el-button type="primary" v-throttle @click="onSubmit" size="default" v-if="!allDisabled">确 定</el-button> |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | |
| | | interface UserState { |
| | | title: string; |
| | | disabled: boolean; |
| | | allDisabled: boolean; |
| | | isShowUserDialog: boolean; |
| | | userForm: { |
| | | username: string; |
| | | realName: string; |
| | | roleId: number | null; |
| | | roleIds: Array<number> |
| | | depId: number | null; |
| | | positionId: number | null; |
| | | positionIds: Array<number> |
| | | phone: string; |
| | | email: string; |
| | | gender: number | null; |
| | | type: number | null; |
| | | password: string; |
| | | expireTime: string; |
| | | status: number; |
| | | identify: string; |
| | | }; |
| | |
| | | const state = reactive<UserState>({ |
| | | title: '', |
| | | disabled: false, |
| | | allDisabled: false, |
| | | isShowUserDialog: false, |
| | | userForm: { |
| | | username: '', // 账户名称 |
| | | realName: '', // 用户昵称 |
| | | roleId: null, // 关联角色 |
| | | roleIds: [], // 关联角色 |
| | | depId: null, // 部门 |
| | | phone: '', // 手机号 |
| | | email: '', // 邮箱 |
| | | identify: '', |
| | | gender: null, // 性别 |
| | | password: '', // 账户密码 |
| | | positionId: null, // 岗位 |
| | | positionIds: [], // 岗位 |
| | | type: null, // 用户类型 |
| | | expireTime: '', // 账户过期 |
| | | status: 1 // 用户状态 |
| | | }, |
| | | userFormRules:{ |
| | | username: [{ required: true, message: '请填写用户名', trigger: 'blur' }], |
| | | realName: [{ required: true, message: '请填写真实姓名', trigger: 'blur' }], |
| | | roleId: [{ required: true, message: '请选择用户角色', trigger: 'change' }], |
| | | roleIds: [{ required: true, message: '请选择用户角色', trigger: 'change' }], |
| | | depId: [{ required: true, message: '请选择部门', trigger: 'change' }], |
| | | positionId: [{ required: true, message: '请选择职务', trigger: 'change' }], |
| | | positionIds: [{ required: true, message: '请选择职务', trigger: 'change' }], |
| | | phone: [{ required: true, message: '请填写手机号', trigger: 'blur' }], |
| | | type: [{ required: true, message: '请填写用户类型', trigger: 'blur' }], |
| | | gender: [{ required: true, message: '请选择性别', trigger: 'change' }], |
| | | expireTime: [{ required: true, message: '请输入账户过期时间', trigger: 'blur' }], |
| | | password: [{ required: true, message: '请输入账户密码', trigger: 'blur' }], |
| | | }, |
| | | departmentData: [], // 部门数据 |
| | |
| | | state.dutyData = dutyList |
| | | if (type === '新增') { |
| | | state.disabled = false |
| | | state.allDisabled = false |
| | | state.title = '新增用户'; |
| | | state.userForm = { |
| | | username: '', |
| | | realName: '', |
| | | roleId: null, |
| | | roleIds: [], |
| | | depId: null, |
| | | phone: '', |
| | | email: '', |
| | | identify: '', |
| | | positionId: null, |
| | | positionIds: [], |
| | | gender: null, |
| | | type: null, |
| | | password: '', |
| | | expireTime: '', |
| | | status: 1 |
| | | }; |
| | | } else { |
| | | } else{ |
| | | if(type === '修改'){ |
| | | state.disabled = true |
| | | state.allDisabled = false |
| | | state.title = '修改用户'; |
| | | state.userForm = JSON.parse(JSON.stringify(value)); |
| | | state.userForm.roleIds = JSON.parse(JSON.stringify(value)).roles?.map(obj=>obj.roleId) |
| | | state.userForm.positionIds = JSON.parse(JSON.stringify(value)).positions?.map(obj=>obj.positionId) |
| | | }else{ |
| | | state.disabled = true |
| | | state.allDisabled = true |
| | | state.title = '查看'; |
| | | state.userForm = JSON.parse(JSON.stringify(value)); |
| | | state.userForm.roleIds = JSON.parse(JSON.stringify(value)).roles?.map(obj=>obj.roleId) |
| | | state.userForm.positionIds = JSON.parse(JSON.stringify(value)).positions?.map(obj=>obj.positionId) |
| | | } |
| | | } |
| | | }; |
| | | |