feat:修改投票

This commit is contained in:
lixg
2023-02-25 17:04:36 +08:00
9 changed files with 478 additions and 552 deletions

View File

@@ -79,7 +79,6 @@
<div class="item2">浏览数</div>
</div>
</div>
<div class="title">
<img
style="width: 20px; height: 20px"
@@ -88,10 +87,9 @@
<div class="text">参与投票</div>
<div class="box"></div>
</div>
<div class="join">
<div
v-for="(item, index) in state.dataInfo?.voteStemDtoList"
v-for="(item, index) in state.dataInfo.voteStemDtoList"
:key="index"
style="margin-bottom: 41px"
>
@@ -219,7 +217,6 @@
style="width: 20px; height: 20px"
src="../../assets/image/yuan.png"
/>
<div class="text">投票说明</div>
<div class="box"></div>
</div>
@@ -240,7 +237,6 @@
<!-- 详细信息 -->
</div>
</template>
<script setup>
import { useRequest, request } from "@/api/request";
import { VOTE_DETAIL2, VOTE_DETAIL3, VOTE_DETAIL_SUBMIT } from "@/api/api";
@@ -267,11 +263,9 @@ const returnclick = () => {
const state = reactive({
dataInfo: {},
});
//获取基本信息
// const {data: dataInfo} = useRequest(VOTE_DETAIL2(courseId));
const userInfo = computed(() => store.state.userInfo);
let timer = setInterval(() => {
if (userInfo.value.id) {
clearInterval(timer);
@@ -282,7 +276,6 @@ let timer = setInterval(() => {
targetId: infoId,
type: btype,
});
request(VOTE_DETAIL3(courseId), {})
.then((res) => {
console.log(res);
@@ -293,12 +286,9 @@ let timer = setInterval(() => {
});
}
}, 500);
console.log("我是获取的投票基本信息", state.dataInfo);
// 答题时间
const answerTime = dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss");
// 选择题目
const choiceQuestion = (order, id, dates, torder) => {
// 当已经提交过时候 不让选择题目
@@ -306,56 +296,51 @@ const choiceQuestion = (order, id, dates, torder) => {
return;
}
console.log("当前选择题目的id及序号", order, id, dates, torder);
console.log("state.dataInfo", state.dataInfo);
for (
let i = 0;
i < dates.voteStemDtoList[torder].optionDetailList.length;
i < state.dataInfo.voteStemDtoList[torder].optionDetailList.length;
i++
) {
dates.voteStemDtoList[torder].optionDetailList[i].isAnswer = false;
state.dataInfo.voteStemDtoList[torder].optionDetailList[i].isAnswer = false;
}
dates.voteStemDtoList[torder].optionDetailList[order].isAnswer = true;
console.log(state.dataInfo);
state.dataInfo.voteStemDtoList[torder].optionDetailList[
order
].isAnswer = true;
};
// 提交投票
const submitVote = () => {
console.log(state.dataInfo);
let nowTime = new Date().getTime();
let maxTime = new Date(state.dataInfo.voteEndTime).getTime();
let minTime = new Date(state.dataInfo.voteStartTime).getTime();
console.log(nowTime, maxTime, minTime);
// 当未到开始时间
if (nowTime < minTime || nowTime > maxTime) {
ElMessage.error("未到投票开始时间");
return;
}
// 当已经提交过时候 不让提交即可
if (state.dataInfo.isSubmit) {
return;
}
let isSubmit = true;
let isSubArr = [];
console.log("state.dataInfo", state.dataInfo);
if (state.dataInfo) {
for (let i = 0; i < state.dataInfo.voteStemDtoList.length; i++) {
for (
let j = 0;
j < state.dataInfo.voteStemDtoList[i].optionDetailList.length;
j++
) {
if (state.dataInfo.voteStemDtoList[i].optionDetailList[j].isAnswer) {
isSubArr[i] =
state.dataInfo.voteStemDtoList[i].optionDetailList[j].isAnswer;
break;
} else {
isSubArr[i] = false;
}
for (let i = 0; i < state.dataInfo.voteStemDtoList.length; i++) {
for (
let j = 0;
j < state.dataInfo.voteStemDtoList[i].optionDetailList.length;
j++
) {
if (state.dataInfo.voteStemDtoList[i].optionDetailList[j].isAnswer) {
isSubArr[i] =
state.dataInfo.voteStemDtoList[i].optionDetailList[j].isAnswer;
break;
} else {
isSubArr[i] = false;
}
}
}
for (let i = 0; i < isSubArr.length; i++) {
if (isSubArr[i] == false) {
isSubmit = false;
@@ -366,7 +351,6 @@ const submitVote = () => {
ElMessage.error("请选择投票问题后进行提交");
return;
}
let obj = {
beginTime: answerTime,
chapterOrStageId: chapterOrStageId ? chapterOrStageId : 0,
@@ -374,11 +358,11 @@ const submitVote = () => {
targetId: infoId, // 项目 路径图 id
taskId: id,
type: btype, // 1 项目 2 路径图
voteId: state.dataInfo.voteId,
voteId: state.dataInfo.id,
voteName: state.dataInfo.voteName,
};
console.log("我是投票提交的信息", obj);
useRequest(VOTE_DETAIL_SUBMIT, obj, (e) => {
console.log(e);
request(VOTE_DETAIL3(courseId), {})
@@ -407,7 +391,6 @@ const submitVote = () => {
});
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
.clearfix:before,
@@ -416,7 +399,6 @@ const submitVote = () => {
display: table;
clear: both;
}
.moreactive {
.crumb {
color: #fff;
@@ -438,7 +420,6 @@ const submitVote = () => {
.preNext {
position: absolute;
right: 0px;
.content {
font-size: 14px;
color: #fff;
@@ -449,7 +430,6 @@ const submitVote = () => {
top: -6px;
cursor: pointer;
}
.btn {
width: 23px;
height: 23px;
@@ -457,16 +437,13 @@ const submitVote = () => {
border: 0;
cursor: pointer;
}
.btn01 {
background-image: url("../../assets/image/prev.png");
}
.btn02 {
background-image: url("../../assets/image/next.png");
}
}
.debateTitle {
margin-top: 15px;
font-size: 20px;
@@ -476,12 +453,10 @@ const submitVote = () => {
color: #fff;
margin-left: -10px;
}
.detailinfo {
width: 100%;
margin-top: 20px;
display: flex;
.detail {
flex: 1;
// margin-right: 20px;
@@ -492,28 +467,23 @@ const submitVote = () => {
color: rgba(51, 51, 51, 1);
display: flex;
padding-bottom: 20px;
.left {
margin-left: 48px;
flex: 1;
}
.right {
width: 417px;
margin-right: 48px;
.righttitle {
display: flex;
padding-top: 39px;
position: relative;
.text {
margin-left: 8px;
font-size: 16px;
color: rgba(51, 51, 51, 1);
font-weight: 800;
}
.box {
width: 75px;
height: 10px;
@@ -523,7 +493,6 @@ const submitVote = () => {
top: 53px;
}
}
.timebox {
width: 417px;
height: 149px;
@@ -531,7 +500,6 @@ const submitVote = () => {
border-radius: 4px;
margin-top: 42px;
}
.innertime {
margin-top: 17px;
margin-left: 55px;
@@ -540,7 +508,6 @@ const submitVote = () => {
color: #ffffff;
line-height: 24px;
}
.endtime {
margin-left: 10px;
margin-top: 16px;
@@ -548,11 +515,9 @@ const submitVote = () => {
height: 81px;
background: #f2f5f7;
border-radius: 0px 8px 0px 8px;
.endtimetext {
margin-top: 25px;
margin-left: 46px;
.te {
font-size: 28px;
font-weight: 800;
@@ -561,7 +526,6 @@ const submitVote = () => {
}
}
}
.explain {
margin-top: 30px;
width: 416px;
@@ -569,7 +533,6 @@ const submitVote = () => {
background: #f2f5f7;
border-radius: 8px;
}
.explaincontent {
width: 368px;
font-size: 16px;
@@ -580,21 +543,18 @@ const submitVote = () => {
margin-top: 47px;
}
}
.title {
display: flex;
align-items: center;
padding-top: 39px;
position: relative;
}
.title .text {
margin-left: 8px;
font-size: 16px;
color: rgba(51, 51, 51, 1);
font-weight: 800;
}
.title .box {
width: 75px;
height: 10px;
@@ -603,14 +563,12 @@ const submitVote = () => {
left: 23px;
top: 53px;
}
.all {
display: flex;
justify-content: space-between;
// width: 1280px;
margin-right: 48px;
margin-top: 43px;
.allbox1 {
margin-right: 22px;
background: linear-gradient(
@@ -619,7 +577,6 @@ const submitVote = () => {
rgba(161, 195, 231, 0.2) 100%
);
}
.allbox2 {
margin-right: 22px;
background: linear-gradient(
@@ -628,7 +585,6 @@ const submitVote = () => {
rgba(172, 216, 227, 0.2) 100%
);
}
.allbox3 {
background: linear-gradient(
0deg,
@@ -636,21 +592,18 @@ const submitVote = () => {
rgba(191, 206, 231, 0.2) 100%
);
}
.item {
// width: 410px;
width: calc(100% - 44px);
height: 149px;
text-align: center;
border-radius: 4px;
.item1 {
color: #089dff;
font-size: 24px;
font-weight: bold;
margin-top: 36px;
}
.item2 {
color: #333330;
font-size: 14px;
@@ -658,7 +611,6 @@ const submitVote = () => {
}
}
}
.join {
// width: 1280px;
margin-right: 48px;
@@ -668,7 +620,6 @@ const submitVote = () => {
margin-top: 32px;
margin-left: 21px;
flex: 1;
.stem {
display: flex;
font-size: 16px;
@@ -676,26 +627,22 @@ const submitVote = () => {
color: #333330;
line-height: 38px;
}
.options {
display: flex;
align-items: center;
flex-wrap: wrap;
}
.radio {
margin-top: 14px;
margin-left: -16px;
position: relative;
}
.radio label {
line-height: 20px;
position: relative;
display: flex;
align-items: center;
font-weight: normal;
.opt-text {
font-size: 14px;
font-weight: bold;
@@ -704,7 +651,6 @@ const submitVote = () => {
margin-left: 10px;
}
}
.radio .option {
width: 19px;
height: 18px;
@@ -716,21 +662,17 @@ const submitVote = () => {
background: url(../../assets/image/noselect.png) no-repeat;
background-size: cover;
}
.radio input[type="radio"] {
display: inline-block;
margin-right: -3px;
opacity: 0;
}
.radio input[type="radio"]:checked + div {
background: url(../../assets/image/select.png) no-repeat;
background-size: cover;
}
.imgcontent {
display: flex;
.imgone {
width: 140px;
height: 140px;
@@ -740,7 +682,6 @@ const submitVote = () => {
background-position: center;
}
}
.ontitle {
margin-top: 27px;
font-size: 14px;
@@ -748,24 +689,20 @@ const submitVote = () => {
}
}
}
.detailB {
min-height: 363px;
background: #ffffff;
border-radius: 8px;
margin-top: 20px;
.el-tabs__item {
height: 69px;
padding: 25px 7px 0px 52px;
font-size: 14px;
font-weight: 500;
}
.el-tabs__nav-wrap::after {
background-color: rgba(56, 125, 247, 0.2);
}
.enclosure {
height: 89px;
margin-left: 51px;
@@ -774,7 +711,6 @@ const submitVote = () => {
display: flex;
justify-content: space-between;
align-items: center;
.enclosureL {
display: flex;
align-items: center;
@@ -783,7 +719,6 @@ const submitVote = () => {
color: #677d86;
line-height: 24px;
}
.download {
display: flex;
align-items: center;
@@ -794,7 +729,6 @@ const submitVote = () => {
cursor: pointer;
}
}
.work {
margin-left: 51px;
margin-right: 40px;
@@ -803,14 +737,12 @@ const submitVote = () => {
align-items: center;
margin-top: 37px;
}
.work .question {
font-size: 14px;
font-weight: 500;
color: #333330;
line-height: 18px;
}
.work .active {
width: 82px;
height: 28px;
@@ -826,7 +758,6 @@ const submitVote = () => {
cursor: pointer;
margin-right: 11px;
}
.work .unactive {
width: 80px;
height: 26px;
@@ -842,19 +773,15 @@ const submitVote = () => {
margin-right: 11px;
cursor: pointer;
}
.work .btncolor {
background: linear-gradient(90deg, #84aad2 0%, #a4c5e9 100%);
}
.work .bordercolor {
border: 1px solid #85aad2;
}
.work .fontcolor {
color: rgba(133, 170, 210, 1);
}
.work .submit {
width: 126px;
height: 46px;
@@ -874,4 +801,4 @@ const submitVote = () => {
}
}
}
</style>
</style>