Browse Source

feat: 任务过滤条件展示

zhangjie 1 year ago
parent
commit
4a0deb3fc1

+ 7 - 0
electron/db/models/trackTask.ts

@@ -36,6 +36,8 @@ class TrackTask extends Model<
 
   declare trackConfig: string;
 
+  declare filterData: string;
+
   declare status: number;
 
   declare error: string | null;
@@ -93,6 +95,11 @@ TrackTask.init(
       allowNull: false,
       comment: '导出设置',
     },
+    filterData: {
+      type: DataTypes.TEXT,
+      allowNull: true,
+      comment: '详情条件',
+    },
     status: {
       type: DataTypes.INTEGER,
       allowNull: false,

+ 3 - 0
src/views/base/track-export/index.vue

@@ -259,6 +259,7 @@
       paperNumber: null,
       schoolId: userStore.curSchoolInfo.id,
       trackConfig: JSON.stringify(appStore.trackConfig),
+      filterData: '',
       status: 0,
       courseId: '',
     }).catch(() => {
@@ -322,6 +323,7 @@
       paperNumber: row.paperNumber,
       schoolId: userStore.curSchoolInfo.id,
       trackConfig: JSON.stringify(appStore.trackConfig),
+      filterData: JSON.stringify(filterData),
       status: 0,
     }).catch(() => {
       result = false;
@@ -375,6 +377,7 @@
       paperNumber: row.paperNumber,
       schoolId: userStore.curSchoolInfo.id,
       trackConfig: JSON.stringify(appStore.trackConfig),
+      filterData: JSON.stringify(students.map((item) => item.studentId)),
       status: 0,
     }).catch(() => {
       result = false;

+ 97 - 0
src/views/base/track-export/taskProgress.vue

@@ -12,6 +12,35 @@
   >
     <template #title> 任务进度 </template>
 
+    <a-descriptions
+      :data="taskInfo"
+      title="任务详情"
+      :align="{ label: 'right' }"
+      :column="1"
+    />
+    <a-collapse v-if="taskFilterInfo.length">
+      <a-collapse-item header="筛选条件">
+        <a-descriptions
+          :data="taskFilterInfo"
+          title=""
+          :align="{ label: 'right' }"
+          :column="1"
+        />
+      </a-collapse-item>
+    </a-collapse>
+
+    <a-descriptions title="进度" :column="1" :align="{ label: 'right' }">
+      <a-descriptions-item label="任务总数">
+        {{ total }}
+      </a-descriptions-item>
+      <a-descriptions-item label="完成数量">
+        {{ finishCount }}
+      </a-descriptions-item>
+      <a-descriptions-item label="总体进度">
+        <a-progress :percent="progressNum" :stroke-width="10" />
+      </a-descriptions-item>
+    </a-descriptions>
+
     <template #footer>
       <a-button v-if="progressNum >= 1" type="primary" @click="close"
         >确定</a-button
@@ -29,10 +58,14 @@
   import { PICTURE_TYPE } from '@/constants/enumerate';
   import { useUserStore } from '@/store';
   import { TrackConfigType } from '@/store/modules/app/types';
+  import { TrackExportDetailListFilter } from '@/api/types/task';
+  import { objTypeOf } from '@/utils/utils';
 
   import { modalConfirm } from '../../../utils/arco';
   import { TrackTaskData } from '../../../../electron/db/models/trackTask';
 
+  type FilterDataType = TrackExportDetailListFilter | string[];
+
   defineOptions({
     name: 'ModifySet',
   });
@@ -47,6 +80,7 @@
   const PROGRESS_KEY = 'progress';
 
   const taskInfo = ref<DescData[]>([]);
+  const taskFilterInfo = ref<DescData[]>([]);
   const task = ref<TrackTaskData>({} as TrackTaskData);
   const total = ref(0);
   const finishCount = ref(0);
@@ -98,6 +132,11 @@
 
     task.value = res;
     const trackConfig = JSON.parse(res.trackConfig) as TrackConfigType;
+    const filterData = res.filterData
+      ? (JSON.parse(res.filterData) as FilterDataType)
+      : null;
+    updateTaskFilerInfo(filterData);
+
     taskInfo.value = [
       {
         value: res.semesterName,
@@ -142,6 +181,64 @@
     window.electron.startWinProcess(2, getExportUrl());
   }
 
+  function updateTaskFilerInfo(data: FilterDataType | null) {
+    taskFilterInfo.value = [];
+    if (!data) return;
+
+    if (objTypeOf(data) === 'array') {
+      taskFilterInfo.value = [
+        {
+          value: (data as string[]).join(),
+          label: '选择的学生',
+        },
+      ];
+      return;
+    }
+
+    if (Object.keys(data as TrackExportDetailListFilter).length === 2) return;
+
+    const datas = data as Required<TrackExportDetailListFilter>;
+    // 设置的详情数据
+    taskFilterInfo.value = [
+      {
+        label: '学院',
+        value: datas.college,
+      },
+      {
+        label: '专业',
+        value: datas.majorName,
+      },
+      {
+        label: '班级',
+        value: datas.className,
+      },
+      {
+        label: '姓名',
+        value: datas.studentName,
+      },
+      {
+        label: '学号',
+        value: datas.studentCode,
+      },
+      {
+        label: '学号区间',
+        value: `${datas.startStudentCode}~${datas.endStudentCode}`,
+      },
+      {
+        label: '成绩区间',
+        value: `${datas.startScore}~${datas.endScore}`,
+      },
+      {
+        label: '客观题分区间',
+        value: `${datas.objectiveStartScore}~${datas.objectiveEndScore}`,
+      },
+      {
+        label: '主观题分区间',
+        value: `${datas.subjectiveStartScore}~${datas.subjectiveEndScore}`,
+      },
+    ].filter((item) => item.value && item.value !== '~');
+  }
+
   async function toCancel() {
     const confirmRes = await modalConfirm(
       '提示',