diff --git a/package.json b/package.json index 9648486..d3a448c 100755 --- a/package.json +++ b/package.json @@ -8,17 +8,18 @@ "lint": "vue-cli-service lint" }, "dependencies": { + "axios": "^0.21.1", "core-js": "^3.6.5", "echarts": "5.3.2", "element-ui": "^2.15.1", + "font-awesome": "^4.7.0", "js-cookie": "^2.2.0", "jsencrypt": "^3.2.0", "nprogress": "^0.2.0", - "font-awesome": "^4.7.0", + "script-ext-html-webpack-plugin": "^2.1.5", "vue": "^2.6.11", "vue-i18n": "^8.4.0", "vue-router": "^3.5.1", - "axios": "^0.21.1", "vuex": "^3.6.2" }, "devDependencies": { @@ -26,8 +27,8 @@ "@vue/cli-service": "~4.5.0", "autoprefixer": "^7.1.2", "babel-core": "^6.22.1", - "babel-loader": "^7.1.1", "babel-eslint": "^10.1.0", + "babel-loader": "^7.1.1", "babel-polyfill": "^6.26.0", "eslint": "^6.7.2", "eslint-plugin-vue": "^6.2.2", @@ -35,11 +36,11 @@ "html-webpack-plugin": "^4.2.0", "mini-css-extract-plugin": "^0.9.0", "node-sass": "^4.13.0", - "sass-loader": "^7.1.0", + "optimize-css-assets-webpack-plugin": "^3.2.0", "postcss-import": "^12.0.1", "postcss-loader": "^3.0.0", "postcss-url": "^7.2.1", - "optimize-css-assets-webpack-plugin": "^3.2.0", + "sass-loader": "^7.1.0", "vue-template-compiler": "^2.5.2" } } diff --git a/src/api/axios.js b/src/api/axios.js index ff65b10..a9cf526 100644 --- a/src/api/axios.js +++ b/src/api/axios.js @@ -1,9 +1,9 @@ -import axios from "axios" -import Cookies from "js-cookie" -import NProgress from "nprogress" -import { Message } from "element-ui" -import router from "@/router/index" -import store from "@/store" +import axios from "axios"; +import Cookies from "js-cookie"; +import NProgress from "nprogress"; +import { Message } from "element-ui"; +import router from "@/router/index"; +import store from "@/store"; import conf from "../config/index"; // 路径配置 // axios默认配置 const service = axios.create({ @@ -12,86 +12,84 @@ const service = axios.create({ withCredentials: true, }); // http request 拦截器 -service.interceptors.request.use(config => { - NProgress.start() - config.headers["Content-Type"] = "application/json;charset=UTF-8" +service.interceptors.request.use( + (config) => { + NProgress.start(); + config.headers["Content-Type"] = "application/json;charset=UTF-8"; - const source = axios.CancelToken.source(); - store.commit('setTokenSources', [source.token, source.cancel]) - config.cancelToken = source.token; - // if (Cookies.get("access_token")) { - // config.headers.Authorization = "Bearer" + Cookies.get("access_token") - // } - return config -}, - error => { - return Promise.reject(error.response) - }) + const source = axios.CancelToken.source(); + store.commit("setTokenSources", [source.token, source.cancel]); + config.cancelToken = source.token; + // if (Cookies.get("access_token")) { + // config.headers.Authorization = "Bearer" + Cookies.get("access_token") + // } + return config; + }, + (error) => { + return Promise.reject(error.response); + } +); // http response 拦截器 service.interceptors.response.use( - response => { + (response) => { const res = response.data; - NProgress.done() + NProgress.done(); if (response.config.cancelToken) { - store.commit('delTokenSources', response.config.cancelToken) + store.commit("delTokenSources", response.config.cancelToken); } if (response.status == 200) { // Cookies.set("access_token", response.data.message, { expires: 1 / 12 }) // console.log(response.status) - if (res.code == 999) { - if (!location.href.includes('localhost')) { + if (res.status == 999) { + // if (!location.href.includes("localhost")) { if (res.data) { - window.location.href = res.data + window.location.href = res.data; } else { - router.push({ path: '/login' }) - if (res.message.includes('不存在')) { + router.push({ path: "/login" }); + if (res.message.includes("不存在")) { Message({ message: res.message, - type: 'error', - duration: 3 * 1000 - }) + type: "error", + duration: 3 * 1000, + }); } } - } - return + // } } else { // Cookies.set("access_token", response.data.message, { expires: 1 / 12 }) } } - console.log(response) - return Promise.resolve(res) + return Promise.resolve(res); }, - error => { + (error) => { Message({ - message: error.message, - type: 'error', - duration: 3 * 1000 - }) + message: error, + type: "error", + duration: 3 * 1000, + }); if (error.response == undefined) { return Promise.reject(error); } - Message.closeAll() - const { - data, - status - } = error.response + const { data, status } = error.response; if (status === 403 || status === 401) { + Message.closeAll(); Message({ - message: data.info||"未登录或登录超时,即将跳转到登录页面", - type: 'error', - duration: 3 * 1000 - }) - if (!window.location.href.includes('login')) { + message: data.info || "未登录或登录超时,即将跳转到登录页面", + type: "error", + duration: 3 * 1000, + }); + if (!window.location.href.includes("login")) { router.push({ - path: '/login', + path: "/login", query: { - url: window.location.href - } - }) + url: window.location.href, + }, + }); } - return + return; } - return Promise.reject(error.response) // 返回接口返回的错误信息 - }) -export default service + return Promise.reject(error.response); // 返回接口返回的错误信息 + } +); +export default service; diff --git a/src/views/examinationPaper/add.vue b/src/views/examinationPaper/add.vue index 7c0129a..098afa5 100644 --- a/src/views/examinationPaper/add.vue +++ b/src/views/examinationPaper/add.vue @@ -78,7 +78,7 @@ :key="item.value" :label="item.label" :value="item.value" - > + >{{ item.label }} @@ -470,7 +470,7 @@ export default { { label: "判断题", value: 4 }, { label: "主观题", value: 5 }, ], - rightOptions: ["A","B","C","D","E","F","G"], + rightOptions: ["A", "B", "C", "D", "E", "F", "G"], addSubQuestionsType: "", step: 0, //步骤 gradeList: [], //年级 @@ -509,8 +509,9 @@ export default { }; }, async created() { - await this._GradeList() - await this._CreatedTypeList() + await this._GradeList(); + await this._QuerySubjectList(this.gradeList[0]); + await this._TypeList(); this.type = this.$route.query.type ? this.$route.query.type : 1; if (this.type == 2) { this._QueryDetail(); @@ -630,16 +631,14 @@ export default { }; switch (questionsOptions.questionType) { case 2: - questionsOptions.answerOptions = this.rightOptions.slice( - 0, - questionsOptions.selectNum - ).join(','); + questionsOptions.answerOptions = this.rightOptions + .slice(0, questionsOptions.selectNum) + .join(","); break; case 3: - questionsOptions.answerOptions = this.rightOptions.slice( - 0, - questionsOptions.selectNum - ).join(','); + questionsOptions.answerOptions = this.rightOptions + .slice(0, questionsOptions.selectNum) + .join(","); questionsOptions.partScore = 0.5; break; case 4: @@ -678,16 +677,14 @@ export default { }; switch (questionsOptions.questionType) { case 2: - questionsOptions.answerOptions = this.rightOptions.slice( - 0, - questionsOptions.selectNum - ).join(','); + questionsOptions.answerOptions = this.rightOptions + .slice(0, questionsOptions.selectNum) + .join(","); break; case 3: - questionsOptions.answerOptions = this.rightOptions.slice( - 0, - questionsOptions.selectNum - ).join(','); + questionsOptions.answerOptions = this.rightOptions + .slice(0, questionsOptions.selectNum) + .join(","); questionsOptions.partScore = 0.5; break; case 4: @@ -708,16 +705,14 @@ export default { subQuestions.selectNum = 4; switch (val) { case 2: - subQuestions.answerOptions = that.rightOptions.slice( - 0, - subQuestions.selectNum - ).join(','); + subQuestions.answerOptions = that.rightOptions + .slice(0, subQuestions.selectNum) + .join(","); break; case 3: - subQuestions.answerOptions = that.rightOptions.slice( - 0, - subQuestions.selectNum - ).join(','); + subQuestions.answerOptions = that.rightOptions + .slice(0, subQuestions.selectNum) + .join(","); subQuestions.partScore = 0.5; break; case 4: @@ -728,23 +723,21 @@ export default { }, addOptions(subQuestions) { //添加选项 - let length = subQuestions.answerOptions.split(',').length; + let length = subQuestions.answerOptions.split(",").length; if (length > 6) return; subQuestions.selectNum = length + 1; - subQuestions.answerOptions = this.rightOptions.slice( - 0, - subQuestions.selectNum - ).join(','); + subQuestions.answerOptions = this.rightOptions + .slice(0, subQuestions.selectNum) + .join(","); }, removeOptions(subQuestions) { //删除选项 - let length = subQuestions.answerOptions.split(',').length; + let length = subQuestions.answerOptions.split(",").length; if (length < 2) return; subQuestions.selectNum = length - 1; - subQuestions.answerOptions = this.rightOptions.slice( - 0, - subQuestions.selectNum - ).join(','); + subQuestions.answerOptions = this.rightOptions + .slice(0, subQuestions.selectNum) + .join(","); }, changAnswer(sub, option) { //设置多选答案 @@ -765,10 +758,10 @@ export default { } //添加测验类型 const { data, status, info } = await this.$request.addPaperType({ - typeName: this.answerTypeName, + tag: this.answerTypeName, }); if (status == 0) { - this._CreatedTypeList(); + this._TypeList(); this.dialogVisible = false; this.answerTypeName = ""; this.$message.success("添加成功"); @@ -777,8 +770,8 @@ export default { } }, async save() { - if (this.saceLoading) return; - this.saceLoading = true; + if (this.saveLoading) return; + this.saveLoading = true; //添加题目ID、序号 this.form.questionList.map((item, index) => { item.questionId = index + 1; @@ -792,7 +785,7 @@ export default { const { data, status, info } = await this.$request.addPaper({ ...this.form, }); - this.saceLoading = false; + this.saveLoading = false; if (status == 0) { this.$router.push({ path: "/examinationPaper", @@ -805,17 +798,20 @@ export default { //切换年级查询科目 this._QuerySubjectList(this.form.gradeName); }, - async _CreatedTypeList() { + async _TypeList() { //测验类型查询 - const { data, status, info } = await this.$request.fetchTypeNames( - {gradeName :grade} - ); + const { data, status, info } = await this.$request.fetchTypeNames({ + gradeName: this.form.gradeName, + type: 1, + }); if (status == 0) { - this.answerTypeList = [...data.list] || []; - this.answerTypeList.unshift({ - typeName: "", - id: "", - }); + this.answerTypeList = + data.list.map((item) => { + return { + typeName: item.tag, + id: item.tagId, + }; + }) || []; if (this.type != 2) { this.form.tagId = this.answerTypeList[0].id || ""; } @@ -831,26 +827,27 @@ export default { if (this.type != 2) { this.form.gradeName = this.gradeList[0]; } - this._QuerySubjectList(this.gradeList[0]); } else { this.$message.error(info); } }, async _QuerySubjectList(grade) { //查询科目列表 - const { data, status, info } = await this.$request.fetchSubjectList( - {gradeName :grade} - ); + const { data, status, info } = await this.$request.fetchSubjectList({ + gradeName: grade, + }); if (status === 0) { - this.subjectList = data.list.map((item) => { + this.subjectList = data.subjectNames.map((item) => { return { - value: item.subjectName, - label: item.subjectName, + value: item, + label: item, }; }); + console.log(this.subjectList); if (this.subjectList.length) { this.form.subjectName = this.subjectList[0].value; } + console.log(this.form); } else { this.$message.error(info); } @@ -861,10 +858,10 @@ export default { paperId: this.$route.query.paperId, }); if (status == 0) { - this.form.title = data.title; + this.form.title = data.title+'_副本'; this.form.tagId = data.tagId; this.form.subjectName = data.subjectName; - this.form.gradeName = data.grade; + this.form.gradeName = data.gradeName; this.form.examsDuration = data.examsDuration; this.form.sharingType = data.sharingType; this.form.questionList = data.questionList?.map((item) => { @@ -874,8 +871,8 @@ export default { questionType: items.questionType, score: items.score, partScore: items.partScore, - selectNum: items.answerOptions.split(',').length, - answerOptions: items.answerOptions||"A,B,C,D", + selectNum: items.answerOptions.split(",").length, + answerOptions: items.answerOptions || "A,B,C,D", correctAnswer: items.correctAnswer, }; }) || []; diff --git a/src/views/examinationPaper/edit.vue b/src/views/examinationPaper/edit.vue index a3e9fe8..3723994 100644 --- a/src/views/examinationPaper/edit.vue +++ b/src/views/examinationPaper/edit.vue @@ -204,8 +204,8 @@ export default { async save() { let questionList = this.form.questionList.map((item) => { item.score = null; - items.questionId = ""; - items.questionIndex = ""; + // item.questionId = ""; + // item.questionIndex = ""; return item; }); //更新答题卡 diff --git a/src/views/examinationPaper/index.vue b/src/views/examinationPaper/index.vue index ce7582a..9c367c1 100644 --- a/src/views/examinationPaper/index.vue +++ b/src/views/examinationPaper/index.vue @@ -87,7 +87,7 @@

