Commit 8f573b82501c0067d9b6dad6b009de94c38fc1dc

Authored by 阿宝
1 parent 6fffbd55

组卷接口联调

package.json
... ... @@ -8,17 +8,18 @@
8 8 "lint": "vue-cli-service lint"
9 9 },
10 10 "dependencies": {
  11 + "axios": "^0.21.1",
11 12 "core-js": "^3.6.5",
12 13 "echarts": "5.3.2",
13 14 "element-ui": "^2.15.1",
  15 + "font-awesome": "^4.7.0",
14 16 "js-cookie": "^2.2.0",
15 17 "jsencrypt": "^3.2.0",
16 18 "nprogress": "^0.2.0",
17   - "font-awesome": "^4.7.0",
  19 + "script-ext-html-webpack-plugin": "^2.1.5",
18 20 "vue": "^2.6.11",
19 21 "vue-i18n": "^8.4.0",
20 22 "vue-router": "^3.5.1",
21   - "axios": "^0.21.1",
22 23 "vuex": "^3.6.2"
23 24 },
24 25 "devDependencies": {
... ... @@ -26,8 +27,8 @@
26 27 "@vue/cli-service": "~4.5.0",
27 28 "autoprefixer": "^7.1.2",
28 29 "babel-core": "^6.22.1",
29   - "babel-loader": "^7.1.1",
30 30 "babel-eslint": "^10.1.0",
  31 + "babel-loader": "^7.1.1",
31 32 "babel-polyfill": "^6.26.0",
32 33 "eslint": "^6.7.2",
33 34 "eslint-plugin-vue": "^6.2.2",
... ... @@ -35,11 +36,11 @@
35 36 "html-webpack-plugin": "^4.2.0",
36 37 "mini-css-extract-plugin": "^0.9.0",
37 38 "node-sass": "^4.13.0",
38   - "sass-loader": "^7.1.0",
  39 + "optimize-css-assets-webpack-plugin": "^3.2.0",
39 40 "postcss-import": "^12.0.1",
40 41 "postcss-loader": "^3.0.0",
41 42 "postcss-url": "^7.2.1",
42   - "optimize-css-assets-webpack-plugin": "^3.2.0",
  43 + "sass-loader": "^7.1.0",
43 44 "vue-template-compiler": "^2.5.2"
44 45 }
45 46 }
... ...
src/api/axios.js
1   -import axios from "axios"
2   -import Cookies from "js-cookie"
3   -import NProgress from "nprogress"
4   -import { Message } from "element-ui"
5   -import router from "@/router/index"
6   -import store from "@/store"
  1 +import axios from "axios";
  2 +import Cookies from "js-cookie";
  3 +import NProgress from "nprogress";
  4 +import { Message } from "element-ui";
  5 +import router from "@/router/index";
  6 +import store from "@/store";
