Chairman.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <template>
  2. <div class="directorVote">
  3. <!-- 主席候选人-->
  4. <div class="Chairman" v-for="(item,index) in positionDic" :key="index">
  5. <div style="width: 1200px;margin: auto">
  6. <div class="chairTitle" v-show="candidateList[index].length>0">
  7. {{item.label}} {{$t('common.Candidate')}}
  8. </div>
  9. <div :class="candidateList[index].length>1?'chairBox1':'chairBox2'">
  10. <div class="tempspace" v-for="(canItem,index1) in candidateList[index]" :key="index1">
  11. <div class="votePhoto">
  12. <img :src="'api/file/pub/'+canItem.photoUrl" alt="" style="height: 100%">
  13. </div>
  14. <div class="candidate">
  15. {{canItem.name}}
  16. </div>
  17. <div class="voteBtn" v-if="votedLeader == false">
  18. <el-button size="small" type="info" @click="statistical(canItem,'0')" :class="activeIndex.a0.indexOf(canItem.id) != -1 ?'active':''">{{$t('common.Approve')}}</el-button>
  19. <el-button size="small" type="info" @click="statistical(canItem,'1')" :class="activeIndex.a1.indexOf(canItem.id) != -1 ?'active':''">{{$t('common.Oppose')}}</el-button>
  20. <el-button size="small" type="info" @click="statistical(canItem,'2')" :class="activeIndex.a2.indexOf(canItem.id) != -1 ?'active':''">{{$t('common.waiver')}}</el-button>
  21. </div>
  22. <div class="voteBtn2" v-if="votedLeader == true">
  23. {{$t('common.AreadyVote')}}
  24. </div>
  25. <!-- <div class="moreMessage">
  26. <div>{{canItem.name}}</div>
  27. <div v-html="canItem.introduction"></div>
  28. </div> -->
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. <div class="submitVote" v-if="votedLeader == false">
  34. <el-button class="voteSty" type="danger" @click="statistical('','4')">{{$t('common.ApproveAll')}}</el-button>
  35. <el-button type="primary" @click="submitVote()" style="padding:0">{{$t('common.SubmitToVote')}}</el-button>
  36. </div>
  37. <!-- 进入下一页的探窗 -->
  38. <el-dialog
  39. :show-close="false"
  40. :visible.sync="OverFlag"
  41. :close-on-click-modal="false"
  42. width="700px">
  43. <div class="category-body submit-success">
  44. <p style="font-size: 24px; color: #666; margin-bottom: 20px;text-align:center">{{$i18n.locale=='en'? 'The vote was successful.Click Confirm to go to the next page': '投票成功,点击确定进入下一页.'}}</p>
  45. <p style="text-align:center">
  46. <!-- <el-button style="background: #2c558a; color: #fff" @click="toView('home')">{{$i18n.locale=='en'? 'Back Home': '返回首页'}}</el-button> -->
  47. <el-button type="primary" @click="Iknow">{{$i18n.locale=='en'? 'Confirm': '确定'}}</el-button>
  48. </p>
  49. </div>
  50. </el-dialog>
  51. </div>
  52. </template>
  53. <script>
  54. import {getMeetingGeidcoLeaders,saveOrUpdateLeader,getCouncilVoteSituation} from "@/api/vote/council";
  55. import Base from "@/views/base/Base";
  56. import { getDicts } from "@/api/dict";
  57. import vote from "../AddFeatures/vote/vote";
  58. export default {
  59. name:'DirectorVote',
  60. extends: Base,
  61. props:[
  62. 'vote'
  63. ],
  64. data () {
  65. return {
  66. candidateList:[],
  67. //职位字典
  68. positionDic:[],
  69. endVote:[],
  70. allVoteList:new Map(),
  71. meetingGeidcoLeaderNumDetail:[],
  72. leaderState:[],
  73. //所有的候选人
  74. leaderlist:[],
  75. isShow:false,
  76. votedLeader:'',
  77. showVote:[],
  78. isShow:false,
  79. VoteState:'',
  80. clickId:'',
  81. activeIndex:{
  82. a0:[],
  83. a1:[],
  84. a2:[]
  85. },
  86. isVote:false,
  87. OverFlag:false,
  88. }
  89. },
  90. mounted() {
  91. this.getDictsList();
  92. // this.getVoteState()
  93. },
  94. methods:{
  95. //获取字典
  96. async getDictsList(){
  97. let dicts = this.$i18n.locale=='zh'?'GEIDCO_LEADER_DICT':'GEIDCO_LEADER_DICT_EN';
  98. getDicts(dicts).then((result)=>{
  99. result.data[0].forEach((item,index)=>{
  100. if(item.value!='governing-unit'){
  101. this.positionDic.push(item);
  102. index = new Array();
  103. this.candidateList.push(index);
  104. }
  105. });
  106. this. getLeaders()
  107. })
  108. },
  109. //将投票结果统计到数组
  110. statistical(item,sta){
  111. this.VoteState = sta;
  112. this.clickId = item;
  113. let arr0 = this.activeIndex.a0
  114. let arr1 = this.activeIndex.a1
  115. let arr2 = this.activeIndex.a2
  116. let leaderId = item.id;
  117. if(sta=='0'){
  118. if(arr0.indexOf(item.id)==-1) arr0.push(item.id)
  119. if(arr1.indexOf(item.id)!=-1) arr1 = arr1.filter(ele=>{return ele!=item.id})
  120. if(arr2.indexOf(item.id)!=-1) arr2 = arr2.filter(ele=>{return ele!=item.id})
  121. this.activeIndex.a0 = arr0
  122. this.activeIndex.a1 = arr1
  123. this.activeIndex.a2 = arr2
  124. }
  125. if(sta=='1'){
  126. if(arr0.indexOf(item.id)!=-1) arr0 = arr0.filter(ele=>{return ele!=item.id})
  127. if(arr1.indexOf(item .id)==-1) arr1.push(item.id)
  128. if(arr2.indexOf(item.id)!=-1) arr2 = arr2.filter(ele=>{return ele!=item.id})
  129. this.activeIndex.a0 = arr0
  130. this.activeIndex.a1 = arr1
  131. this.activeIndex.a2 = arr2
  132. }
  133. if(sta=='2'){
  134. if(arr0.indexOf(item.id)!=-1) arr0 = arr0.filter(ele=>{return ele!=item.id})
  135. if(arr1.indexOf(item.id)!=-1) arr1 = arr1.filter(ele=>{return ele!=item.id})
  136. if(arr2.indexOf(item.id)==-1) arr2.push(item.id)
  137. this.activeIndex.a0 = arr0
  138. this.activeIndex.a1 = arr1
  139. this.activeIndex.a2 = arr2
  140. }
  141. // if(sta=='4'){
  142. // this.activeIndex.a1 = []
  143. // this.activeIndex.a2 = []
  144. // this.leaderlist.forEach((item)=>{
  145. //
  146. // arr0.push(item.id)
  147. // })
  148. // this.activeIndex.a0 = arr0
  149. // }
  150. if(sta=='4'){
  151. //加全选样式
  152. this.activeIndex.a1 = []
  153. this.activeIndex.a2 = []
  154. this.leaderlist.forEach((item)=>{
  155. arr0.push(item.id)
  156. })
  157. this.activeIndex.a0 = arr0
  158. //添加全选数据
  159. this.endVote=[];
  160. this.leaderlist.forEach((item)=>{
  161. this.allVoteList.set(item.id,'0')
  162. })
  163. this.endVote = [...this.allVoteList].map(ele=>{
  164. return {
  165. leaderId:ele[0],
  166. type:ele[1]
  167. }
  168. })
  169. }else{
  170. this.allVoteList.set(leaderId,sta)
  171. this.endVote = [...this.allVoteList].map(ele=>{
  172. return {
  173. leaderId:ele[0],
  174. type:ele[1]
  175. }
  176. })
  177. }
  178. },
  179. //查询数据
  180. getLeaders(){
  181. let params = {
  182. language: this.$i18n.locale
  183. }
  184. getMeetingGeidcoLeaders(params).then((res)=>{
  185. this.leaderlist = [];
  186. res.data.meetingGeidcoLeaders.forEach((item)=>{
  187. if(item.positionName!='governing-unit'){
  188. this.leaderlist.push(item)
  189. }
  190. })
  191. this.leaderlist.forEach((item)=>{
  192. if(this.$i18n.locale == 'en'){
  193. item.name = item.nameEn;
  194. item.positionName = item.positionNameEn;
  195. item.introduction = item.introductionEn;
  196. }
  197. if(item.voted == true){
  198. this.votedLeader = true;
  199. }else{
  200. this.votedLeader = false;
  201. }
  202. for (let i=0;i<this.candidateList.length;i++){
  203. if(item.positionName == this.positionDic[i].value){
  204. this.candidateList[i].push(item)
  205. }
  206. }
  207. });
  208. this.$emit('pushFlag',this.votedLeader);
  209. this.statistical('','4')
  210. })
  211. },
  212. //提交投票结果
  213. submitVote(){
  214. // this.OverFlag = true;
  215. if(this.votedLeader == false ){
  216. // if( this.isVote == false){
  217. if(this.endVote.length == this.leaderlist.length){
  218. this.submitHandler((token)=>{
  219. saveOrUpdateLeader(JSON.stringify(this.endVote),token).then((res)=>{
  220. if(res.status==200) {
  221. // let msgTxt = this.$i18n.locale == 'en' ? 'Submitted successfully. Thank you for your feedback' : '投票成功';
  222. // this.$message({
  223. // message: msgTxt,
  224. // type: 'success'
  225. // });
  226. this.isVote = true;
  227. this.endVote=[];
  228. this.activeIndex.a0 = [];
  229. this.activeIndex.a1 = [];
  230. this.activeIndex.a2 = [];
  231. for(let i = 0;i<this.candidateList.length ;i++){
  232. this.candidateList[i] = [];
  233. // console.log(this.candidateList[i])
  234. }
  235. this.OverFlag = true;
  236. this.resetToken();
  237. this.getLeaders()
  238. }
  239. }).catch((error) => {
  240. this.endVote=[];
  241. this.activeIndex.a0 = [];
  242. this.resetToken();
  243. this.getLeaders()
  244. console.log(this.votedLeader)
  245. });
  246. })
  247. }else {
  248. let msgTxt =this.$i18n.locale == 'en' ? 'Please vote for all candidates' : '请为全部候选人投票';
  249. this.$message({
  250. message: msgTxt,
  251. type: 'warning'
  252. });
  253. // }
  254. }
  255. }else{
  256. let msgTxt = this.$i18n.locale == 'en' ? 'You have voted for the current page, please do not submit twice' : '您已为当前点击模块投过票,请勿重复提交';
  257. this.$message({
  258. message: msgTxt,
  259. type: 'warning'
  260. });
  261. }
  262. },
  263. Iknow(){
  264. this.$emit('getVotepage',4)
  265. this.OverFlag = false
  266. }
  267. }
  268. }
  269. </script>
  270. <style scoped>
  271. .directorVote{
  272. margin: 0;
  273. padding: 0;
  274. width: 100%;
  275. background: #fff;
  276. }
  277. .Chairman{
  278. padding: 20px 0;
  279. /*height: 380px;*/
  280. background:#F0F3F7 url("../../assets/img/electionBallot/DirectorVotes/1.png") repeat;
  281. }
  282. .chairTitle{
  283. height: 45px;
  284. text-align: center;
  285. font-size: 28px;
  286. font-weight: 600;
  287. color: #666666;
  288. }
  289. .tempspace{
  290. /*width: 198px;*/
  291. width:20%;
  292. height: 215px;
  293. background: #ffffff;
  294. padding: 30px 20px;
  295. margin:20px 10px;
  296. position: relative;
  297. }
  298. .chairBox2{
  299. width: 100%;
  300. display: flex;
  301. justify-content:center;
  302. flex-wrap: wrap;
  303. }
  304. .chairBox1{
  305. width: 100%;
  306. display: flex;
  307. justify-content:center;
  308. flex-wrap: wrap;
  309. }
  310. .votePhoto{
  311. width: 118px;
  312. height: 145px;
  313. border-radius: 5px;
  314. margin: auto;
  315. text-align: center;
  316. }
  317. .moreMessage{
  318. display: none;
  319. }
  320. /* .tempspace:hover .moreMessage{
  321. display: block;
  322. padding: 30px;
  323. background: #ffffff;
  324. box-shadow: 0px 2px 10px 0px rgba(167, 167, 167, 0.5);
  325. width: 100%;
  326. position: absolute;
  327. border-radius: 6px;
  328. left:105%;
  329. top: 10px;
  330. z-index: 999;
  331. font-size:22px;
  332. font-weight: 600;
  333. } */
  334. .candidate{
  335. text-align: center;
  336. margin-top: 10px;
  337. font-weight: 600;
  338. }
  339. .voteBtn{
  340. margin: 10px auto 0;
  341. display: flex;
  342. justify-content: space-between;
  343. }
  344. .voteBtn2{
  345. text-align: center;
  346. margin: 10px;
  347. }
  348. .Secretarygeneral{
  349. padding: 20px 0;
  350. /*height: 380px;*/
  351. background:#F0F3F7 url("../../assets/img/electionBallot/DirectorVotes/1.png") repeat;
  352. }
  353. .submitVote{
  354. height: 100px;
  355. line-height: 100px;
  356. text-align: center;
  357. }
  358. .submitVote > .el-button{
  359. width: 150px;
  360. height: 50px;
  361. border-radius: 5px;
  362. font-size: 20px;
  363. }
  364. .submitVote .el-button:nth-child(1){
  365. background-color: #6dd400;
  366. }
  367. .submitVote .el-button:nth-child(2){
  368. background-color: #6f9fe8;
  369. }
  370. .el-button{
  371. border: none;
  372. }
  373. .active{
  374. background: #6dd400;
  375. border: none;
  376. }
  377. .notActive{
  378. background: none;
  379. }
  380. </style>