Просмотр исходного кода

我的考试,高级搜索问题;数据展示显示NAN的处理

lidie 1 год назад
Родитель
Сommit
1fcdf57310
1 измененных файлов с 28 добавлено и 71 удалено
  1. 28 71
      src/views/platform/bpmn/my-test/index.vue

+ 28 - 71
src/views/platform/bpmn/my-test/index.vue

@@ -33,29 +33,29 @@
                         <template #label>
                             <van-row>
                                 <van-col span="12">考试类别</van-col>
-                                <van-col span="12">{{ item.examType==''?'/':item.examType==null?'/':item.examType }}</van-col>
+                                <van-col span="12">{{ item.examType==''?'/':item.examType==null?'/':item.examType==undefined?'/':item.examType }}</van-col>
                             </van-row>
                             <van-row>
                                 <van-col span="12">考试状态</van-col>
-                                <van-col span="12">{{ item.examState===''?'/':item.examState===null?'/':item.examState }}</van-col>
+                                <van-col span="12">{{ item.examState===''?'/':item.examState===null?'/':item.examState===undefined?'/':item.examState }}</van-col>
                             </van-row>
                             <van-row>
                                 <van-col span="12">限考时间</van-col>
-                                <van-col span="12">{{ item.limitDate===''?'/':item.limitDate===null?'/':item.limitDate }}</van-col>
+                                <van-col span="12">{{ item.limitDate===''?'/':item.limitDate===null?'/':item.limitDate===undefined?'/':item.limitDate }}</van-col>
                             </van-row>
                             <van-row>
                                 <van-col span="12">限考次数</van-col>
-                                <van-col span="12">{{ item.limitCount===''?'/':item.limitCount===null?'/':item.limitCount }}</van-col>
+                                <van-col span="12">{{ item.limitCount===''?'/':item.limitCount===undefined?'/':item.limitCount===null?'/':item.limitCount }}</van-col>
                             </van-row>
                             <van-row>
                                 <van-col span="12">考试时长</van-col>
                                 <van-col
                                     span="12"
-                                >{{ item.duration===''?'/':item.duration===null?'/':item.duration==='不限'?item.duration:transformTime(item.duration) }}</van-col>
+                                >{{ item.duration===''?'/':item.duration===undefined?'/':item.duration===null?'/':item.duration==='不限'?item.duration:transformTime(item.duration) }}</van-col>
                             </van-row>
                             <van-row>
                                 <van-col span="12">考试题库</van-col>
-                                <van-col span="12">{{ item.bankName===''?'/':item.bankName===null?'/':item.bankName }}</van-col>
+                                <van-col span="12">{{ item.bankName===''?'/':item.bankName===null?'/':item.bankName===undefined?'/':item.bankName }}</van-col>
                             </van-row>
                         </template>
                         <!-- 插入内容 -->
