Quellcode durchsuchen

修改问卷调查

plg vor 5 Monaten
Ursprung
Commit
4bc8796f55
6 geänderte Dateien mit 250 neuen und 14 gelöschten Zeilen
  1. 32 0
      src/api/home.ts
  2. 2 1
      src/components/CpmdHeader.vue
  3. 169 0
      src/components/CpmdQuestionnaire.vue
  4. 4 1
      src/main.ts
  5. 2 2
      src/utils/http.ts
  6. 41 10
      src/views/HomeView.vue

+ 32 - 0
src/api/home.ts

@@ -1,10 +1,18 @@
 import { http } from '@/utils/http'
+
 const homeUrl = ''
 
 //测试计划
 const userPlanUrl = '/plan/findRunningPlanByUserNo'
 //测试计划详细信息
 const userPlanDetailUrl = '/planContent/findAllByPlanId'
+//获取问卷调查项的列表
+const queryQuestionUrl = '/questionnaire/findAllByType'
+//查看当前用户是否需要填写问卷调查
+const queryIsQuestionUrl = '/userQuestionnaire/checkByUser'
+
+//保存问卷调查
+const quesQuestionUrl = `/userQuestionnaire/saveResult`
 //首页API
 export const homeApi = (val: any) => {
     return http<any>(
@@ -40,4 +48,28 @@ export const userPlanDetailApi = (val: any) => {
             method: 'get',
             url: `${userPlanDetailUrl}?planId=${val.planId}&userNo=${val.userNo}`
         })
+}
+
+//获取问卷调查项的列表
+export const queryQuestionApi = (val: any) => {
+    return http<any>({
+        methods: 'get',
+        url: `${queryQuestionUrl}?type=${val}`
+    })
+}
+
+//查看当前用户是否需要填写问卷调查
+export const queryIsQuestionApi = () => {
+    return http<any>({
+        method: 'get',
+        url: `${queryIsQuestionUrl}`
+    })
+}
+//保存当前问卷调查
+export const sqveQuesQuestionApi = (val: any) => {
+    return http<any>({
+        method: 'post',
+        url: `${quesQuestionUrl}`,
+        data: val
+    })
 }

+ 2 - 1
src/components/CpmdHeader.vue