7 7 import conf from "../config/index"; // 路径配置
8 8 // axios默认配置
9 9 const service = axios.create({
... ... @@ -12,86 +12,84 @@ const service = axios.create({
12 12 withCredentials: true,
13 13 });
14 14 // http request 拦截器
15   -service.interceptors.request.use(config => {
16   - NProgress.start()
17   - config.headers["Content-Type"] = "application/json;charset=UTF-8"
  15 +service.interceptors.request.use(
  16 + (config) => {
  17 + NProgress.start();
  18 + config.headers["Content-Type"] = "application/json;charset=UTF-8";
18 19  
19   - const source = axios.CancelToken.source();
20   - store.commit('setTokenSources', [source.token, source.cancel])
21   - config.cancelToken = source.token;
22   - // if (Cookies.get("access_token")) {
23   - // config.headers.Authorization = "Bearer" + Cookies.get("access_token")
24   - // }
25   - return config
26   -},
27   - error => {
28   - return Promise.reject(error.response)
29   - })
  20 + const source = axios.CancelToken.source();
  21 + store.commit("setTokenSources", [source.token, source.cancel]);
  22 + config.cancelToken = source.token;
  23 + // if (Cookies.get("access_token")) {
  24 + // config.headers.Authorization = "Bearer" + Cookies.get("access_token")
  25 + // }
  26 + return config;
  27 + },
  28 + (error) => {
  29 + return Promise.reject(error.response);
  30 + }
  31 +);
30 32  
31 33 // http response 拦截器
32 34 service.interceptors.response.use(
33   - response => {
  35 + (response) => {
34 36 const res = response.data;
35   - NProgress.done()
  37 + NProgress.done();
36 38 if (response.config.cancelToken) {
37   - store.commit('delTokenSources', response.config.cancelToken)
  39 + store.commit("delTokenSources", response.config.cancelToken);
38 40 }
39 41 if (response.status == 200) {
40 42 // Cookies.set("access_token", response.data.message, { expires: 1 / 12 })
41 43 // console.log(response.status)
42   - if (res.code == 999) {
43   - if (!location.href.includes('localhost')) {
  44 + if (res.status == 999) {
  45 + // if (!location.href.includes("localhost")) {
44 46 if (res.data) {
45   - window.location.href = res.data
  47 + window.location.href = res.data;
46 48 } else {
47   - router.push({ path: '/login' })
48   - if (res.message.includes('不存在')) {
  49 + router.push({ path: "/login" });
  50 + if (res.message.includes("不存在")) {
49 51 Message({
50 52 message: res.message,
51   - type: 'error',
52   - duration: 3 * 1000
53   - })
  53 + type: "error",
  54 + duration: 3 * 1000,
  55 + });
54 56 }
55 57 }
56   - }
57   - return
  58 + // }
58 59 } else {
59 60 // Cookies.set("access_token", response.data.message, { expires: 1 / 12 })
60 61 }
61 62 }
62   - console.log(response)
63   - return Promise.resolve(res)
  63 + return Promise.resolve(res);
64 64 },
65   - error => {
  65 + (error) => {
66 66 Message({
67   - message: error.message,
68   - type: 'error',
69   - duration: 3 * 1000
70   - })
  67 + message: error,
  68 + type: "error",
  69 + duration: 3 * 1000,
  70 + });
71 71 if (error.response == undefined) {
72 72 return Promise.reject(error);
73 73 }
74   - Message.closeAll()
75   - const {
76   - data,
77   - status
78   - } = error.response
  74 + const { data, status } = error.response;
79 75 if (status === 403 || status === 401) {
  76 + Message.closeAll();
80 77 Message({
81   - message: data.info||"未登录或登录超时,即将跳转到登录页面",
82   - type: 'error',
83   - duration: 3 * 1000
84   - })
85   - if (!window.location.href.includes('login')) {
  78 + message: data.info || "未登录或登录超时,即将跳转到登录页面",
  79 + type: "error",
  80 + duration: 3 * 1000,
  81 + });
  82 + if (!window.location.href.includes("login")) {
86 83 router.push({
87   - path: '/login',
  84 + path: "/login",
88 85 query: {
89   - url: window.location.href
90   - }
91   - })
  86 + url: window.location.href,
  87 + },
  88 + });
92 89 }
93   - return
  90 + return;
94 91 }
95   - return Promise.reject(error.response) // 返回接口返回的错误信息
96   - })
97   -export default service
  92 + return Promise.reject(error.response); // 返回接口返回的错误信息
  93 + }
  94 +);
  95 +export default service;
... ...
src/views/examinationPaper/add.vue
... ... @@ -78,7 +78,7 @@
78 78 :key="item.value"
79 79 :label="item.label"
80 80 :value="item.value"
81   - >
  81 + >{{ item.label }}
82 82 </el-option>
83 83 </el-select>
84 84 </el-form-item>
... ... @@ -470,7 +470,7 @@ export default {
470 470 { label: "判断题", value: 4 },
471 471 { label: "主观题", value: 5 },
472 472 ],
473   - rightOptions: ["A","B","C","D","E","F","G"],
  473 + rightOptions: ["A", "B", "C", "D", "E", "F", "G"],
474 474 addSubQuestionsType: "",
475 475 step: 0, //步骤
476 476 gradeList: [], //年级
... ... @@ -509,8 +509,9 @@ export default {
509 509 };
510 510 },
511 511 async created() {
512   - await this._GradeList()
513   - await this._CreatedTypeList()
  512 + await this._GradeList();
  513 + await this._QuerySubjectList(this.gradeList[0]);
  514 + await this._TypeList();
514 515 this.type = this.$route.query.type ? this.$route.query.type : 1;
515 516 if (this.type == 2) {
516 517 this._QueryDetail();
... ... @@ -630,16 +631,14 @@ export default {
630 631 };
631 632 switch (questionsOptions.questionType) {
632 633 case 2:
633   - questionsOptions.answerOptions = this.rightOptions.slice(
634   - 0,
635   - questionsOptions.selectNum
636   - ).join(',');
  634 + questionsOptions.answerOptions = this.rightOptions
  635 + .slice(0, questionsOptions.selectNum)
  636 + .join(",");
637 637 break;
638 638 case 3:
639   - questionsOptions.answerOptions = this.rightOptions.slice(
640   - 0,
641   - questionsOptions.selectNum
642   - ).join(',');
  639 + questionsOptions.answerOptions = this.rightOptions
  640 + .slice(0, questionsOptions.selectNum)
  641 + .join(",");
643 642 questionsOptions.partScore = 0.5;
644 643 break;
645 644 case 4:
... ... @@ -678,16 +677,14 @@ export default {
678 677 };
679 678 switch (questionsOptions.questionType) {
680 679 case 2:
681   - questionsOptions.answerOptions = this.rightOptions.slice(
682   - 0,
683   - questionsOptions.selectNum
684   - ).join(',');
  680 + questionsOptions.answerOptions = this.rightOptions
  681 + .slice(0, questionsOptions.selectNum)
  682 + .join(",");
685 683 break;
686 684 case 3:
687   - questionsOptions.answerOptions = this.rightOptions.slice(
688   - 0,
689   - questionsOptions.selectNum
690   - ).join(',');
  685 + questionsOptions.answerOptions = this.rightOptions
  686 + .slice(0, questionsOptions.selectNum)
  687 + .join(",");
691 688 questionsOptions.partScore = 0.5;
692 689 break;
693 690 case 4:
... ... @@ -708,16 +705,14 @@ export default {
708 705 subQuestions.selectNum = 4;
709 706 switch (val) {
710 707 case 2:
711   - subQuestions.answerOptions = that.rightOptions.slice(
712   - 0,
713   - subQuestions.selectNum
714   - ).join(',');
  708 + subQuestions.answerOptions = that.rightOptions
  709 + .slice(0, subQuestions.selectNum)
  710 + .join(",");
715 711 break;
716 712 case 3:
717   - subQuestions.answerOptions = that.rightOptions.slice(
718   - 0,
719   - subQuestions.selectNum
720   - ).join(',');
  713 + subQuestions.answerOptions = that.rightOptions
  714 + .slice(0, subQuestions.selectNum)
  715 + .join(",");
721 716 subQuestions.partScore = 0.5;
722 717 break;
723 718 case 4:
... ... @@ -728,23 +723,21 @@ export default {
728 723 },
729 724 addOptions(subQuestions) {
730 725 //添加选项
731   - let length = subQuestions.answerOptions.split(',').length;
  726 + let length = subQuestions.answerOptions.split(",").length;
732 727 if (length > 6) return;
733 728 subQuestions.selectNum = length + 1;
734   - subQuestions.answerOptions = this.rightOptions.slice(
735   - 0,
736   - subQuestions.selectNum
737   - ).join(',');
  729 + subQuestions.answerOptions = this.rightOptions
  730 + .slice(0, subQuestions.selectNum)
  731 + .join(",");
738 732 },
739 733 removeOptions(subQuestions) {
740 734 //删除选项
741   - let length = subQuestions.answerOptions.split(',').length;
  735 + let length = subQuestions.answerOptions.split(",").length;
742 736 if (length < 2) return;
743 737 subQuestions.selectNum = length - 1;
744   - subQuestions.answerOptions = this.rightOptions.slice(
745   - 0,
746   - subQuestions.selectNum
747   - ).join(',');
  738 + subQuestions.answerOptions = this.rightOptions
  739 + .slice(0, subQuestions.selectNum)
  740 + .join(",");
748 741 },
749 742 changAnswer(sub, option) {
750 743 //设置多选答案
... ... @@ -765,10 +758,10 @@ export default {
765 758 }
766 759 //添加测验类型
767 760 const { data, status, info } = await this.$request.addPaperType({
768   - typeName: this.answerTypeName,
  761 + tag: this.answerTypeName,
769 762 });
770 763 if (status == 0) {
771   - this._CreatedTypeList();
  764 + this._TypeList();
772 765 this.dialogVisible = false;
773 766 this.answerTypeName = "";
774 767 this.$message.success("添加成功");
... ... @@ -777,8 +770,8 @@ export default {
777 770 }
778 771 },
779 772 async save() {
780   - if (this.saceLoading) return;
781   - this.saceLoading = true;
  773 + if (this.saveLoading) return;
  774 + this.saveLoading = true;
782 775 //添加题目ID、序号
783 776 this.form.questionList.map((item, index) => {
784 777 item.questionId = index + 1;
... ... @@ -792,7 +785,7 @@ export default {
792 785 const { data, status, info } = await this.$request.addPaper({
793 786 ...this.form,
794 787 });
795   - this.saceLoading = false;
  788 + this.saveLoading = false;
796 789 if (status == 0) {
797 790 this.$router.push({
798 791 path: "/examinationPaper",
... ... @@ -805,17 +798,20 @@ export default {
805 798 //切换年级查询科目
806 799 this._QuerySubjectList(this.form.gradeName);
807 800 },
808   - async _CreatedTypeList() {
  801 + async _TypeList() {
809 802 //测验类型查询
810   - const { data, status, info } = await this.$request.fetchTypeNames(
811   - {gradeName :grade}
812   - );
  803 + const { data, status, info } = await this.$request.fetchTypeNames({
  804 + gradeName: this.form.gradeName,
  805 + type: 1,
  806 + });
813 807 if (status == 0) {
814   - this.answerTypeList = [...data.list] || [];
815   - this.answerTypeList.unshift({
816   - typeName: "",
817   - id: "",
818   - });
  808 + this.answerTypeList =
  809 + data.list.map((item) => {
  810 + return {
  811 + typeName: item.tag,
  812 + id: item.tagId,
  813 + };
  814 + }) || [];
819 815 if (this.type != 2) {
820 816 this.form.tagId = this.answerTypeList[0].id || "";
821 817 }
... ... @@ -831,26 +827,27 @@ export default {
831 827 if (this.type != 2) {
832 828 this.form.gradeName = this.gradeList[0];
833 829 }
834   - this._QuerySubjectList(this.gradeList[0]);
835 830 } else {
836 831 this.$message.error(info);
837 832 }
838 833 },
839 834 async _QuerySubjectList(grade) {
840 835 //查询科目列表
841   - const { data, status, info } = await this.$request.fetchSubjectList(
842   - {gradeName :grade}
843   - );
  836 + const { data, status, info } = await this.$request.fetchSubjectList({
  837 + gradeName: grade,
  838 + });
844 839 if (status === 0) {
845   - this.subjectList = data.list.map((item) => {
  840 + this.subjectList = data.subjectNames.map((item) => {
846 841 return {
847   - value: item.subjectName,
848   - label: item.subjectName,
  842 + value: item,
  843 + label: item,
849 844 };
850 845 });
  846 + console.log(this.subjectList);
851 847 if (this.subjectList.length) {
852 848 this.form.subjectName = this.subjectList[0].value;
853 849 }
  850 + console.log(this.form);
854 851 } else {
855 852 this.$message.error(info);
856 853 }
... ... @@ -861,10 +858,10 @@ export default {
861 858 paperId: this.$route.query.paperId,
862 859 });
863 860 if (status == 0) {
864   - this.form.title = data.title;
  861 + this.form.title = data.title+'_副本';
865 862 this.form.tagId = data.tagId;
866 863 this.form.subjectName = data.subjectName;
867   - this.form.gradeName = data.grade;
  864 + this.form.gradeName = data.gradeName;
868 865 this.form.examsDuration = data.examsDuration;
869 866 this.form.sharingType = data.sharingType;
870 867 this.form.questionList = data.questionList?.map((item) => {
... ... @@ -874,8 +871,8 @@ export default {
874 871 questionType: items.questionType,
875 872 score: items.score,
876 873 partScore: items.partScore,
877   - selectNum: items.answerOptions.split(',').length,
878   - answerOptions: items.answerOptions||"A,B,C,D",
  874 + selectNum: items.answerOptions.split(",").length,
  875 + answerOptions: items.answerOptions || "A,B,C,D",
879 876 correctAnswer: items.correctAnswer,
880 877 };
881 878 }) || [];
... ...
src/views/examinationPaper/edit.vue
... ... @@ -204,8 +204,8 @@ export default {
204 204 async save() {
205 205 let questionList = this.form.questionList.map((item) => {
206 206 item.score = null;
207   - items.questionId = "";
208   - items.questionIndex = "";
  207 + // item.questionId = "";
  208 + // item.questionIndex = "";
209 209 return item;
210 210 });
211 211 //更新答题卡
... ...
src/views/examinationPaper/index.vue
... ... @@ -87,7 +87,7 @@
87 87 </div>
88 88 <div class="info">
89 89 <p class="title">
90   - {{ item.title }} <span class="label">{{ item.tag }}</span>
  90 + {{ item.title }} <span class="label" v-if="item.tag">{{ item.tag }}</span>
91 91 </p>
92 92 <p class="num">
93 93 总题数:{{ item.questionNum }}
... ... @@ -104,7 +104,7 @@
104 104 indexs != item.classList.length-1? "、" : ""
105 105 }`
106 106 }}
107   - <i v-if="clazzChild.keepStatus == 1" class="el-icon-success"></i
  107 + <i v-if="clazzChild.keepStatus !== 1" class="el-icon-success"></i
108 108 ></span>
109 109 </p>
110 110 <p class="person">
... ... @@ -134,7 +134,7 @@
134 134 icon="el-icon-more"
135 135 ></el-button>
136 136 <el-dropdown-menu slot="dropdown">
137   - <el-dropdown-item :command="1" v-if="userId == item.id"
  137 + <el-dropdown-item :command="1" v-if="userName == item.realName"
138 138 >修改分享范围</el-dropdown-item
139 139 >
140 140 <el-dropdown-item :command="2">复制</el-dropdown-item>
... ... @@ -147,9 +147,9 @@
147 147 <el-dialog title="选择分享范围" :visible.sync="dialogVisible" width="400">
148 148 <el-form :model="shareForm" :rules="shareRulesForm" label-width="160px">
149 149 <el-form-item prop="share" label="分享范围:">
150   - <el-radio-group v-model="shareForm.share">
151   - <el-radio :label="1">任课班级分享</el-radio>
152   - <el-radio :label="2">全年级分享</el-radio>
  150 + <el-radio-group v-model="shareForm.sharingType">
  151 + <el-radio :label="0">任课班级分享</el-radio>
  152 + <el-radio :label="1">全年级分享</el-radio>
153 153 </el-radio-group>
154 154 </el-form-item>
155 155 </el-form>
... ... @@ -166,7 +166,7 @@ export default {
166 166 name: "examinationPaper",
167 167 data() {
168 168 return {
169   - userId: "",
  169 + userName: "",
170 170 dialogVisible: false,
171 171 query: {
172 172 classId: "",
... ... @@ -181,17 +181,17 @@ export default {
181 181 tableData: [],
182 182 shareForm: {
183 183 id: "",
184   - share: 1,
  184 + sharingType: 1,//0-任课班级/1-全年级
185 185 },
186 186 shareRulesForm: {
187   - share: [{ required: true, message: "选择分享范围", trigger: "blur" }],
  187 + sharingType: [{ required: true, message: "选择分享范围", trigger: "blur" }],
188 188 },
189 189 page: 1,
190 190 size: 20,
191 191 };
192 192 },
193 193 async created() {
194   - this.userId = this.$store.getters.info.uid || "";
  194 + this.userName = this.$store.getters.info.name || "";
195 195 await this._QueryClassList();
196 196 await this._QuerySubjectList();
197 197 this._QueryData();
... ... @@ -220,7 +220,7 @@ export default {
220 220 case 1:
221 221 //修改分享范围
222 222 that.shareForm.id = item.id;
223   - that.shareForm.share = item.share || 1;
  223 + that.shareForm.sharingType = item.sharingType || 1;
224 224 that.dialogVisible = true;
225 225 break;
226 226 case 2:
... ... @@ -236,14 +236,15 @@ export default {
236 236 async saveShare() {
237 237 //修改分享范围
238 238 const { data, status, info } = await this.$request.modifyPaper({
239   - paperId: that.shareForm.id,
240   - sharingType: that.shareForm.share,
  239 + paperId: this.shareForm.id,
  240 + sharingType: this.shareForm.sharingType,
241 241 });
242 242 this.loading = false;
243 243 if (status === 0) {
244 244 this.shareForm.id = "";
245   - this.shareForm.share = 1;
246   - dialogVisible = false;
  245 + this.shareForm.sharingType = 1;
  246 + this.dialogVisible = false;
  247 + this.$message.success(info)
247 248 } else {
248 249 this.$message.error(info);
249 250 }
... ... @@ -271,6 +272,7 @@ export default {
271 272 async _QueryTypeList() {
272 273 const { data, status, info } = await this.$request.fetchTypeNames({
273 274 classId: this.query.classId,
  275 + type:0
274 276 });
275 277 if (status === 0) {
276 278 this.typeList =
... ... @@ -355,6 +357,7 @@ export default {
355 357 });
356 358 this.loading = false;
357 359 if (status === 0) {
  360 + this.archivedTotal = data.archivedTotal
358 361 this.total = data.total;
359 362 this.tableData = (data.list && [...data.list]) || [];
360 363 } else {
... ... @@ -443,7 +446,11 @@ export default {
443 446 color: #667ffd;
444 447 font-weight: 500;
445 448 position: relative;
446   - margin-right: 8px;
  449 + position: relative;
  450 + &.active:after{
  451 + content: "\e79c";
  452 + color: #667ffd;
  453 + }
447 454 .el-icon-success {
448 455 position: absolute;
449 456 right: 0;
... ...
src/views/examinationPaper/recycle.vue
... ... @@ -86,7 +86,7 @@
86 86 </div>
87 87 <div class="info">
88 88 <p class="title">
89   - {{ item.title }} <span class="label">{{ item.tag }}</span>
  89 + {{ item.title }} <span class="label" v-if="item.tag">{{ item.tag }}</span>
90 90 </p>
91 91 <p class="num">
92 92 {{ item.gradeName }}
... ... @@ -124,7 +124,7 @@
124 124 </div>
125 125 </li>
126 126 </ul>
127   - <el-empty :image-size="100" v-if="tableData&&!tableData.legnth&&loading==false" description="没有更多数据"></el-empty>
  127 + <el-empty :image-size="100" v-if="!tableData.length&&loading==false" description="没有更多数据"></el-empty>
128 128 </div>
129 129 </template>
130 130  
... ... @@ -283,6 +283,7 @@ export default {
283 283 async _QueryTypeList() {
284 284 const { data, status, info } = await this.$request.fetchTypeNames({
285 285 classId: this.query.classId,
  286 + tyle:0
286 287 });
287 288 if (status === 0) {
288 289 this.typeList =
... ...