|
|
@@ -1,28 +1,37 @@
|
|
1
|
1
|
<script lang="ts" setup>
|
|
2
|
2
|
import type { VbenFormProps } from '@vben/common-ui';
|
|
|
3
|
+
|
|
3
|
4
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
|
4
|
5
|
|
|
5
|
|
-import { ref, onMounted } from 'vue';
|
|
|
6
|
+import { onMounted, ref } from 'vue';
|
|
6
|
7
|
import { useRoute, useRouter } from 'vue-router';
|
|
7
|
|
-import { Page } from '@vben/common-ui';
|
|
8
|
|
-import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|
|
8
|
+
|
|
|
9
|
+import { Page, useVbenDrawer } from '@vben/common-ui';
|
|
9
|
10
|
|
|
10
|
11
|
import {
|
|
11
|
|
- Plus,
|
|
12
|
|
- Edit,
|
|
13
|
|
- Delete,
|
|
14
|
12
|
DArrowLeft,
|
|
|
13
|
+ Delete,
|
|
|
14
|
+ Edit,
|
|
15
|
15
|
Expand,
|
|
|
16
|
+ Plus,
|
|
16
|
17
|
} from '@element-plus/icons-vue';
|
|
17
|
18
|
import {
|
|
18
|
|
- ElTree,
|
|
19
|
19
|
ElButton,
|
|
20
|
20
|
ElIcon,
|
|
21
|
21
|
ElMessage,
|
|
22
|
|
- ElSpace,
|
|
23
|
22
|
ElMessageBox,
|
|
|
23
|
+ ElSpace,
|
|
|
24
|
+ ElTree,
|
|
24
|
25
|
} from 'element-plus';
|
|
25
|
26
|
|
|
|
27
|
+import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|
|
28
|
+import {
|
|
|
29
|
+ deleteQuestionCategory,
|
|
|
30
|
+ questionCategoryTree,
|
|
|
31
|
+} from '#/api/exam/question/category';
|
|
|
32
|
+
|
|
|
33
|
+import ChapterDrawer from './cpn/chapter/drawer.vue';
|
|
|
34
|
+
|
|
26
|
35
|
// 路由实例
|
|
27
|
36
|
const router = useRouter();
|
|
28
|
37
|
const route = useRoute();
|
|
|
@@ -32,39 +41,10 @@ const classId = route.params.classId;
|
|
32
|
41
|
const isCollapse = ref(false);
|
|
33
|
42
|
|
|
34
|
43
|
// 章节数据
|
|
35
|
|
-const chapterData = ref([
|
|
36
|
|
- {
|
|
37
|
|
- id: 1,
|
|
38
|
|
- label: '第一章 基础知识',
|
|
39
|
|
- children: [
|
|
40
|
|
- { id: 2, label: '1.1 概述', saved: true },
|
|
41
|
|
- { id: 3, label: '1.2 基本概念', saved: false },
|
|
42
|
|
- { id: 4, label: '1.3 核心原理', saved: true },
|
|
43
|
|
- ],
|
|
44
|
|
- },
|
|
45
|
|
- {
|
|
46
|
|
- id: 5,
|
|
47
|
|
- label: '第二章 进阶知识',
|
|
48
|
|
- children: [
|
|
49
|
|
- { id: 6, label: '2.1 高级特性', saved: true },
|
|
50
|
|
- { id: 7, label: '2.2 最佳实践', saved: true },
|
|
51
|
|
- ],
|
|
52
|
|
- },
|
|
53
|
|
- {
|
|
54
|
|
- id: 8,
|
|
55
|
|
- label: '第三章 案例分析',
|
|
56
|
|
- children: [
|
|
57
|
|
- { id: 9, label: '3.1 案例一', saved: false },
|
|
58
|
|
- { id: 10, label: '3.2 案例二', saved: true },
|
|
59
|
|
- ],
|
|
60
|
|
- },
|
|
61
|
|
-]);
|
|
|
44
|
+const chapterData = ref([]);
|
|
62
|
45
|
|
|
63
|
46
|
// 选中的章节
|
|
64
|
|
-const selectedChapter = ref({
|
|
65
|
|
- id: '1',
|
|
66
|
|
- label: '第一章 基础知识',
|
|
67
|
|
-});
|
|
|
47
|
+const selectedChapter = ref({});
|
|
68
|
48
|
|
|
69
|
49
|
// 模拟试题数据
|
|
70
|
50
|
const mockQuestionData = ref([
|
|
|
@@ -223,38 +203,38 @@ const gridOptions: VxeGridProps = {
|
|
223
|
203
|
query: async ({ page }, formValues = {}) => {
|
|
224
|
204
|
// 模拟API请求
|
|
225
|
205
|
console.log('查询参数:', formValues, page);
|
|
226
|
|
-
|
|
|
206
|
+
|
|
227
|
207
|
// 模拟搜索过滤
|
|
228
|
208
|
let filteredData = [...mockQuestionData.value];
|
|
229
|
|
-
|
|
|
209
|
+
|
|
230
|
210
|
if (formValues.content) {
|
|
231
|
|
- filteredData = filteredData.filter(item =>
|
|
232
|
|
- item.content.includes(formValues.content)
|
|
|
211
|
+ filteredData = filteredData.filter((item) =>
|
|
|
212
|
+ item.content.includes(formValues.content),
|
|
233
|
213
|
);
|
|
234
|
214
|
}
|
|
235
|
|
-
|
|
|
215
|
+
|
|
236
|
216
|
if (formValues.reminder) {
|
|
237
|
|
- filteredData = filteredData.filter(item =>
|
|
238
|
|
- item.reminder === formValues.reminder
|
|
|
217
|
+ filteredData = filteredData.filter(
|
|
|
218
|
+ (item) => item.reminder === formValues.reminder,
|
|
239
|
219
|
);
|
|
240
|
220
|
}
|
|
241
|
|
-
|
|
|
221
|
+
|
|
242
|
222
|
if (formValues.difficulty) {
|
|
243
|
|
- filteredData = filteredData.filter(item =>
|
|
244
|
|
- item.difficulty === formValues.difficulty
|
|
|
223
|
+ filteredData = filteredData.filter(
|
|
|
224
|
+ (item) => item.difficulty === formValues.difficulty,
|
|
245
|
225
|
);
|
|
246
|
226
|
}
|
|
247
|
|
-
|
|
|
227
|
+
|
|
248
|
228
|
// 模拟分页
|
|
249
|
229
|
const start = (page.currentPage - 1) * page.pageSize;
|
|
250
|
230
|
const end = start + page.pageSize;
|
|
251
|
231
|
const paginatedData = filteredData.slice(start, end);
|
|
252
|
232
|
console.log('分页数据:', paginatedData);
|
|
253
|
|
-
|
|
|
233
|
+
|
|
254
|
234
|
// 确保返回格式正确,使用 items 作为数据键
|
|
255
|
|
- return {
|
|
256
|
|
- items: paginatedData,
|
|
257
|
|
- total: filteredData.length
|
|
|
235
|
+ return {
|
|
|
236
|
+ items: paginatedData,
|
|
|
237
|
+ total: filteredData.length,
|
|
258
|
238
|
};
|
|
259
|
239
|
},
|
|
260
|
240
|
},
|
|
|
@@ -286,18 +266,27 @@ const handleChapterClick = (node) => {
|
|
286
|
266
|
};
|
|
287
|
267
|
|
|
288
|
268
|
// 添加章节
|
|
289
|
|
-const addChapter = (parentId = null) => {
|
|
290
|
|
- ElMessage.info('添加章节功能待实现');
|
|
|
269
|
+const addChapter = (chapter: any) => {
|
|
|
270
|
+ chapterVbenDrawerApi.setData({ ...chapter, isUpdate: false }).open();
|
|
291
|
271
|
};
|
|
292
|
272
|
|
|
293
|
273
|
// 编辑章节
|
|
294
|
|
-const editChapter = (node) => {
|
|
295
|
|
- ElMessage.info('编辑章节功能待实现');
|
|
|
274
|
+const editChapter = (chapter: any) => {
|
|
|
275
|
+ chapterVbenDrawerApi.setData({ ...chapter, isUpdate: true }).open();
|
|
296
|
276
|
};
|
|
297
|
277
|
|
|
298
|
278
|
// 删除章节
|
|
299
|
|
-const deleteChapter = (node) => {
|
|
300
|
|
- ElMessage.info('删除章节功能待实现');
|
|
|
279
|
+const deleteChapter = (chapter: any) => {
|
|
|
280
|
+ // ElMessage.info('删除章节功能待实现');
|
|
|
281
|
+ // 二次确认
|
|
|
282
|
+ ElMessageBox.confirm('确认删除该章节吗?', '提示', {
|
|
|
283
|
+ confirmButtonText: '确定',
|
|
|
284
|
+ cancelButtonText: '取消',
|
|
|
285
|
+ type: 'warning',
|
|
|
286
|
+ }).then(async () => {
|
|
|
287
|
+ await deleteQuestionCategory(chapter.id);
|
|
|
288
|
+ await getChapterTree();
|
|
|
289
|
+ });
|
|
301
|
290
|
};
|
|
302
|
291
|
|
|
303
|
292
|
// 新增试题
|
|
|
@@ -324,7 +313,7 @@ const editQuestion = (row) => {
|
|
324
|
313
|
|
|
325
|
314
|
// 预览试题
|
|
326
|
315
|
const previewQuestion = (row) => {
|
|
327
|
|
- // 跳转到预览页面,并传递试题ID
|
|
|
316
|
+ // 跳转到预览页面,并传递试题ID
|
|
328
|
317
|
router.push(`/examManage/questionBank/questionPreview?id=${row.id}`);
|
|
329
|
318
|
};
|
|
330
|
319
|
|
|
|
@@ -340,7 +329,7 @@ const deleteHandle = () => {
|
|
340
|
329
|
if (ids.length <= 0) {
|
|
341
|
330
|
return;
|
|
342
|
331
|
}
|
|
343
|
|
-
|
|
|
332
|
+
|
|
344
|
333
|
ElMessageBox.confirm(`确认删除选中的${ids.length}条数据吗?`, '提示', {
|
|
345
|
334
|
confirmButtonText: '确定',
|
|
346
|
335
|
cancelButtonText: '取消',
|
|
|
@@ -352,9 +341,22 @@ const deleteHandle = () => {
|
|
352
|
341
|
});
|
|
353
|
342
|
};
|
|
354
|
343
|
|
|
|
344
|
+const [ChapterVbenDrawer, chapterVbenDrawerApi] = useVbenDrawer({
|
|
|
345
|
+ connectedComponent: ChapterDrawer,
|
|
|
346
|
+});
|
|
|
347
|
+
|
|
|
348
|
+const getChapterTree = async () => {
|
|
|
349
|
+ const { rows } = await questionCategoryTree();
|
|
|
350
|
+ chapterData.value = rows;
|
|
|
351
|
+};
|
|
|
352
|
+
|
|
355
|
353
|
// 页面加载时获取数据
|
|
356
|
354
|
onMounted(() => {
|
|
357
|
355
|
// 默认选中第一个章节
|
|
|
356
|
+
|
|
|
357
|
+ // 获取试题分类树形图
|
|
|
358
|
+ getChapterTree().then();
|
|
|
359
|
+
|
|
358
|
360
|
if (chapterData.value.length > 0) {
|
|
359
|
361
|
handleChapterClick(chapterData.value[0]);
|
|
360
|
362
|
}
|
|
|
@@ -364,22 +366,22 @@ onMounted(() => {
|
|
364
|
366
|
<template>
|
|
365
|
367
|
<Page :auto-content-height="true">
|
|
366
|
368
|
<div class="knowledge-detail">
|
|
367
|
|
-
|
|
368
|
369
|
<!-- 主体内容区 -->
|
|
369
|
370
|
<div class="main-content">
|
|
370
|
371
|
<!-- 左侧目录 -->
|
|
371
|
|
- <div class="left-sidebar" :class="{ 'collapsed': isCollapse }">
|
|
|
372
|
+ <div class="left-sidebar" :class="{ collapsed: isCollapse }">
|
|
372
|
373
|
<!-- 折叠按钮 -->
|
|
373
|
374
|
<div class="collapse-btn" @click="isCollapse = true">
|
|
374
|
375
|
<ElIcon><DArrowLeft /></ElIcon>
|
|
375
|
376
|
</div>
|
|
376
|
|
-
|
|
|
377
|
+
|
|
377
|
378
|
<div class="sidebar-content">
|
|
378
|
379
|
<!-- 章节树 -->
|
|
379
|
380
|
<div class="chapter-tree">
|
|
380
|
381
|
<ElTree
|
|
381
|
382
|
:data="chapterData"
|
|
382
|
383
|
node-key="id"
|
|
|
384
|
+ :props="{ label: 'name' }"
|
|
383
|
385
|
default-expand-all
|
|
384
|
386
|
:expand-on-click-node="false"
|
|
385
|
387
|
@node-click="handleChapterClick"
|
|
|
@@ -392,8 +394,8 @@ onMounted(() => {
|
|
392
|
394
|
type="text"
|
|
393
|
395
|
size="small"
|
|
394
|
396
|
circle
|
|
395
|
|
- @click.stop="addQuestion"
|
|
396
|
|
- title="添加题目"
|
|
|
397
|
+ @click.stop="addChapter"
|
|
|
398
|
+ title="添加章节"
|
|
397
|
399
|
>
|
|
398
|
400
|
<ElIcon><Plus /></ElIcon>
|
|
399
|
401
|
</ElButton>
|
|
|
@@ -425,8 +427,15 @@ onMounted(() => {
|
|
425
|
427
|
|
|
426
|
428
|
<!-- 中间内容 -->
|
|
427
|
429
|
<div class="center-content">
|
|
428
|
|
- <ElIcon v-if="isCollapse" :size="20" class="collapse-control-btn" @click="isCollapse = false"><Expand /></ElIcon>
|
|
429
|
|
-
|
|
|
430
|
+ <ElIcon
|
|
|
431
|
+ v-if="isCollapse"
|
|
|
432
|
+ :size="20"
|
|
|
433
|
+ class="collapse-control-btn"
|
|
|
434
|
+ @click="isCollapse = false"
|
|
|
435
|
+ >
|
|
|
436
|
+ <Expand />
|
|
|
437
|
+ </ElIcon>
|
|
|
438
|
+
|
|
430
|
439
|
<!-- 题目列表区域 -->
|
|
431
|
440
|
<div class="question-list">
|
|
432
|
441
|
<!-- 试题列表 -->
|
|
|
@@ -442,33 +451,20 @@ onMounted(() => {
|
|
442
|
451
|
>
|
|
443
|
452
|
批量删除
|
|
444
|
453
|
</ElButton>
|
|
445
|
|
- <ElButton
|
|
446
|
|
- type="primary"
|
|
447
|
|
- @click="addQuestion"
|
|
448
|
|
- >
|
|
|
454
|
+ <ElButton type="primary" @click="addQuestion">
|
|
449
|
455
|
新增试题
|
|
450
|
456
|
</ElButton>
|
|
451
|
|
- <ElButton
|
|
452
|
|
- type="primary"
|
|
453
|
|
- @click="importQuestions"
|
|
454
|
|
- >
|
|
|
457
|
+ <ElButton type="primary" @click="importQuestions">
|
|
455
|
458
|
导入
|
|
456
|
459
|
</ElButton>
|
|
457
|
|
- <ElButton
|
|
458
|
|
- type="primary"
|
|
459
|
|
- @click="exportQuestions"
|
|
460
|
|
- >
|
|
|
460
|
+ <ElButton type="primary" @click="exportQuestions">
|
|
461
|
461
|
导出
|
|
462
|
462
|
</ElButton>
|
|
463
|
463
|
</ElSpace>
|
|
464
|
464
|
</template>
|
|
465
|
465
|
<template #action="{ row }">
|
|
466
|
466
|
<div class="action-buttons">
|
|
467
|
|
- <ElButton
|
|
468
|
|
- type="text"
|
|
469
|
|
- size="small"
|
|
470
|
|
- @click="editQuestion(row)"
|
|
471
|
|
- >
|
|
|
467
|
+ <ElButton type="text" size="small" @click="editQuestion(row)">
|
|
472
|
468
|
<ElIcon><Edit /></ElIcon>
|
|
473
|
469
|
编辑
|
|
474
|
470
|
</ElButton>
|
|
|
@@ -495,6 +491,7 @@ onMounted(() => {
|
|
495
|
491
|
</div>
|
|
496
|
492
|
</div>
|
|
497
|
493
|
</div>
|
|
|
494
|
+ <ChapterVbenDrawer @reload="getChapterTree" />
|
|
498
|
495
|
</Page>
|
|
499
|
496
|
</template>
|
|
500
|
497
|
|
|
|
@@ -630,12 +627,3 @@ onMounted(() => {
|
|
630
|
627
|
gap: 8px;
|
|
631
|
628
|
}
|
|
632
|
629
|
</style>
|
|
633
|
|
-
|
|
634
|
|
-
|
|
635
|
|
-
|
|
636
|
|
-
|
|
637
|
|
-
|
|
638
|
|
-
|
|
639
|
|
-
|
|
640
|
|
-
|
|
641
|
|
-
|