wuheng 1 rok pred
rodič
commit
3f4ecbf1c3

+ 1 - 0
src/assets/svg-icon/training-class.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 48 48"><path fill="currentColor" fill-rule="evenodd" d="M6 6h31v5h-2V8H8v23h21.387v2H6V6Zm30 13a3 3 0 1 0 0-6a3 3 0 0 0 0 6Zm2.031 2.01c1.299 0 2.327.584 3 1.486c.629.845.895 1.89.955 2.855a7.626 7.626 0 0 1-.397 2.92c-.3.87-.807 1.77-1.589 2.387V40.5a1.5 1.5 0 0 1-2.98.247L35.73 33h-.298l-1.458 7.776A1.5 1.5 0 0 1 31 40.5V26.233a63.223 63.223 0 0 0-.592.919l-.078.123l-.02.032l-.005.009a1.5 1.5 0 0 1-1.274.707h-5a1.5 1.5 0 1 1 0-3h4.177c.243-.376.563-.864.899-1.354c.35-.511.736-1.052 1.08-1.476c.167-.207.354-.423.542-.6c.092-.087.22-.2.376-.3a1.72 1.72 0 0 1 .926-.282h6Z" clip-rule="evenodd"/></svg>

+ 2 - 1
src/locales/lang/en.ts

@@ -77,7 +77,8 @@ const locale: LocaleMessages<I18nType.Schema> = {
         route: 'Route',
         user: 'User',
         sort: 'category',
-        student: 'Student'
+        student: 'Student',
+        group: 'class'
       },
       about: 'About'
     }

+ 2 - 1
src/locales/lang/zh-cn.ts

@@ -77,7 +77,8 @@ const locale: LocaleMessages<I18nType.Schema> = {
         route: '路由管理',
         user: '用户管理',
         sort: '课程分类',
-        student: '学生管理'
+        student: '学生管理',
+        group: '班级管理'
       },
       about: '关于'
     }

+ 11 - 0
src/router/modules/management.ts

@@ -47,6 +47,17 @@ const management: AuthRoute.Route = {
         localIcon: 'academic-cap'
       }
     },
