|
|
|
@ -1,22 +1,24 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
import { getVoteprogress, voteMember } from '../../api/votingElection' |
|
|
|
import useUserStore from '@/store/user' |
|
|
|
const userStore = useUserStore() |
|
|
|
import { getVoteprogress, voteMember } from '../../api/votingElection' |
|
|
|
import useUserStore from '@/store/user' |
|
|
|
const userStore = useUserStore() |
|
|
|
|
|
|
|
const xjList = ref({}) |
|
|
|
const doSearch = (_formData: { page: number; limit: number }, onSuccess: Function) => { |
|
|
|
const xjList = ref<any>({}) |
|
|
|
|
|
|
|
const doSearch = (_formData : { page : number; limit : number }, onSuccess : Function) => { |
|
|
|
getVoteprogress().then((res) => { |
|
|
|
xjList.value = res.data |
|
|
|
res.data.data = res.data.candidate |
|
|
|
// 2. 删除旧属性名 |
|
|
|
delete res.data.candidate |
|
|
|
res.data.total = res.data.candidate?.length |
|
|
|
const { data } = res as { data: { data: any; total: number } } |
|
|
|
onSuccess({ data }) |
|
|
|
const { data } = res as { data : { candidate : any[] } } |
|
|
|
xjList.value = data || {} |
|
|
|
onSuccess({ |
|
|
|
data: { |
|
|
|
data: data.candidate || [], |
|
|
|
total: (data.candidate || []).length |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const buttlist = ref([ |
|
|
|
const buttlist = ref([ |
|
|
|
{ |
|
|
|
type: '1', |
|
|
|
butname: '同意' |
|
|
|
@ -29,12 +31,12 @@ const buttlist = ref([ |
|
|
|
type: '3', |
|
|
|
butname: '弃权' |
|
|
|
} |
|
|
|
]) |
|
|
|
]) |
|
|
|
|
|
|
|
const params = ref([]) |
|
|
|
const selectBut = (data: any, cardid: any, type: string, butname: string) => { |
|
|
|
const params = ref([]) |
|
|
|
const selectBut = (data : any, cardid : any, type : string, butname : string) => { |
|
|
|
if (cardid) { |
|
|
|
const target = data.find((card: { id: any }) => card.id === cardid) |
|
|
|
const target = data.find((card : { id : any }) => card.id === cardid) |
|
|
|
uni.showModal({ |
|
|
|
title: '您本轮选举投' + butname + '票', |
|
|
|
content: '确定吗?', |
|
|
|
@ -50,18 +52,18 @@ const selectBut = (data: any, cardid: any, type: string, butname: string) => { |
|
|
|
}) |
|
|
|
params.value.push(target) |
|
|
|
} else { |
|
|
|
data.forEach((ele: { vote_result: number; id: any }) => { |
|
|
|
data.forEach((ele : { vote_result : number; id : any }) => { |
|
|
|
ele.vote_result = 1 |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
const allChange = () => { |
|
|
|
} |
|
|
|
const allChange = () => { |
|
|
|
uni.showModal({ |
|
|
|
title: '您本轮选举全投同意票', |
|
|
|
content: '确定吗?', |
|
|
|
success: function (res) { |
|
|
|
if (res.confirm) { |
|
|
|
xjList.value.data?.forEach((ele: { vote_result: number }) => { |
|
|
|
xjList.value.data?.forEach((ele : { vote_result : number }) => { |
|
|
|
ele.vote_result = 1 |
|
|
|
}) |
|
|
|
params.value = xjList.value.data |
|
|
|
@ -71,15 +73,15 @@ const allChange = () => { |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function extractTwoProps(arr: any, key1: string, key2: string) { |
|
|
|
function extractTwoProps(arr : any, key1 : string, key2 : string) { |
|
|
|
return arr.map(({ [key1]: prop1, [key2]: prop2 }) => ({ |
|
|
|
[key1]: prop1, |
|
|
|
[key2]: prop2 |
|
|
|
})) |
|
|
|
} |
|
|
|
const submit = () => { |
|
|
|
} |
|
|
|
const submit = () => { |
|
|
|
let param = { |
|
|
|
openid: userStore.openId, |
|
|
|
id: xjList.value.id, |
|
|
|
@ -96,19 +98,19 @@ const submit = () => { |
|
|
|
console.log(res, 555555555555555) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
onShow(() => { |
|
|
|
if (userStore.mobile) { |
|
|
|
} |
|
|
|
onShow(() => { |
|
|
|
if (!userStore.mobile) { |
|
|
|
uni.navigateTo({ |
|
|
|
url: '/pages/login/login' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
</script> |
|
|
|
|
|
|
|
<template> |
|
|
|
<!-- 你的页面内容 --> |
|
|
|
<view class="box"> |
|
|
|
<view class="box" v-if="xjList.length != 0"> |
|
|
|
<view class="headpart"> |
|
|
|
<view class="title">{{ xjList.title }}</view> |
|
|
|
<view class="time">投票开始时间:{{ xjList.start_time }}</view> |
|
|
|
@ -130,13 +132,9 @@ onShow(() => { |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="bottomp"> |
|
|
|
<view |
|
|
|
class="minbut" |
|
|
|
v-for="(item, ele) in buttlist" |
|
|
|
:key="ele" |
|
|
|
<view class="minbut" v-for="(item, ele) in buttlist" :key="ele" |
|
|
|
@click="selectBut(data, row.id, item.type, item.butname)" |
|
|
|
:class="{ active: row.vote_result === item.type }" |
|
|
|
> |
|
|
|
:class="{ active: row.vote_result === item.type }"> |
|
|
|
{{ item.butname }} |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
@ -149,10 +147,16 @@ onShow(() => { |
|
|
|
<view class="tjtp" @click="submit">提交投票</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view style="display: grid;align-items: center;justify-content: center;width: 100%;height: 100vh;align-content: center;" v-else> |
|
|
|
<img style="width: 188px;height: 140px;" src="@/static/img/Group.png" alt="" /> |
|
|
|
<text class="nodata"> |
|
|
|
暂时没有选举 请刷新重试 |
|
|
|
</text> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
|
<style scoped lang="scss"> |
|
|
|
.box { |
|
|
|
.box { |
|
|
|
width: 100%; |
|
|
|
background-color: #f9fafb; |
|
|
|
|
|
|
|
@ -382,5 +386,13 @@ onShow(() => { |
|
|
|
bottom: 0; |
|
|
|
border-top: 2rpx solid #ebebec; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.nodata { |
|
|
|
margin-top: 43px; |
|
|
|
font-family: Source Han Sans; |
|
|
|
font-size: 18px; |
|
|
|
font-weight: 500; |
|
|
|
letter-spacing: normal; |
|
|
|
color: #34343F; |
|
|
|
} |
|
|
|
</style> |