123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- <template>
- <!--事项选票-->
- <div class="matterVote">
- <div class="voteTable">
- <!-- 表决Title-->
- <div class="matterTitle">
- <span>{{$t('common.Avote')}}</span>
- <button class="refreshBtn" @click="refreshMatter" v-if="showLink == true">{{$t('common.Refresh')}}</button>
- </div>
- <div class="matterContent">
- <el-row :gutter="20">
- <el-col :span="4"><div class="grid-content bg-purple">{{$t('common.serialNumber')}}</div></el-col>
- <el-col :span="16"><div class="grid-content bg-purple">{{$t('common.Content')}}</div></el-col>
- <el-col :span="4"><div class="grid-content bg-purple">{{$t('common.opinion')}}</div></el-col>
- </el-row>
- <div class="voteMessage" v-for="(item,index) in meetingContent" :key="index">
- <div @click="dialogVisibleChange(item)">
- <div class="message" v-if="$i18n.locale == 'zh'" >{{index+1}}、{{item.title}}</div>
- <div class="message" v-if="$i18n.locale == 'en'">{{index+1}}、{{item.titleEn}}</div>
- </div>
- <!-- 投票按钮-->
- <div class="voteBtn" v-if="item.voted === false">
- <el-button size="small" type="info" @click="statistical(item,'0')" :class="activeIndex.a0.indexOf(item.id) != -1 ?'active':''">{{$t('common.Approve')}}</el-button>
- <el-button size="small" type="info" @click="statistical(item,'1')" :class="activeIndex.a1.indexOf(item.id) != -1 ?'active':''">{{$t('common.Oppose')}}</el-button>
- <el-button size="small" type="info" @click="statistical(item,'2')" :class="activeIndex.a2.indexOf(item.id) != -1 ?'active':''">{{$t('common.waiver')}}</el-button>
- </div>
- <div class="voteBtn" v-if="item.voted === true">
- {{$t('common.AreadyVote')}}
- </div>
- <div style="clear: both"></div>
- </div>
- <!-- 事项投票内容展示-->
- <el-dialog
- :title="$t('common.VoteContent')"
- :visible.sync="dialogVisible"
- width="50%">
- <div v-html="showIntroduction"></div>
- </el-dialog>
- </div>
- </div>
- <div class="submitVote" v-if="flalseLength > 0">
- <el-button class="voteSty" type="danger" @click="statistical('','4')">{{$t('common.ApproveAll')}}</el-button>
- <el-button type="primary" @click="submitVote">{{$t('common.SubmitToVote')}}</el-button>
- </div>
- </div>
- </template>
- <script>
- import {getMeetingGeidcoMatters,saveOrUpdateMatter,getCouncilVoteSituation} from "@/api/vote/council";
- import Base from "@/views/base/Base";
- import vote from "../AddFeatures/vote/vote";
- export default {
- name:'MatterVote',
- extends: Base,
- props:[
- 'vote',
- 'showLink'
- ],
- data () {
- return {
- num:0,
- meetingContent:[],
- allVoteList:new Map(),
- endVote:[],
- mattersList:[],
- activeIndex:{
- a0:[],
- a1:[],
- a2:[]
- },
- votedLeader:'',
- votedMatter:'',
- dialogVisible:false,
- showIntroduction:'',
- // showLink:'',
- isRefresh:'',
- trueVote:[],
- falseVote:[],
- flalseLength:'',
- }
- },
- mounted() {
- this.getVoteState();
- this.refreshMatter();
- // this.getMatters()
- },
- destroyed(){
- clearInterval(this.isRefresh)
- },
- methods:{
- //将投票结果统计到数组
- statistical(item,sta){
- let matterId = item.id;
- let arr0 = this.activeIndex.a0
- let arr1 = this.activeIndex.a1
- let arr2 = this.activeIndex.a2
- if(sta=='0'){
- if(arr0.indexOf(item.id)==-1) arr0.push(item.id)
- if(arr1.indexOf(item.id)!=-1) arr1 = arr1.filter(ele=>{return ele!=item.id})
- if(arr2.indexOf(item.id)!=-1) arr2 = arr2.filter(ele=>{return ele!=item.id})
- this.activeIndex.a0 = arr0
- this.activeIndex.a1 = arr1
- this.activeIndex.a2 = arr2
- }
- if(sta=='1'){
- if(arr0.indexOf(item.id)!=-1) arr0 = arr0.filter(ele=>{return ele!=item.id})
- if(arr1.indexOf(item .id)==-1) arr1.push(item.id)
- if(arr2.indexOf(item.id)!=-1) arr2 = arr2.filter(ele=>{return ele!=item.id})
- this.activeIndex.a0 = arr0
- this.activeIndex.a1 = arr1
- this.activeIndex.a2 = arr2
- }
- if(sta=='2'){
- if(arr0.indexOf(item.id)!=-1) arr0 = arr0.filter(ele=>{return ele!=item.id})
- if(arr1.indexOf(item.id)!=-1) arr1 = arr1.filter(ele=>{return ele!=item.id})
- if(arr2.indexOf(item.id)==-1) arr2.push(item.id)
- this.activeIndex.a0 = arr0
- this.activeIndex.a1 = arr1
- this.activeIndex.a2 = arr2
- }
- if(sta=='4'){
- }
- if(sta=='4'){
- //添加全选样式
- this.activeIndex.a1 = []
- this.activeIndex.a2 = []
- this.mattersList.forEach((item)=>{
- arr0.push(item.id)
- })
- this.activeIndex.a0 = arr0
- //统计全选数据
- this.endVote=[];
- this.falseVote.forEach((item)=>{
- this.allVoteList.set(item.id,'0')
- })
- this.endVote = [...this.allVoteList].map(ele=>{
- return {
- matterId:ele[0],
- type:ele[1]
- }
- })
- }else{
- this.activeIndex.a0 = arr0
- this.allVoteList.set(matterId,sta)
- this.endVote = [...this.allVoteList].map(ele=>{
- return {
- matterId:ele[0],
- type:ele[1]
- }
- })
- }
- },
- // 获取事项列表信息
- getMatters(){
- this.meetingContent = [];
- this.trueVote = [];
- this.falseVote = [];
- let params = {
- language: this.$i18n.locale
- }
- getMeetingGeidcoMatters(params).then((res)=>{
- this.mattersList = res.data.meetingGeidcoMatters;
- this.mattersList.forEach((position)=>{
- if( this.$i18n.locale =='en'){
- position.title = position.titleEn
- position.introduction = position.introductionEn;
- }
- if(position.voted == true){
- this.trueVote.push(position)
- }else {
- this.falseVote.push(position)
- }
- this.meetingContent.push(position)
- });
- this.flalseLength = this.falseVote.length;
- })
- },
- //提交投票结果
- submitVote(){
- if(this.endVote.length == this.falseVote.length){
- this.submitHandler((token)=>{
- saveOrUpdateMatter(JSON.stringify(this.endVote),token).then((res)=>{
- if(res.status=="200") {
- let msgTxt =this.$i18n.locale == 'en' ? 'Submitted successfully. Thank you for your feedback' : '投票成功';
- this.$message({
- message: msgTxt,
- type: 'success'
- });
- this.activeIndex.a0 = [];
- this.activeIndex.a1 = [];
- this.activeIndex.a2 = [];
- this.trueVote = [];
- this.falseVote = [];
- this.endVote=[];
- this.resetToken();
- }
- //重新查询
- this.refreshMatter()
- }).catch((error) => {
- this.endVote=[];
- this.resetToken();
- });
- this.getVoteState();
- })
- }else{
- let msgTxt = this.$i18n.locale == 'en' ? 'Please vote on all the items' : '请为全部事项投票';
- this.$message({
- message: msgTxt,
- type: 'warning'
- });
- }
- },
- // 查询投票状态
- getVoteState(){
- const that = this;
- getCouncilVoteSituation().then((res)=>{
- let sta = res.data.councilVoteSituation;
- this.votedLeader=sta.votedLeader;
- this.votedMatter=sta.votedMatter
- // this.showLink = sta.showCouncilLiveingLink;
- this.refreshPage()
- })
- },
- // //10s定时刷新
- // refreshPage(){
- // const that = this;
- // if(this.showLink){
- // console.log('可以刷新')
- // console.log(this.showLink)
- // this.isRefresh = setInterval(()=>{
- // if(this.showLink == true){
- // this.getMatters()
- // }else{
- // clearInterval(that.isRefresh)
- // }
- // },10000)
- // }else {
- // console.log('不刷新')
- // return
- // }
- // },
- // 事项详情弹窗
- dialogVisibleChange(item){
- this.dialogVisible = true;
- this.showIntroduction = item.introduction
- },
- // 刷新按钮事件
- refreshMatter(){
- this.getMatters()
- }
- }
- }
- </script>
- <style scoped>
- .matterVote{
- margin: 20px 0 0 0;
- padding: 0;
- width: 100%;
- background: #fff;
- }
- .voteTable{
- width: 100%;
- padding: 42px 0 20px 0;
- background:#F0F3F7 url("../../assets/img/electionBallot/DirectorVotes/1.png") repeat;
- }
- .matterTitle{
- width: 1200px;
- margin: auto;
- height: 45px;
- text-align: center;
- font-size: 28px;
- font-weight: 600;
- color: #666666;
- }
- .el-row {
- margin-bottom: 20px;
- text-align: center;
- line-height: 42px;
- }
- .el-col {
- border-radius: 4px;
- }
- .bg-purple-dark {
- background: #99a9bf;
- }
- .bg-purple {
- background: #d3dce6;
- }
- .bg-purple-light {
- background: #e5e9f2;
- }
- .grid-content {
- height: 42px;
- border-radius: 4px;
- min-height: 36px;
- }
- .row-bg {
- padding: 10px 0;
- background-color: #f9fafc;
- }
- .matterContent{
- width: 1200px;
- margin:20px auto;
- }
- .voteMessage{
- /*width: 100%;*/
- height:80px;
- line-height: 80px;
- padding: 0 20px;
- border-radius: 8px;
- background: #ffffff;
- margin-bottom: 20px;
- position: relative;
- cursor: pointer;
- }
- /*.moreMessage{*/
- /* display: none;*/
- /*}*/
- /*.voteMessage:hover .moreMessage{*/
- /* display: block;*/
- /* padding: 30px;*/
- /* background: #ffffff;*/
- /* box-shadow: 0px 2px 10px 0px rgba(167, 167, 167, 0.5);*/
- /* width:60%;*/
- /* line-height: 40px;*/
- /* position: absolute;*/
- /* border-radius: 6px;*/
- /* left:-10%;*/
- /* top: 60px;*/
- /* z-index: 999;*/
- /* overflow: scroll;*/
- /* max-height:300px;*/
- /*}*/
- .message{
- width: 75%;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- display: inline-block;
- float: left;
- }
- .voteBtn{
- float: right;
- display: inline-block;
- }
- .submitVote{
- height: 146px;
- line-height: 150px;
- text-align: center;
- }
- .el-button{
- border: none;
- }
- .active{
- background: #66B1FF;
- border: none;
- }
- .refreshBtn{
- float: right;
- height: 30px;
- margin-top: 10px;
- padding: 5px 5px;
- border-radius: 5px;
- background: #409EFF;
- border: none;
- color: #ffffff;
- cursor: pointer;
- }
- .notActive{
- background: #A6A9AD;
- }
- </style>
|