feat:增加外部考试跳转界面及数据接入,增加投票数据接入及部分界面修改

This commit is contained in:
wyx
2023-02-01 17:40:26 +08:00
parent 8dffddef63
commit 5e8a11feaf
7 changed files with 697 additions and 16 deletions

View File

@@ -96,16 +96,16 @@
style="
width: 140px;
margin-right: 114px;
margin-bottom: 25px;
"
>
<img
margin-bottom: 25px;">
<!-- <img
style="width: 140px; height: 140px; border-radius: 8px"
:src="value.optionPictureAddress"
/>
/> -->
<div class="radio">
<label>
<input type="radio" name="one" value="right"/>
<label @click="choiceQuestion(key,value.optionId,dataInfo,index)">
<!-- <input type="radio" name="one" value="right"/> -->
<div v-if="value.isAnswer" style="width:10px;height:10px;background:#4a9cf8;position:relative;left:15px;border-radius:10px;"></div>
<div v-else style="width:10px;height:10px;background:#fff;position:relative;left:15px;border-radius:10px;"></div>
<div class="option"></div>
<div class="opt-text">{{ value.optionName }}</div>
</label>
@@ -119,10 +119,8 @@
width: 100%;
display: flex;
justify-content: center;
margin-top: 30px;
"
>
<button class="submitbtn btn01" @click="submitVote">提交</button>
margin-top: 30px;">
<button class="submitbtn btn01" :style="{background:dataInfo.isSubmit?'#ccc':''}" @click="submitVote(dataInfo)">{{dataInfo.isSubmit?'已提交':'提交'}}</button>
</div>
</div>
<div class="right">
@@ -186,9 +184,11 @@
import {useRequest} from "@/api/request";
import {
VOTE_DETAIL2,
VOTE_DETAIL_SUBMIT
} from "@/api/api";
import dayjs from "dayjs";
import {useRoute} from "vue-router/dist/vue-router";
import { ElMessage } from "element-plus";
import {useRoute,useRouter} from "vue-router/dist/vue-router";
import {watch, reactive, toRefs} from "vue";
// const { data } = useRequest(TASK_VOTE_DETAIL, {});
// console.log("datadatadata", data);
@@ -197,12 +197,75 @@ import {watch, reactive, toRefs} from "vue";
// });
// let { votedetail } = toRefs(state);
const {
query: {courseId, pName, sName},
query: {courseId, pName, sName, chapterOrStageId, infoId, id},
} = useRoute();
const router = useRouter();
const returnclick = () => {
router.back();
};
//获取基本信息
const {data: dataInfo} = useRequest(VOTE_DETAIL2(courseId));
console.log('我是获取的投票基本信息', dataInfo)
// 答题时间
const answerTime = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss');
// 选择题目
const choiceQuestion = (order, id, dates, torder) => {
console.log('当前选择题目的id及序号', order, id, dates,torder)
for(let i=0;i<dates.ballotVo.voteStemVoList[torder].optionDetailList.length;i++){
dates.ballotVo.voteStemVoList[torder].optionDetailList[i].isAnswer = false;
}
dates.ballotVo.voteStemVoList[torder].optionDetailList[order].isAnswer = true;
console.log(dataInfo)
}
// 提交投票
const submitVote = () => {
// 当已经提交过时候 不让提交即可
if(dataInfo.value.isSubmit){
return
}
let isSubmit = true;
let isSubArr = []
for(let i=0;i<dataInfo.value.ballotVo.voteStemVoList.length;i++){
for(let j=0; j<dataInfo.value.ballotVo.voteStemVoList[i].optionDetailList.length;j++){
if(dataInfo.value.ballotVo.voteStemVoList[i].optionDetailList[j].isAnswer){
isSubArr[i] = dataInfo.value.ballotVo.voteStemVoList[i].optionDetailList[j].isAnswer
break
}else{
isSubArr[i] = false
}
}
}
for(let i=0; i<isSubArr.length;i++){
if(isSubArr[i]==false){
isSubmit = false
}
}
if(isSubmit==false){
ElMessage.error("请选择投票问题后进行提交")
return
}
let obj = {
"beginTime": answerTime,
"chapterOrStageId": chapterOrStageId ? chapterOrStageId : 0,
"result": JSON.stringify(dataInfo.value),
"targetId": infoId, // 项目 路径图 id
"taskId": id,
"type": 1, // 1 项目 2 路径图
"voteId": dataInfo.value.voteId
}
console.log('我是投票提交的信息', obj)
useRequest(VOTE_DETAIL_SUBMIT,obj,(e)=>{
console.log(e)
})
};
</script>