Browse Source

限制考试次数的修改

lidie 1 year ago
parent
commit
b859f43a0a
1 changed files with 20 additions and 8 deletions
  1. 20 8
      src/views/platform/bpmn/my-test/index.vue

+ 20 - 8
src/views/platform/bpmn/my-test/index.vue

@@ -87,7 +87,7 @@
         <!-- 点击搜索的左边显示 -->
         <!-- <ibps-type-tree v-model="typeTreePopup" title="流程分类" category-key="FLOW_TYPE" @node-click="clickTypeNode"
       @close="visible => typeTreePopup = visible" /> -->
-        <!-- 遮罩层 -->
+        <!-- 遮罩层,提示信息 -->
         <template>
             <van-popup
                 ref="examPopup"
@@ -148,7 +148,7 @@
                         <van-col
                             span="16"
                             class="popupContent"
-                        >{{ examPopup.limitCount===''?'/':examPopup.limitCount===null?'/':examPopup.limitCount }}</van-col>
+                        >{{ examPopup.limitCount===''?'/':examPopup.limitCount===null?'/':countTotal?`${examPopup.limitCount}次 (您已参加${countTotal.count - 1}次 ,本次不消耗次数)`:'' }}</van-col>
                     </van-row>
                     <van-row class="examRow">
                         <van-col span="8" class="popupTitle">考试时长:</van-col>
@@ -176,7 +176,7 @@
                     </div>
                     <van-row class="examRowto">
                         <van-col span="12"> <van-button type="default" @click="ReachBottomShow=false">取消</van-button></van-col>
-                        <van-col span="12"> <van-button type="info" @click="changeShowPop()">确定</van-button></van-col>
+                        <van-col span="12"> <van-button type="info" @click="changeShowPop(examPopup)">确定</van-button></van-col>
                     </van-row>
                 </div>
             </van-popup>
@@ -209,6 +209,7 @@ import IbpsAvatar from '@/components/ibps-avatar'
 import IbpsToolbar from '@/components/ibps-toolbar'
 import IbpsListResultPage from '@/components/ibps-list-result-page'
 import IbpsBpmnFormrenderDialog from '@/business/platform/bpmn/form/dialog'
+import { Notify } from 'vant'
 
 export default {
     components: {
@@ -224,6 +225,7 @@ export default {
     data() {
         const { userId, userList = [], deptList = [], menus, userInfo } = this.$store.getters
         return {
+            userId: userId,
             footText: false,
             showPop: false,
             noData: false,
@@ -314,9 +316,14 @@ export default {
 
     methods: {
         // 点击开始考试
-        onClick(item, index) {
-            this.ReachBottomShow = true
+        async onClick(item, index) {
             this.examPopup = item
+            this.countTotal = await this.getExamCount(item.examId) || 0
+            if (this.countTotal.count > +item.limitCount) {
+                return Notify({ type: 'primary', message: '本次考试次数已达到上限!' })
+            } else {
+                this.ReachBottomShow = true
+            }
         },
 
         showPopup() {
@@ -326,7 +333,11 @@ export default {
             this.ReachBottomShow = false
         },
         // 点击确定进入考试界面
-        async changeShowPop() {
+        async changeShowPop(item) {
+            this.countTotal = await this.getExamCount(item.examId) || 0
+            if (this.countTotal.count > +item.limitCount) {
+                return Notify({ type: 'primary', message: '本次考试次数已达到上限!' })
+            }
             this.ReachBottomShow = false
             if (this.countTotal.notStart && this.examPopup.bankId !== '') {
                 // 已有未开始的试卷 更新开始时间
@@ -350,12 +361,13 @@ export default {
                 this.createPaper({ ...mid }, this.info)
             }
         },
+
         async getExamCount(id) {
             const param = id ? `exam_id_ = '${id}'` : 'exam_id_ is null'
-            const sql = `select id_, zhuang_tai_ from t_examination where ${param} and kao_shi_ren_ = '${this.userInfo}' and zhuang_tai_ !== '已取消' order by bao_ming_shi_jian asc`
+            const sql = `select id_, zhuang_tai_ from t_examination where ${param} and kao_shi_ren_ = '${this.userId}' and zhuang_tai_ != '已取消' order by bao_ming_shi_jian asc`
             return new Promise((resolve, reject) => {
                 this.$common.request('sql', sql).then(res => {
-                    const { data = [] } = res.data.variables || {}
+                    const { data = [] } = res.variables || {}
                     const temp = data.find(item => item.zhuang_tai_ === '未开始')
                     resolve({
                         count: data.length,