|
@@ -68,7 +68,7 @@
|
|
|
<div class="title-rect-group">
|
|
|
<div class="title-rect" />
|
|
|
<h2 class="title-rect-name">{{ $t("studentWeb.vote.bollotbox") }}</h2>
|
|
|
- <p style="margin-left:15px;margin-top:2px">剩余票数 <span @click="getVote" style="font-size:16px">{{voteInfo.voteNum}}</span><span> 票</span></p>
|
|
|
+ <p style="margin-left:15px;margin-top:2px">剩余票数 <span @click="getVote" style="font-size:16px">{{voteCount}}</span><span> 票</span></p>
|
|
|
</div>
|
|
|
</div>
|
|
|
<!--和評測模組一樣-->
|
|
@@ -85,9 +85,9 @@
|
|
|
<InputNumber v-model="item.count"
|
|
|
:formatter="value => `${value}票`"
|
|
|
:parser="value => value.replace('票', '')"
|
|
|
- :min="1"
|
|
|
+ :min="0"
|
|
|
v-if="voteInfo.repeat"
|
|
|
- controls-outside
|
|
|
+ @on-change="setVoteNum(item)"
|
|
|
>
|
|
|
</InputNumber>
|
|
|
</div>
|
|
@@ -179,12 +179,12 @@ export default {
|
|
|
getVoteResult() {
|
|
|
if (this.$store.getters.getItemTitle.id) {
|
|
|
this.voteRes = {}
|
|
|
-
|
|
|
let params = {
|
|
|
- "id": "ff86005f-fc57-4a73-a5b7-551b45e446e7",
|
|
|
- "code": "Vote-1595321354",
|
|
|
- "userid": "123132123"
|
|
|
+ "id": this.$store.getters.getItemTitle.id,
|
|
|
+ "code": this.$store.getters.getItemTitle.scode,
|
|
|
+ "userid": this.$store.state.userInfo.sub
|
|
|
}
|
|
|
+ console.log('777777', params)
|
|
|
this.$api.studentWeb.getVoteResult(params).then(res => {
|
|
|
if (res) {
|
|
|
console.log('获取投票结果数据')
|
|
@@ -213,6 +213,7 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
//获取投票结果
|
|
|
getVote(data) {
|
|
|
if (!this.voteInfo.repeat) {
|
|
@@ -315,26 +316,51 @@ export default {
|
|
|
this.nextItem = nextItems[0];
|
|
|
}
|
|
|
},
|
|
|
+ setVoteNum(data) {
|
|
|
+ if (this.isOverCount) {
|
|
|
+ data.count = 0
|
|
|
+ }
|
|
|
+ },
|
|
|
submitMessage() {
|
|
|
- if (this.voteChecked != "") {
|
|
|
- this.clickbutnoChoose = false;
|
|
|
+ console.log(this.voteInfo)
|
|
|
+ console.log(this.voteChecked)
|
|
|
+ this.clickbutnoChoose = false;
|
|
|
+ if (this.voteChecked.length) {
|
|
|
this.WarmMessageisOpen = true;
|
|
|
this.isFirstVoted = true;
|
|
|
- this.$store.commit(
|
|
|
- "SavefinishedItemID",
|
|
|
- this.$store.getters.getItemTitle.eventID
|
|
|
- );
|
|
|
- setTimeout(() => {
|
|
|
- this.WarmMessageisOpen = false;
|
|
|
- }, 2000);
|
|
|
- this.previewNext();
|
|
|
- //加入下一個活動的提示框
|
|
|
- console.log(localStorage.getItem("hintNextItem")); //讀取是否顯示提示下一個
|
|
|
- if (localStorage.getItem("hintNextItem") != "false") {
|
|
|
- setTimeout(() => {
|
|
|
- this.isHintNextItem = true;
|
|
|
- }, 4000);
|
|
|
+ console.log(this.$store.getters.getItemTitle)
|
|
|
+ let params = {
|
|
|
+ "id": this.$store.state.userInfo.sub,
|
|
|
+ "code": this.$store.getters.getItemTitle.id,
|
|
|
+ "option": {}
|
|
|
}
|
|
|
+ for (let item of this.voteChecked) {
|
|
|
+ params.option[item.code] = item.count
|
|
|
+ }
|
|
|
+ console.log(params)
|
|
|
+ this.$api.studentWeb.sendVoteResult(params).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ //if (res) {
|
|
|
+ // console.log('获取投票结果数据')
|
|
|
+ // console.log(res)
|
|
|
+ // this.voteRes = res
|
|
|
+ // this.timeStatus(this.voteInfo, this.voteRes)
|
|
|
+ // //this.voteInfo = res.vote
|
|
|
+ //}
|
|
|
+ setTimeout(() => {
|
|
|
+ this.WarmMessageisOpen = false;
|
|
|
+ }, 2000);
|
|
|
+ })
|
|
|
+
|
|
|
+ //this.previewNext();
|
|
|
+ //加入下一個活動的提示框
|
|
|
+ //console.log(localStorage.getItem("hintNextItem")); //讀取是否顯示提示下一個
|
|
|
+ //if (localStorage.getItem("hintNextItem") != "false") {
|
|
|
+ // setTimeout(() => {
|
|
|
+ // this.isHintNextItem = true;
|
|
|
+ // }, 4000);
|
|
|
+ //}
|
|
|
+ this.voteChecked = []
|
|
|
} else if (this.voteChecked == "") {
|
|
|
this.clickbutnoChoose = true;
|
|
|
}
|
|
@@ -367,6 +393,24 @@ export default {
|
|
|
computed: {
|
|
|
listData() {
|
|
|
return this.$store.getters.getItemTitle.id;
|
|
|
+ },
|
|
|
+ voteCount() {
|
|
|
+ if (this.voteInfo.voteNum !== undefined) {
|
|
|
+ console.log('00000000000',this.voteInfo)
|
|
|
+ let num = 0
|
|
|
+ this.isOverCount = false
|
|
|
+ for (let item of this.voteInfo.options) {
|
|
|
+ if (item.count !== null) {
|
|
|
+ num += item.count
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (num > this.voteInfo.voteNum) {
|
|
|
+ this.isOverCount = true
|
|
|
+ this.$Message.warning("已超出最大投票数量!")
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ return this.voteInfo.voteNum - num
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
@@ -379,6 +423,7 @@ export default {
|
|
|
// 深度观察监听
|
|
|
deep: true
|
|
|
},
|
|
|
+
|
|
|
listData: {
|
|
|
handler() {
|
|
|
if (this.$store.getters.getItemTitle.id !== '') {
|