Commit c412d95df69de6c193f5e2f62467a72a0430a2a1

Authored by 刘有才luck
1 parent adea2553

wip: 代码提交

src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue
@@ -275,6 +275,13 @@ export default { @@ -275,6 +275,13 @@ export default {
275 return null; 275 return null;
276 }, 276 },
277 }, 277 },
  278 + userId: {
  279 + // uid
  280 + type: [String, Number],
  281 + default() {
  282 + return null;
  283 + },
  284 + },
278 }, 285 },
279 data() { 286 data() {
280 return { 287 return {
@@ -303,26 +310,32 @@ export default { @@ -303,26 +310,32 @@ export default {
303 visible(val) { 310 visible(val) {
304 if (val) { 311 if (val) {
305 // 上面数据测试 312 // 上面数据测试
306 - this.testData = JSON.parse(localStorage.getItem("testData")) || [];  
307 - this.groups = JSON.parse(localStorage.getItem("question")) || []; 313 + this.testData =
  314 + JSON.parse(localStorage.getItem(this.userId + "testData")) || [];
  315 + this.groups =
  316 + JSON.parse(localStorage.getItem(this.userId + "question")) || [];
308 // 如果都没有直接return 执行初始化 317 // 如果都没有直接return 执行初始化
309 if (this.groups.length == 0) { 318 if (this.groups.length == 0) {
310 this.init(); 319 this.init();
311 - localStorage.setItem("testData", JSON.stringify(this.list)); 320 + localStorage.setItem(
  321 + this.userId + "testData",
  322 + JSON.stringify(this.list)
  323 + );
312 return; 324 return;
313 } 325 }
314 // 如果一致 就直接赋值 326 // 如果一致 就直接赋值
315 if ( 327 if (
316 this.arraysHaveSameIds(this.testData, this.list) && 328 this.arraysHaveSameIds(this.testData, this.list) &&
317 - JSON.parse(localStorage.getItem("question")) 329 + JSON.parse(localStorage.getItem(this.userId + "question"))
318 ) { 330 ) {
319 - console.log("一致");  
320 return; 331 return;
321 } else { 332 } else {
322 - console.log("不一致", this.testData, this.list);  
323 let data = this.findMissingIds(this.testData, this.list); 333 let data = this.findMissingIds(this.testData, this.list);
324 this.testData = this.list; 334 this.testData = this.list;
325 - localStorage.setItem("testData", JSON.stringify(this.testData)); 335 + localStorage.setItem(
  336 + this.userId + "testData",
  337 + JSON.stringify(this.testData)
  338 + );
326 this.testAddDel(this.groups, data.addArr, data.delArr); 339 this.testAddDel(this.groups, data.addArr, data.delArr);
327 } 340 }
328 } else { 341 } else {
@@ -349,7 +362,10 @@ export default { @@ -349,7 +362,10 @@ export default {
349 this.groups.reduce((accumulator, current) => { 362 this.groups.reduce((accumulator, current) => {
350 return accumulator.concat(current.subQuestionIds); 363 return accumulator.concat(current.subQuestionIds);
351 }, []) || []; 364 }, []) || [];
352 - localStorage.setItem("testData", JSON.stringify(this.testData)); 365 + localStorage.setItem(
  366 + this.userId + "testData",
  367 + JSON.stringify(this.testData)
  368 + );
353 }, 369 },
354 /** 按钮 - 取消 */ 370 /** 按钮 - 取消 */
355 handleClose() { 371 handleClose() {
@@ -373,7 +389,10 @@ export default { @@ -373,7 +389,10 @@ export default {
373 allItems.forEach((item, index) => { 389 allItems.forEach((item, index) => {
374 item.globalIndex = index + 1; 390 item.globalIndex = index + 1;
375 }); 391 });
376 - localStorage.setItem("question", JSON.stringify(this.groups)); 392 + localStorage.setItem(
  393 + this.userId + "question",
  394 + JSON.stringify(this.groups)
  395 + );
377 }, 396 },
378 classifyByType(arr) { 397 classifyByType(arr) {
379 const result = {}; 398 const result = {};
@@ -424,7 +443,10 @@ export default { @@ -424,7 +443,10 @@ export default {
424 // 保存修改后的内容,回车或失去焦点时触发 443 // 保存修改后的内容,回车或失去焦点时触发
425 save() { 444 save() {
426 this.isEditing = false; 445 this.isEditing = false;
427 - localStorage.setItem("question", JSON.stringify(this.groups)); 446 + localStorage.setItem(
  447 + this.userId + "question",
  448 + JSON.stringify(this.groups)
  449 + );
428 }, 450 },
429 451
430 // 单题title修改 452 // 单题title修改
@@ -441,7 +463,10 @@ export default { @@ -441,7 +463,10 @@ export default {
441 // 单体title保存 463 // 单体title保存
442 groupSave(index) { 464 groupSave(index) {
443 this.$set(this.groups[index], "input", false); 465 this.$set(this.groups[index], "input", false);
444 - localStorage.setItem("question", JSON.stringify(this.groups)); 466 + localStorage.setItem(
  467 + this.userId + "question",
  468 + JSON.stringify(this.groups)
  469 + );
445 }, 470 },
446 // 高亮 471 // 高亮
447 selectItem(id, type) { 472 selectItem(id, type) {
@@ -459,10 +484,16 @@ export default { @@ -459,10 +484,16 @@ export default {
459 let _index = this.groups.findIndex((item) => item.questionType == id); 484 let _index = this.groups.findIndex((item) => item.questionType == id);
460 if (_index != -1) { 485 if (_index != -1) {
461 this.groups.splice(_index, 1); 486 this.groups.splice(_index, 1);
462 - localStorage.setItem("question", JSON.stringify(this.groups)); 487 + localStorage.setItem(
  488 + this.userId + "question",
  489 + JSON.stringify(this.groups)
  490 + );
463 this.updateGlobalIndexes(); 491 this.updateGlobalIndexes();
464 this.testDataFun(); 492 this.testDataFun();
465 - localStorage.setItem("testlist", JSON.stringify(this.testData)); 493 + localStorage.setItem(
  494 + this.userId + "testlist",
  495 + JSON.stringify(this.testData)
  496 + );
466 this.$emit("setQuestions"); 497 this.$emit("setQuestions");
467 } 498 }
468 } else { 499 } else {
@@ -473,10 +504,16 @@ export default { @@ -473,10 +504,16 @@ export default {
473 ); 504 );
474 } 505 }
475 }); 506 });
476 - localStorage.setItem("question", JSON.stringify(this.groups)); 507 + localStorage.setItem(
  508 + this.userId + "question",
  509 + JSON.stringify(this.groups)
  510 + );
477 this.updateGlobalIndexes(); 511 this.updateGlobalIndexes();
478 this.testDataFun(); 512 this.testDataFun();
479 - localStorage.setItem("testlist", JSON.stringify(this.testData)); 513 + localStorage.setItem(
  514 + this.userId + "testlist",
  515 + JSON.stringify(this.testData)
  516 + );
480 this.$emit("setQuestions"); 517 this.$emit("setQuestions");
481 } 518 }
482 }, 519 },
@@ -620,8 +657,6 @@ export default { @@ -620,8 +657,6 @@ export default {
620 let matchedArray1Item = arr1.find((item1) => 657 let matchedArray1Item = arr1.find((item1) =>
621 item1.subQuestionIds.filter((item) => item.id == item3.id) 658 item1.subQuestionIds.filter((item) => item.id == item3.id)
622 ); 659 );
623 - console.log(matchedArray1Item, "matchedArray1Item");  
624 -  
625 if (matchedArray1Item) { 660 if (matchedArray1Item) {
626 // 如果找到了匹配的 type,遍历 matchedArray1Item 的 items 661 // 如果找到了匹配的 type,遍历 matchedArray1Item 的 items
627 let _index = matchedArray1Item.subQuestionIds.findIndex( 662 let _index = matchedArray1Item.subQuestionIds.findIndex(
@@ -682,8 +717,14 @@ export default { @@ -682,8 +717,14 @@ export default {
682 if (res.status == 0) { 717 if (res.status == 0) {
683 this.groups = []; 718 this.groups = [];
684 this.testData = []; 719 this.testData = [];
685 - localStorage.setItem("testlist", JSON.stringify(this.testData));  
686 - localStorage.setItem("question", JSON.stringify(this.groups)); 720 + localStorage.setItem(
  721 + this.userId + "testlist",
  722 + JSON.stringify(this.testData)
  723 + );
  724 + localStorage.setItem(
  725 + this.userId + "question",
  726 + JSON.stringify(this.groups)
  727 + );
687 this.$emit("setQuestions"); 728 this.$emit("setQuestions");
688 this.handleClose(); 729 this.handleClose();
689 if (type == "print") { 730 if (type == "print") {
@@ -714,8 +755,15 @@ export default { @@ -714,8 +755,15 @@ export default {
714 .then(() => { 755 .then(() => {
715 this.groups = []; 756 this.groups = [];
716 this.testDataFun(); 757 this.testDataFun();
717 - localStorage.setItem("question", JSON.stringify(this.groups));  
718 - localStorage.setItem("testlist", JSON.stringify(this.testData)); 758 + localStorage.setItem(
  759 + this.userId + "question",
  760 + JSON.stringify(this.groups)
  761 + );
  762 + localStorage.setItem(
  763 + this.userId + "testlist",
  764 + JSON.stringify(this.testData)
  765 + );
  766 +
719 this.$emit("setQuestions"); 767 this.$emit("setQuestions");
720 }) 768 })
721 .catch(() => { 769 .catch(() => {
@@ -736,7 +784,10 @@ export default { @@ -736,7 +784,10 @@ export default {
736 784
737 // 当分数发生变化的时候 785 // 当分数发生变化的时候
738 handleInput() { 786 handleInput() {
739 - localStorage.setItem("question", JSON.stringify(this.groups)); 787 + localStorage.setItem(
  788 + this.userId + "question",
  789 + JSON.stringify(this.groups)
  790 + );
740 }, 791 },
741 }, 792 },
742 }; 793 };
src/views/basic/askTestQuestion/wrongQuestion.vue
@@ -247,6 +247,7 @@ @@ -247,6 +247,7 @@
247 :sectionId="formData.sectionId" 247 :sectionId="formData.sectionId"
248 :gradeId="formData.grade" 248 :gradeId="formData.grade"
249 @setQuestions="setQuestions" 249 @setQuestions="setQuestions"
  250 + :userId="userId"
250 /> 251 />
251 <analysisDialog 252 <analysisDialog
252 :visible.sync="analysisVisible" 253 :visible.sync="analysisVisible"
@@ -316,18 +317,25 @@ export default { @@ -316,18 +317,25 @@ export default {
316 grade: null, // 年级 317 grade: null, // 年级
317 gradeName: null, // 年级名称 318 gradeName: null, // 年级名称
318 }, 319 },
  320 + userId: "",
319 questions: [], 321 questions: [],
320 }; 322 };
321 }, 323 },
322 created() { 324 created() {
  325 + let user = JSON.parse(localStorage.getItem("info"));
  326 + this.userId = user.uid;
323 this.handleDate(this.formData.type); 327 this.handleDate(this.formData.type);
324 this.queryLoading = true; 328 this.queryLoading = true;
325 this.getGradeList(); 329 this.getGradeList();
326 - if (!localStorage.getItem("testlist")) {  
327 - localStorage.setItem("testlist", JSON.stringify(this.questions)); 330 + if (!localStorage.getItem(this.userId + "testlist")) {
  331 + localStorage.setItem(
  332 + this.userId + "testlist",
  333 + JSON.stringify(this.questions)
  334 + );
328 } else { 335 } else {
329 - this.questions = JSON.parse(localStorage.getItem("testlist"));  
330 - console.log(this.questions, "==="); 336 + this.questions = JSON.parse(
  337 + localStorage.getItem(this.userId + "testlist")
  338 + );
331 } 339 }
332 }, 340 },
333 methods: { 341 methods: {
@@ -458,43 +466,56 @@ export default { @@ -458,43 +466,56 @@ export default {
458 handleAddTest(item) { 466 handleAddTest(item) {
459 // if (this.questions.includes(item.id)) return; 467 // if (this.questions.includes(item.id)) return;
460 if (this.questions.some((obj) => obj.id === item.id)) return; 468 if (this.questions.some((obj) => obj.id === item.id)) return;
461 - this.questions = JSON.parse(localStorage.getItem("testlist")) || []; 469 + this.questions =
  470 + JSON.parse(localStorage.getItem(this.userId + "testlist")) || [];
462 this.questions.push(item); 471 this.questions.push(item);
463 - localStorage.setItem("testlist", JSON.stringify(this.questions)); 472 + localStorage.setItem(
  473 + this.userId + "testlist",
  474 + JSON.stringify(this.questions)
  475 + );
464 }, 476 },
465 // 移除试卷 477 // 移除试卷
466 handleDel(item) { 478 handleDel(item) {
467 let _index = this.questions.findIndex((obj) => obj.id === item.id); 479 let _index = this.questions.findIndex((obj) => obj.id === item.id);
468 if (_index !== -1) { 480 if (_index !== -1) {
469 this.questions.splice(_index, 1); // 从索引位置删除一个元素 481 this.questions.splice(_index, 1); // 从索引位置删除一个元素
470 - localStorage.setItem("testlist", JSON.stringify(this.questions)); 482 + localStorage.setItem(
  483 + this.userId + "testlist",
  484 + JSON.stringify(this.questions)
  485 + );
471 } 486 }
472 }, 487 },
473 // 全部选中 488 // 全部选中
474 handleAllTest() { 489 handleAllTest() {
475 // 获取原来的localStorage 490 // 获取原来的localStorage
476 - let list = JSON.parse(localStorage.getItem("testlist")) || []; 491 + let list =
  492 + JSON.parse(localStorage.getItem(this.userId + "testlist")) || [];
477 493
478 let ids = this.topicList.map((item) => { 494 let ids = this.topicList.map((item) => {
479 return item; 495 return item;
480 }); 496 });
481 - console.log(list, "-=-11-=");  
482 -  
483 this.questions = this.removeDuplicates([...ids, ...list]); 497 this.questions = this.removeDuplicates([...ids, ...list]);
484 - localStorage.setItem("testlist", JSON.stringify(this.questions)); 498 + localStorage.setItem(
  499 + this.userId + "testlist",
  500 + JSON.stringify(this.questions)
  501 + );
485 }, 502 },
486 // 全部删除 503 // 全部删除
487 handleDelTest() { 504 handleDelTest() {
488 let list = this.removeMatchingValues(this.topicList, this.questions); 505 let list = this.removeMatchingValues(this.topicList, this.questions);
489 this.questions = list; 506 this.questions = list;
490 - console.log("移除本业", this.questions);  
491 -  
492 - localStorage.setItem("testlist", JSON.stringify(this.questions)); 507 + localStorage.setItem(
  508 + this.userId + "testlist",
  509 + JSON.stringify(this.questions)
  510 + );
493 }, 511 },
494 // 重置 去除locastorage 以及 questions 512 // 重置 去除locastorage 以及 questions
495 handleRest() { 513 handleRest() {
496 this.questions = []; 514 this.questions = [];
497 - localStorage.setItem("testlist", JSON.stringify(this.questions)); 515 + localStorage.setItem(
  516 + this.userId + "testlist",
  517 + JSON.stringify(this.questions)
  518 + );
498 }, 519 },
499 // 去重 520 // 去重
500 removeDuplicates(arr) { 521 removeDuplicates(arr) {
@@ -532,27 +553,17 @@ export default { @@ -532,27 +553,17 @@ export default {
532 553
533 // 获取科目列表 554 // 获取科目列表
534 async getSubject(params) { 555 async getSubject(params) {
535 - console.log(params, "params");  
536 -  
537 let data = await this.$request.getSubjectList(params); 556 let data = await this.$request.getSubjectList(params);
538 - console.log(data, "--------");  
539 -  
540 this.subjectList = data.data.subjectNames; 557 this.subjectList = data.data.subjectNames;
541 - console.log(this.subjectList, "我被打印了");  
542 -  
543 this.formData.subjectName = this.subjectList[0]; 558 this.formData.subjectName = this.subjectList[0];
544 this.getClassList(); 559 this.getClassList();
545 }, 560 },
546 // 获取年级列表 561 // 获取年级列表
547 async getGradeList() { 562 async getGradeList() {
548 let data = await this.$request.getClassList(); 563 let data = await this.$request.getClassList();
549 - console.log(data, "----------data");  
550 -  
551 this.gradeList = Array.from( 564 this.gradeList = Array.from(
552 new Map(data.data.list.map((item) => [item.grade, item])).values() 565 new Map(data.data.list.map((item) => [item.grade, item])).values()
553 ); 566 );
554 - console.log(this.gradeList, "gradeList");  
555 -  
556 this.formData.grade = this.gradeList[0].grade; 567 this.formData.grade = this.gradeList[0].grade;
557 this.formData.sectionId = this.gradeList[0].section; 568 this.formData.sectionId = this.gradeList[0].section;
558 this.formData.gradeName = this.gradeList.find( 569 this.formData.gradeName = this.gradeList.find(
@@ -562,8 +573,6 @@ export default { @@ -562,8 +573,6 @@ export default {
562 }, 573 },
563 // 获取班级信息 574 // 获取班级信息
564 async getClassList() { 575 async getClassList() {
565 - console.log(this.formData, "this.formDate");  
566 -  
567 let data = await this.$request.getGradeList({ 576 let data = await this.$request.getGradeList({
568 grade: this.formData.grade, 577 grade: this.formData.grade,
569 subjectName: this.formData.subjectName, 578 subjectName: this.formData.subjectName,
@@ -632,7 +641,8 @@ export default { @@ -632,7 +641,8 @@ export default {
632 641
633 // 子集删除后 父级需要更新 642 // 子集删除后 父级需要更新
634 setQuestions() { 643 setQuestions() {
635 - this.questions = JSON.parse(localStorage.getItem("testlist")) || []; 644 + this.questions =
  645 + JSON.parse(localStorage.getItem(this.userId + "testlist")) || [];
636 }, 646 },
637 647
638 // 查看解析 648 // 查看解析