Commit 47e919133345e7f26f070bc2e1561b1a8141dbdd

Authored by liufangjia
1 parent d8f38eeb

feat: 代码提交

src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue
1 <template> 1 <template>
2 - <el-dialog :visible.sync="visible" width="70%" :before-close="handleClose" :modal-append-to-body="false"> 2 + <el-dialog
  3 + :visible.sync="visible"
  4 + width="70%"
  5 + :before-close="handleClose"
  6 + :modal-append-to-body="false"
  7 + >
3 <div class="test-box" v-if="groups"> 8 <div class="test-box" v-if="groups">
4 <div class="test"> 9 <div class="test">
5 <div class="test-title" @click="enableEditing"> 10 <div class="test-title" @click="enableEditing">
6 - <div class="test-title" v-if="!isEditing" @mouseenter="handleMouseEnter" @mouseleave="handleMouseLeave"  
7 - :class="isHovered ? 'hover' : ''"> 11 + <div
  12 + class="test-title"
  13 + v-if="!isEditing"
  14 + @mouseenter="handleMouseEnter"
  15 + @mouseleave="handleMouseLeave"
  16 + :class="isHovered ? 'hover' : ''"
  17 + >
8 {{ inputValue }} 18 {{ inputValue }}
9 </div> 19 </div>
10 - <div v-if="isHovered" class="tooltip" :style="{  
11 - top: tooltipPosition.y + 'px',  
12 - left: tooltipPosition.x + 'px',  
13 - }"> 20 + <div
  21 + v-if="isHovered"
  22 + class="tooltip"
  23 + :style="{
  24 + top: tooltipPosition.y + 'px',
  25 + left: tooltipPosition.x + 'px',
  26 + }"
  27 + >
14 单击设置试卷标题 28 单击设置试卷标题
15 </div> 29 </div>
16 - <el-input class="test-title" ref="editInput" v-if="isEditing" v-model="inputValue" @blur="save"  
17 - @keyup.enter.native="save" style="padding: 0 200px" /> 30 + <el-input
  31 + class="test-title"
  32 + ref="editInput"
  33 + v-if="isEditing"
  34 + v-model="inputValue"
  35 + @blur="save"
  36 + @keyup.enter.native="save"
  37 + style="padding: 0 200px"
  38 + />
18 </div> 39 </div>
19 <div class="test-group"> 40 <div class="test-group">
20 - <div class="outer-item" v-for="(group, index) in groups" :key="group.questionType" :class="{  
21 - border: selectedIndex === group.questionType,  
22 - }" @mouseenter="handleGroupMouseEnter(group.questionType, 'all')" @mouseleave="handleGroupMouseLeave">  
23 - <div v-if="selectedIndex == group.questionType" class="border-del"  
24 - @click="handleDel(group.questionType, 'all')"> 41 + <div
  42 + class="outer-item"
  43 + v-for="(group, index) in groups"
  44 + :key="group.questionType"
  45 + :class="{
  46 + border: selectedIndex === group.questionType,
  47 + }"
  48 + @mouseenter="handleGroupMouseEnter(group.questionType, 'all')"
  49 + @mouseleave="handleGroupMouseLeave"
  50 + >
  51 + <div
  52 + v-if="selectedIndex == group.questionType"
  53 + class="border-del"
  54 + @click="handleDel(group.questionType, 'all')"
  55 + >
25 删除 56 删除
26 </div> 57 </div>
27 <!-- 每个组的标题 --> 58 <!-- 每个组的标题 -->
28 - <div class="test-group-title" :class="{  
29 - border: selectedIndex == group.questionType,  
30 - }" @mouseenter="handleGroupMouseEnter(group.questionType, 'all')"> 59 + <div
  60 + class="test-group-title"
  61 + :class="{
  62 + border: selectedIndex == group.questionType,
  63 + }"
  64 + @mouseenter="handleGroupMouseEnter(group.questionType, 'all')"
  65 + >
