Huanyi 11 часов назад
Родитель
Сommit
714e331918
2 измененных файлов с 35 добавлено и 10 удалено
  1. 17 6
      src/api/system/employee/index.ts
  2. 18 4
      src/views/employee/index.vue

+ 17 - 6
src/api/system/employee/index.ts

@@ -50,25 +50,36 @@ export const addEmployee = (data: EmployeeForm) => {
 
 /**
  * 授权客户(支持多个,逗号分隔)
- * @param id 员工ID
- * @param authClientFRowIDs 授权客户 RowID 列表(逗号分隔)
+ * @param data 包含 id 和 authClientFRowIDs
  */
-export const authEmployee = (id: string | number, authClientFRowIDs: string) => {
+export const authEmployee = (data: { id: string | number; authClientFRowIDs: string }) => {
   return request({
     url: '/system/employee/auth',
     method: 'put',
-    params: { id, authClientFRowIDs }
+    data
   });
 };
 
 /**
  * 修改员工状态(启用/禁用)
  */
-export const changeEmployeeStatus = (id: string | number, status: string) => {
+export const changeEmployeeStatus = (data: { id: string | number; status: string }) => {
   return request({
     url: '/system/employee/changeStatus',
     method: 'put',
-    params: { id, status }
+    data
+  });
+};
+
+/**
+ * 管理员重置员工密码
+ * @param data 包含 id
+ */
+export const adminResetPassword = (data: { id: string | number }) => {
+  return request({
+    url: '/system/employee/adminResetPassword',
+    method: 'put',
+    data
   });
 };
 

+ 18 - 4
src/views/employee/index.vue

@@ -50,12 +50,14 @@
             </el-tag>
           </template>
         </el-table-column>
-        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120">
+        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
           <template #default="scope">
             <el-button v-hasPermi="['employee:employee:auth']" link type="success"
               @click="handleAuth(scope.row)">授权</el-button>
             <el-button v-hasPermi="['employee:employee:query']" link type="primary"
               @click="handleDetail(scope.row)">详情</el-button>
+            <el-button v-hasPermi="['employee:employee:resetPassword']" link type="warning"
+              @click="handleResetPwd(scope.row)">重置密码</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -178,7 +180,7 @@
 </template>
 
 <script setup name="Customer" lang="ts">
-import { listEmployee, addEmployee, getEmployeeDetail, authEmployee, changeEmployeeStatus } from '@/api/system/employee';
+import { listEmployee, addEmployee, getEmployeeDetail, authEmployee, changeEmployeeStatus, adminResetPassword } from '@/api/system/employee';
 import { EmployeeVO, EmployeeQuery, EmployeeForm, ErpClientBriefVO } from '@/api/system/employee/types';
 import { searchErpClient, getErpClientByIds } from '@/api/erp/client';
 import { ErpClientVO } from '@/api/erp/client/types';
@@ -303,7 +305,7 @@ const handleStatusChange = async (row: EmployeeVO & { _statusActive: boolean; _s
   const newStatus = row._statusActive ? '1' : '0';
   try {
     row._statusLoading = true;
-    await changeEmployeeStatus(row.id, newStatus);
+    await changeEmployeeStatus({ id: row.id, status: newStatus });
     proxy?.$modal.msgSuccess(newStatus === '1' ? '已启用' : '已禁用');
   } catch (e: any) {
     // 失败回滚状态
@@ -364,7 +366,7 @@ const confirmAuth = async () => {
   buttonLoading.value = true;
   try {
     const authClientFRowIDs = selectedAuthClients.value.map(c => c.rowId).join(',');
-    await authEmployee(authDialog.employeeId!, authClientFRowIDs);
+    await authEmployee({ id: authDialog.employeeId!, authClientFRowIDs });
     proxy?.$modal.msgSuccess('授权成功');
     authDialog.visible = false;
     getList();
@@ -390,6 +392,18 @@ const handleDetail = async (row: EmployeeVO) => {
   }
 };
 
+/** 重置员工密码 */
+const handleResetPwd = (row: EmployeeVO) => {
+  proxy?.$modal.confirm(`确认将员工「${row.name}」的密码重置为 123456?`).then(async () => {
+    try {
+      await adminResetPassword({ id: row.id });
+      proxy?.$modal.msgSuccess('密码已重置为 123456');
+    } catch (e: any) {
+      proxy?.$modal.msgError(e?.msg || '重置密码失败');
+    }
+  }).catch(() => { });
+};
+
 /** 新增按钮操作 */
 const handleAdd = () => {
   resetAddForm();