+    {
+      name: 'management_group',
+      path: '/management/group',
+      component: 'self',
+      meta: {
+        title: '班级管理',
+        i18nTitle: 'message.routes.management.group',
+        requiresAuth: true,
+        localIcon: 'training-class'
+      }
+    },
     {
       name: 'management_sort',
       path: '/management/sort',

+ 2 - 0
src/typings/page-route.d.ts

@@ -58,6 +58,7 @@ declare namespace PageRoute {
     | 'management_route'
     | 'management_sort'
     | 'management_student'
+    | 'management_group'
     | 'management_user'
     | 'multi-menu'
     | 'multi-menu_first'
@@ -117,6 +118,7 @@ declare namespace PageRoute {
     | 'management_route'
     | 'management_sort'
     | 'management_student'
+    | 'management_group'
     | 'management_user'
     | 'multi-menu_first_second-new_third'
     | 'multi-menu_first_second'

+ 1 - 0
src/typings/system.d.ts

@@ -384,6 +384,7 @@ declare namespace I18nType {
         user: string;
         sort: string;
         student: string;
+        group: string;
       };
       about: string;
     };

+ 1 - 0
src/views/index.ts

@@ -37,6 +37,7 @@ export const views: Record<
   management_route: () => import('./management/route/index.vue'),
   management_sort: () => import('./management/sort/index.vue'),
   management_student: () => import('./management/student/index.vue'),
+  management_group: () => import('./management/group/index.vue'),
   management_user: () => import('./management/user/index.vue'),
   'multi-menu_first_second-new_third': () => import('./multi-menu/first/second-new/third/index.vue'),
   'multi-menu_first_second': () => import('./multi-menu/first/second/index.vue'),

+ 76 - 0
src/views/management/group/api.ts

@@ -0,0 +1,76 @@
+import { request } from '@/service/request';
+
+// 参数接口
+export interface SelectConditionParams {
+  id?: number;
+  name?: string;
+  manageId?: number;
+  assistantId?: number;
+  createTime?: Record<string, unknown>;
+  modifyTime?: Record<string, unknown>;
+  createUid?: number;
+  disabled?: string;
+}
+
+export interface QueryParams {
+  id: number;
+  username?: string;
+  passwd?: string;
+  email?: string;
+  relname: string;
+  phone?: string;
+  address?: string;
+  createTime?: Record<string, unknown>;
+  modifyTime?: Record<string, unknown>;
+  createUid?: number;
+  disabled?: string;
+}
+
+export interface AddClassRes {
+  status: boolean;
+  msg: string;
+  data: Record<string, unknown>;
+  code: number;
+}
+
+export interface UserList {
+  [index: string]: string;
+}
+
+export function editRequest(params: SelectConditionParams): Promise<Service.RequestResult<SelectConditionParams>> {
+  return request.put(`/class/updateClass`, params);
+}
+
+export function pageRequest(
+  pageNum: number,
+  pageSize: number,
+  params: SelectConditionParams
+): Promise<Service.RequestResult<AddClassRes>> {
+  return request.post(`/class/selectCondition?pageNum=${pageNum}&pageSize=${pageSize}`, params);
+}
+
+export function delRequest(id: number): Promise<Service.RequestResult<AddClassRes>> {
+  return request.delete(`/class/deleteClass/${id}`);
+}
+
+export function addRequest(params: SelectConditionParams): Promise<Service.RequestResult<AddClassRes>> {
+  return request.post(`/class/addClass`, params);
+}
+
+export function queryUserById(uid: number): Promise<Service.RequestResult<QueryParams>> {
+  return request.get(`/userinfo/queryUserById/${uid}`);
+}
+
+export function queryByRealname(realname: string): Promise<Service.RequestResult<QueryParams>> {
+  return request.get(`/userinfo/queryUserByRealname/${realname}`);
+}
+
+export async function queryAll(): Promise<UserList> {
+  const ret: UserList = {};
+  const respone: Service.RequestResult = await request.get(`/userinfo/queryAll`);
+  respone.data?.map((result: QueryParams) => {
+    ret[result.id] = result.relname;
+    return result;
+  });
+  return ret;
+}

+ 177 - 0
src/views/management/group/crud.ts

@@ -0,0 +1,177 @@
+import type { CreateCrudOptionsRet } from '@fast-crud/fast-crud';
+import { dict } from '@fast-crud/fast-crud';
+import _ from 'lodash';
+import { isString } from '~/src/utils';
+import type { UserList } from './api';
+import { addRequest, delRequest, editRequest, pageRequest, queryAll } from './api';
+const userList: UserList = await queryAll();
+const dictOpt = {
+  url: '/userinfo/queryAll',
+  label: 'relname',
+  value: 'id'
+};
+function curd(): CreateCrudOptionsRet {
+  return {
+    crudOptions: {
+      request: {
+        pageRequest: async ({ page, query }) => {
+          const { total, data } = await pageRequest(page.offset + 1, page.limit, query);
+          return { records: data, total, currentPage: page.offset, pageSize: page.limit };
+        },
+        addRequest: ({ form }) => {
+          return addRequest(form);
+        },
+        editRequest: ({ form }) => {
+          editRequest(form);
+        },
+        delRequest: ({ row }) => {
+          return delRequest(row.id);
+        }
+      },
+      toolbar: {
+        show: true
+      },
+      actionbar: {
+        show: true,
+        buttons: {
+          add: {
+            text: '新增班级',
+            title: '使用表单新增班级',
+            circle: false,
+            tooltip: {
+              slots: {
+                default() {
+                  return '使用表单新增班级';
+                }
+              }
+            }
+          }
+        }
+      },
+      form: {
+        beforeSubmit: context => {
+          if (isString(context.form.createUid)) {
+            context.form.createUid = null;
+          }
+          if (isString(context.form.manageId)) {
+            context.form.manageId = null;
+          }
+          return true;
+        }
+      },
+      columns: {
+        id: {
+          title: '班级ID',
+          type: 'text',
+          search: { show: true },
+          form: {
+            show: false
+          },
+          column: {
+            resizable: true,
+            width: 120,
+            align: 'center',
+            fixed: 'left'
+          }
+        },
+        name: {
+          title: '班级名称',
+          type: 'text',
+          search: {
+            title: '名称',
+            show: true
+          },
+          column: {
+            resizable: true,
+            width: 60,
+            align: 'center',
+            fixed: 'left'
+          }
+        },
+        createUid: {
+          title: '创建用户',
+          type: 'text',
+          valueBuilder(context) {
+            if (userList[context.row.createUid]) {
+              context.row.createUid = userList[context.row.createUid];
+            }
+          },
+          form: {
+            component: {
+              name: 'fs-dict-select',
+              dict: dict(dictOpt)
+            }
+          },
+          search: { show: false },
+          column: {
+            resizable: true,
+            width: 90,
+            align: 'center',
+            fixed: 'left'
+          }
+        },
+        manageId: {
+          title: '负责人',
+          type: 'text',
+          valueBuilder(context) {
+            if (userList[context.row.manageId]) {
+              context.row.manageId = userList[context.row.manageId];
+            }
+          },
+          form: {
+            component: {
+              name: 'fs-dict-select',
+              dict: dict(dictOpt)
+            }
+          },
+          search: { show: false },
+          column: {
+            resizable: true,
+            width: 90,
+            align: 'center',
+            fixed: 'left'
+          }
+        },
+        modifyTime: {
+          title: '更新时间',
+          type: 'easDateTime',
+          search: { show: false },
+          form: { show: false },
+          column: {
+            resizable: true,
+            width: 110,
+            align: 'center',
+            fixed: 'left'
+          }
+        },
+        createTime: {
+          title: '创建时间',
+          type: 'easDateTime',
+          search: { show: true },
+          form: { show: false },
+          column: {
+            resizable: true,
+            width: 110,
+            align: 'center',
+            fixed: 'left'
+          }
+        },
+        disabled: {
+          title: '状态',
+          type: 'dict-select',
+          dict: dict({
+            data: [
+              { value: 'N', label: '启用中' },
+              { value: 'Y', label: '已禁用' }
+            ]
+          }),
+          column: {
+            resizable: true,
+            width: 80
+          }
+        }
+      }
+    }
+  };
+}
+export default curd;

+ 19 - 0
src/views/management/group/index.vue

@@ -0,0 +1,19 @@
+<template>
+  <div class="h-full">
+    <fs-crud ref="crudRef" v-bind="crudBinding" />
+  </div>
+</template>
+
+<script setup lang="ts">
+import { onMounted } from 'vue';
+import { useFs } from '@fast-crud/fast-crud';
+import createCrudOptions from './crud';
+
+const { crudRef, crudBinding, crudExpose } = useFs({ createCrudOptions });
+
+onMounted(() => {
+  crudExpose.doRefresh();
+});
+</script>
+
+<style scoped></style>

+ 27 - 27
src/views/management/student/index.vue

@@ -1,34 +1,34 @@
 <template>
   <div class="h-full">
     <fs-crud ref="crudRef" v-bind="crudBinding" />
+    <n-modal v-model:show="showModal" preset="dialog" title="Dialog">
+      <template #header>
+        <div>Excel 文件导入</div>
+      </template>
+      <div style="padding: 1rem">
+        <n-upload
+          multiple
+          directory-dnd
+          :action="uploadFile"
+          :max="1"
+          @before-upload="beforeUpload"
+          @finish="handleFinish"
+        >
+          <n-upload-dragger>
+            <div style="margin-bottom: 12px">
+              <n-icon size="48" :depth="3">
+                <archive-icon />
+              </n-icon>
+            </div>
+            <n-text style="font-size: 16px"> 点击或者拖动文件到该区域来上传 </n-text>
+            <n-p depth="3" style="margin: 8px 0 0 0">
+              请不要上传敏感数据,比如你的银行卡号和密码,信用卡号有效期和安全码
+            </n-p>
+          </n-upload-dragger>
+        </n-upload>
+      </div>
+    </n-modal>
   </div>
-  <n-modal v-model:show="showModal" preset="dialog" title="Dialog">
-    <template #header>
-      <div>Excel 文件导入</div>
-    </template>
-    <div style="padding: 1rem">
-      <n-upload
-        multiple
-        directory-dnd
-        :action="uploadFile"
-        :max="1"
-        @before-upload="beforeUpload"
-        @finish="handleFinish"
-      >
-        <n-upload-dragger>
-          <div style="margin-bottom: 12px">
-            <n-icon size="48" :depth="3">
-              <archive-icon />
-            </n-icon>
-          </div>
-          <n-text style="font-size: 16px"> 点击或者拖动文件到该区域来上传 </n-text>
-          <n-p depth="3" style="margin: 8px 0 0 0">
-            请不要上传敏感数据,比如你的银行卡号和密码,信用卡号有效期和安全码
-          </n-p>
-        </n-upload-dragger>
-      </n-upload>
-    </div>
-  </n-modal>
 </template>
 
 <script setup lang="ts">