|
|
|
@ -1,24 +1,22 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
import { getVoteprogress, voteMember } from '../../api/votingElection' |
|
|
|
import { getUserList } from '../../api/user' |
|
|
|
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({}) |
|
|
|
const doSearch = (_formData: { page: number; limit: number }, onSuccess: Function) => { |
|
|
|
getVoteprogress().then((res) => { |
|
|
|
xjList.value = res.data |
|
|
|
res.data.data = res.data.candidate; |
|
|
|
res.data.data = res.data.candidate |
|
|
|
// 2. 删除旧属性名 |
|
|
|
delete res.data.candidate; |
|
|
|
delete res.data.candidate |
|
|
|
res.data.total = res.data.candidate?.length |
|
|
|
const { data } = res as { data : { data : any; total : number } } |
|
|
|
const { data } = res as { data: { data: any; total: number } } |
|
|
|
onSuccess({ data }) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const buttlist = ref([ |
|
|
|
const buttlist = ref([ |
|
|
|
{ |
|
|
|
type: '1', |
|
|
|
butname: '同意' |
|
|
|
@ -31,11 +29,11 @@ |
|
|
|
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: '确定吗?', |
|
|
|
@ -51,20 +49,18 @@ |
|
|
|
}) |
|
|
|
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 |
|
|
|
@ -74,32 +70,32 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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, |
|
|
|
candidate: JSON.stringify(extractTwoProps(params.value,'id','vote_result')) |
|
|
|
candidate: JSON.stringify(extractTwoProps(params.value, 'id', 'vote_result')) |
|
|
|
} |
|
|
|
if(param.candidate === '[]') { |
|
|
|
if (param.candidate === '[]') { |
|
|
|
uni.showToast({ |
|
|
|
title: '未选举', |
|
|
|
icon: 'none', // 可选,图标类型,'success', 'loading', 'none' |
|
|
|
duration: 1500 // 持续时长,单位ms |
|
|
|
}); |
|
|
|
}) |
|
|
|
} else { |
|
|
|
voteMember(param).then((res)=> { |
|
|
|
console.log(res,555555555555555) |
|
|
|
voteMember(param).then((res) => { |
|
|
|
console.log(res, 555555555555555) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<template> |
|
|
|
@ -126,9 +122,13 @@ |
|
|
|
</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> |
|
|
|
@ -144,7 +144,7 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<style scoped lang="scss"> |
|
|
|
.box { |
|
|
|
.box { |
|
|
|
width: 100%; |
|
|
|
background-color: #f9fafb; |
|
|
|
|
|
|
|
@ -374,5 +374,5 @@ |
|
|
|
bottom: 0; |
|
|
|
border-top: 2rpx solid #ebebec; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |