|
|
|
@ -1,73 +1,40 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
import { getCategoryData } from '../../api/votingElection' |
|
|
|
import { getVoteprogress, voteMember } from '../../api/votingElection' |
|
|
|
import { getUserList } from '../../api/user' |
|
|
|
import useUserStore from '@/store/user' |
|
|
|
const userStore = useUserStore() |
|
|
|
|
|
|
|
const xjList = ref({}) |
|
|
|
const doSearch = (_formData : { page : number; limit : number }, onSuccess : Function) => { |
|
|
|
// const submitData = { ...formData } |
|
|
|
// listApi(submitData, userStore.useType).then((res) => { |
|
|
|
// const { data } = res as { data: { data: any; total: number } } |
|
|
|
// onSuccess({ data }) |
|
|
|
// }) |
|
|
|
|
|
|
|
onSuccess({ |
|
|
|
data: { |
|
|
|
data: [ |
|
|
|
{ |
|
|
|
id: 1, |
|
|
|
img: '', |
|
|
|
name: '陈志远', |
|
|
|
class: '现任财务总监', |
|
|
|
yijian: '' |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 2, |
|
|
|
img: '', |
|
|
|
name: '陈志远', |
|
|
|
class: '现任财务总监', |
|
|
|
yijian: '' |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 3, |
|
|
|
img: '', |
|
|
|
name: '陈志远', |
|
|
|
class: '现任财务总监', |
|
|
|
yijian: '' |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 4, |
|
|
|
img: '', |
|
|
|
name: '陈志远', |
|
|
|
class: '现任财务总监', |
|
|
|
yijian: '' |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 5, |
|
|
|
img: '', |
|
|
|
name: '陈志远', |
|
|
|
class: '现任财务总监', |
|
|
|
yijian: '' |
|
|
|
} |
|
|
|
], |
|
|
|
total: 0 |
|
|
|
} |
|
|
|
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 buttlist = ref([ |
|
|
|
{ |
|
|
|
type: 'agree', |
|
|
|
type: '1', |
|
|
|
butname: '同意' |
|
|
|
}, |
|
|
|
{ |
|
|
|
type: 'disagree', |
|
|
|
type: '2', |
|
|
|
butname: '反对' |
|
|
|
}, |
|
|
|
{ |
|
|
|
type: 'neutral', |
|
|
|
type: '3', |
|
|
|
butname: '弃权' |
|
|
|
} |
|
|
|
]) |
|
|
|
|
|
|
|
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) |
|
|
|
uni.showModal({ |
|
|
|
title: '您本轮选举投' + butname + '票', |
|
|
|
@ -75,8 +42,33 @@ const selectBut = (data: any, cardid: any, type: string, butname: string) => { |
|
|
|
success: function (res) { |
|
|
|
if (res.confirm) { |
|
|
|
if (target) { |
|
|
|
target.yijian = target.yijian === type ? null : type |
|
|
|
target.vote_result = type |
|
|
|
} |
|
|
|
} else if (res.cancel) { |
|
|
|
console.log('用户点击取消') |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
params.value.push(target) |
|
|
|
} else { |
|
|
|
data.forEach((ele : { |
|
|
|
vote_result : number; id : any; |
|
|
|
}) => { |
|
|
|
ele.vote_result = 1 |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
const allChange = () => { |
|
|
|
uni.showModal({ |
|
|
|
title: '您本轮选举全投同意票', |
|
|
|
content: '确定吗?', |
|
|
|
success: function (res) { |
|
|
|
if (res.confirm) { |
|
|
|
xjList.value.data?.forEach((ele : { vote_result : number; }) => { |
|
|
|
ele.vote_result = 1 |
|
|
|
}) |
|
|
|
params.value = xjList.value.data |
|
|
|
submit() |
|
|
|
} else if (res.cancel) { |
|
|
|
console.log('用户点击取消') |
|
|
|
} |
|
|
|
@ -84,44 +76,59 @@ const selectBut = (data: any, cardid: any, type: string, butname: string) => { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
onShow(()=> { |
|
|
|
getCategoryData().then((res)=> { |
|
|
|
console.log(res,55555555555) |
|
|
|
}) |
|
|
|
function extractTwoProps(arr:any, key1:string, key2:string) { |
|
|
|
return arr.map(({ [key1]: prop1, [key2]: prop2 }) => ({ |
|
|
|
[key1]: prop1, |
|
|
|
[key2]: prop2 |
|
|
|
})); |
|
|
|
} |
|
|
|
const submit = () => { |
|
|
|
let param = { |
|
|
|
openid: userStore.openId, |
|
|
|
id: xjList.value.id, |
|
|
|
candidate: JSON.stringify(extractTwoProps(params.value,'id','vote_result')) |
|
|
|
} |
|
|
|
if(param.candidate === '[]') { |
|
|
|
uni.showToast({ |
|
|
|
title: '未选举', |
|
|
|
icon: 'none', // 可选,图标类型,'success', 'loading', 'none' |
|
|
|
duration: 1500 // 持续时长,单位ms |
|
|
|
}); |
|
|
|
} else { |
|
|
|
voteMember(param).then((res)=> { |
|
|
|
console.log(res,555555555555555) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<template> |
|
|
|
<!-- 你的页面内容 --> |
|
|
|
<view class="box"> |
|
|
|
<view class="headpart"> |
|
|
|
<view class="title">2024年度董事会成员选举</view> |
|
|
|
<view class="time">投票开始时间:2024年3月15日 18:00</view> |
|
|
|
<view class="time">投票截止时间:2024年3月15日 18:00</view> |
|
|
|
<view class="title">{{ xjList.title }}</view> |
|
|
|
<view class="time">投票开始时间:{{ xjList.start_time }}</view> |
|
|
|
<view class="time">投票截止时间:{{ xjList.end_time }}</view> |
|
|
|
</view> |
|
|
|
<ex-list ref="reListRef" custom-list-type="custom" :on-form-search="doSearch"> |
|
|
|
<template v-slot="{ data }"> |
|
|
|
<view class="tppart"> |
|
|
|
<view class="tpone" v-for="(row, index) of data" :key="'tpone' + index"> |
|
|
|
<view class="topp"> |
|
|
|
<img style="width: 96rpx; height: 96rpx; border-radius: 50%" :src="row.img" alt="" /> |
|
|
|
<img style="width: 96rpx; height: 96rpx; border-radius: 50%" :src="row.photo" alt="" /> |
|
|
|
<view class="rightpart"> |
|
|
|
<view class="name"> |
|
|
|
{{ row.name }} |
|
|
|
</view> |
|
|
|
<view class="class"> |
|
|
|
{{ row.class }} |
|
|
|
{{ row.position }} |
|
|
|
</view> |
|
|
|
</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.yijian === item.type }" |
|
|
|
> |
|
|
|
:class="{ active: row.vote_result === item.type }"> |
|
|
|
{{ item.butname }} |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
@ -130,8 +137,8 @@ onShow(()=> { |
|
|
|
</template> |
|
|
|
</ex-list> |
|
|
|
<view class="bottbutton"> |
|
|
|
<view class="qbty">全部同意</view> |
|
|
|
<view class="tjtp">提交投票</view> |
|
|
|
<view class="qbty" @click="allChange">全部同意</view> |
|
|
|
<view class="tjtp" @click="submit">提交投票</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|