mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 10:57:13 +08:00 
			
		
		
		
	新增:新增系统管理/用户管理重置密码、分配角色功能
This commit is contained in:
		| @@ -61,3 +61,15 @@ export function updateUser(req: UserRecord) { | ||||
| export function deleteUser(ids: number | Array<number>) { | ||||
|   return axios.delete(`${BASE_URL}/${ids}`); | ||||
| } | ||||
|  | ||||
| export function resetPassword(id: number) { | ||||
|   return axios.patch(`${BASE_URL}/${id}/password`); | ||||
| } | ||||
|  | ||||
| export interface UpdateUserRoleReq { | ||||
|   roleIds?: Array<number>; | ||||
| } | ||||
|  | ||||
| export function updateUserRole(req: UpdateUserRoleReq, id: number) { | ||||
|   return axios.patch(`${BASE_URL}/${id}/role`, req); | ||||
| } | ||||
|   | ||||
							
								
								
									
										1
									
								
								continew-admin-ui/src/assets/icons/svg/privacy.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								continew-admin-ui/src/assets/icons/svg/privacy.svg
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| <svg width="24" height="24" viewBox="0 0 48 48" fill="currentColor"><g clip-path="url(#svg_21cec257fe__clip0_0:2566)"><path fill-rule="evenodd" clip-rule="evenodd" d="M24.999.347l1.077.757c.083.059.162.123.234.194-.06-.06-.057-.064-.055-.067.001-.002-.003-.005-.035-.027l-.014-.01c.085.059.19.128.312.207.373.24.816.509 1.318.795a37.83 37.83 0 004.824 2.306c1.659.654 3.43 1.093 5.19 1.353.619.092 1.191.154 1.7.192.294.022.542.034.6.034l1.783.028a1.91 1.91 0 011.879 1.908l.001 1.837.002 4.38.001 2.61a24347.202 24347.202 0 01.002 8.072V25.63l-.001.046v.014c-.014 9.194-11.785 20.13-19.911 20.13C15.78 45.818 4 34.868 4 25.671V8.018a1.91 1.91 0 011.879-1.909l1.818-.028c.026 0 .275-.012.568-.034.509-.038 1.08-.1 1.7-.192 1.759-.26 3.53-.699 5.184-1.352a38.254 38.254 0 004.825-2.31c.844-.48 1.603-.968 1.755-1.084l1.068-.757a1.909 1.909 0 012.202-.005zm14.999 16.499l-.001-2.61-.002-4.339c-.531-.012-1.565-.096-2.703-.264-2.03-.3-4.078-.808-6.033-1.58-3.093-1.22-6.283-2.988-7.356-3.804-.344.244-1.157.759-2.04 1.261a42.053 42.053 0 01-5.31 2.544c-1.953.77-4 1.278-6.03 1.579-1.159.17-2.21.255-2.705.265v15.774C7.818 32.695 17.828 42 23.906 42c6.082 0 16.093-9.304 16.093-16.328v-.757-1.999l-.001-6.07zM32 18c0 3.728-2.55 6.86-6 7.748V28h3a1 1 0 011 1v2a1 1 0 01-1 1h-3v3a1 1 0 01-1 1h-2a1 1 0 01-1-1v-9.252A8 8 0 1132 18zm-8 4a4 4 0 110-8 4 4 0 010 8z" fill="currentColor"/></g><defs><clipPath id="svg_21cec257fe__clip0_0:2566"><path fill="currentColor" d="M0 0h48v48H0z"/></clipPath></defs></svg> | ||||
| After Width: | Height: | Size: 1.5 KiB | 
							
								
								
									
										1
									
								
								continew-admin-ui/src/assets/icons/svg/reference.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								continew-admin-ui/src/assets/icons/svg/reference.svg
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| <svg width="24" height="24" viewBox="0 0 48 48" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M24.05 26a1 1 0 011 1v2a1 1 0 01-1 1H16c-3.73 0-6.86 2.55-7.75 6A8.226 8.226 0 008 38v2h16.05a1 1 0 011 1v2a1 1 0 01-1 1H6c-1.1 0-2-.895-2-2v-4c0-6.627 5.37-12 12-12h8.05zm12.728-.707l7.071 7.071a1 1 0 010 1.414l-1.414 1.414a1 1 0 01-1.414 0l-2.937-2.937v10.33a1 1 0 01-1 1h-2a1 1 0 01-1-1V32.229l-2.963 2.964a1 1 0 01-1.414 0l-1.414-1.414a1 1 0 010-1.414l7.071-7.071a1 1 0 011.414 0zM21 3c5.52 0 10 4.477 10 10s-4.48 10-10 10-10-4.477-10-10S15.48 3 21 3zm0 4c-3.31 0-6 2.686-6 6s2.69 6 6 6 6-2.686 6-6-2.69-6-6-6z" fill="currentColor"/></svg> | ||||
| After Width: | Height: | Size: 660 B | 
| @@ -121,6 +121,10 @@ body { | ||||
|   } | ||||
| } | ||||
|  | ||||
| .arco-form-item-layout-inline { | ||||
|   margin-right: 15px; | ||||
| } | ||||
|  | ||||
| fieldset { | ||||
|   padding: 15px 15px 0 15px; | ||||
|   margin-bottom: 15px; | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
|     <Breadcrumb :items="['menu.system', 'menu.system.user.list']" /> | ||||
|     <a-card class="general-card" :title="$t('menu.system.user.list')"> | ||||
|       <a-row> | ||||
|         <a-col :xs="9" :sm="6" :md="5" :lg="4" :xl="4" style="margin-right: 12px"> | ||||
|         <a-col :xs="9" :sm="6" :md="5" :lg="4" :xl="4" style="margin-right: 10px"> | ||||
|           <a-input-search | ||||
|             v-model="deptName" | ||||
|             placeholder="输入部门名称搜索" | ||||
| @@ -182,7 +182,7 @@ | ||||
|                 title="操作" | ||||
|                 align="center" | ||||
|                 fixed="right" | ||||
|                 :width="120" | ||||
|                 :width="90" | ||||
|               > | ||||
|                 <template #cell="{ record }"> | ||||
|                   <a-button | ||||
| @@ -192,7 +192,7 @@ | ||||
|                     title="修改" | ||||
|                     @click="toUpdate(record.userId)" | ||||
|                   > | ||||
|                     <template #icon><icon-edit /></template>修改 | ||||
|                     <template #icon><icon-edit /></template> | ||||
|                   </a-button> | ||||
|                   <a-popconfirm | ||||
|                     content="确定要删除当前选中的数据吗?" | ||||
| @@ -206,9 +206,32 @@ | ||||
|                       title="删除" | ||||
|                       :disabled="record.disabled" | ||||
|                     > | ||||
|                       <template #icon><icon-delete /></template>删除 | ||||
|                       <template #icon><icon-delete /></template> | ||||
|                     </a-button> | ||||
|                   </a-popconfirm> | ||||
|                   <a-popconfirm | ||||
|                     content="确定要重置当前用户的密码吗?" | ||||
|                     type="warning" | ||||
|                     @ok="handleResetPassword(record.userId)" | ||||
|                   > | ||||
|                     <a-button | ||||
|                       v-permission="['admin']" | ||||
|                       type="text" | ||||
|                       size="small" | ||||
|                       title="重置密码" | ||||
|                     > | ||||
|                       <template #icon><svg-icon icon-class="privacy" /></template> | ||||
|                     </a-button> | ||||
|                   </a-popconfirm> | ||||
|                   <a-button | ||||
|                     v-permission="['admin']" | ||||
|                     type="text" | ||||
|                     size="small" | ||||
|                     title="分配角色" | ||||
|                     @click="toUpdateRole(record.userId)" | ||||
|                   > | ||||
|                     <template #icon><svg-icon icon-class="reference" /></template> | ||||
|                   </a-button> | ||||
|                 </template> | ||||
|               </a-table-column> | ||||
|             </template> | ||||
| @@ -308,6 +331,32 @@ | ||||
|         </a-form> | ||||
|       </a-modal> | ||||
|  | ||||
|       <!-- 表单区域 --> | ||||
|       <a-modal | ||||
|         title="分配角色" | ||||
|         :visible="userRoleVisible" | ||||
|         :mask-closable="false" | ||||
|         unmount-on-close | ||||
|         render-to-body | ||||
|         @ok="handleUpdateUserRole" | ||||
|         @cancel="handleCancel" | ||||
|       > | ||||
|         <a-form ref="userRoleFormRef" :model="form" :rules="rules" size="large"> | ||||
|           <a-form-item label="所属角色" field="roleIds"> | ||||
|             <a-select | ||||
|               v-model="form.roleIds" | ||||
|               :options="roleOptions" | ||||
|               placeholder="请选择所属角色" | ||||
|               :loading="roleLoading" | ||||
|               multiple | ||||
|               allow-clear | ||||
|               :allow-search="{ retainInputValue: true }" | ||||
|               style="width: 416px" | ||||
|             /> | ||||
|           </a-form-item> | ||||
|         </a-form> | ||||
|       </a-modal> | ||||
|  | ||||
|       <!-- 详情区域 --> | ||||
|       <a-drawer | ||||
|         title="用户详情" | ||||
| @@ -420,6 +469,8 @@ | ||||
|     addUser, | ||||
|     updateUser, | ||||
|     deleteUser, | ||||
|     resetPassword, | ||||
|     updateUserRole, | ||||
|   } from '@/api/system/user'; | ||||
|   import { listRoleDict, listDeptTree } from '@/api/common'; | ||||
|   import getAvatar from '@/utils/avatar'; | ||||
| @@ -452,6 +503,7 @@ | ||||
|   const detailLoading = ref(false); | ||||
|   const exportLoading = ref(false); | ||||
|   const visible = ref(false); | ||||
|   const userRoleVisible = ref(false); | ||||
|   const detailVisible = ref(false); | ||||
|   const statusOptions = ref<SelectOptionData[]>([ | ||||
|     { label: '启用', value: 1 }, | ||||
| @@ -550,6 +602,20 @@ | ||||
|     }); | ||||
|   }; | ||||
|  | ||||
|   /** | ||||
|    * 打开分配角色对话框 | ||||
|    * | ||||
|    * @param id ID | ||||
|    */ | ||||
|   const toUpdateRole = (id: number) => { | ||||
|     reset(); | ||||
|     getRoleOptions(); | ||||
|     getUser(id).then((res) => { | ||||
|       form.value = res.data; | ||||
|       userRoleVisible.value = true; | ||||
|     }); | ||||
|   }; | ||||
|  | ||||
|   /** | ||||
|    * 查询角色列表 | ||||
|    */ | ||||
| @@ -591,7 +657,7 @@ | ||||
|       phone: undefined, | ||||
|       description: '', | ||||
|       status: 1, | ||||
|       roleIds: [], | ||||
|       roleIds: [] as Array<number>, | ||||
|       deptId: undefined, | ||||
|     }; | ||||
|     proxy.$refs.formRef?.resetFields(); | ||||
| @@ -602,7 +668,9 @@ | ||||
|    */ | ||||
|   const handleCancel = () => { | ||||
|     visible.value = false; | ||||
|     proxy.$refs.formRef.resetFields(); | ||||
|     userRoleVisible.value = false; | ||||
|     proxy.$refs.formRef?.resetFields(); | ||||
|     proxy.$refs.userRoleFormRef?.resetFields(); | ||||
|   }; | ||||
|  | ||||
|   /** | ||||
| @@ -628,6 +696,23 @@ | ||||
|     }); | ||||
|   }; | ||||
|  | ||||
|   /** | ||||
|    * 修改用户角色 | ||||
|    */ | ||||
|   const handleUpdateUserRole = () => { | ||||
|     proxy.$refs.userRoleFormRef.validate((valid: any) => { | ||||
|       if (!valid && form.value.userId !== undefined) { | ||||
|         updateUserRole({ roleIds: form.value.roleIds }, form.value.userId).then( | ||||
|           (res) => { | ||||
|             handleCancel(); | ||||
|             getList(); | ||||
|             proxy.$message.success(res.msg); | ||||
|           } | ||||
|         ); | ||||
|       } | ||||
|     }); | ||||
|   }; | ||||
|  | ||||
|   /** | ||||
|    * 查看详情 | ||||
|    * | ||||
| @@ -684,6 +769,17 @@ | ||||
|     }); | ||||
|   }; | ||||
|  | ||||
|   /** | ||||
|    * 重置密码 | ||||
|    * | ||||
|    * @param id ID | ||||
|    */ | ||||
|   const handleResetPassword = (id: number) => { | ||||
|     resetPassword(id).then((res) => { | ||||
|       proxy.$message.success(res.msg); | ||||
|     }); | ||||
|   }; | ||||
|  | ||||
|   /** | ||||
|    * 已选择的数据行发生改变时触发 | ||||
|    * | ||||
|   | ||||
		Reference in New Issue
	
	Block a user