|
@@ -11,13 +11,13 @@
|
|
|
<div>
|
|
|
<div>
|
|
|
<!--超时-->
|
|
|
- <!-- <div v-if="getItemTitle.endTime < (new Date()).getTime() && !voteRes.records.length">
|
|
|
+ <div v-show="!isVote && !isVoteOK">
|
|
|
<br />
|
|
|
<div class="dec animate__animated animate__bounceInLeft">
|
|
|
<svg-icon icon-class="handonHint" class="warm-icon" />
|
|
|
<span class="warm-hint">{{ $t("studentWeb.vote.timeoutHint") }}</span>
|
|
|
</div>
|
|
|
- </div> -->
|
|
|
+ </div>
|
|
|
<div v-if="!showResult">
|
|
|
<div class="load-box">
|
|
|
<Load :active.sync="isLoad"
|
|
@@ -32,7 +32,12 @@
|
|
|
<div class="title-rect-group">
|
|
|
<!-- <div class="title-rect" /> -->
|
|
|
<h2 class="title-rect-name">{{ $t("studentWeb.vote.bollotbox") }}</h2>
|
|
|
- <p v-if="voteInfo.repeat" style="margin-left:15px;margin-top:2px">{{ $t("studentWeb.vote.surplusTickets")}} <span style="font-size:16px">{{voteCount}}</span><span> {{ $t("studentWeb.vote.tickets")}} </span></p>
|
|
|
+ <p v-if="voteInfo.voteNum > 1 && isVote" style="margin-left:15px;margin-top:2px">
|
|
|
+ {{ $t("studentWeb.vote.surplusTickets")}}
|
|
|
+ <span style="font-size:16px" v-show="voteInfo.repeat">{{voteCount}}</span>
|
|
|
+ <span style="font-size:16px" v-show="!voteInfo.repeat">{{ votesNum }}</span>
|
|
|
+ <span> {{ $t("studentWeb.vote.tickets")}} </span>
|
|
|
+ </p>
|
|
|
</div>
|
|
|
<Button v-show="isResult"
|
|
|
style="float:right;margin-top:-30px"
|
|
@@ -47,30 +52,47 @@
|
|
|
<span v-html="voteInfo.description"></span>
|
|
|
</div> -->
|
|
|
<div class="vote-option">
|
|
|
- <!-- 1票
|
|
|
- <RadioGroup v-model="voteChecked" v-if="voteInfo.voteNum == 1" class="option-group">
|
|
|
- <Radio :label="item.code" v-for="(item, index) in voteInfo.options" :key="index" class="option-wrapper">
|
|
|
+ <!-- 1票 -->
|
|
|
+ <RadioGroup v-model="radioCheck" v-if="voteInfo.voteNum == 1" class="option-group">
|
|
|
+ <Radio border
|
|
|
+ :label="item.code"
|
|
|
+ v-for="(item, index) in voteInfo.options"
|
|
|
+ :key="index"
|
|
|
+ class="option-wrapper"
|
|
|
+ :disabled="!isVote"
|
|
|
+ >
|
|
|
<span v-html="item.value"></span>
|
|
|
</Radio>
|
|
|
</RadioGroup>
|
|
|
- 多票 不重复
|
|
|
- <CheckboxGroup v-model="voteChecked" v-if="voteInfo.voteNum > 1 && !voteInfo.repeat" class="option-group">
|
|
|
- <Checkbox :label="item.code" v-for="(item, index) in voteInfo.options" :key="index" class="option-wrapper">
|
|
|
+ <!-- 多票 -->
|
|
|
+ <CheckboxGroup v-model="voteChecked" v-if="voteInfo.voteNum > 1 && !voteInfo.repeat" class="option-group" @on-change="controlNum">
|
|
|
+ <Checkbox border
|
|
|
+ :label="item.code"
|
|
|
+ v-for="(item, index) in voteInfo.options"
|
|
|
+ :key="index"
|
|
|
+ class="option-wrapper"
|
|
|
+ :disabled="!isVote"
|
|
|
+ >
|
|
|
<span v-html="item.value"></span>
|
|
|
</Checkbox>
|
|
|
</CheckboxGroup>
|
|
|
- 多票 重复
|
|
|
- <CheckboxGroup v-model="voteChecked" v-if="voteInfo.voteNum > 1 && voteInfo.repeat" class="option-group option-repeat">
|
|
|
- <Checkbox :label="item.code" v-for="(item, index) in voteInfo.options" :key="index" class="option-wrapper">
|
|
|
+ <!-- 重复 -->
|
|
|
+ <div v-if="voteInfo.voteNum > 1 && voteInfo.repeat">
|
|
|
+ <div v-for="(item, index) in voteInfo.options"
|
|
|
+ :key="index"
|
|
|
+ :class="['option-repeat', {'action-rep': item.count}]"
|
|
|
+ >
|
|
|
<InputNumber v-model="item.count"
|
|
|
+ controls-outside
|
|
|
:min="0"
|
|
|
size="small"
|
|
|
:formatter="value => `${value}` +$t('studentWeb.vote.tickets')"
|
|
|
+ :disabled="!isVote"
|
|
|
></InputNumber>
|
|
|
<span v-html="item.value"></span>
|
|
|
- </Checkbox>
|
|
|
- </CheckboxGroup> -->
|
|
|
- <div class="checkAnswer" v-for="(item, index) in voteInfo.options" :key="index">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- <div class="checkAnswer" v-for="(item, index) in voteInfo.options" :key="index">
|
|
|
<label class="testBtn">
|
|
|
<input type="checkbox" :value="item" v-model="voteChecked" @click="getVote(item)" />
|
|
|
<div class="testbg">
|
|
@@ -87,12 +109,16 @@
|
|
|
</InputNumber>
|
|
|
</div>
|
|
|
</label>
|
|
|
- </div>
|
|
|
+ </div> -->
|
|
|
</div>
|
|
|
- <Button :disabled="!isVote" size="large" type="success" @click="submitMessage()">
|
|
|
+ <Button v-if="isVote || !isVoteOK" :disabled="!isVote" size="large" type="success" @click="submitMessage()">
|
|
|
<svg-icon icon-class="vote" class="uploadBtn-icon" />
|
|
|
<span style="margin-left:5px">{{ $t("studentWeb.vote.submitBVote") }}</span>
|
|
|
</Button>
|
|
|
+ <Button v-if="isVoteOK" :disabled="true" size="large" type="success" @click="submitMessage()">
|
|
|
+ <svg-icon icon-class="vote" class="uploadBtn-icon" />
|
|
|
+ <span style="margin-left:5px">{{ $t("studentWeb.vote.submitOKVote") }}</span>
|
|
|
+ </Button>
|
|
|
<span class="clickbutnoChoosehint"
|
|
|
v-if="clickbutnoChoose == true && voteChecked == ''">{{ $t("studentWeb.vote.note") }}</span>
|
|
|
<span v-if="isOverCount" style="margin-top:5px;margin-left:15px;color:red">{{$t("studentWeb.vote.warning2")}}</span>
|
|
@@ -146,15 +172,18 @@
|
|
|
data() {
|
|
|
return {
|
|
|
isHintNextItem: false,
|
|
|
- voteChecked: [],
|
|
|
+ radioCheck: "", //单选
|
|
|
+ voteChecked: [], //多选——不重复
|
|
|
+ numChecked: 0, //多选——重复
|
|
|
WarmMessageisOpen: false,
|
|
|
- clickbutnoChoose: false,
|
|
|
+ clickbutnoChoose: false, //没有选中选项
|
|
|
voteInfo: {}, //投票信息
|
|
|
// voteRes: {},
|
|
|
voteResData: [], //投票结果的数据
|
|
|
isVote: false, //不可以投票
|
|
|
+ isVoteOK: false, //已经投票
|
|
|
voteStatus:false,
|
|
|
- voteNum: 0, //剩余投票数
|
|
|
+ votesNum: 0, //剩余投票数
|
|
|
showResult: false, //显示投票结果
|
|
|
chooseVoteRes: {},
|
|
|
isLoad: false,
|
|
@@ -179,16 +208,23 @@
|
|
|
if (res) {
|
|
|
// this.voteRes = res
|
|
|
this.timeStatus(this.voteInfo, res)
|
|
|
- this.voteResData = res.records.sort((a, b) => {
|
|
|
- return b > a
|
|
|
- })
|
|
|
- this.isLoad = false
|
|
|
+ if(res.records.length) {
|
|
|
+ this.voteResData = res.records.sort((a, b) => {
|
|
|
+ return b > a
|
|
|
+ })
|
|
|
+ this.isVoteOK = true
|
|
|
+ }
|
|
|
}
|
|
|
+ }).finally(() => {
|
|
|
+ this.isLoad = false
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
//获取活动投票结果数据
|
|
|
getVoteInfo() {
|
|
|
+ this.isOverCount = false
|
|
|
+ this.clickbutnoChoose = false
|
|
|
+ this.isVoteOK = false
|
|
|
if (this.getItemTitle.id) {
|
|
|
let params = {
|
|
|
"id": this.getItemTitle.id,
|
|
@@ -213,6 +249,7 @@
|
|
|
for (let item of res.vote.options) {
|
|
|
item.count = 0
|
|
|
}
|
|
|
+ this.votesNum = res.vote.voteNum
|
|
|
this.voteInfo = res.vote
|
|
|
if (res.vote.progress == "finish") {
|
|
|
this.getVoteRecord()
|
|
@@ -406,9 +443,54 @@
|
|
|
data.count = 0
|
|
|
}
|
|
|
},
|
|
|
+ // 多选框改变时
|
|
|
+ controlNum(arr) {
|
|
|
+ if(arr.length > this.voteInfo.voteNum) {
|
|
|
+ this.isOverCount = true
|
|
|
+ this.votesNum = 0
|
|
|
+ } else {
|
|
|
+ this.isOverCount = false
|
|
|
+ this.votesNum = this.voteInfo.voteNum - arr.length
|
|
|
+ }
|
|
|
+ },
|
|
|
submitMessage() {
|
|
|
- this.clickbutnoChoose = false;
|
|
|
- if (this.voteChecked.length && this.voteChecked.length <= this.voteInfo.voteNum) {
|
|
|
+ // this.clickbutnoChoose = false;
|
|
|
+ if((!this.voteChecked.length && this.voteInfo.voteNum > 1) || (this.radioCheck === '' && this.voteInfo.voteNum === 1)) {
|
|
|
+ this.clickbutnoChoose = true;
|
|
|
+ } else if ((this.voteChecked.length > this.voteInfo.voteNum || this.numChecked > this.voteInfo.voteNum) && this.voteInfo.voteNum > 1) {
|
|
|
+ this.$Message.warning(this.$t("studentWeb.vote.warning2"))
|
|
|
+ } else {
|
|
|
+ let params = {
|
|
|
+ "id": this.getItemTitle.id,
|
|
|
+ "code": this.getItemTitle.scode,
|
|
|
+ "option": {}
|
|
|
+ }
|
|
|
+ if(this.voteInfo.voteNum > 1) {
|
|
|
+ for (let item of this.voteChecked) {
|
|
|
+ if (this.voteInfo.repeat) {
|
|
|
+ params.option[item.code] = item.count
|
|
|
+ } else {
|
|
|
+ params.option[item] = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ params.option[this.radioCheck] = 1
|
|
|
+ }
|
|
|
+ this.$api.studentWeb.sendVoteResult(params).then(res => {
|
|
|
+ if (res.msgid == 1) {
|
|
|
+ this.WarmMessageisOpen = true;
|
|
|
+ this.getVoteInfo()
|
|
|
+ setTimeout(() => {
|
|
|
+ this.WarmMessageisOpen = false;
|
|
|
+ }, 1000);
|
|
|
+ } else {
|
|
|
+ this.$Message.warning(this.$t('studentWeb.vote.warning'))
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.voteChecked = []
|
|
|
+ this.radioCheck = ""
|
|
|
+ }
|
|
|
+ /* if (this.voteChecked.length && this.voteChecked.length <= this.voteInfo.voteNum) {
|
|
|
let params = {
|
|
|
"id": this.getItemTitle.id,
|
|
|
"code": this.getItemTitle.scode,
|
|
@@ -421,6 +503,7 @@
|
|
|
params.option[item.code] = 1
|
|
|
}
|
|
|
}
|
|
|
+ console.log(params);
|
|
|
this.$api.studentWeb.sendVoteResult(params).then(res => {
|
|
|
if (res.msgid == 1) {
|
|
|
this.WarmMessageisOpen = true;
|
|
@@ -437,7 +520,7 @@
|
|
|
this.clickbutnoChoose = true;
|
|
|
} else if (this.voteChecked.length > this.voteInfo.voteNum) {
|
|
|
this.$Message.warning(this.$t("studentWeb.vote.warning2"))
|
|
|
- }
|
|
|
+ } */
|
|
|
},
|
|
|
cancelPreview() {
|
|
|
this.isHintNextItem = false;
|
|
@@ -456,16 +539,17 @@
|
|
|
voteCount() {
|
|
|
if (this.voteInfo.voteNum !== undefined) {
|
|
|
let num = 0
|
|
|
- this.isVote = true
|
|
|
+ // this.isVote = true
|
|
|
this.isOverCount = false
|
|
|
for (let item of this.voteInfo.options) {
|
|
|
if (item.count !== null) {
|
|
|
num += item.count
|
|
|
}
|
|
|
}
|
|
|
+ this.numChecked = num
|
|
|
if (num > this.voteInfo.voteNum) {
|
|
|
this.isOverCount = true
|
|
|
- this.isVote = false
|
|
|
+ // this.isVote = false
|
|
|
return 0
|
|
|
}
|
|
|
return this.voteInfo.voteNum - num
|