Commit e9713b69a6febaf0dfcb95c7c084b3ece0849bbf

Authored by 梁保满
1 parent d4e9b596

备题支持无大题

public/static/课件模板.docx
No preview for this file type
src/components/exportDia.vue
... ... @@ -149,7 +149,10 @@ export default {
149 149 return item.studentId;
150 150 });
151 151 }
152   - this.$emit("exportData", this.downType == 1 ? null : studentIds);
  152 + this.$emit(
  153 + "exportData",
  154 + this.downType == 1 ? null : studentIds.length == 0 ? null : studentIds
  155 + );
153 156 this.cancelSelection();
154 157 },
155 158 cancel() {
... ...
src/views/basic/test/index.vue
... ... @@ -29,7 +29,7 @@
29 29 </p>
30 30 </div>
31 31 </div>
32   - <div class="sel-item sel-item2">
  32 + <div class="sel-item sel-item2" v-if="role == 'ROLE_BANZHUREN'">
33 33 <span class="sel-label">科目:</span>
34 34 <div class="sel-d">
35 35 <p class="p-all">
... ... @@ -55,6 +55,21 @@
55 55 </p>
56 56 </div>
57 57 </div>
  58 + <div class="sel-item sel-item2" v-else>
  59 + <span class="sel-label">科目:</span>
  60 + <div class="sel-d">
  61 + <p class="sel-p">
  62 + <el-radio-group v-model="query.subjectNames" @change="CheckedSub">
  63 + <el-radio
  64 + v-for="item in subjectList"
  65 + :label="item"
  66 + :key="item"
  67 + >{{ item }}</el-radio
  68 + >
  69 + </el-radio-group>
  70 + </p>
  71 + </div>
  72 + </div>
58 73 <div class="sel-item">
59 74 <span class="sel-label">日期:</span>
60 75 <div class="d1">
... ... @@ -294,6 +309,9 @@ export default {
294 309 return;
295 310 }
296 311 let query = { ...this.query };
  312 + if (this.role != "ROLE_BANZHUREN") {
  313 + query.subjectNames = [query.subjectNames];
  314 + }
297 315 this.$router.push({
298 316 path: "/testList",
299 317 query: {
... ...
src/views/basic/test/list.vue
... ... @@ -242,6 +242,7 @@ export default {
242 242 endDay: "",
243 243 },
244 244 multipleSelection: [],
  245 + multipleSelectionObj: {},
245 246 tableData: [],
246 247 page: 1,
247 248 size: 20,
... ... @@ -269,6 +270,14 @@ export default {
269 270 this.init();
270 271 }
271 272 },
  273 + multipleSelection: {
  274 + handler: function (nVal) {
  275 + this.multipleSelectionObj[this.page] = this.tableData.filter((item) =>
  276 + nVal.includes(item.id)
  277 + );
  278 + },
  279 + deep: true,
  280 + },
272 281 },
273 282 methods: {
274 283 //初始化
... ... @@ -323,7 +332,13 @@ export default {
323 332 let subjectArr = [];
324 333 let classIds = "";
325 334 let multipleData = [];
326   - this.tableData.map((item) => {
  335 + let multipleSelectionData = [];
  336 + Object.keys(this.multipleSelectionObj).map((keys) => {
  337 + multipleSelectionData = multipleSelectionData.concat(
  338 + this.multipleSelectionObj[keys]
  339 + );
  340 + });
  341 + multipleSelectionData.map((item) => {
327 342 if (this.multipleSelection.includes(item.id)) {
328 343 subjectArr.push(item.subjectName);
329 344 multipleData.push(item);
... ...
src/views/examinationPaper/addQs.vue
... ... @@ -105,178 +105,364 @@
105 105 </ul>
106 106 <template v-for="(question, index) in form.questionList">
107 107 <ul class="questions-ul">
108   - <li
109   - v-for="(subQuestions, indexs) in question.subQuestions"
110   - :key="indexs"
111   - >
112   - <p
113   - class="set-ans-btn"
114   - v-if="
115   - subQuestions.qusType &&
116   - subQuestions.subNum &&
117   - subQuestions.subNum > 4
118   - "
119   - >
120   - <el-button type="primary" @click="setFormAns(indexs, index)"
121   - >批量设置答案</el-button
  108 + <template v-if="!question.subQuestions">
  109 + <li>
  110 + <p
  111 + class="set-ans-btn"
  112 + v-if="
  113 + question.qusType && question.subNum && question.subNum > 4
  114 + "
122 115 >
123   - </p>
124   - <div v-else class="sub-questions">
125   - <div class="qs-num">
126   - {{ setNum(index, indexs, subQuestions) }}
127   - </div>
128   - <div class="qs-type">
129   - <el-select
130   - v-model="subQuestions.questionType"
131   - placeholder="选择题目类型"
132   - @change="changeSubQuestions($event, subQuestions)"
  116 + <el-button type="primary" @click="setFormAns(index)"
  117 + >批量设置答案</el-button
133 118 >
134   - <el-option
135   - v-for="options in questionOptions"
136   - :key="options.value"
137   - :label="options.label"
138   - :value="options.value"
139   - ></el-option>
140   - </el-select>
141   - </div>
142   - <div class="qs-score">
143   - <el-input-number
144   - class="number-ipt"
145   - size="medium"
146   - :min="1"
147   - :max="200"
148   - :precision="2"
149   - v-model="subQuestions.score"
150   - label="单题分值"
151   - ></el-input-number>
152   - </div>
153   - <div class="qs-partScore">
154   - <p v-if="subQuestions.questionType != 3">--</p>
155   - <el-input-number
156   - class="number-ipt"
157   - v-else
158   - size="medium"
159   - :min="0"
160   - :precision="2"
161   - :max="subQuestions.score"
162   - :step="0.5"
163   - v-model="subQuestions.partScore"
164   - label="漏选得分"
165   - ></el-input-number>
166   - </div>
167   - <div class="qs-options qs-options2">
168   - <p v-if="subQuestions.questionType == 5">--</p>
169   - <p v-if="subQuestions.questionType == 4" class="answer-box">
170   - <span
171   - class="answer-s"
172   - :class="subQuestions.correctAnswer == 1 ? 'active' : ''"
173   - @click="subQuestions.correctAnswer = 1"
174   - >✓</span
  119 + </p>
  120 + <div v-else class="sub-questions">
  121 + <div class="qs-num">{{ question.questionIndex }}</div>
  122 + <div class="qs-type">
  123 + <el-select
  124 + v-model="question.questionType"
  125 + placeholder="选择题目类型"
  126 + @change="changeSubQuestions($event, question)"
175 127 >
176   - <span
177   - class="answer-s"
178   - :class="subQuestions.correctAnswer == 2 ? 'active' : ''"
179   - @click="subQuestions.correctAnswer = 2"
180   - >✗</span
181   - >
182   - </p>
183   - <p v-if="subQuestions.questionType == 3" class="answer-box">
184   - <span
185   - class="answer-s"
186   - v-for="option in subQuestions.answerOptions.split(',')"
187   - :class="
188   - subQuestions.correctAnswer?.includes(option)
189   - ? 'active'
190   - : ''
191   - "
192   - :key="option"
193   - @click="changAnswer(subQuestions, option)"
194   - >{{ option }}</span
195   - >
196   - </p>
197   - <p v-if="subQuestions.questionType == 2" class="answer-box">
198   - <span
199   - class="answer-s"
200   - v-for="option in subQuestions.answerOptions.split(',')"
201   - :class="
202   - subQuestions.correctAnswer == option ? 'active' : ''
  128 + <el-option
  129 + v-for="options in questionOptions"
  130 + :key="options.value"
  131 + :label="options.label"
  132 + :value="options.value"
  133 + ></el-option>
  134 + </el-select>
  135 + </div>
  136 + <div class="qs-score">
  137 + <el-input-number
  138 + class="number-ipt"
  139 + size="medium"
  140 + :min="1"
  141 + :max="200"
  142 + :precision="2"
  143 + v-model="question.score"
  144 + label="单题分值"
  145 + ></el-input-number>
  146 + </div>
  147 + <div class="qs-partScore">
  148 + <p v-if="question.questionType != 3">--</p>
  149 + <el-input-number
  150 + class="number-ipt"
  151 + v-else
  152 + size="medium"
  153 + :min="0"
  154 + :precision="2"
  155 + :max="question.score"
  156 + :step="0.5"
  157 + v-model="question.partScore"
  158 + label="漏选得分"
  159 + ></el-input-number>
  160 + </div>
  161 + <div class="qs-options qs-options2">
  162 + <p v-if="question.questionType == 5">--</p>
  163 + <p v-if="question.questionType == 4" class="answer-box">
  164 + <span
  165 + class="answer-s"
  166 + :class="question.correctAnswer == 1 ? 'active' : ''"
  167 + @click="question.correctAnswer = 1"
  168 + >✓</span
  169 + >
  170 + <span
  171 + class="answer-s"
  172 + :class="question.correctAnswer == 2 ? 'active' : ''"
  173 + @click="question.correctAnswer = 2"
  174 + >✗</span
  175 + >
  176 + </p>
  177 + <p v-if="question.questionType == 3" class="answer-box">
  178 + <span
  179 + class="answer-s"
  180 + v-for="option in question.answerOptions.split(',')"
  181 + :class="
  182 + question.correctAnswer?.includes(option)
  183 + ? 'active'
  184 + : ''
  185 + "
  186 + :key="option"
  187 + @click="changAnswer(question, option)"
  188 + >{{ option }}</span
  189 + >
  190 + </p>
  191 + <p v-if="question.questionType == 2" class="answer-box">
  192 + <span
  193 + class="answer-s"
  194 + v-for="option in question.answerOptions.split(',')"
  195 + :class="
  196 + question.correctAnswer == option ? 'active' : ''
  197 + "
  198 + :key="option"
  199 + @click="question.correctAnswer = option"
  200 + >{{ option }}</span
  201 + >
  202 + </p>
  203 + <p
  204 + v-if="
  205 + question.questionType == 3 ||
  206 + question.questionType == 2
203 207 "
204   - :key="option"
205   - @click="subQuestions.correctAnswer = option"
206   - >{{ option }}</span
  208 + class="answer-box answer-box2"
207 209 >
208   - </p>
209   - <p
210   - v-if="
211   - subQuestions.questionType == 3 ||
212   - subQuestions.questionType == 2
213   - "
214   - class="answer-box answer-box2"
215   - >
  210 + <el-button
  211 + size="mini"
  212 + type="primary"
  213 + icon="el-icon-plus"
  214 + circle
  215 + @click="addOptions(question)"
  216 + ></el-button>
  217 + <el-button
  218 + size="mini"
  219 + type="primary"
  220 + icon="el-icon-minus"
  221 + round
  222 + circle
  223 + @click="removeOptions(question)"
  224 + ></el-button>
  225 + </p>
  226 + </div>
  227 +
  228 + <div class="qs-upload">
216 229 <el-button
217   - size="mini"
  230 + class="icon-tickets"
218 231 type="primary"
219   - icon="el-icon-plus"
220 232 circle
221   - @click="addOptions(subQuestions)"
  233 + size="mini"
  234 + icon="el-icon-tickets"
  235 + @click="openStem(question, 1, index)"
222 236 ></el-button>
  237 + </div>
  238 + <div class="qs-upload">
223 239 <el-button
  240 + class="icon-tickets"
  241 + type="primary"
  242 + circle
224 243 size="mini"
  244 + icon="el-icon-tickets"
  245 + @click="openStem(question, 2, index)"
  246 + ></el-button>
  247 + </div>
  248 + <div class="qs-upload" v-if="knowledgeData.length">
  249 + <el-button
225 250 type="primary"
226   - icon="el-icon-minus"
227   - round
228 251 circle
229   - @click="removeOptions(subQuestions)"
  252 + size="mini"
  253 + icon="el-icon-price-tag"
  254 + @click="openKnowledge(question, index)"
230 255 ></el-button>
231   - </p>
232   - </div>
233   -
234   - <div class="qs-upload">
235   - <el-button
236   - class="icon-tickets"
237   - type="primary"
238   - circle
239   - size="mini"
240   - icon="el-icon-tickets"
241   - @click="openStem(subQuestions, index, indexs, 1)"
242   - ></el-button>
243   - </div>
244   - <div class="qs-upload">
245   - <el-button
246   - class="icon-tickets"
247   - type="primary"
248   - circle
249   - size="mini"
250   - icon="el-icon-tickets"
251   - @click="openStem(subQuestions, index, indexs, 2)"
252   - ></el-button>
253   - </div>
254   - <div class="qs-upload" v-if="knowledgeData.length">
255   - <el-button
256   - type="primary"
257   - circle
258   - size="mini"
259   - icon="el-icon-price-tag"
260   - @click="openKnowledge(subQuestions, index, indexs)"
261   - ></el-button>
  256 + </div>
  257 + <div class="qs-set">
  258 + <el-popconfirm
  259 + title="确定删除这道题吗?"
  260 + @confirm="delTabData(index)"
  261 + >
  262 + <el-button
  263 + slot="reference"
  264 + class="delete"
  265 + type="danger"
  266 + size="mini"
  267 + circle
  268 + icon="el-icon-delete"
  269 + ></el-button>
  270 + </el-popconfirm>
  271 + </div>
262 272 </div>
263   - <div class="qs-set">
264   - <el-popconfirm
265   - title="确定删除这道题吗?"
266   - @confirm="delTabData(indexs, index)"
  273 + </li>
  274 + </template>
  275 + <template v-else>
  276 + <li
  277 + v-for="(subQuestions, indexs) in question.subQuestions"
  278 + :key="indexs"
  279 + >
  280 + <p
  281 + class="set-ans-btn"
  282 + v-if="
  283 + subQuestions.qusType &&
  284 + subQuestions.subNum &&
  285 + subQuestions.subNum > 4
  286 + "
  287 + >
  288 + <el-button type="primary" @click="setFormAns(index, indexs)"
  289 + >批量设置答案</el-button
267 290 >
  291 + </p>
  292 + <div v-else class="sub-questions">
  293 + <div class="qs-num">
  294 + {{ setNum(index, indexs, subQuestions) }}
  295 + </div>
  296 + <div class="qs-type">
  297 + <el-select
  298 + v-model="subQuestions.questionType"
  299 + placeholder="选择题目类型"
  300 + @change="changeSubQuestions($event, subQuestions)"
  301 + >
  302 + <el-option
  303 + v-for="options in questionOptions"
  304 + :key="options.value"
  305 + :label="options.label"
  306 + :value="options.value"
  307 + ></el-option>
  308 + </el-select>
  309 + </div>
  310 + <div class="qs-score">
  311 + <el-input-number
  312 + class="number-ipt"
  313 + size="medium"
  314 + :min="1"
  315 + :max="200"
  316 + :precision="2"
  317 + v-model="subQuestions.score"
  318 + label="单题分值"
  319 + ></el-input-number>
  320 + </div>
  321 + <div class="qs-partScore">
  322 + <p v-if="subQuestions.questionType != 3">--</p>
  323 + <el-input-number
  324 + class="number-ipt"
  325 + v-else
  326 + size="medium"
  327 + :min="0"
  328 + :precision="2"
  329 + :max="subQuestions.score"
  330 + :step="0.5"
  331 + v-model="subQuestions.partScore"
  332 + label="漏选得分"
  333 + ></el-input-number>
  334 + </div>
  335 + <div class="qs-options qs-options2">
  336 + <p v-if="subQuestions.questionType == 5">--</p>
  337 + <p
  338 + v-if="subQuestions.questionType == 4"
  339 + class="answer-box"
  340 + >
  341 + <span
  342 + class="answer-s"
  343 + :class="
  344 + subQuestions.correctAnswer == 1 ? 'active' : ''
  345 + "
  346 + @click="subQuestions.correctAnswer = 1"
  347 + >✓</span
  348 + >
  349 + <span
  350 + class="answer-s"
  351 + :class="
  352 + subQuestions.correctAnswer == 2 ? 'active' : ''
  353 + "
  354 + @click="subQuestions.correctAnswer = 2"
  355 + >✗</span
  356 + >
  357 + </p>
  358 + <p
  359 + v-if="subQuestions.questionType == 3"
  360 + class="answer-box"
  361 + >
  362 + <span
  363 + class="answer-s"
  364 + v-for="option in subQuestions.answerOptions.split(
  365 + ','
  366 + )"
  367 + :class="
  368 + subQuestions.correctAnswer?.includes(option)
  369 + ? 'active'
  370 + : ''
  371 + "
  372 + :key="option"
  373 + @click="changAnswer(subQuestions, option)"
  374 + >{{ option }}</span
  375 + >
  376 + </p>
  377 + <p
  378 + v-if="subQuestions.questionType == 2"
  379 + class="answer-box"
  380 + >
  381 + <span
  382 + class="answer-s"
  383 + v-for="option in subQuestions.answerOptions.split(
  384 + ','
  385 + )"
  386 + :class="
  387 + subQuestions.correctAnswer == option ? 'active' : ''
  388 + "
  389 + :key="option"
  390 + @click="subQuestions.correctAnswer = option"
  391 + >{{ option }}</span
  392 + >
  393 + </p>
  394 + <p
  395 + v-if="
  396 + subQuestions.questionType == 3 ||
  397 + subQuestions.questionType == 2
  398 + "
  399 + class="answer-box answer-box2"
  400 + >
  401 + <el-button
  402 + size="mini"
  403 + type="primary"
  404 + icon="el-icon-plus"
  405 + circle
  406 + @click="addOptions(subQuestions)"
  407 + ></el-button>
  408 + <el-button
  409 + size="mini"
  410 + type="primary"
  411 + icon="el-icon-minus"
  412 + round
  413 + circle
  414 + @click="removeOptions(subQuestions)"
  415 + ></el-button>
  416 + </p>
  417 + </div>
  418 +
  419 + <div class="qs-upload">
268 420 <el-button
269   - slot="reference"
270   - class="delete"
271   - type="danger"
  421 + class="icon-tickets"
  422 + type="primary"
  423 + circle
  424 + size="mini"
  425 + icon="el-icon-tickets"
  426 + @click="openStem(subQuestions, 1, index, indexs)"
  427 + ></el-button>
  428 + </div>
  429 + <div class="qs-upload">
  430 + <el-button
  431 + class="icon-tickets"
  432 + type="primary"
  433 + circle
272 434 size="mini"
  435 + icon="el-icon-tickets"
  436 + @click="openStem(subQuestions, 2, index, indexs)"
  437 + ></el-button>
  438 + </div>
  439 + <div class="qs-upload" v-if="knowledgeData.length">
  440 + <el-button
  441 + type="primary"
273 442 circle
274   - icon="el-icon-delete"
  443 + size="mini"
  444 + icon="el-icon-price-tag"
  445 + @click="openKnowledge(subQuestions, index, indexs)"
275 446 ></el-button>
276   - </el-popconfirm>
  447 + </div>
  448 + <div class="qs-set">
  449 + <el-popconfirm
  450 + title="确定删除这道题吗?"
  451 + @confirm="delTabData(index, indexs)"
  452 + >
  453 + <el-button
  454 + slot="reference"
  455 + class="delete"
  456 + type="danger"
  457 + size="mini"
  458 + circle
  459 + icon="el-icon-delete"
  460 + ></el-button>
  461 + </el-popconfirm>
  462 + </div>
277 463 </div>
278   - </div>
279   - </li>
  464 + </li>
  465 + </template>
280 466 </ul>
281 467 </template>
282 468 </div>
... ... @@ -454,14 +640,21 @@
454 640 </div>
455 641 <div class="question-box">
456 642 <template v-for="question in form.questionList">
457   - <div v-for="subQuestions in question.subQuestions">
458   - <div class="screenshot-box" v-if="subQuestions.screenshot">
459   - <iframe
460   - class="screenshot"
461   - :src="subQuestions.screenshot"
462   - ></iframe>
  643 + <template v-if="!question.subQuestions">
  644 + <div class="screenshot-box" v-if="question.screenshot">
  645 + <iframe class="screenshot" :src="question.screenshot"></iframe>
463 646 </div>
464   - </div>
  647 + </template>
  648 + <template v-else>
  649 + <div v-for="subQuestions in question.subQuestions">
  650 + <div class="screenshot-box" v-if="subQuestions.screenshot">
  651 + <iframe
  652 + class="screenshot"
  653 + :src="subQuestions.screenshot"
  654 + ></iframe>
  655 + </div>
  656 + </div>
  657 + </template>
465 658 </template>
466 659 </div>
467 660 <div class="btn-box">
... ... @@ -616,11 +809,11 @@ export default {
616 809 methods: {
617 810 // v1.5
618 811 //上传截图
619   - openStem(obj, index, indexs, type) {
  812 + openStem(obj, type, index, indexs) {
620 813 this.iframeLoading = true;
  814 + this.stem.type = type;
621 815 this.stem.index = index;
622 816 this.stem.indexs = indexs;
623   - this.stem.type = type;
624 817 if (type == 1) {
625 818 if (!obj.screenshot || obj.screenshot == "") {
626 819 this.iframeLoading = false;
... ... @@ -643,14 +836,24 @@ export default {
643 836 if (res && res.status == 0) {
644 837 if (this.stem.type == 1) {
645 838 this.stem.screenshot = res.data.url;
646   - this.form.questionList[this.stem.index].subQuestions[
647   - this.stem.indexs
648   - ].screenshot = this.stem.screenshot;
  839 + if (this.form.questionList[0]?.subQuestions) {
  840 + this.form.questionList[this.stem.index].subQuestions[
  841 + this.stem.indexs
  842 + ].screenshot = this.stem.screenshot;
  843 + } else {
  844 + this.form.questionList[this.stem.index].screenshot =
  845 + this.stem.screenshot;
  846 + }
649 847 } else {
650 848 this.stem.answerScreenshot = res.data.url;
651   - this.form.questionList[this.stem.index].subQuestions[
652   - this.stem.indexs
653   - ].answerScreenshot = this.stem.answerScreenshot;
  849 + if (this.form.questionList[0]?.subQuestions) {
  850 + this.form.questionList[this.stem.index].subQuestions[
  851 + this.stem.indexs
  852 + ].answerScreenshot = this.stem.answerScreenshot;
  853 + } else {
  854 + this.form.questionList[this.stem.index].answerScreenshot =
  855 + this.stem.answerScreenshot;
  856 + }
654 857 }
655 858 this.$message.success("上传成功");
656 859 } else {
... ... @@ -662,7 +865,7 @@ export default {
662 865 this.$message.error("上传失败");
663 866 },
664 867 // 知识点
665   - openKnowledge(obj, index) {
  868 + openKnowledge(obj, index, indexs) {
666 869 this.stem.index = index;
667 870 this.stem.indexs = indexs;
668 871 this.stem.knowledge = (obj.knowledge && obj.knowledge.split("#")) || [];
... ... @@ -742,10 +945,67 @@ export default {
742 945 //整理问题
743 946 formateQuestion() {
744 947 this.formatQuestionList();
745   - this.form.questionList?.map((item) => {
  948 + if (this.form.questionList[0]?.subQuestions) {
  949 + this.form.questionList?.map((item) => {
  950 + let types = [{}];
  951 + let addndex = 0;
  952 + item.subQuestions?.map((sub, index) => {
  953 + if (!!sub.questionType) {
  954 + if (
  955 + sub.questionType == types[addndex].qusType &&
  956 + sub.questionType != 5
  957 + ) {
  958 + //同类型批量答案+1
  959 + types[addndex].subNum += 1;
  960 + if (
  961 + types[addndex].answerOptions.length < sub.answerOptions.length
  962 + ) {
  963 + types[addndex].answerOptions = sub.answerOptions;
  964 + }
  965 +
  966 + // types[addndex].answerList += this.setAnswer(
  967 + // sub.questionType,
  968 + // sub.correctAnswer
  969 + // );
  970 + types[addndex].answerList = "";
  971 + if (index == item.subQuestions.length - 1) {
  972 + //循环最后类型数量大于等于5,保存批量答案
  973 + if (types[addndex].subNum && types[addndex].subNum >= 5) {
  974 + types[addndex].endIndex = sub.questionIndex;
  975 + types[addndex].index = index;
  976 + }
  977 + }
  978 + } else {
  979 + if (types[addndex].subNum && types[addndex].subNum >= 5) {
  980 + //不同类型时如果原有类型数量大于等于5,保存批量答案
  981 + types[addndex].endIndex =
  982 + item.subQuestions[index - 1].questionIndex;
  983 + types[addndex].index = index - 1;
  984 + addndex += 1;
  985 + types[addndex] = {};
  986 + }
  987 + //不同类型初始化批量答案
  988 + types[addndex].qusType = sub.questionType;
  989 + types[addndex].subNum = 1;
  990 + types[addndex].answerOptions = sub.answerOptions;
  991 + types[addndex].answerList = "";
  992 + }
  993 + }
  994 + });
  995 + for (let i = 0; i < types.length; i++) {
  996 + if (types[i].subNum >= 5) {
  997 + item.subQuestions?.splice(
  998 + types[i].index + i + 1,
  999 + 0,
  1000 + deepClone(types[i])
  1001 + );
  1002 + }
  1003 + }
  1004 + });
  1005 + } else {
746 1006 let types = [{}];
747 1007 let addndex = 0;
748   - item.subQuestions?.map((sub, index) => {
  1008 + this.form.questionList = this.form.questionList.map((sub, index) => {
749 1009 if (!!sub.questionType) {
750 1010 if (
751 1011 sub.questionType == types[addndex].qusType &&
... ... @@ -758,13 +1018,12 @@ export default {
758 1018 ) {
759 1019 types[addndex].answerOptions = sub.answerOptions;
760 1020 }
761   -
762 1021 // types[addndex].answerList += this.setAnswer(
763 1022 // sub.questionType,
764 1023 // sub.correctAnswer
765 1024 // );
766 1025 types[addndex].answerList = "";
767   - if (index == item.subQuestions.length - 1) {
  1026 + if (index == this.form.questionList.length - 1) {
768 1027 //循环最后类型数量大于等于5,保存批量答案
769 1028 if (types[addndex].subNum && types[addndex].subNum >= 5) {
770 1029 types[addndex].endIndex = sub.questionIndex;
... ... @@ -775,7 +1034,7 @@ export default {
775 1034 if (types[addndex].subNum && types[addndex].subNum >= 5) {
776 1035 //不同类型时如果原有类型数量大于等于5,保存批量答案
777 1036 types[addndex].endIndex =
778   - item.subQuestions[index - 1].questionIndex;
  1037 + this.form.questionList[index - 1].questionIndex;
779 1038 types[addndex].index = index - 1;
780 1039 addndex += 1;
781 1040 types[addndex] = {};
... ... @@ -787,35 +1046,56 @@ export default {
787 1046 types[addndex].answerList = "";
788 1047 }
789 1048 }
  1049 + return sub;
790 1050 });
791 1051 for (let i = 0; i < types.length; i++) {
  1052 + if (types[i].qusType == 3) {
  1053 + types[i].answerList = types[i].answerList.slice(0, -1);
  1054 + }
792 1055 if (types[i].subNum >= 5) {
793   - item.subQuestions?.splice(
  1056 + this.form.questionList.splice(
794 1057 types[i].index + i + 1,
795 1058 0,
796 1059 deepClone(types[i])
797 1060 );
798 1061 }
799 1062 }
800   - });
  1063 + }
801 1064 },
802 1065 //初始化要修改的答案
803   - setFormAns(indexs, index) {
804   - this.formAns = { ...this.form.questionList[index].subQuestions[indexs] };
805   - this.formAns.listIndex = index;
  1066 + setFormAns(index, indexs) {
806 1067 let answerList = "";
807   - let startIndex = indexs - this.formAns.subNum; //批量设置大难开始位置
808   - this.form.questionList[index].subQuestions.map((item, subIdx) => {
809   - if (subIdx >= startIndex && subIdx < indexs) {
810   - answerList += this.setAnswer(item.questionType, item.correctAnswer);
811   -
812   - if (item.qusType == 3) {
813   - answerList = answerList.slice(0, -1);
  1068 + if (this.form.questionList[0]?.subQuestions) {
  1069 + this.formAns = {
  1070 + ...this.form.questionList[index].subQuestions[indexs],
  1071 + };
  1072 + this.formAns.listIndex = index;
  1073 + let startIndex = indexs - this.formAns.subNum; //批量设置大难开始位置
  1074 + this.form.questionList[index].subQuestions.map((item, subIdx) => {
  1075 + if (subIdx >= startIndex && subIdx < indexs) {
  1076 + answerList += this.setAnswer(item.questionType, item.correctAnswer);
  1077 +
  1078 + if (item.qusType == 3) {
  1079 + answerList = answerList.slice(0, -1);
  1080 + }
814 1081 }
815   - }
816   - });
817   - this.formAns.answerList = answerList;
  1082 + });
  1083 + } else {
  1084 + this.formAns = { ...this.form.questionList[index] };
  1085 + let startIndex = index - this.formAns.subNum; //批量设置开始位置
  1086 + this.formAns.answerList = [];
  1087 + this.formAns.listIndex = index;
  1088 + this.form.questionList.map((item, subIdx) => {
  1089 + if (subIdx >= startIndex && subIdx < index) {
  1090 + answerList += this.setAnswer(item.questionType, item.correctAnswer);
  1091 + if (item.qusType == 3) {
  1092 + answerList = answerList.slice(0, -1);
  1093 + }
  1094 + }
  1095 + });
  1096 + }
818 1097  
  1098 + this.formAns.answerList = answerList;
819 1099 this.diaSetAns = true;
820 1100 },
821 1101 insertTxtAndSetcursor(element, answerList, str) {
... ... @@ -992,20 +1272,31 @@ export default {
992 1272 //删除批量操作数据
993 1273 formatQuestionList() {
994 1274 for (let i = 0; i < this.form.questionList.length; i++) {
995   - for (
996   - let j = 0;
997   - j < this.form.questionList[i].subQuestions?.length;
998   - j++
999   - ) {
1000   - if (this.form.questionList[i].subQuestions[j]?.qusType) {
1001   - this.form.questionList[i].subQuestions?.splice(j, 1);
  1275 + if (this.form.questionList[0]?.subQuestions) {
  1276 + for (
  1277 + let j = 0;
  1278 + j < this.form.questionList[i].subQuestions?.length;
  1279 + j++
  1280 + ) {
  1281 + if (this.form.questionList[i].subQuestions[j]?.qusType) {
  1282 + this.form.questionList[i].subQuestions?.splice(j, 1);
  1283 + }
  1284 + }
  1285 + } else {
  1286 + if (this.form.questionList[i].qusType) {
  1287 + this.form.questionList.splice(i, 1);
  1288 + i--;
1002 1289 }
1003 1290 }
1004 1291 }
1005 1292 },
1006 1293 //删除题
1007   - delTabData(subIndex, index) {
1008   - this.form.questionList[index].subQuestions.splice(subIndex, 1);
  1294 + delTabData(index, subIndex) {
  1295 + if (this.form.questionList[0].subQuestions) {
  1296 + this.form.questionList[index].subQuestions.splice(subIndex, 1);
  1297 + } else {
  1298 + this.form.questionList[index].splice(subIndex, 1);
  1299 + }
1009 1300 this.formateQuestion();
1010 1301 },
1011 1302 //切换题型
... ... @@ -1188,22 +1479,28 @@ export default {
1188 1479 }
1189 1480 }
1190 1481 this.form.questionList = data.questionList?.map((item) => {
1191   - let subQuestions =
1192   - item.subQuestions?.map((items) => {
1193   - return {
1194   - ...items,
1195   - selectNum: items.answerOptions?.split(",").length,
1196   - answerOptions: items.answerOptions || "A,B,C,D",
1197   - screenshot: items.screenshot || "",
1198   - correctAnswer: items.correctAnswer || "",
1199   - knowledge: items.knowledge || "",
1200   - };
1201   - }) || [];
1202   - return {
1203   - questionTitle: item.questionTitle,
1204   - subQuestions: subQuestions,
1205   - show: false,
1206   - };
  1482 + if (item.subQuestions) {
  1483 + let subQuestions =
  1484 + item.subQuestions?.map((items) => {
  1485 + return {
  1486 + ...items,
  1487 + selectNum: items.answerOptions?.split(",").length,
  1488 + answerOptions: items.answerOptions || "A,B,C,D",
  1489 + screenshot: items.screenshot || "",
  1490 + correctAnswer: items.correctAnswer || "",
  1491 + knowledge: items.knowledge || "",
  1492 + };
  1493 + }) || [];
  1494 + return {
  1495 + questionTitle: item.questionTitle,
  1496 + subQuestions: subQuestions,
  1497 + show: false,
  1498 + };
  1499 + } else {
  1500 + return {
  1501 + ...item,
  1502 + };
  1503 + }
1207 1504 });
1208 1505 },
1209 1506 },
... ...