|
@@ -8,11 +8,12 @@ import {
|
|
import { Task, Track, SpecialTag, Question } from '@/api/types/task';
|
|
import { Task, Track, SpecialTag, Question } from '@/api/types/task';
|
|
import { TrackConfigType } from '@/store/modules/app/types';
|
|
import { TrackConfigType } from '@/store/modules/app/types';
|
|
import { PictureTypeEnum, PICTURE_TYPE } from '@/constants/enumerate';
|
|
import { PictureTypeEnum, PICTURE_TYPE } from '@/constants/enumerate';
|
|
-import { calcSum, maxNum, strGbLen } from '@/utils/utils';
|
|
|
|
|
|
+import { calcSum, deepCopy, maxNum, strGbLen } from '@/utils/utils';
|
|
import { useAppStore } from '@/store';
|
|
import { useAppStore } from '@/store';
|
|
|
|
|
|
import { DrawTrackItem } from '../../../../electron/preload/types';
|
|
import { DrawTrackItem } from '../../../../electron/preload/types';
|
|
import { TrackTaskData } from '../../../../electron/db/models/trackTask';
|
|
import { TrackTaskData } from '../../../../electron/db/models/trackTask';
|
|
|
|
+import { TrackTaskDetailData } from '../../../../electron/db/models/trackTaskDetail';
|
|
|
|
|
|
type AnswerMap = Record<string, { answer: string; isRight: boolean }>;
|
|
type AnswerMap = Record<string, { answer: string; isRight: boolean }>;
|
|
|
|
|
|
@@ -107,10 +108,25 @@ export default function useDraw(winId: number) {
|
|
let isOnlyOrigin = false;
|
|
let isOnlyOrigin = false;
|
|
let hasPdf = false;
|
|
let hasPdf = false;
|
|
let curStudentId = '';
|
|
let curStudentId = '';
|
|
|
|
+ const defaultColorConfig = {
|
|
|
|
+ track: ['red', 'blue', 'gray'],
|
|
|
|
+ head: 'green',
|
|
|
|
+ };
|
|
|
|
+ let colorConfig = { track: ['red', 'blue', 'gray'], head: 'green' };
|
|
const task = ref({} as TrackTaskData);
|
|
const task = ref({} as TrackTaskData);
|
|
|
|
+ const taskDetail = ref({} as TrackTaskDetailData);
|
|
const trackConfig = ref({} as TrackConfigType);
|
|
const trackConfig = ref({} as TrackConfigType);
|
|
const appStore = useAppStore();
|
|
const appStore = useAppStore();
|
|
|
|
|
|
|
|
+ function updateColorConfig() {
|
|
|
|
+ if (trackConfig.value.trackColorType === 'ALL_RED') {
|
|
|
|
+ colorConfig.head = 'red';
|
|
|
|
+ colorConfig.track = ['red', 'red', 'red'];
|
|
|
|
+ } else {
|
|
|
|
+ colorConfig = deepCopy(defaultColorConfig);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
function addLog(content: string, type?: 'info' | 'error') {
|
|
function addLog(content: string, type?: 'info' | 'error') {
|
|
window.api.logger(`win:${curWinId} ${content}`, type);
|
|
window.api.logger(`win:${curWinId} ${content}`, type);
|
|
}
|
|
}
|
|
@@ -119,28 +135,27 @@ export default function useDraw(winId: number) {
|
|
const res = await window.db.getUnfinishTrackTask(schoolId);
|
|
const res = await window.db.getUnfinishTrackTask(schoolId);
|
|
if (!res) return Promise.reject(new Error('无任务'));
|
|
if (!res) return Promise.reject(new Error('无任务'));
|
|
task.value = res;
|
|
task.value = res;
|
|
- trackConfig.value = {
|
|
|
|
- pictureType: res.pictureType.split(',') as PictureTypeEnum[],
|
|
|
|
- outputDir: res.outputDir,
|
|
|
|
- curOutputDir: res.outputDir,
|
|
|
|
- outputDirIsDefault: false,
|
|
|
|
- };
|
|
|
|
|
|
+ trackConfig.value = JSON.parse(res.trackConfig) as TrackConfigType;
|
|
isOnlyOrigin = checkOnlyOrigin();
|
|
isOnlyOrigin = checkOnlyOrigin();
|
|
hasPdf = trackConfig.value.pictureType.includes('pdf');
|
|
hasPdf = trackConfig.value.pictureType.includes('pdf');
|
|
|
|
+ updateColorConfig();
|
|
return res.id;
|
|
return res.id;
|
|
}
|
|
}
|
|
|
|
|
|
- function getTrackTaskDetail() {
|
|
|
|
- return window.db.getUnfinishTrackTaskDetail(task.value.id);
|
|
|
|
|
|
+ async function getTrackTaskDetail() {
|
|
|
|
+ const res = await window.db.getUnfinishTrackTaskDetail(task.value.id);
|
|
|
|
+ if (!res) return null;
|
|
|
|
+ taskDetail.value = res;
|
|
|
|
+ return taskDetail.value;
|
|
}
|
|
}
|
|
|
|
|
|
- async function runTask(studentId: string) {
|
|
|
|
|
|
+ async function runTask() {
|
|
initData();
|
|
initData();
|
|
- curStudentId = studentId;
|
|
|
|
|
|
+ curStudentId = taskDetail.value.studentId;
|
|
addLog(`[${curStudentId}] 01-开始任务`);
|
|
addLog(`[${curStudentId}] 01-开始任务`);
|
|
|
|
|
|
try {
|
|
try {
|
|
- await getTaskData(studentId);
|
|
|
|
|
|
+ await getTaskData(curStudentId);
|
|
addLog(`[${curStudentId}] 02-获取任务数据成功`);
|
|
addLog(`[${curStudentId}] 02-获取任务数据成功`);
|
|
|
|
|
|
originImgs = await downloadImages(rawTask.sheetUrls);
|
|
originImgs = await downloadImages(rawTask.sheetUrls);
|
|
@@ -193,7 +208,6 @@ export default function useDraw(winId: number) {
|
|
rawTask = await getSingleStudentTaskOfStudentTrack(studentId);
|
|
rawTask = await getSingleStudentTaskOfStudentTrack(studentId);
|
|
if (!rawTask) return;
|
|
if (!rawTask) return;
|
|
|
|
|
|
- // rawTask.sheetUrls = ["/1-1.jpg", "/1-2.jpg"];
|
|
|
|
if (!rawTask.sheetUrls) rawTask.sheetUrls = [];
|
|
if (!rawTask.sheetUrls) rawTask.sheetUrls = [];
|
|
|
|
|
|
if (isOnlyOrigin) return;
|
|
if (isOnlyOrigin) return;
|
|
@@ -216,8 +230,15 @@ export default function useDraw(winId: number) {
|
|
cardData = cardContent.pages;
|
|
cardData = cardContent.pages;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取文件存储路径,规则:学期/考试/课程/试卷编号/教学班/下载文件类型/学生图片
|
|
|
|
+ */
|
|
function getOutputPath(type: PictureTypeEnum, index?: number) {
|
|
function getOutputPath(type: PictureTypeEnum, index?: number) {
|
|
- let filename = rawTask.studentCode;
|
|
|
|
|
|
+ let filename =
|
|
|
|
+ trackConfig.value.studentFileRule === 'CODE_NAME'
|
|
|
|
+ ? `${rawTask.studentCode}-${rawTask.studentName}`
|
|
|
|
+ : rawTask.studentCode;
|
|
|
|
+
|
|
if (index !== undefined) {
|
|
if (index !== undefined) {
|
|
filename += `-${index}`;
|
|
filename += `-${index}`;
|
|
}
|
|
}
|
|
@@ -228,6 +249,7 @@ export default function useDraw(winId: number) {
|
|
task.value.examName,
|
|
task.value.examName,
|
|
`${rawTask.courseName}(${rawTask.courseCode})`,
|
|
`${rawTask.courseName}(${rawTask.courseCode})`,
|
|
rawTask.paperNumber,
|
|
rawTask.paperNumber,
|
|
|
|
+ taskDetail.value.className,
|
|
PICTURE_TYPE[type],
|
|
PICTURE_TYPE[type],
|
|
filename,
|
|
filename,
|
|
];
|
|
];
|
|
@@ -379,7 +401,7 @@ export default function useDraw(winId: number) {
|
|
|
|
|
|
function addHeaderTrackColorAttr(headerTrack: Track[]): Track[] {
|
|
function addHeaderTrackColorAttr(headerTrack: Track[]): Track[] {
|
|
return headerTrack.map((item) => {
|
|
return headerTrack.map((item) => {
|
|
- item.color = 'green';
|
|
|
|
|
|
+ item.color = colorConfig.head;
|
|
return item;
|
|
return item;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -392,11 +414,11 @@ export default function useDraw(winId: number) {
|
|
for (let i = 0; i < markerIds.length; i++) {
|
|
for (let i = 0; i < markerIds.length; i++) {
|
|
const mId = markerIds[i];
|
|
const mId = markerIds[i];
|
|
if (i === 0) {
|
|
if (i === 0) {
|
|
- colorMap[mId] = 'red';
|
|
|
|
|
|
+ colorMap[mId] = colorConfig.track[0];
|
|
} else if (i === 1) {
|
|
} else if (i === 1) {
|
|
- colorMap[mId] = 'blue';
|
|
|
|
|
|
+ colorMap[mId] = colorConfig.track[1];
|
|
} else if (i > 1) {
|
|
} else if (i > 1) {
|
|
- colorMap[mId] = 'gray';
|
|
|
|
|
|
+ colorMap[mId] = colorConfig.track[2];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
type ColorK = keyof typeof colorMap;
|
|
type ColorK = keyof typeof colorMap;
|