Преглед на файлове

修改测试量表---及选不选逻辑

plg преди 2 месеца
родител
ревизия
a0d750d817
променени са 4 файла, в които са добавени 363 реда и са изтрити 41 реда
  1. 1 1
      src/router/index.ts
  2. 2 2
      src/views/Plan.vue
  3. 290 34
      src/views/Scale.vue
  4. 70 4
      src/views/ScaleDetail.vue

+ 1 - 1
src/router/index.ts

@@ -77,7 +77,7 @@ const routes = [
 
     },
     {
-      path: 'scale/:planId/:planName/:flag/:flagName',
+      path: 'scale/:planId/:planName/:flag/:flagName/:isComplate',
       name: 'scale',
       component: () => import('@/views/Scale.vue')
 

+ 2 - 2
src/views/Plan.vue

@@ -233,11 +233,11 @@ const planNumGet = async () => {
                         }
                     }
 
-                    if (planList.value[i].list[j].contentType == '0' && planList.value[i].list[j].isAvailable == '1') {
+                    if (planList.value[i].list[j].contentType == '0' && planList.value[i].list[j].isAvailable == '1' && planList.value[i].list[j].isDisplayed == '1') {
                         console.log(planList.value[i].list[j])
                         planList.value[i].scaleList.push(planList.value[i].list[j])
                     }
-                    if (planList.value[i].list[j].contentType == '1' && planList.value[i].list[j].isAvailable == '1') {
+                    if (planList.value[i].list[j].contentType == '1' && planList.value[i].list[j].isAvailable == '1' && planList.value[i].list[j].isDisplayed == '1') {
                         console.log(planList.value[i].list[j])
                         planList.value[i].taskList.push(planList.value[i].list[j])
                     }

+ 290 - 34
src/views/Scale.vue

@@ -7,13 +7,15 @@ import { Check } from '@element-plus/icons-vue'
 import { number } from 'echarts';
 import { ElMessage } from 'element-plus';
 import { useRouter, useRoute } from 'vue-router';
-import { getScaleApi, saveScaleApi } from '@/api/plan';
+import { getScaleApi, queryScaleDetailApi, saveScaleApi } from '@/api/plan';
 import { userInfoStore } from '@/stores'
 
 // 加一个锁表示不能重复点击
 const isLock = ref<boolean>(false)
 
 import { isHaveManage } from '@/utils/test'
+import { userPlanApi, userPlanDetailApi } from '@/api/home';
+import { id } from 'element-plus/es/locales.mjs';
 const userInfo = userInfoStore()
 const router = useRouter()
 const route = useRoute()
@@ -25,13 +27,22 @@ const route = useRoute()
 //当前量表是否已经提交
 const isCompleted = ref<boolean>(false)
 
+const planObj = ref<any>({})
+
 const flag = ref<string>('')
 const flagName = ref<string>('')
 const planId = ref<string>('')
 const planName = ref<string>('')
 const startTime = ref<string>('')
 const num = ref<string>('')
+const isComplate = ref<string>('')
 
+//测试全部数字
+const planAllNum = ref<number>(0);
+//测试已完成的 
+const planIsComplateNum = ref<number>(0);
+//测试未完成的
+const planNoComplateNum = ref<number>(0);
 
 //获取到的题目数组
 const scaleList = ref<any>([
@@ -61,8 +72,23 @@ const scaleList = ref<any>([
 //刚进页面时第几题
 const topicIndex = ref<number>(1)
 
+//存储--方法的
+//有三个储存数组分别储存
+
+//抑郁自评量表
+//抑郁自评量表flag是"20210617020516"
+const listDepressed = ref<any>([])
+//知觉压力问卷
+//知觉压力量表flag是"20210913093250"
+const listStress = ref<any>([])
+//焦虑自评量表
+//焦虑自评量表flag是"20210617000853"
+const listAnxiety = ref<any>([])
+
+
 //下一题的方法
 const nextTopic = () => {
+    //当前选项的flag //是多少题
     //判断当前索引下的数组中是否有isCheck为空
     //先判断这个是不是
     if (scaleList.value[topicIndex.value - 1].isCheck == '') {
@@ -72,26 +98,91 @@ const nextTopic = () => {
         })
         return
     }
+    //已经选择的话---需要拿到当前对象---判断flag是另外三个的flag吗
+    //如果是--则判断是否在数组里边--如果不在则存储
+    //将抑郁自评量表的数据存储进数组
+    if (scaleList.value[topicIndex.value - 1].flag == '20210617020516' && !listDepressed.value.includes(scaleList.value[topicIndex.value - 1].id)) {
+        listDepressed.value.push(scaleList.value[topicIndex.value - 1].id)
+        //判断抑郁压力数组的长度是20 调用保存接口
+        //循环到数组 当前中所有flag 等于抑郁自评量表的数组--然后传输给保存方法
+        //判断此数组长度是多少
+        if (listDepressed.value.length == 20) {
+            let list = []
+            for (let i = 0; i < scaleList.value.length; i++) {
+                if (scaleList.value[i].flag == '20210617020516') {
+                    list.push(scaleList.value[i])
+                }
+            }
+            let listTm = JSON.parse(JSON.stringify(list))
+            subScaleData(listTm, "20210617020516")
+        }
+
+
+    }
+    //将知觉压力问卷的数据存储进数组
+
+    if (scaleList.value[topicIndex.value - 1].flag == '20210913093250' && !listStress.value.includes(scaleList.value[topicIndex.value - 1].id)) {
+        listStress.value.push(scaleList.value[topicIndex.value - 1].id)
+        //调用知觉压力数据保存接口
+        //如果长度达到指定数目
+        if (listStress.value.length == 30) {
+            let list = []
+            for (let i = 0; i < scaleList.value.length; i++) {
+                if (scaleList.value[i].flag == '20210913093250') {
+                    list.push(scaleList.value[i])
+                }
+            }
+            let listTm = JSON.parse(JSON.stringify(list))
+
+            subScaleData(listTm, "20210913093250")
+        }
+
+    }
+    //将焦虑自评量的数据存储进数组
+    if (scaleList.value[topicIndex.value - 1].flag == '20210617000853' && !listAnxiety.value.includes(scaleList.value[topicIndex.value - 1].id)) {
+        listAnxiety.value.push(scaleList.value[topicIndex.value - 1].id)
+        //调用焦虑
+        if (listAnxiety.value.length == 20) {
+            let list = []
+            for (let i = 0; i < scaleList.value.length; i++) {
+                if (scaleList.value[i].flag == '20210617000853') {
+                    list.push(scaleList.value[i])
+                }
+            }
+            let listTm = JSON.parse(JSON.stringify(list))
+            subScaleData(listTm, "20210617000853")
+        }
+
+    }
+
     //判断当前是不是最后一题
     //如果是最后一题就不++了
     if (topicIndex.value == scaleList.value.length) {
+        // 最后一题就进行提交了
+        //判断不是这三个的话
+        if (scaleList.value[topicIndex.value - 1].flag != '20210617020516' && scaleList.value[topicIndex.value - 1].flag != '20210913093250' && scaleList.value[topicIndex.value - 1].flag != '20210617000853') {
+            let listTm = JSON.parse(JSON.stringify(scaleList.value))
+            subScaleData(listTm, flag.value)
+        }
+        // subScaleData(listTm, "20210617000853")
         return
     }
     topicIndex.value++
 
 }
-const subScaleData = async () => {
+//将选择的传输给方法---自带flag
+const subScaleData = async (data: any, flag: string) => {
     if (isLock.value) {
         return
     }
     isLock.value = true
-    if (scaleList.value[topicIndex.value - 1].isCheck == '') {
-        ElMessage({
-            message: '请选择当前题目',
-            type: "warning",
-        })
-        return
-    }
+    // if (scaleList.value[topicIndex.value - 1].isCheck == '') {
+    //     ElMessage({
+    //         message: '请选择当前题目',
+    //         type: "warning",
+    //     })
+    //     return
+    // }
     //开始调用提交数据的方法
 
     // testRecord: JSON.stringify(productData()),
@@ -104,47 +195,190 @@ const subScaleData = async () => {
         orgNo: userInfo.userInfo.orgNo,
         planId: planId.value,
         planName: planName.value,
-        taskFlag: flag.value,
+        taskFlag: flag,
         taskName: flagName.value,
-        testRecord: JSON.stringify(productData()),
+        testRecord: JSON.stringify(productData(data)),
         type: '0',
         userName: userInfo.userInfo.userName,
         userNo: userInfo.userInfo.userNo,
     }
     const res = await saveScaleApi(params)
 
-    //提交后需要调用----看看是否还需要做附加题
+    //1.先判断是否需要做附加题---根据查询出来列表  --不显示但是必做的---且状态含有未完成,
+    //2.接下来查看需要看总共几个需要做的附加题---将未完成的题目---合并到一块---到时候
+    //3.判断做完的有且有多少个题目-----未做完的量表有多少个题目    
+
+
+    isLock.value = false
     ElMessage({
         message: '提交完成',
         type: "success",
     })
+    //判断当前 flag 是可选的三个吗
+    //如果是的话---
+    if (flag == '20210617020516' || flag == '20210913093250' || flag == '20210617000853') {
+        //判断是否是做完了
+        if (topicIndex.value == scaleList.value.length) {
+            //这时是全部的都做完了
+            //做完后目前先跳转到测试计划页面
+            router.push({ name: 'plan' })
+        }
+    }
+    if (flag == '20210617140713') {
+
+        queryNeedScale()
+        //如果是排除是其他两个则直接返回
+    } else if (flag != '20210617020516' && flag != '20210913093250' && flag != '20210617000853') {
+        //此时做完需要跳转到计划页面
+        router.push({ name: 'plan' })
+    }
+
+
+
+
+
     // isCompleted.value = true
     //跳转到缓冲中间件
-    setTimeout(() => {
-        isLock.value = false;
-        router.push({
-            name: 'scaleMid', params: {
-                planId: planId.value,
-                planName: planName.value,
-                flag: flag.value,
-                flagName: flagName.value,
-                // num: num.value
+    // setTimeout(() => {
+    //     isLock.value = false;
+    //     router.push({
+    //         name: 'scaleMid', params: {
+    //             planId: planId.value,
+    //             planName: planName.value,
+    //             flag: flag.value,
+    //             flagName: flagName.value,
+    //             // num: num.value
+    //         }
+    //     })
+    // }, 1500)
+}
+//根据计划ID查询问题
+const queryNeedScale = async () => {
+    //
+    //查询需要测试的计划
+    //如果在就是登录了
+    if (userInfo.token) {
+        let userNo = ''
+        //登录的话
+        //判断当前是否有后台管理
+
+        userNo = userInfo.userInfo.userNo
+
+        //调用根据用户查询计划的API
+        let res: any = await userPlanApi(userNo)
+        //
+
+        for (let i = 0; i < res.data.length; i++) {
+            if (res.data[i].id = planId.value) {
+                planObj.value = res.data[i]
             }
-        })
-    }, 1500)
+
+        }
+        //将list赋值进去
+        planObj.value.list = [];
+        let params = {
+            planId: planObj.value.id,
+            userNo: userInfo.userInfo.userNo
+        }
+        //调用详细的API
+        let temp: any = await userPlanDetailApi(params)
+        planObj.value.list = temp.data
+        console.log('planObj')
+        console.log(planObj.value)
+        //判断是否需要
+        //判断量表中有几个是必须测试的且不显示的
+        let list = []
+        for (let i = 0; i < planObj.value.list.length; i++) {
+            //先判断类型--在判断必做且不显示的---将这个写存储在数组
+            if (planObj.value.list[i].contentType == '0' && planObj.value.list[i].isAvailable == '1' && planObj.value.list[i].isDisplayed == '0') {
+                //修改
+                //
+                list.push(planObj.value.list[i])
+            }
+        }
+        //将对象的list字段设置新的需要测试的
+        planObj.value.list = list;
+
+        //以此查询出来需要需要做的但是未完成的
+        //必做的全部计算出来全部需要做的题
+        let listNeedAll = []
+        let listIsComplate = []
+        let listNoComplate = []
+        for (let i = 0; i < planObj.value.list.length; i++) {
+            //查询出全部的问题
+            //根据flag查询出来的题
+            //let res: any = await queryScaleDetailApi(planObj.value.list[i].flag)
+            if (planObj.value.list[i].isCompleted == '1') {
+                let res: any = await getScaleApi(planObj.value.list[i].flag)
+                listIsComplate.push(...res.data)
+                listNeedAll.push(...res.data)
+            }
+            //计算未完成数目
+            if (planObj.value.list[i].isCompleted == '0') {
+                let res: any = await getScaleApi(planObj.value.list[i].flag)
+                listNoComplate.push(...res.data)
+                listNeedAll.push(...res.data)
+            }
+            //查询出来后将值赋值给另一数组
+            //总共需要做的题的数目
+        }
+        //测试全部数字
+        planAllNum.value = listNeedAll.length;
+        //测试已完成
+        planIsComplateNum.value = listIsComplate.length;
+        //测试未完成
+        planNoComplateNum.value = listNoComplate.length;
+        console.log('总长度')
+        console.log(listNeedAll.length)
+        console.log('已经测过的长度')
+        console.log(listIsComplate.length)
+        console.log('未测过的长度')
+        console.log(listNoComplate.length)
+        //判断 如果总长度是0的话--需要跳转到测试计划页
+        if (planAllNum.value == 0) {
+            //跳转计划页面
+            router.push({ name: 'plan' })
+        } else {
+            //如果长度不是0的话--需要修改文本
+            //设置标志为2
+            isComplate.value = '2'
+        }
+        //这时应该清空一下index 
+        topicIndex.value = 1
+        scaleList.value = listNoComplate
+        for (let i = 0; i < scaleList.value.length; i++) {
+            scaleList.value[i].isCheck = ''
+        }
+        console.log(scaleList.value)
+
+    }
+
 
 }
-const productData = () => {
+//根据flag查询量表详情
+
+
+// console.log(res)
+// scaleName.value = res.data.name;
+// detail.value = res.data.description;
+// theory.value = res.data.theory;
+// //参考文献
+// console.log(res.data.reference)
+// reference.value = res.data.reference.split('//');
+// console.log(reference.value)
+
+
+const productData = (data: any) => {
     //循环列表
     //查看isCheck字段
     //根据字段拿出答案
     //将答案放入数组
     let testRecord = []
-    for (let i = 0; i < scaleList.value.length; i++) {
-        for (let k = 0; k < scaleList.value[i].answerList.length; k++) {
-            if (scaleList.value[i].isCheck === scaleList.value[i].answerList[k].name) {
+    for (let i = 0; i < data.length; i++) {
+        for (let k = 0; k < data[i].answerList.length; k++) {
+            if (data[i].isCheck === data[i].answerList[k].name) {
                 //r
-                testRecord.push(scaleList.value[i].answerList[k])
+                testRecord.push(data[i].answerList[k])
             }
         }
     }
@@ -180,9 +414,25 @@ onMounted(() => {
     planName.value = route.params.planName as string
     flagName.value = route.params.flagName as string
     num.value = route.params.num as string
+    isComplate.value = route.params.isComplate as string
     //进到界面开始轮询
+
+    // 判断是否SCL90
+    if (flag.value == '20210617140713') {
+        //如果是的话--判断scl90的状态
+        if (isComplate.value == '0') {
+            getScaleFun(flag.value)
+        } else if (isComplate.value == '2') {
+            queryNeedScale();
+        }
+    } else {
+        getScaleFun(flag.value)
+    }
     getStartTime()
-    getScaleFun(flag.value)
+
+    //判断是否是完成了
+    //如果标志是
+
 })
 //获取当前时间
 const getStartTime = () => {
@@ -225,7 +475,8 @@ onUnmounted(() => {
             <CpmdHeader />
             <div class="report_top">
                 <div class="report_jt">
-                    <span v-show="!isCompleted">{{ flagName }}</span>
+                    <span v-if="!(flag == '20210617140713' && isComplate == '2')">{{ flagName }}</span>
+                    <span v-if="flag == '20210617140713' && isComplate == '2'"> 症状自评量表(附加题)</span>
                     <span v-show="!isCompleted" class="des">请根据您的表现回答下列问题,每道题请选择最符合您的情况的选项。</span>
                 </div>
                 <img v-show="!isCompleted" class="xlts_img" src="../assets/scale/scale.png" />
@@ -235,10 +486,15 @@ onUnmounted(() => {
         <div class="kply">
             <div class="kply_inner" :style="{ border: isCompleted ? '8px solid #ffffff' : '8px solid #B2F2D2' }">
                 <div style="padding :10px 100px">
-                    <el-progress v-show="!isCompleted" :text-inside="true" :stroke-width="20"
-                        :percentage="(topicIndex / scaleList.length) * 100" color="#48D68E">
+                    <el-progress v-if="!(flag == '20210617140713' && isComplate == '2')" :text-inside="true"
+                        :stroke-width="20" :percentage="(topicIndex / scaleList.length) * 100" color="#48D68E">
                         <span style="color:#000000">{{ topicIndex }}/{{ scaleList.length }}</span>
                     </el-progress>
+                    <el-progress v-if="flag == '20210617140713' && isComplate == '2'" :text-inside="true"
+                        :stroke-width="20" :percentage="((topicIndex + planIsComplateNum) / planAllNum) * 100"
+                        color="#48D68E">
+                        <span style="color:#000000">{{ topicIndex + planIsComplateNum }}/{{ planAllNum }}</span>
+                    </el-progress>
                     <div v-if="scaleList.length > 0">
                         <div class="scale_title">{{ topicIndex }}:{{ scaleList[topicIndex - 1].content }}</div>
 
@@ -256,8 +512,8 @@ onUnmounted(() => {
                                 <el-col :span="12" class="scale_button_inner">
                                     <div v-show="topicIndex < scaleList.length" class="scale_button_self"
                                         @click="nextTopic">下一题</div>
-                                    <div v-show="topicIndex == scaleList.length" class="scale_button_self"
-                                        @click="subScaleData">提交</div>
+                                    <!-- <div v-show="topicIndex == scaleList.length" class="scale_button_self"
+                                        @click="subScaleData">提交</div> -->
                                 </el-col>
                             </el-row>
 

+ 70 - 4
src/views/ScaleDetail.vue

@@ -2,7 +2,10 @@
 import CpmdHeader from '@/components/CpmdHeader.vue';
 import { queryScaleDetailApi } from '@/api/plan'
 import { ref, onMounted } from 'vue'
+import { userInfoStore } from '@/stores'
 import { useRoute, useRouter } from 'vue-router'
+import { userPlanApi, userPlanDetailApi } from '@/api/home';
+const userInfo = userInfoStore();
 const route = useRoute()
 const router = useRouter()
 //测试flag
@@ -22,6 +25,10 @@ const theory = ref<string>('')
 const reference = ref<string>('')
 //量表名称
 const scaleName = ref<string>('')
+
+//
+const planObj = ref<any>({})
+const isComplate = ref<string>()
 onMounted(() => {
     //修改 flag    
     flag.value = route.params.flag as string;
@@ -36,8 +43,69 @@ onMounted(() => {
     //拿到以后根据根据flag查询
     if (type.value == '0') {
         queryScaleDetail()
+        sclStatus()
     }
 })
+//在这个页面设置一下
+//查询scl90的状态是什么
+const sclStatus = async () => {
+    //先判断是否是scl90
+    //如果是的话---则判断是否状态已完成
+    if (flag.value == "20210617140713") {
+        //
+        let userNo = ''
+        //登录的话
+        //判断当前是否有后台管理
+        userNo = userInfo.userInfo.userNo
+        //调用根据用户查询计划的API
+        let res: any = await userPlanApi(userNo)
+        for (let i = 0; i < res.data.length; i++) {
+            if (res.data[i].id = planId.value) {
+                planObj.value = res.data[i]
+            }
+
+        }
+        //将list赋值进去
+        planObj.value.list = [];
+        let params = {
+            planId: planObj.value.id,
+            userNo: userInfo.userInfo.userNo
+        }
+        //调用详细的API
+        let temp: any = await userPlanDetailApi(params)
+        planObj.value.list = temp.data
+        //循环list 查询到量表的状态
+        for (let i = 0; i < planObj.value.list.length; i++) {
+            if (planObj.value.list[i].flag == '20210617140713') {
+                if (planObj.value.list[i].isCompleted == '0') {
+                    isComplate.value = planObj.value.list[i].isCompleted
+                } else if (planObj.value.list[i].isCompleted == '1') {
+                    //此时应该判断--他后边还有需要做的吗  必做--不显示的量表--如果有状态改为2 --如果没有状态改为1
+                    let listTmp = []
+                    for (let j = 0; j < planObj.value.list.length; j++) {
+
+                        if (planObj.value.list[j].isDisplayed == '0' && planObj.value.list[j].isAvailable == '1' && planObj.value.list[j].isCompleted == '0') {
+                            listTmp.push('1')
+                        }
+                    }
+                    if (listTmp.length > 0) {
+                        isComplate.value = '2'
+                    } else {
+                        isComplate.value = '1'
+                    }
+                }
+            }
+        }
+        //得到list
+
+
+    }
+    //如果是1的状态 需要
+
+    //判断当前scl90的状态是什么
+
+}
+
 const queryScaleDetail = async () => {
     //根据flag查询量表详情
     let res: any = await queryScaleDetailApi(flag.value)
@@ -49,7 +117,6 @@ const queryScaleDetail = async () => {
     console.log(res.data.reference)
     reference.value = res.data.reference.split('//');
     console.log(reference.value)
-    debugger
 }
 const startText = () => {
     //当;类型是0时、、跳转到量表测试界面
@@ -57,15 +124,14 @@ const startText = () => {
         //开始跳转到scal90测试界面
         router.push({
             name: 'scale',
-
             params: {
                 planId: planId.value,
                 planName: planName.value,
                 flag: flag.value,
-                flagName: scaleName.value
+                flagName: scaleName.value,
+                isComplate: isComplate.value
             }
         })
-
     }
 }
 //接受来自计划页面的参数