31 <div class="size-16" style="font-weight: 600"> 66 <div class="size-16" style="font-weight: 600">
32 {{ index + 1 }}、 67 {{ index + 1 }}、
33 - <span @mouseenter="(event) => handleItemMouseEnter(event, group.questionType)  
34 - " @mouseleave="handleItemMouseLeave" :class="isItemHovered == group.questionType ? 'hover' : ''"  
35 - class="size-16" @click="groupEditing(index)" v-show="!group.input">{{ group.questionTitle }}</span>  
36 -  
37 - <el-input :ref="'refInput' + index" class="size-16" size="mini" v-show="group.input"  
38 - v-model="group.questionTitle" @blur="groupSave(index)" @keyup.enter.native="groupSave(index)"  
39 - style="width: fit-content" />  
40 - <div v-if="isItemHovered == group.questionType" class="tooltip" :style="{  
41 - top: tooltipPosition.y + 'px',  
42 - left: tooltipPosition.x + 'px',  
43 - }"> 68 + <span
  69 + @mouseenter="
  70 + (event) => handleItemMouseEnter(event, group.questionType)
  71 + "
  72 + @mouseleave="handleItemMouseLeave"
  73 + :class="isItemHovered == group.questionType ? 'hover' : ''"
  74 + class="size-16"
  75 + @click="groupEditing(index)"
  76 + v-show="!group.input"
  77 + >{{ group.questionTitle }}</span
  78 + >
  79 +
  80 + <el-input
  81 + :ref="'refInput' + index"
  82 + class="size-16"
  83 + size="mini"
  84 + v-show="group.input"
  85 + v-model="group.questionTitle"
  86 + @blur="groupSave(index)"
  87 + @keyup.enter.native="groupSave(index)"
  88 + style="width: fit-content"
  89 + />
  90 + <div
  91 + v-if="isItemHovered == group.questionType"
  92 + class="tooltip"
  93 + :style="{
  94 + top: tooltipPosition.y + 'px',
  95 + left: tooltipPosition.x + 'px',
  96 + }"
  97 + >
44 单击设置试卷标题 98 单击设置试卷标题
45 </div> 99 </div>
46 100
47 - <span v-if="group.subQuestionIds" class="size-16" style="margin-left: 10px">(共{{  
48 - group.subQuestionIds.length }}题 / 共{{ 101 + <span
  102 + v-if="group.subQuestionIds"
  103 + class="size-16"
  104 + style="margin-left: 10px"
  105 + >(共{{ group.subQuestionIds.length }}题 / 共{{
49 group.questionScore * group.subQuestionIds.length 106 group.questionScore * group.subQuestionIds.length
50 - }}分)</span> 107 + }}分)</span
  108 + >
51 </div> 109 </div>
52 </div> 110 </div>
53 111
54 <!-- 内部的题目列表,允许组内排序 --> 112 <!-- 内部的题目列表,允许组内排序 -->
55 - <div style="display: flex" v-for="question in group.subQuestionIds" :key="question.id" :class="{  
56 - border: selectedItemIndex === question.id,  
57 - }" @mouseenter="handleGroupMouseEnter(question.id, 'number')" @mouseleave="handleGroupMouseLeave"  
58 - class="inner-item">  
59 - <div v-if="selectedItemIndex === question.id" class="border-del"  
60 - @click="handleDel(question.id, group.questionType)"> 113 + <div
  114 + style="display: flex"
  115 + v-for="question in group.subQuestionIds"
  116 + :key="question.id"
  117 + :class="{
  118 + border: selectedItemIndex === question.id,
  119 + }"
  120 + @mouseenter="handleGroupMouseEnter(question.id, 'number')"
  121 + @mouseleave="handleGroupMouseLeave"
  122 + class="inner-item"
  123 + >
  124 + <div
  125 + v-if="selectedItemIndex === question.id"
  126 + class="border-del"
  127 + @click="handleDel(question.id, group.questionType)"
  128 + >
