Ver Fonte

洗澡能呢个格式化时间的全局方法,新增判断题的显示判断

yellowtaotao há 4 anos atrás
pai
commit
7589bad346

+ 36 - 2
src/utils/common.js

@@ -23,10 +23,10 @@ exports.install = function(Vue, options) {
 
   /**
    *
-   * 过滤标准日期为 x-x-x
+   * 过滤标准日期为 x-x-x
    * @time {String} 标准日期时间格式
    */
-  Vue.prototype.formateDateTimeFun = function(time) {
+  Vue.prototype.formateDatesFun = function(time) {
     // 全局函数
     // 获取当前日期
     let date = new Date(time);
@@ -48,6 +48,40 @@ exports.install = function(Vue, options) {
     return date.getFullYear() + seperator + nowMonth + seperator + strDate;
   };
 
+  /**
+   *
+   * 过滤标准日期为 x-x-x x:x:x
+   * @time {String} 标准日期时间格式
+   */
+  Vue.prototype.formateDateTimeFun = function(time) {
+    // 全局函数
+    // 获取当前日期
+    let date = new Date(time);
+    // 获取当前月份
+    let nowMonth = date.getMonth() + 1;
+    // 获取当前是几号
+    let strDate = date.getDate();
+    // 对月份进行处理,1-9月在前面添加一个“0”
+    if (nowMonth >= 1 && nowMonth <= 9) {
+      nowMonth = "0" + nowMonth;
+    }
+    // 对月份进行处理,1-9号在前面添加一个“0”
+    if (strDate >= 0 && strDate <= 9) {
+      strDate = "0" + strDate;
+    }
+    let hours = date.getHours()
+    let minutes = date.getMinutes()
+    if (minutes >= 0 && minutes <= 9) {
+      minutes = "0" + minutes;
+    }
+    let seconds = date.getSeconds()
+    if (seconds >= 0 && seconds <= 9) {
+      seconds = "0" + seconds;
+    }
+    // 最后拼接字符串,得到一个格式为(yyyy-MM-dd hh:mm:ss)的日期
+    return date.getFullYear() + "-" + nowMonth + "-" + strDate + ' ' + hours + ":" + minutes + ":" + seconds;
+  };
+
   /**
    * 根据秒数获取 XX时:XX分:XX秒
    * @secondsNumber {Number} 数字

+ 12 - 4
src/views/home/answer/page-answer-recruit.vue

@@ -34,7 +34,9 @@
         <!-- 单选题、多选题的选项区域 -->
         <div
           v-if="
-            examQuestionList[answerIndex].type === questionType.singleChoice ||
+            examQuestionList[answerIndex].type === questionType.TrueOrFalse ||
+              examQuestionList[answerIndex].type ===
+                questionType.singleChoice ||
               examQuestionList[answerIndex].type === questionType.multipleChoice
           "
           class="exam-question-options"
@@ -120,7 +122,8 @@ export default {
       questionType: {
         singleChoice: "DanXuan", // 单选题
         multipleChoice: "DuoXuan", // 多选题
-        gapFilling: "TianKong" // 填空题
+        gapFilling: "TianKong", // 填空题
+        TrueOrFalse: "PanDuanTi" // 判断题
       }, // 试题类型
       examQuestionList: [], // 试题列表
       answerIndex: null, // 当前试题的下标索引
@@ -244,7 +247,10 @@ export default {
           console.log(content);
           questionInputNum = this.getPlaceholderCount(content);
           questionContent = content.replace("$PH$", "()");
-          console.log(questionContent, questionInputNum);
+          break;
+        case this.questionType.TrueOrFalse:
+          console.log("判断题");
+          typeTxt = "判断题";
           break;
         default:
           break;
@@ -313,7 +319,8 @@ export default {
       }
       let answerQuestionType = this.examQuestionList[this.answerIndex].type;
       switch (answerQuestionType) {
-        // 单选题
+        // 判断题、单选题
+        case this.questionType.TrueOrFalse:
         case this.questionType.singleChoice:
           this.answerValue = [value];
           break;
@@ -362,6 +369,7 @@ export default {
     },
     // 方法:判断当前题目是否正确
     getAnswerItemResultFun(item) {
+      console.log(item);
       let isSure = false;
       let sureNum = 0;
       item.finalAnswer.forEach(it => {

+ 4 - 2
src/views/home/exam/page-exam-item-detail.vue

@@ -5,10 +5,12 @@
       <div class="exam-item-detial">
         <div class="exam-item-detial-title">{{ examItemData.name }}</div>
         <div class="exam-item-detial-txt">
-          考试时间:{{ examItemData.startTime }}
+          考试时间:{{
+            formateDateTimeFun(examItemData.startTime) || examItemData.startTime
+          }}
         </div>
         <div class="exam-item-detial-txt">
-          考试时长:{{ examItemData.examTimeMins }}
+          考试时长:{{ examItemData.examTimeMinsTxt }}
         </div>
         <div class="exam-item-detial-describe">
           考试描述:<span>{{ examItemData.description }}</span>

+ 11 - 3
src/views/home/exam/page-exam-item-doing.vue

@@ -60,7 +60,9 @@
           v-if="
             examQuestionList.length &&
               (examQuestionList[answerIndex].type ===
-                questionType.singleChoice ||
+                questionType.TrueOrFalse ||
+                examQuestionList[answerIndex].type ===
+                  questionType.singleChoice ||
                 examQuestionList[answerIndex].type ===
                   questionType.multipleChoice)
           "
@@ -141,7 +143,8 @@ export default {
       questionType: {
         singleChoice: "DanXuan", // 单选题
         multipleChoice: "DuoXuan", // 多选题
-        gapFilling: "TianKong" // 填空题
+        gapFilling: "TianKong", // 填空题
+        TrueOrFalse: "PanDuanTi" // 判断题
       }, // 试题类型
       examEndTimeSeconds: null, // 考试结束时的毫秒秒数
       examBeforeHalfEndTimeSeconds: null, // 开始考试一半时间的毫秒秒数
@@ -388,6 +391,10 @@ export default {
           questionContent = content.replace("$PH$", "()");
           console.log(questionContent, questionInputNum);
           break;
+        case this.questionType.TrueOrFalse:
+          console.log("判断题");
+          typeTxt = "判断题";
+          break;
         default:
           break;
       }
@@ -430,7 +437,8 @@ export default {
     handleExamQuestionOptionsItemFun(value, index) {
       let answerQuestionType = this.examQuestionList[this.answerIndex].type;
       switch (answerQuestionType) {
-        // 单选题
+        // 判断题、单选题
+        case this.questionType.TrueOrFalse:
         case this.questionType.singleChoice:
           this.answerValue = [value];
           break;

+ 3 - 1
src/views/home/exam/page-exam.vue

@@ -24,7 +24,9 @@
             {{ item.examStatusTxt }}
           </div>
         </div>
-        <div class="exam-item-describe">考试时间:{{ item.startTime }}</div>
+        <div class="exam-item-describe">
+          考试时间:{{ formateDateTimeFun(item.startTime) || item.startTime }}
+        </div>
         <div class="exam-item-describe">
           考试时长:{{ item.examTimeMinsTxt }}
         </div>

+ 7 - 6
src/views/home/index.vue

@@ -95,6 +95,13 @@ export default {
   methods: {
     // 初始化
     initFun() {
+      this.engineeringWorkList = [
+        { text: "桥隧工", value: "QiaoSuiGong" },
+        { text: "桥梁工", value: "QiaoLiangGong" },
+        { text: "线路工", value: "XianLuGong" }
+      ];
+      this.engineeringWorkChooseValue = this.engineeringWorkList[0].value;
+      this.handleChangeEngneeringWorkFun(this.engineeringWorkChooseValue);
       // 获取所有用户
       this.$_http
         .get(this.$_API.JTXT_GET_USER_ADMIN_USERS)
@@ -110,12 +117,6 @@ export default {
         .catch(() => {
           this.$store.commit("toggleLoading", false);
         });
-      this.engineeringWorkList = [
-        { text: "桥隧工", value: "QiaoSuiGong" },
-        { text: "桥梁工", value: "QiaoLiangGong" },
-        { text: "线路工", value: "XianLuGong" }
-      ];
-      this.handleChangeEngneeringWorkFun(this.engineeringWorkList[0].value);
       this.activeTabName = 0;
       this.onChangeTabFun(this.activeTabName);
     },

+ 1 - 1
src/views/home/learn/page-learn-child.vue

@@ -46,7 +46,7 @@
               <div class="contentItemDescription">
                 <div class="contentItemDescriptionTime">
                   {{
-                    formateDateTimeFun(contentItem.createdTime) ||
+                    formateDatesFun(contentItem.createdTime) ||
                       contentItem.createdTime
                   }}
                 </div>

+ 2 - 2
src/views/home/learn/page-learn-content.vue

@@ -18,7 +18,7 @@
         <div class="learn-content-body-time">
           发布日期:
           {{
-            formateDateTimeFun(contentObj.createdTime) || contentObj.createdTime
+            formateDatesFun(contentObj.createdTime) || contentObj.createdTime
           }}
         </div>
         <div class="learn-content-body-collect">
@@ -80,7 +80,7 @@
               {{ item.content }}
             </div>
             <div class="learn-content-comment-item-createdtime">
-              {{ formateDateTimeFun(item.createdTime) || item.createdTime }}
+              {{ formateDatesFun(item.createdTime) || item.createdTime }}
             </div>
           </div>
         </div>

+ 1 - 1
src/views/home/person/collection.vue

@@ -20,7 +20,7 @@
             <div class="contentItemDescription">
               收藏时间:
               <span>{{
-                formateDateTimeFun(item.createdTime) || item.createdTime
+                formateDatesFun(item.createdTime) || item.createdTime
               }}</span>
             </div>
           </div>

+ 2 - 2
src/views/home/person/exam-history.vue

@@ -19,7 +19,7 @@
               <div class="contentItemDescription">
                 考试时间:
                 <span>{{
-                  formateDateTimeFun(item.startTime) || item.startTime
+                  formateDatesFun(item.startTime) || item.startTime
                 }}</span>
               </div>
             </div>
@@ -28,7 +28,7 @@
                 'exam-point': true,
                 'exam-point-green': item.points >= 90,
                 'exam-point-yellow': item.points >= 60 && item.points < 90,
-                'exam-point-red': item.points < 60,
+                'exam-point-red': item.points < 60
               }"
             >
               {{ item.points }}