|
@@ -6,6 +6,7 @@
|
|
|
:clearable="false"
|
|
|
select-default
|
|
|
placeholder="请选择"
|
|
|
+ @change="semesterChange"
|
|
|
/>
|
|
|
<SelectExam
|
|
|
v-model="searchModel.examId"
|
|
@@ -14,12 +15,14 @@
|
|
|
select-default
|
|
|
placeholder="请选择"
|
|
|
@default-selected="toPage(1)"
|
|
|
+ @change="examChange"
|
|
|
/>
|
|
|
<SelectCourse
|
|
|
v-model="searchModel.courseId"
|
|
|
:semester-id="searchModel.semesterId"
|
|
|
:exam-id="searchModel.examId"
|
|
|
placeholder="请选择"
|
|
|
+ @change="courseChange"
|
|
|
/>
|
|
|
<SelectPaperNumber
|
|
|
v-model="searchModel.paperNumber"
|
|
@@ -71,6 +74,14 @@
|
|
|
|
|
|
<!-- ModifySet -->
|
|
|
<ModifySet ref="modifySetRef" />
|
|
|
+ <TaskProgress ref="taskProgressRef" />
|
|
|
+
|
|
|
+ <!-- data loading tips -->
|
|
|
+ <TaskDetailBuildProgess
|
|
|
+ ref="taskDetailBuildProgessRef"
|
|
|
+ :task-id="trackTaskId"
|
|
|
+ :task-stop="detailBuildStop"
|
|
|
+ />
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
@@ -78,19 +89,26 @@
|
|
|
import { Message, TableColumnData } from '@arco-design/web-vue';
|
|
|
|
|
|
import useTable from '@/hooks/table';
|
|
|
+ import useLoading from '@/hooks/loading';
|
|
|
+
|
|
|
import { courseNameCodeFilter } from '@/utils/filter';
|
|
|
- import { TrackExportItem } from '@/api/types/task';
|
|
|
+ import { CourseItem, TrackExportItem } from '@/api/types/task';
|
|
|
import { trackExportListPage } from '@/api/task';
|
|
|
import { TrackConfigType } from '@/store/modules/app/types';
|
|
|
- import { useAppStore } from '@/store';
|
|
|
+ import { useAppStore, useUserStore } from '@/store';
|
|
|
+ import { OptionListItem } from '@/types/global';
|
|
|
+ import useTask from './useTask';
|
|
|
|
|
|
+ import TaskDetailBuildProgess from './taskDetailBuildProgess.vue';
|
|
|
import ModifySet from './modifySet.vue';
|
|
|
+ import TaskProgress from './taskProgress.vue';
|
|
|
|
|
|
defineOptions({
|
|
|
name: 'TrackExport',
|
|
|
});
|
|
|
|
|
|
const appStore = useAppStore();
|
|
|
+ const userStore = useUserStore();
|
|
|
|
|
|
const searchModel = reactive({
|
|
|
semesterId: '',
|
|
@@ -126,29 +144,174 @@
|
|
|
false
|
|
|
);
|
|
|
|
|
|
+ const seNames = {
|
|
|
+ semesterName: '',
|
|
|
+ examName: '',
|
|
|
+ courseName: '',
|
|
|
+ courseCode: '',
|
|
|
+ };
|
|
|
+
|
|
|
+ function semesterChange(val: OptionListItem) {
|
|
|
+ seNames.semesterName = val.label;
|
|
|
+ seNames.examName = '';
|
|
|
+ seNames.courseName = '';
|
|
|
+ seNames.courseCode = '';
|
|
|
+ }
|
|
|
+ function examChange(val: OptionListItem) {
|
|
|
+ seNames.examName = val.label;
|
|
|
+ seNames.courseName = '';
|
|
|
+ seNames.courseCode = '';
|
|
|
+ }
|
|
|
+ function courseChange(val: CourseItem) {
|
|
|
+ seNames.courseName = val.name;
|
|
|
+ seNames.courseCode = val.code;
|
|
|
+ }
|
|
|
+
|
|
|
// table action
|
|
|
const modifySetRef = ref();
|
|
|
function toSet() {
|
|
|
modifySetRef.value?.open();
|
|
|
}
|
|
|
+
|
|
|
+ const {
|
|
|
+ trackTaskId,
|
|
|
+ createTrackTask,
|
|
|
+ updateTrackTaskReady,
|
|
|
+ getTrackExportDetailList,
|
|
|
+ getTrackExportList,
|
|
|
+ } = useTask();
|
|
|
+ const taskProgressRef = ref();
|
|
|
+ const taskDetailBuildProgessRef = ref();
|
|
|
+ const detailBuildStop = ref(false);
|
|
|
+
|
|
|
function checkTrackConfigExist() {
|
|
|
return Boolean(
|
|
|
appStore.trackConfig.outputDir && appStore.trackConfig.pictureType.length
|
|
|
);
|
|
|
}
|
|
|
- function toBatchDownload() {
|
|
|
+
|
|
|
+ // 下载前的检查
|
|
|
+ async function downloadCheck() {
|
|
|
if (!checkTrackConfigExist()) {
|
|
|
Message.error('请先编辑下载设置');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!appStore.trackConfig.outputDirIsDefault) {
|
|
|
+ const result = await window.electron.dialogSelectFile({
|
|
|
+ title: '选择保存目录',
|
|
|
+ properties: ['openDirectory'],
|
|
|
+ });
|
|
|
+
|
|
|
+ if (result.canceled) return false;
|
|
|
+
|
|
|
+ appStore.setInfo({
|
|
|
+ trackConfig: {
|
|
|
+ ...appStore.trackConfig,
|
|
|
+ curOutputDir: result.filePaths[0],
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ const { loading, setLoading } = useLoading();
|
|
|
+ // 批量下载
|
|
|
+ async function toBatchDownload() {
|
|
|
+ detailBuildStop.value = false;
|
|
|
+ if (loading.value) return;
|
|
|
+
|
|
|
+ const res = await downloadCheck();
|
|
|
+ if (!res) return;
|
|
|
+
|
|
|
+ setLoading(true);
|
|
|
+ let result = true;
|
|
|
+ await createTrackTask({
|
|
|
+ ...searchModel,
|
|
|
+ ...seNames,
|
|
|
+ schoolId: userStore.curSchoolInfo.id,
|
|
|
+ pictureType: appStore.trackConfig.pictureType.join(),
|
|
|
+ outputDir: appStore.trackConfig.curOutputDir,
|
|
|
+ status: 0,
|
|
|
+ }).catch(() => {
|
|
|
+ result = false;
|
|
|
+ setLoading(false);
|
|
|
+ });
|
|
|
+ if (!result) {
|
|
|
+ Message.error('创建任务错误!');
|
|
|
return;
|
|
|
}
|
|
|
- console.log('batch');
|
|
|
+
|
|
|
+ // 构建任务提示
|
|
|
+ taskDetailBuildProgessRef.value?.open();
|
|
|
+
|
|
|
+ // 开始构建任务
|
|
|
+ let tRes = true;
|
|
|
+ await getTrackExportList(searchModel).catch((error) => {
|
|
|
+ console.log(error);
|
|
|
+ tRes = false;
|
|
|
+ });
|
|
|
+ setLoading(false);
|
|
|
+
|
|
|
+ if (!tRes) {
|
|
|
+ detailBuildStop.value = true;
|
|
|
+ Message.error('创建任务详情错误!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ await updateTrackTaskReady();
|
|
|
+ detailBuildStop.value = true;
|
|
|
+ taskProgressRef.value?.open();
|
|
|
}
|
|
|
- function toDownload(row: TrackExportItem) {
|
|
|
- if (!checkTrackConfigExist()) {
|
|
|
- Message.error('请先编辑下载设置');
|
|
|
+
|
|
|
+ // 单个课程下载
|
|
|
+ async function toDownload(row: TrackExportItem) {
|
|
|
+ detailBuildStop.value = false;
|
|
|
+ if (loading.value) return;
|
|
|
+
|
|
|
+ const res = await downloadCheck();
|
|
|
+ if (!res) return;
|
|
|
+
|
|
|
+ setLoading(true);
|
|
|
+ let result = true;
|
|
|
+ await createTrackTask({
|
|
|
+ ...searchModel,
|
|
|
+ ...seNames,
|
|
|
+ courseCode: row.courseCode,
|
|
|
+ courseName: row.courseName,
|
|
|
+ paperNumber: row.paperNumber,
|
|
|
+ schoolId: userStore.curSchoolInfo.id,
|
|
|
+ pictureType: appStore.trackConfig.pictureType.join(),
|
|
|
+ outputDir: appStore.trackConfig.curOutputDir,
|
|
|
+ status: 0,
|
|
|
+ }).catch(() => {
|
|
|
+ result = false;
|
|
|
+ setLoading(false);
|
|
|
+ });
|
|
|
+ if (!result) {
|
|
|
+ Message.error('创建任务错误!');
|
|
|
return;
|
|
|
}
|
|
|
- console.log('download', row);
|
|
|
+
|
|
|
+ // 构建任务提示
|
|
|
+ taskDetailBuildProgessRef.value?.open();
|
|
|
+
|
|
|
+ // 开始构建任务
|
|
|
+ let tRes = true;
|
|
|
+ await getTrackExportDetailList(row).catch((error) => {
|
|
|
+ console.log(error);
|
|
|
+ tRes = false;
|
|
|
+ });
|
|
|
+ setLoading(false);
|
|
|
+
|
|
|
+ if (!tRes) {
|
|
|
+ Message.error('创建任务详情错误!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ await updateTrackTaskReady();
|
|
|
+ detailBuildStop.value = true;
|
|
|
+ taskProgressRef.value?.open();
|
|
|
}
|
|
|
|
|
|
async function initData() {
|