wuheng 1 gadu atpakaļ
vecāks
revīzija
35057f9f62

+ 16 - 2
src/views/lesson/calendar/index.vue

@@ -66,7 +66,20 @@
               <template #default>
                 {{ `${item.category} -- ${item.subjects}` }}
                 <br />
-                <n-button> 考勤打卡 </n-button>
+                <n-button
+                  @click="
+                    () => {
+                      router.push({
+                        path: '/lesson/checkin',
+                        query: {
+                          scheduleId: item.id
+                        }
+                      });
+                    }
+                  "
+                >
+                  考勤打卡
+                </n-button>
               </template>
             </n-timeline-item>
           </n-timeline>
@@ -80,7 +93,7 @@
 </template>
 <script setup lang="ts">
 import { ref, reactive } from 'vue';
-import { useRoute } from 'vue-router';
+import { useRoute, useRouter } from 'vue-router';
 import { formatDate, getFirstDayOfMonth, getLastDayOfMonth } from '@/utils';
 import {
   querySchedule,
@@ -92,6 +105,7 @@ import {
 } from './api';
 import type { QueryScheduleParams } from './api';
 const route = useRoute();
+const router = useRouter();
 const classId = route.query.classId;
 const studentId = route.query.studentId;
 const show = ref(false);

+ 57 - 0
src/views/lesson/checkin/api.ts

@@ -0,0 +1,57 @@
+import { request } from '@/service/request';
+
+// 参数接口
+export interface AttendanceParams {
+  id?: number;
+  checkinDate?: string;
+  scheduleId?: number;
+  month?: number;
+  morning?: string;
+  afternoon?: string;
+  studentName?: string;
+  studentNumber?: string;
+  createUid?: number;
+  createTime?: string;
+  modifyTime?: string;
+}
+
+// 响应接口
+export interface AttendanceRes {
+  status: boolean;
+  msg: string;
+  data: Record<string, unknown>;
+  code: number;
+}
+
+/**
+ * 添加签到记录
+ * @param {object} params EasArcTlsAttendance
+ * @param {number} params.id
+ * @param {object} params.checkinDate 签到日期
+ * @param {number} params.scheduleId 排课ID
+ * @param {number} params.month 月份
+ * @param {string} params.morning a  表示正常出勤,   b  表示迟到、早退, c  表示旷课, d  表示请假, e表示无效
+ * @param {string} params.afternoon a  表示正常出勤,   b  表示迟到、早退, c  表示旷课, d  表示请假, e表示无效
+ * @param {string} params.studentName 学员姓名
+ * @param {string} params.studentNumber 学生档案号
+ * @param {number} params.createUid 创建用户
+ * @param {object} params.createTime 创建时间
+ * @param {object} params.modifyTime 修改时间
+ * @returns
+ */
+export function addAttendance(params: AttendanceParams): Promise<Service.RequestResult<AttendanceRes[]>> {
+  return request.post(`/attendance/add`, params);
+}
+
+export function updateAttendance(params: AttendanceParams): Promise<Service.RequestResult<AttendanceRes[]>> {
+  return request.put(`/attendance/update`, params);
+}
+
+/**
+ * 获取学生列表
+ * @param {string} scheduleId
+ * @returns
+ */
+export function getStudentList(scheduleId: number): Promise<Service.RequestResult<AttendanceParams[]>> {
+  return request.get(`/attendance/getStudentList?scheduleId=${scheduleId}`);
+}

+ 136 - 0
src/views/lesson/checkin/crud.ts

@@ -0,0 +1,136 @@
+import type { CreateCrudOptionsProps, CreateCrudOptionsRet } from '@fast-crud/fast-crud';
+import { dict } from '@fast-crud/fast-crud';
+import { addAttendance, updateAttendance, getStudentList } from './api';
+
+function curd({ context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
+  return {
+    crudOptions: {
+      search: {
+        show: false
+      },
+      pagination: {
+        show: false
+      },
+      request: {
+        pageRequest: async ({ page }) => {
+          const { data } = await getStudentList(context?.route.query.scheduleId ?? 0);
+          return { records: data, total: 0, currentPage: page.offset, pageSize: page.limit };
+        },
+        addRequest: ({ form }) => {
+          return addAttendance(form);
+        },
+        editRequest: ({ form }) => {
+          updateAttendance(form);
+        }
+      },
+      toolbar: {
+        show: true
+      },
+      actionbar: {
+        show: false
+      },
+      rowHandle: {
+        buttons: {
+          remove: {
+            show: false
+          }
+        }
+      },
+      columns: {
+        scheduleId: {
+          title: '排课ID',
+          type: 'text',
+          column: {
+            show: false
+          }
+        },
+        checkinDate: {
+          title: '签到日期',
+          type: 'easDateTime',
+          sortable: true,
+          column: {
+            width: 180
+          }
+        },
+        morning: {
+          title: '上午出勤状态',
+          type: 'dict-select',
+          dict: dict({
+            data: [
+              // a  表示正常出勤,   b  表示迟到、早退, c  表示旷课, d  表示请假, e表示无效
+              { value: 'a', label: '正常' },
+              { value: 'b', label: '迟到/早退' },
+              { value: 'c', label: '旷课' },
+              { value: 'd', label: '请假' },
+              { value: 'e', label: '无效' }
+            ]
+          }),
+          column: {
+            resizable: true,
+            width: 180
+          }
+        },
+        afternoon: {
+          title: '下午出勤状态',
+          type: 'dict-select',
+          dict: dict({
+            data: [
+              // a  表示正常出勤,   b  表示迟到、早退, c  表示旷课, d  表示请假, e表示无效
+              { value: 'a', label: '正常' },
+              { value: 'b', label: '迟到/早退' },
+              { value: 'c', label: '旷课' },
+              { value: 'd', label: '请假' },
+              { value: 'e', label: '无效' }
+            ]
+          }),
+          column: {
+            resizable: true,
+            width: 180
+          }
+        },
+        studentName: {
+          title: '学生姓名',
+          type: 'text',
+          sortable: true,
+          width: 100
+        },
+        studentNumber: {
+          title: '学生学号',
+          type: 'text',
+          sortable: true,
+          column: {
+            width: 280
+          }
+        },
+        createUid: {
+          title: '录入用户',
+          type: 'text',
+          sortable: true,
+          width: 60,
+          form: {
+            show: false
+          }
+        },
+        createTime: {
+          title: '创建时间',
+          type: 'easDateTime',
+          sortable: true,
+          width: 100,
+          form: {
+            show: false
+          }
+        },
+        modifyTime: {
+          title: '修改时间',
+          type: 'easDateTime',
+          sortable: true,
+          width: 100,
+          form: {
+            show: false
+          }
+        }
+      }
+    }
+  };
+}
+export default curd;

+ 17 - 2
src/views/lesson/checkin/index.vue

@@ -1,5 +1,20 @@
 <template>
-  <div class="wh-full"></div>
+  <div class="wh-full">
+    <fs-crud ref="crudRef" v-bind="crudBinding" />
+  </div>
 </template>
-<script setup lang="ts"></script>
+<script setup lang="ts">
+import { onMounted } from 'vue';
+import { useRoute } from 'vue-router';
+import { useFs } from '@fast-crud/fast-crud';
+import createCrudOptions from './crud';
+const route = useRoute();
+const context: any = {
+  route
+};
+const { crudRef, crudBinding, crudExpose } = useFs({ createCrudOptions, context });
+onMounted(() => {
+  crudExpose.doRefresh();
+});
+</script>
 <style scoped></style>