投票
This commit is contained in:
@@ -35,14 +35,14 @@
|
|||||||
|
|
||||||
<div class="options" v-if="form.type == 1">
|
<div class="options" v-if="form.type == 1">
|
||||||
<div class="oneopt">
|
<div class="oneopt">
|
||||||
<div class="items info" v-for="(item, index) in list" :key="index">
|
<!-- <div class="items info" v-for="(item, index) in list" :key="index">
|
||||||
<img src="./img/22.png" alt="" @click="del(index)" />
|
<img src="./img/22.png" alt="" @click="del(index)" />
|
||||||
<div class="rightopts" style="color: #666">{{ item }}</div>
|
<div class="rightopts" style="color: #666">{{ item }}</div>
|
||||||
</div>
|
</div> -->
|
||||||
<div class="items">
|
<div class="items" v-for="(item, index) in list" :key="index">
|
||||||
<img src="./img/22.png" alt="" />
|
<img src="./img/22.png" alt="" @click="del(index)" />
|
||||||
<div class="rightopts">
|
<div class="rightopts">
|
||||||
<u-input v-model="contents" placeholder="选项" maxlength="200" :clearable="false" />
|
<u-input v-model="item.content" placeholder="选项" maxlength="200" :clearable="false" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="items" @click="addOpts">
|
<div class="items" @click="addOpts">
|
||||||
@@ -133,6 +133,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
|
let list = []
|
||||||
if (this.flag) return
|
if (this.flag) return
|
||||||
if (!this.form.content) {
|
if (!this.form.content) {
|
||||||
return this.$u.toast('请输入主题')
|
return this.$u.toast('请输入主题')
|
||||||
@@ -146,26 +147,27 @@ export default {
|
|||||||
if (!this.form.publicityDeadline) {
|
if (!this.form.publicityDeadline) {
|
||||||
return this.$u.toast('请选择公示截止时间')
|
return this.$u.toast('请选择公示截止时间')
|
||||||
}
|
}
|
||||||
if (this.form.type == 1 && this.opts == 0 && !this.contents) {
|
|
||||||
return this.$u.toast('请输入单选选项')
|
|
||||||
}
|
|
||||||
if (this.opts == 1 && !this.list.length) {
|
|
||||||
return this.$u.toast('请输入多选选项')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.contents) {
|
if (this.form.type === '1') {
|
||||||
this.list.push(this.contents)
|
if (!this.list.length) {
|
||||||
}
|
return this.$u.toast('请添加选项')
|
||||||
if (this.opts == 1) {
|
}
|
||||||
var lists = []
|
if (this.list.length < 2) {
|
||||||
this.list.map((item, index) => {
|
return this.$u.toast('选项不能少于2个')
|
||||||
item.contents == item, item.item == this.keys[index]
|
}
|
||||||
lists.push({
|
|
||||||
content: item,
|
list = this.list.map((v, index) => {
|
||||||
item: this.keys[index],
|
return {
|
||||||
})
|
content: v.content,
|
||||||
|
item: this.keys[index]
|
||||||
|
}
|
||||||
})
|
})
|
||||||
console.log(lists)
|
|
||||||
|
for (let i = 0; i < list.length; i ++) {
|
||||||
|
if (!list[i].content) {
|
||||||
|
return this.$u.toast(`请输入弟${i + 1}个选项的内容`)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var params = {
|
var params = {
|
||||||
@@ -173,7 +175,7 @@ export default {
|
|||||||
// voteItems: this.list,
|
// voteItems: this.list,
|
||||||
areaId: this.form.areaId,
|
areaId: this.form.areaId,
|
||||||
areaName: this.form.areaName,
|
areaName: this.form.areaName,
|
||||||
voteItems: lists,
|
voteItems: list,
|
||||||
anonymous: this.checked == true ? 1 : 0,
|
anonymous: this.checked == true ? 1 : 0,
|
||||||
createUserId: this.user.id,
|
createUserId: this.user.id,
|
||||||
createUserName: this.user.name,
|
createUserName: this.user.name,
|
||||||
@@ -194,11 +196,12 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
addOpts() {
|
addOpts() {
|
||||||
if (!this.contents) {
|
// if (!this.contents) {
|
||||||
return this.$u.toast('请输入选项内容')
|
// return this.$u.toast('请输入选项内容')
|
||||||
}
|
// }
|
||||||
this.list.push(this.contents)
|
this.list.push({
|
||||||
this.contents = ''
|
content: ''
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
del(index) {
|
del(index) {
|
||||||
@@ -211,8 +214,6 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
confirmTime(e) {
|
confirmTime(e) {
|
||||||
console.log(e)
|
|
||||||
|
|
||||||
if (this.showStartTime == true) {
|
if (this.showStartTime == true) {
|
||||||
var nowTime = new Date().getTime() * 1
|
var nowTime = new Date().getTime() * 1
|
||||||
|
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ export default {
|
|||||||
this.timestamp = discussTime - nowTime
|
this.timestamp = discussTime - nowTime
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.data.voteType === '1') {
|
if (res.data.type === '1') {
|
||||||
const total = Object.values(res.data.statistic).reduce((x, y) => {
|
const total = Object.values(res.data.statistic).reduce((x, y) => {
|
||||||
return x + y
|
return x + y
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user