Browse Source

feat:修改用户修改状态

DESKTOP-USV654P\pc 8 months ago
parent
commit
c807cfc083
3 changed files with 48 additions and 2 deletions
  1. 4 0
      src/services/apis/UserController.ts
  2. 7 0
      src/services/typing.d.ts
  3. 37 2
      src/views/system/user/index.vue

+ 4 - 0
src/services/apis/UserController.ts

@@ -37,6 +37,10 @@ export async function postUserBindStudent(params:API.UserStudentBindDto
 export async function postUserBindUnionid(params:API.BindOpenidDto
 ,mode: ErrorMessageMode = 'modal'){ return defHttp.post<any>
         ({url: '/organization/user/bind-unionid', data:params},{errorMessageMode:mode});}
+/** 修改状态 POST /organization/user/change-status */
+export async function postUserChangeStatus(params:API.UserChangeStatusDto
+,mode: ErrorMessageMode = 'modal'){ return defHttp.post<any>
+        ({url: '/organization/user/change-status', data:params},{errorMessageMode:mode});}
 /** 验证登录者的密码 GET /organization/user/check-password */
 export async function getUserCheckPassword(params:any,mode: ErrorMessageMode = 'modal'){ return defHttp.get<any>
         ({url: '/organization/user/check-password', params:params},{errorMessageMode:mode});}

+ 7 - 0
src/services/typing.d.ts

@@ -18426,6 +18426,13 @@ folderId?: string;
 password?: string;
 }
 
+type UserChangeStatusDto = {
+/** 启用状态(0:停用 1:启用) */
+status?: number;
+/** 用户ids */
+userIds?: string[];
+}
+
 type UserDefinedProcessRecordListVo = {
 /** 审批内容 */
 approveComment?: string;

+ 37 - 2
src/views/system/user/index.vue

@@ -38,7 +38,7 @@
   </PageWrapper>
 </template>
 <script lang="ts">
-  import { defineComponent, ref, reactive } from 'vue';
+  import { defineComponent, ref, reactive, h } from 'vue';
   import { BasicTable, useTable, TableAction, FormSchema, BasicColumn } from '/@/components/Table';
   import { getUserPageList, deleteUser, resetUserPassword } from '/@/api/system/user';
   import { PageWrapper } from '/@/components/Page';
@@ -48,6 +48,8 @@
   import AccountModal from './components/UserModal.vue';
   import DeptTree from './components/UserTypeTree.vue';
   import { useI18n } from '/@/hooks/web/useI18n';
+  import { Switch } from 'ant-design-vue';
+  import { postUserChangeStatus } from '/@/services/apis/UserController';
   const { t } = useI18n();
   const searchInfo = reactive<Recordable>({});
   export const searchFormSchema: FormSchema[] = [
@@ -113,7 +115,40 @@
       align: 'left',
       sorter: true,
     },
-
+    {
+      title: t('状态'),
+      dataIndex: 'enabledMark',
+      width: 120,
+      align: 'left',
+      sorter: true,
+      customRender: ({ record }) => {
+        if (!Reflect.has(record, 'pendingStatus')) {
+          record.pendingStatus = false;
+        }
+        return h(Switch, {
+          checked: record.enabledMark === 1,
+          checkedChildren: '启用',
+          unCheckedChildren: '禁用',
+          loading: record.pendingStatus,
+          onChange(checked: boolean) {
+            record.pendingStatus = true;
+            const newStatus = checked ? 1 : 0;
+            const { createMessage } = useMessage();
+            postUserChangeStatus({ userIds: [record.id], status: newStatus })
+              .then(() => {
+                record.enabledMark = newStatus;
+                createMessage.success('已成功修改状态');
+              })
+              .catch(() => {
+                createMessage.error('修改状态失败');
+              })
+              .finally(() => {
+                record.pendingStatus = false;
+              });
+          },
+        });
+      },
+    },
     {
       title: t('邮箱'),
       dataIndex: 'email',