@@ -451,6 +451,7 @@ export default {
         // 下拉刷新
         onRefresh() {
             this.footText = false
+            this.noData = false
             this.refreshing = true
             this.finished = false
             this.loading = true
@@ -460,6 +461,9 @@ export default {
             this.checkedIds = []
             this.checkMode = false
             this.onRefresh()
+        },
+        searchGao() {
+
         },
         /**
        * 加载数据
@@ -473,11 +477,10 @@ export default {
                 page = this.current * 10
             }
             const aa = JSON.parse(JSON.stringify(this.moreParams))
+            let canshu3 = ''
+            let canshu4 = ''
             if ((aa !== '' && aa !== null && aa !== undefined && (typeof aa !== 'object' || Object.keys(aa).length > 0)) ||
           (aa instanceof Array && aa.length > 0)) {
-                //   { prop: 'examName', label: '考试名称', fieldType: 'text' },
-                // { prop: 'bankName', label: '题库名称', fieldType: 'text' },
-                //   //  {examName: '自主考核', bankName: '提示', examType: 'trainingExam'}
                 if (aa.examName !== '' && aa.examName !== undefined && aa.examName !== null) {
                     this.moreSubject = aa.examName
                 }
@@ -487,59 +490,35 @@ export default {
                 if (aa.examType !== '' && aa.examType !== undefined && aa.examType !== null) {
                     this.name = aa.examType === 'trainingExam' ? '培训考试' : aa.examType === 'POCTtraining' ? 'POCT培训' : aa.examType === 'selfAssessment' ? '自主考核' : aa.examType === 'routine' ? '常规' : '全部'
                 }
-                // 两者有一个
-                if (aa.startDateDL || aa.startDateDG) {
-                    // 两者都有
-                    if (aa.startDateDL && aa.startDateDG) {
-                        this.startTime.push(aa.startDateDL)
-                        this.startTime.push(aa.startDateDG)
-                    } else if (aa.startDateDL) {
-                        // 只有左边
-                        this.startTime.push(aa.startDateDL)
-                    } else {
-                        // 只有右边
-                        this.startTime.push(aa.startDateDG)
-                    }
-                }
+                this.startTime = []
                 if (aa.limitDateDL || aa.limitDateDG) {
                     if (aa.limitDateDL && aa.limitDateDG) {
-                        this.endTime.push(aa.limitDateDL)
-                        this.endTime.push(aa.limitDateDG)
+                        canshu4 = `AND limitDate BETWEEN '${aa.limitDateDL}' AND '${aa.limitDateDG}'`
                     } else if (aa.limitDateDL) {
-                        // 只有左边
-                        this.endTime.push(aa.limitDateDL)
-                    } else {
-                        // 只有右边
-                        this.endTime.push(aa.limitDateDG)
+                        canshu4 = `AND limitDate>= '${aa.limitDateDL}'`
+                    } else if (aa.limitDateDG) {
+                        canshu4 = `AND limitDate<='${aa.limitDateDG}'`
+                    }
+                }
+                if (aa.startDateDL || aa.startDateDG) {
+                    if (aa.startDateDL && aa.startDateDG) {
+                        canshu3 = `AND startDate BETWEEN '${aa.startDateDL}' AND '${aa.startDateDG}'`
+                    } else if (aa.startDateDL) {
+                        canshu3 = `AND startDate>= '${aa.startDateDL}'`
+                    } else if (aa.startDateDG) {
+                        canshu3 = `AND startDate<='${aa.startDateDG}'`
                     }
                 }
             }
             const key = this.subject
             const key1 = this.moreSubject
             const key2 = this.subjectTitle
-            const key3 = this.startTime
-            const key4 = this.endTime
             const canshu1 = key1 !== '' ? `and examName like '%${key1}%'` : ''
             const canshu2 = key2 !== '' ? `and bankName like '%${key2}%'` : ''
-            let canshu3 = ''
-            let canshu4 = ''
-            if (this.startTime.length === 1) {
-                canshu3 = `AND startDate>=${key3[0]}`
-            } else if (this.startTime.length === 2) {
-                canshu3 = `AND startDate BETWEEN '${key3[0]}' AND '${key3[1]}'`
-            }
-            if (this.endTime.length === 1) {
-                canshu4 = `AND limitDate<=${key4[0]}`
-            } else if (this.endTime.length === 2) {
-                canshu4 = `AND limitDate BETWEEN '${key4[0]}' AND '${key4[1]}'`
-            }
-            if (canshu4) {
-                canshu4 = `${canshu4} AND limitDate='不限'`
-            }
             const canshu = (key1 !== '' || key2 !== '') ? `${canshu1} ${canshu2}`.trim() : key !== '' ? `and (examName like '%${key}%' or bankName like '%${key}%')` : ''
             // let canshu = key != '' ? `and (examName like '%${key}%' or bankName like '%${key}%')` : ''
             // const sql = `select * from v_examination where examinee = '${this.info.employee.id}' and examType like '%${this.name === '全部' ? '' : this.name}%' ${canshu} ORDER BY startDate DESC LIMIT ${page},10`
-            const sql1 = `select * from (select * from v_examination where examinee = '${this.info.employee.id}' and examType like '%${this.name === '全部' ? '' : this.name}%' ${canshu}${canshu3}${canshu4}  ORDER BY startDate DESC LIMIT ${page},10) a LEFT JOIN (select exam_id_,id_,COUNT(id_) as num from t_examination where kao_shi_ren_ = '${this.info.employee.id}' and zhuang_tai_ != '已取消' GROUP BY exam_id_) b on a.examId = b.exam_id_`
+            const sql1 = `select * from (select * from v_examination where examinee = '${this.info.employee.id}' and examType like '%${this.name === '全部' ? '' : this.name}%' ${canshu}${canshu3}${canshu4} ORDER BY startDate DESC LIMIT ${page},10) a LEFT JOIN (select exam_id_,id_,COUNT(id_) as num from t_examination where kao_shi_ren_ = '${this.info.employee.id}' and zhuang_tai_ != '已取消' GROUP BY exam_id_) b on a.examId = b.exam_id_`
             // let sql2 = `select * from (select * from t-exams ) a LEFT JOIN () B ON a.examId=b.exam_id_`
             this.$common.request('sql', sql1).then(res => {
                 if (this.current === 0 && res.variables.data.length === 0) {
@@ -552,6 +531,7 @@ export default {
                 this.refreshing = false
                 if (this.listData.length !== 0 && (this.listData.length) % 10 !== 0) {
                     this.footText = true
+                    this.noData = false
                     this.finished = true
                     return
                 } else {
@@ -582,29 +562,6 @@ export default {
             const minutes = Math.floor((parseInt(timeStamp) % 3600000) / 60000)
             return hours + '小时' + minutes + '分钟'
         }
-        // onRemove() {
-        //     if (this.checkedIds.length === 0) {
-        //         this.$notify({
-        //             type: 'warning',
-        //             message: this.$t('common.dialog.selectedRecords')
-        //         })
-        //         return
-        //     }
-        //     this.$dialog.confirm({
-        //         title: this.$t('common.dialog.warn'),
-        //         message: this.$t('common.operate.makeSure')
-        //     }).then(() => {
-        //         removeDraft({ ids: this.selectedIds }).then(response => {
-        //             this.$notify({
-        //                 type: 'success',
-        //                 message: '删除草稿成功!'
-        //             })
-        //             this.onRefreshPage()
-        //         }).catch((e) => {
-        //             console.error(e)
-        //         })
-        //     })
-        // }
     }
 }
 </script>