|
@@ -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>
|