- {{ item.title }} {{ item.tag }} + {{ item.title }} {{ item.tag }}

总题数:{{ item.questionNum }} @@ -104,7 +104,7 @@ indexs != item.classList.length-1? "、" : "" }` }} -

@@ -134,7 +134,7 @@ icon="el-icon-more" > - 修改分享范围 复制 @@ -147,9 +147,9 @@ - - 任课班级分享 - 全年级分享 + + 任课班级分享 + 全年级分享 @@ -166,7 +166,7 @@ export default { name: "examinationPaper", data() { return { - userId: "", + userName: "", dialogVisible: false, query: { classId: "", @@ -181,17 +181,17 @@ export default { tableData: [], shareForm: { id: "", - share: 1, + sharingType: 1,//0-任课班级/1-全年级 }, shareRulesForm: { - share: [{ required: true, message: "选择分享范围", trigger: "blur" }], + sharingType: [{ required: true, message: "选择分享范围", trigger: "blur" }], }, page: 1, size: 20, }; }, async created() { - this.userId = this.$store.getters.info.uid || ""; + this.userName = this.$store.getters.info.name || ""; await this._QueryClassList(); await this._QuerySubjectList(); this._QueryData(); @@ -220,7 +220,7 @@ export default { case 1: //修改分享范围 that.shareForm.id = item.id; - that.shareForm.share = item.share || 1; + that.shareForm.sharingType = item.sharingType || 1; that.dialogVisible = true; break; case 2: @@ -236,14 +236,15 @@ export default { async saveShare() { //修改分享范围 const { data, status, info } = await this.$request.modifyPaper({ - paperId: that.shareForm.id, - sharingType: that.shareForm.share, + paperId: this.shareForm.id, + sharingType: this.shareForm.sharingType, }); this.loading = false; if (status === 0) { this.shareForm.id = ""; - this.shareForm.share = 1; - dialogVisible = false; + this.shareForm.sharingType = 1; + this.dialogVisible = false; + this.$message.success(info) } else { this.$message.error(info); } @@ -271,6 +272,7 @@ export default { async _QueryTypeList() { const { data, status, info } = await this.$request.fetchTypeNames({ classId: this.query.classId, + type:0 }); if (status === 0) { this.typeList = @@ -355,6 +357,7 @@ export default { }); this.loading = false; if (status === 0) { + this.archivedTotal = data.archivedTotal this.total = data.total; this.tableData = (data.list && [...data.list]) || []; } else { @@ -443,7 +446,11 @@ export default { color: #667ffd; font-weight: 500; position: relative; - margin-right: 8px; + position: relative; + &.active:after{ + content: "\e79c"; + color: #667ffd; + } .el-icon-success { position: absolute; right: 0; diff --git a/src/views/examinationPaper/recycle.vue b/src/views/examinationPaper/recycle.vue index d3f81a3..339d146 100644 --- a/src/views/examinationPaper/recycle.vue +++ b/src/views/examinationPaper/recycle.vue @@ -86,7 +86,7 @@

- {{ item.title }} {{ item.tag }} + {{ item.title }} {{ item.tag }}

{{ item.gradeName }} @@ -124,7 +124,7 @@

- + @@ -283,6 +283,7 @@ export default { async _QueryTypeList() { const { data, status, info } = await this.$request.fetchTypeNames({ classId: this.query.classId, + tyle:0 }); if (status === 0) { this.typeList =