61 删除 129 删除
62 </div> 130 </div>
63 <div class="size color" style="margin-top: 20px"> 131 <div class="size color" style="margin-top: 20px">
64 - <div style="max-width: 100px; white-space: nowrap; /* 不换行 */"> 132 + <div
  133 + style="max-width: 100px; white-space: nowrap; /* 不换行 */"
  134 + >
65 {{ question.globalIndex }}、 135 {{ question.globalIndex }}、
66 </div> 136 </div>
67 </div> 137 </div>
68 138
69 - <iframe :src="question.screenshot" :ref="'iframe' + question.id" @load="onIFrameLoad(question.id)" style=" 139 + <iframe
  140 + :src="question.screenshot"
  141 + :ref="'iframe' + question.id"
  142 + @load="onIFrameLoad(question.id)"
  143 + style="
70 width: 100%; 144 width: 100%;
71 pointer-events: none; 145 pointer-events: none;
72 border: none; /* 启用点击穿透 */ 146 border: none; /* 启用点击穿透 */
73 - "></iframe> 147 + "
  148 + ></iframe>
74 </div> 149 </div>
75 </div> 150 </div>
76 </div> 151 </div>
@@ -78,23 +153,43 @@ @@ -78,23 +153,43 @@
78 <div class="edit"> 153 <div class="edit">
79 <div class="edit-title"> 154 <div class="edit-title">
80 <div class="edit-title-info"> 155 <div class="edit-title-info">
81 - 共<span>{{ list.length }}</span>小题,卷面分<span>{{ sumValues() }}</span>分 156 + 共<span>{{ list.length }}</span
  157 + >小题,卷面分<span>{{ sumValues() }}</span
  158 + >分
82 </div> 159 </div>
83 <div class="edit-button"> 160 <div class="edit-button">
84 - <el-button class="button-width" type="primary" @click="handleSava">保存试卷</el-button>  
85 - <el-button class="button-width" plain @click="handleSava('print')">保存并打印</el-button>  
86 - <el-button class="button-width" type="danger" plain @click="handleClear">清空题目</el-button>  
87 - <el-button class="button-width" plain @click="handleSelect">继续选题</el-button> 161 + <el-button class="button-width" type="primary" @click="handleSava"
  162 + >保存试卷</el-button
  163 + >
  164 + <el-button class="button-width" plain @click="handleSava('print')"
  165 + >保存并打印</el-button
  166 + >
  167 + <el-button
  168 + class="button-width"
  169 + type="danger"
  170 + plain
  171 + @click="handleClear"
  172 + >清空题目</el-button
  173 + >
  174 + <el-button class="button-width" plain @click="handleSelect"
  175 + >继续选题</el-button
  176 + >
88 </div> 177 </div>
89 </div> 178 </div>
90 <div class="edit-info"> 179 <div class="edit-info">
91 <div class="title size color" style="padding: 15px 0 0 10px"> 180 <div class="title size color" style="padding: 15px 0 0 10px">
92 题目排序 181 题目排序
93 - <span class="title size" style="color: #999999">(拖拽题号可拖拽排序)</span> 182 + <span class="title size" style="color: #999999"
  183 + >(拖拽题号可拖拽排序)</span
  184 + >
94 </div> 185 </div>
95 <!-- 外层容器,允许拖拽整个组 --> 186 <!-- 外层容器,允许拖拽整个组 -->
96 <draggable v-model="groups" group="groups" @end="onEnd"> 187 <draggable v-model="groups" group="groups" @end="onEnd">
97 - <div v-for="(group, index) in groups" :key="group.id" class="group-item"> 188 + <div
  189 + v-for="(group, index) in groups"
  190 + :key="group.id"
  191 + class="group-item"
  192 + >
