Browse Source

新增所选工种数据到vuex

yellowtaotao 4 years ago
parent
commit
81cca0893f

+ 2 - 1
src/store/modules/user.js

@@ -1,6 +1,7 @@
 const user = {
   state: {
-    userInfo: null // 用户信息
+    userInfo: null, // 用户信息
+    chooseEngneeringWorkValue: null // 当前所选的工种
   },
   mutations: {
     updateUserItemStore(state, { field, value }) {

+ 10 - 9
src/views/home/answer/page-answer-recruit.vue

@@ -27,7 +27,7 @@
         <div class="exam-question-describe">
           {{
             examQuestionList[answerIndex].questionContent ||
-            examQuestionList[answerIndex].content
+              examQuestionList[answerIndex].content
           }}
         </div>
         <!-- 答题列表 -->
@@ -35,7 +35,7 @@
         <div
           v-if="
             examQuestionList[answerIndex].type === questionType.singleChoice ||
-            examQuestionList[answerIndex].type === questionType.multipleChoice
+              examQuestionList[answerIndex].type === questionType.multipleChoice
           "
           class="exam-question-options"
         >
@@ -46,7 +46,7 @@
               'exam-question-options-item': true,
               'exam-question-options-item-checked': answerValue.includes(item),
               'exam-question-options-false':
-                answerValue.includes(item) && answerStatus === 2,
+                answerValue.includes(item) && answerStatus === 2
             }"
             @click="handleExamQuestionOptionsItemFun(item)"
           >
@@ -141,7 +141,8 @@ export default {
   computed: {
     ...mapState({
       answerRecruitId: state => state.answer.answerRecruitId,
-      userInfo: state => state.user.userInfo
+      userInfo: state => state.user.userInfo,
+      chooseEngneeringWorkValue: state => state.user.chooseEngneeringWorkValue
     })
   },
   methods: {
@@ -161,16 +162,16 @@ export default {
         return;
       }
       this.$store.commit("toggleLoading", true);
-      //   let params = {
-      //     type: "aaaaaaaa"
-      //   };
+      let params = {
+        type: this.chooseEngneeringWorkValue
+      };
       this.$_http
         .post(
           this.$pathParams(this.$_API.POST_JTXT_GET_EXAMS_START, {
             examId: this.answerRecruitId
           }),
-          this.userInfo
-        //   { params }
+          this.userInfo,
+          { params }
         )
         .then(res => {
           if (res.data) {

+ 15 - 13
src/views/home/exam/page-exam-item-doing.vue

@@ -14,7 +14,7 @@
         :class="{
           'exam-question-item': true,
           'exam-question-item-on': answerIndex === index,
-          'exam-question-item-down': examQuestionList[index].userAnswer.length,
+          'exam-question-item-down': examQuestionList[index].userAnswer.length
         }"
         v-for="(item, index) in examQuestionList"
         :key="index"
@@ -51,7 +51,7 @@
         <div v-if="examQuestionList.length" class="exam-question-describe">
           {{
             examQuestionList[answerIndex].questionContent ||
-            examQuestionList[answerIndex].content
+              examQuestionList[answerIndex].content
           }}
         </div>
         <!-- 答题列表 -->
@@ -59,9 +59,10 @@
         <div
           v-if="
             examQuestionList.length &&
-            (examQuestionList[answerIndex].type === questionType.singleChoice ||
-              examQuestionList[answerIndex].type ===
-                questionType.multipleChoice)
+              (examQuestionList[answerIndex].type ===
+                questionType.singleChoice ||
+                examQuestionList[answerIndex].type ===
+                  questionType.multipleChoice)
           "
           class="exam-question-options"
         >
@@ -70,7 +71,7 @@
             :key="index"
             :class="{
               'exam-question-options-item': true,
-              'exam-question-options-item-checked': answerValue.includes(item),
+              'exam-question-options-item-checked': answerValue.includes(item)
             }"
             @click="handleExamQuestionOptionsItemFun(item)"
           >
@@ -81,7 +82,7 @@
         <div
           v-if="
             examQuestionList.length &&
-            examQuestionList[answerIndex].type === questionType.gapFilling
+              examQuestionList[answerIndex].type === questionType.gapFilling
           "
           class="exam-question-gapFilling"
         >
@@ -181,7 +182,8 @@ export default {
   computed: {
     ...mapState({
       examItem: state => state.exam.examItem,
-      userInfo: state => state.user.userInfo
+      userInfo: state => state.user.userInfo,
+      chooseEngneeringWorkValue: state => state.user.chooseEngneeringWorkValue
     })
   },
   methods: {
@@ -205,16 +207,16 @@ export default {
     // 方法:开始考试
     examStartFun() {
       this.$store.commit("toggleLoading", true);
-      //   let params = {
-      //     type: "aaaaaaaa"
-      //   };
+      let params = {
+        type: this.chooseEngneeringWorkValue
+      };
       this.$_http
         .post(
           this.$pathParams(this.$_API.POST_JTXT_GET_EXAMS_START, {
             examId: this.examItem.id
           }),
-          this.userInfo
-          //   { params }
+          this.userInfo,
+          { params }
         )
         .then(res => {
           if (res.data) {

+ 4 - 0
src/views/home/index.vue

@@ -132,6 +132,10 @@ export default {
           break;
         }
       }
+      this.$store.commit("updateUserItemStore", {
+        field: "chooseEngneeringWorkValue",
+        value: resultItem.text
+      });
       console.log("选择的工种信息:", resultItem);
     },
     // 获取所有收藏