@@ -90,7 +90,7 @@ const formatterName = (val: string) => {
             :ellipsis="false" @select="handleSelect">
             <el-menu-item index="1">首&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;页</el-menu-item>
 
-            <el-menu-item index="3">留言社区</el-menu-item>
+
             <!-- <el-badge :value="200" :max="99" class="item">
                 <el-menu-item index="4">测试计划</el-menu-item>
             </el-badge> -->
@@ -102,6 +102,7 @@ const formatterName = (val: string) => {
             </el-menu-item>
             <el-menu-item index="5">测试记录</el-menu-item>
             <el-menu-item index="2">更多测试</el-menu-item>
+            <el-menu-item index="3">留言社区</el-menu-item>
         </el-menu>
 
         <div class="login_button_bg" @mouseenter="comeMenu" @mouseleave="leaveMenu" v-show="userInfo.userInfo.userName">

+ 169 - 0
src/components/CpmdQuestionnaire.vue

@@ -0,0 +1,169 @@
+<script lang="ts" setup>
+import { queryQuestionApi, sqveQuesQuestionApi, userPlanDetailApi } from '@/api/home';
+import { userInfoStore } from '@/stores';
+import Plan from '@/views/Plan.vue';
+import { Model } from 'echarts';
+import { ElMessage } from 'element-plus';
+import { format } from 'date-fns/format';
+import { ref, defineExpose, reactive } from 'vue'
+import { useRouter } from 'vue-router'
+const router = useRouter()
+const userInfo = userInfoStore()
+const dialogVisible = ref<boolean>(false)
+
+const ruleForm = reactive<any>({
+    //是否是少数民族
+    isMinority: false,
+    //出生年月
+    birthday: '',
+    //是否是独生子女
+    isOnlyChild: false,
+    //父母婚姻状况
+    matrimony: 1,
+    //异常体质
+    abnormal: '',
+    //吸烟程度
+    smoking: '',
+    //饮酒程度
+    drink: '',
+    //您在成长过程中是否有过被寄养在别人家的经历
+    isFoster: false,
+    //您在成长过程中是否有过超过六个月的留守经历
+    isLeftBehind: false,
+    //有无经济压力
+    economy: false,
+    //有无学业压力
+    schoolWork: false,
+    //有无就业压力
+    job: false,
+    //是否迷茫
+    confused: false
+
+})
+const questionList = ref<any>()
+//调用接口  查询问卷调查项的接口
+const queryQuestion = async (planId: string) => {
+    //
+    console.log("userInfo")
+    console.log(userInfo.userInfo)
+    questionList.value = [];
+    let list: any = await queryQuestionApi('0')
+    for (let i = 0; i < list.data.length; i++) {
+        let obj = {
+            quesId: list.data[i].id,
+            optionValue: "",//问题已选的答案
+            idMandatory: list.data[i].idMandatory,
+            mulValue: list.data[i].optionValue.split(';'),//全部备选答案
+            orgNo: userInfo.userInfo.orgNo,//组织编号
+            planId: planId,//计划ID
+            quesName: list.data[i].name,//计划问题
+            quesType: list.data[i].quesType,//问题类型
+            sortValue: list.data[i].sortValue,//排序值
+            topicType: list.data[i].topicType,//本题类型
+            userName: userInfo.userInfo.userName,//用户姓名
+            userNo: userInfo.userInfo.userNo,//用户编号
+        }
+        questionList.value.push(obj)
+    }
+    console.log("questionList.value")
+    console.log(questionList.value)
+
+    //从此得到返回列表
+}
+
+//提交答案时校验
+const submitQuestion = () => {
+    console.log(questionList.value)
+    for (let i = 0; i < questionList.value.length; i++) {
+        console.log(questionList.value[i].optionValue)
+        if (questionList.value[i].topicType == '3' && questionList.value[i].optionValue != '') {
+            //格式化时间格式
+            questionList.value[i].optionValue = format(questionList.value[i].optionValue, "yyyy-MM-dd");
+        }
+        if (questionList.value[i].idMandatory == '1') {
+            if (questionList.value[i].optionValue == '') {
+                ElMessage({
+                    message: `请完成必选项:${questionList.value[i].quesName}`,
+                    type: 'error'
+                })
+                return
+            }
+        }
+    }
+    //调用保存的接口
+    //保存接口
+    saveQuesQuestion()
+
+
+}
+//保存问卷接口
+const saveQuesQuestion = async () => {
+    let res: any = await sqveQuesQuestionApi(questionList.value)
+    if (res.code == 200) {
+        //跳转到测试计划
+        router.push({ name: 'plan' })
+    }
+}
+
+const open = (planId: string) => {
+
+    dialogVisible.value = true
+
+    //拿到登录用户的信息
+
+    queryQuestion(planId)
+}
+//
+defineExpose({ open })
+</script>
+<template>
+    <el-dialog v-model="dialogVisible" title="问卷填写" width="600px" top="15vh">
+        <span style="height: 60vh;display: flex;overflow-y: auto;">
+            <div v-if="questionList.length > 0">
+                <div v-for="item, index in questionList" :key="item.id" class="question_out">
+                    <div class="title_out">
+                        <span class="xing">{{ item.idMandatory == '1' ? '*' : '' }}</span><span>{{
+                            item.quesName }}</span>
+                    </div>
+
+                    <el-radio-group v-model="item.optionValue" v-if="item.topicType == '1'" class="question_radio">
+                        <el-radio :label="ch" v-for="ch in item.mulValue" :key="ch"></el-radio>
+                        <!-- <el-radio label="线下场地免费"></el-radio> -->
+                    </el-radio-group>
+                    <el-date-picker v-model="item.optionValue" type="date" placeholder="选择日期" class="question_radio"
+                        v-if="item.topicType == '3'" />
+                </div>
+            </div>
+        </span>
+        <template #footer>
+            <div class="dialog-footer">
+                <el-button @click="dialogVisible = false">关闭</el-button>
+                <el-button type="primary" @click="submitQuestion">
+                    提交
+                </el-button>
+            </div>
+        </template>
+    </el-dialog>
+</template>
+<style lang="scss">
+.question_out {
+    display: flex;
+    flex-direction: column;
+
+    .title_out {
+        display: flex;
+
+        .xing {
+            width: 30px;
+            text-align: right;
+            color: red;
+        }
+    }
+
+    .question_radio {
+        margin-top: 10px;
+        margin-bottom: 10px;
+        margin-left: 30px;
+    }
+}
+</style>

+ 4 - 1
src/main.ts

@@ -5,6 +5,7 @@ import pinia from '@/stores'
 // import { createPinia } from "pinia"
 // import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
 import ElementPlus from 'element-plus'
+import zhCn from 'element-plus/es/locale/lang/zh-cn'
 import 'element-plus/dist/index.css'
 import App from './App.vue'
 import router from './router'
@@ -16,6 +17,8 @@ const app = createApp(App)
 // pinia.use()
 app.use(pinia)
 app.use(router)
-app.use(ElementPlus)
+app.use(ElementPlus, {
+    locale: zhCn
+})
 
 app.mount('#app')

+ 2 - 2
src/utils/http.ts

@@ -11,8 +11,8 @@ const userInfo = userInfoStore()
 //创建axios实例
 
 //创建基础访问路径
-// const base_url = 'http://10.113.248.4:8089/'
-const base_url = 'http://43.143.198.30:8089/'
+const base_url = 'http://10.113.248.4:8089/'
+// const base_url = 'http://43.143.198.30:8089/'
 
 //设置axios 默认访问路径
 axios.defaults.baseURL = base_url

+ 41 - 10
src/views/HomeView.vue

@@ -1,15 +1,24 @@
 <script setup lang="ts">
 import CpmdHeader from '@/components/CpmdHeader.vue';
+import CpmdQuestionnaire from '@/components/CpmdQuestionnaire.vue'
 import { onMounted, onUnmounted, ref } from 'vue'
 import { menuStatusStore, userInfoStore } from '@/stores'
 import { useRouter } from 'vue-router'
 import { isHaveManage } from '../utils/test'
-import { userPlanApi } from '@/api/home';
+import { queryIsQuestionApi, userPlanApi } from '@/api/home';
 const userInfo = userInfoStore()
 const router = useRouter()
 const menuStatus = menuStatusStore();
 menuStatus.saveActiveIndex('1')
 
+//是否需要做问卷调查
+const isNeed = ref<boolean>(false)
+//planId
+//需要问卷调查的计划ID
+const planId = ref<string>('')
+//调用子组件的ref
+const question = ref<any>()
+
 //点击查看更多展开科普乐园的标志
 const moreFlag = ref<boolean>(false)
 
@@ -32,7 +41,8 @@ const taskCircleFlag = ref<boolean>(true)
 //打开任务去看看
 const openSquare = () => {
   // taskSequareFlag.value = true
-  goView()
+  // goView()
+  question.value.open(planId.value)
 }
 //点击关闭按钮触发
 const closeSquare = () => {
@@ -62,9 +72,25 @@ onMounted(() => {
   window.addEventListener('resize', setHeight);
   forStatus()
   planNumGet()
+  queryIsQuestion()
+  //查询是否需要填写问卷调查
+
   //进到界面开始轮询
 })
 
+//
+const queryIsQuestion = async () => {
+  let res: any = await queryIsQuestionApi()
+  console.log("res")
+  planId.value = res.data;
+  if (planId.value == null) {
+    //设置标识不显示
+    isNeed.value = false
+  } else {
+    //设置标志显示
+    isNeed.value = true
+  }
+}
 
 //界面销毁函数
 
@@ -74,15 +100,10 @@ const forStatus = () => {
   clearInterval(flag_time.value)
   // flag_text.value == 2
   flag_time.value = setInterval(() => {
-    console.log('定时器')
-    console.log(flag_text.value)
     flag_text.value = flag_text.value + 1
     if (flag_text.value > 4) {
       flag_text.value = 1
-
     }
-
-
   }, 3000)
 }
 
@@ -113,7 +134,8 @@ const brightStatusLevel = () => {
   forStatus()
 }
 
-
+//进来查看需不需要做问卷调查
+//查看是否需要测试
 
 //获取计划剩余多少个正在进行的
 //isHaveManage//
@@ -279,14 +301,23 @@ const planNumGet = async () => {
         <img width="100%" style="margin-top:40px;" src="../assets/kepu/bg2.png" />
 
       </div>
-      <div class="home_mid_plan" v-show="taskCircleFlag && userInfo.planCurrentNum != 0" @click="openSquare"
+      <!-- <div class="home_mid_plan" v-show="taskCircleFlag && userInfo.planCurrentNum != 0" @click="openSquare"
         ref="plan_jihua">
         <div class=" badge_custom">
           {{ userInfo.planCurrentNum }}
+
+        </div>
+        <img src="../assets/home/jihua_img.png" />
+      </div> -->
+      <div class="home_mid_plan" v-show="isNeed" @click="openSquare" ref="plan_jihua">
+        <div class=" badge_custom">
+          问卷
         </div>
         <img src="../assets/home/jihua_img.png" />
       </div>
+
     </div>
+    <CpmdQuestionnaire ref="question" />
   </div>
 
 </template>
@@ -305,7 +336,7 @@ const planNumGet = async () => {
   color: 10px;
   padding: 8px;
   font-weight: 300;
-  font-size: 16px;
+  font-size: 10px;
   color: #ffffff;
   border-radius: 30px;
 }