98 <!-- 每个组的标题 --> 193 <!-- 每个组的标题 -->
99 <div class="group-title"> 194 <div class="group-title">
100 <div class="size" style="font-weight: 600"> 195 <div class="size" style="font-weight: 600">
@@ -102,14 +197,28 @@ @@ -102,14 +197,28 @@
102 </div> 197 </div>
103 <div class="size"> 198 <div class="size">
104 单题分值: 199 单题分值:
105 - <el-input-number size="mini" v-model="group.questionScore" :min="1" :max="30"  
106 - style="width: 100px"></el-input-number> 200 + <el-input-number
  201 + size="mini"
  202 + v-model="group.questionScore"
  203 + :min="1"
  204 + :max="30"
  205 + style="width: 100px"
  206 + ></el-input-number>
107 </div> 207 </div>
108 </div> 208 </div>
109 209
110 <!-- 内部的题目列表,允许组内排序 --> 210 <!-- 内部的题目列表,允许组内排序 -->
111 - <draggable class="questions" v-model="group.subQuestionIds" group="questions" @end="onItemEnd(group)">  
112 - <div v-for="question in group.subQuestionIds" :key="question.id" class="question-item"> 211 + <draggable
  212 + class="questions"
  213 + v-model="group.subQuestionIds"
  214 + group="questions"
  215 + @end="onItemEnd(group)"
  216 + >
  217 + <div
  218 + v-for="question in group.subQuestionIds"
  219 + :key="question.id"
  220 + class="question-item"
  221 + >
113 {{ question.globalIndex }} 222 {{ question.globalIndex }}
114 </div> 223 </div>
115 </draggable> 224 </draggable>
@@ -157,6 +266,13 @@ export default { @@ -157,6 +266,13 @@ export default {
157 return null; 266 return null;
158 }, 267 },
159 }, 268 },
  269 + sectionId: {
  270 + // 科目
  271 + type: [String, Number],
  272 + default() {
  273 + return null;
  274 + },
  275 + },
160 }, 276 },
161 data() { 277 data() {
162 return { 278 return {
@@ -279,8 +395,9 @@ export default { @@ -279,8 +395,9 @@ export default {
279 const iframeRef = this.$refs["iframe" + id][0]; // 获取对应的 iframe 395 const iframeRef = this.$refs["iframe" + id][0]; // 获取对应的 iframe
280 const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; 396 const doc = iframeRef.contentDocument || iframeRef.contentWindow.document;
281 const body = iframeRef.contentWindow.document.body; 397 const body = iframeRef.contentWindow.document.body;
  398 + body.style.overflowX = "hidden"; // 不允许出现横向滚动条
282 const height = body.scrollHeight; // 获取内容的高度 399 const height = body.scrollHeight; // 获取内容的高度
283 - iframeRef.style.height = `${height}px`; // 设置 iframe 的高度 400 + iframeRef.style.height = `${height + 20}px`; // 设置 iframe 的高度
284 // 获取第一个P标签 401 // 获取第一个P标签
285 const firstP = doc.getElementsByTagName("p")[0]; 402 const firstP = doc.getElementsByTagName("p")[0];
286 // 或者修改第一个 < p > 标签的内容; 403 // 或者修改第一个 < p > 标签的内容;
@@ -547,6 +664,7 @@ export default { @@ -547,6 +664,7 @@ export default {
547 let param = { 664 let param = {
548 paperTitle: this.inputValue, 665 paperTitle: this.inputValue,
549 subjectName: this.subjectName, 666 subjectName: this.subjectName,
  667 + sectionId: this.sectionId,
550 gradeId: this.gradeId, 668 gradeId: this.gradeId,
551 questions: this.groups.filter((item) => item.subQuestionIds.length > 0), 669 questions: this.groups.filter((item) => item.subQuestionIds.length > 0),
552 }; 670 };
@@ -559,11 +677,13 @@ export default { @@ -559,11 +677,13 @@ export default {
559 this.$emit("setQuestions"); 677 this.$emit("setQuestions");
560 this.handleClose(); 678 this.handleClose();
561 if (type) { 679 if (type) {
562 - this.$request.tPaperDetail({  
563 - paperId: res.data  
564 - }).then(detail => {  
565 - paperPrint(detail.data);  
566 - }); 680 + this.$request
  681 + .tPaperDetail({
  682 + paperId: res.data,
  683 + })
  684 + .then((detail) => {
  685 + paperPrint(detail.data);
  686 + });
567 } 687 }
568 } 688 }
569 }); 689 });
src/views/basic/askTestQuestion/wrongQuestion.vue
@@ -507,7 +507,11 @@ export default { @@ -507,7 +507,11 @@ export default {
507 507
508 // 获取科目列表 508 // 获取科目列表
509 async getSubject(params) { 509 async getSubject(params) {
  510 + console.log(params, "params");
  511 +
510 let data = await this.$request.getSubjectList(params); 512 let data = await this.$request.getSubjectList(params);
  513 + console.log(data, "--------");
  514 +
511 this.subjectList = data.data.subjectNames; 515 this.subjectList = data.data.subjectNames;
512 this.formData.subjectName = this.subjectList[0]; 516 this.formData.subjectName = this.subjectList[0];
513 this.getClassList(); 517 this.getClassList();
@@ -515,10 +519,15 @@ export default { @@ -515,10 +519,15 @@ export default {
515 // 获取年级列表 519 // 获取年级列表
516 async getGradeList() { 520 async getGradeList() {
517 let data = await this.$request.getClassList(); 521 let data = await this.$request.getClassList();
  522 + console.log(data, "----------data");
  523 +
518 this.gradeList = Array.from( 524 this.gradeList = Array.from(
519 - new Map(data.data.list.map((item) => [item.section, item])).values() 525 + new Map(data.data.list.map((item) => [item.grade, item])).values()
520 ); 526 );
  527 + console.log(this.gradeList, "gradeList");
  528 +
521 this.formData.grade = this.gradeList[0].grade; 529 this.formData.grade = this.gradeList[0].grade;
  530 + this.formData.sectionId = this.gradeList[0].section;
522 this.formData.gradeName = this.gradeList.find( 531 this.formData.gradeName = this.gradeList.find(
523 (itme) => itme.grade == this.formData.grade 532 (itme) => itme.grade == this.formData.grade
524 ).gradeName; 533 ).gradeName;
@@ -539,9 +548,12 @@ export default { @@ -539,9 +548,12 @@ export default {
539 }, 548 },
540 549
541 // 年级改变 550 // 年级改变
542 - changeGrade() { 551 + changeGrade(value) {
  552 + let item = this.gradeList.find((subItem) => subItem.grade == value);
  553 + this.formData.sectionId = item.section;
  554 + this.formData.gradeName = item.gradeName;
543 this.queryLoading = true; 555 this.queryLoading = true;
544 - this.getSubject(); 556 + this.getSubject({ gradeName: this.formData.gradeName });
545 }, 557 },
546 // 科目改变 558 // 科目改变
547 changeSubject() { 559 changeSubject() {
@@ -569,6 +581,7 @@ export default { @@ -569,6 +581,7 @@ export default {
569 const iframeRef = this.$refs["iframe" + index][0]; // 获取对应的 iframe 581 const iframeRef = this.$refs["iframe" + index][0]; // 获取对应的 iframe
570 const doc = iframeRef.contentDocument || iframeRef.contentWindow.document; 582 const doc = iframeRef.contentDocument || iframeRef.contentWindow.document;
571 const body = iframeRef.contentWindow.document.body; 583 const body = iframeRef.contentWindow.document.body;
  584 + body.style.overflowX = "hidden"; // 不允许出现横向滚动条
572 const height = body.scrollHeight; // 获取内容的高度 585 const height = body.scrollHeight; // 获取内容的高度
573 iframeRef.style.height = `${height}px`; // 设置 iframe 的高度 586 iframeRef.style.height = `${height}px`; // 设置 iframe 的高度
574 // 获取第一个P标签 587 // 获取第一个P标签