DirectorUnit.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <template>
  2. <!--事项选票-->
  3. <div class="matterVote">
  4. <div class="voteTable">
  5. <!-- 表决Title-->
  6. <div class="matterTitle">
  7. <span>{{ mylocale=='zh'?'理事单位投票':'DirectorUnit Vote' }}</span>
  8. </div>
  9. <div class="matterContent">
  10. <el-row :gutter="20">
  11. <el-col :span="2"><div class="grid-content bg-purple">{{ mylocale=='zh'?'序号':'No. ' }}</div></el-col>
  12. <el-col :span="17"><div class="grid-content bg-purple">{{ mylocale=='zh'?'标题':'Content' }}</div></el-col>
  13. <el-col :span="5"><div class="grid-content bg-purple">{{ mylocale=='zh'?'意见':'opinion' }}</div></el-col>
  14. </el-row>
  15. <div class="voteMessage" v-for="(item,index) in leaderlist" :key="index">
  16. <el-row :gutter="20">
  17. <el-col :span="2"><div class="grid-content bg-purples">{{index+1}}</div></el-col>
  18. <el-col :span="17"><div class="grid-content bg-purples bg-title">{{item.name}}</div></el-col>
  19. <el-col :span="5">
  20. <div class="grid-content bg-purples">
  21. <!-- 投票按钮 -->
  22. <div class="voteBtn" v-if="votedLeader === false">
  23. <el-button size="small" type="info" @click="statistical(item,'0')" :class="activeIndex.a0.indexOf(item.id) != -1 ?'active':''">{{ mylocale=='zh'?'赞成':'Approve'}}</el-button>
  24. <el-button size="small" type="info" @click="statistical(item,'1')" :class="activeIndex.a1.indexOf(item.id) != -1 ?'active':''">{{ mylocale=='zh'?'反对':'Oppose' }}</el-button>
  25. <el-button size="small" type="info" @click="statistical(item,'2')" :class="activeIndex.a2.indexOf(item.id) != -1 ?'active':''">{{ mylocale=='zh'?'弃权':'waiver' }}</el-button>
  26. </div>
  27. <div class="voteBtn" v-if="votedLeader === true">
  28. {{$t('common.AreadyVote')}}
  29. </div>
  30. </div>
  31. </el-col>
  32. </el-row>
  33. </div>
  34. <!-- 事项投票内容展示-->
  35. <el-dialog
  36. :title="'投票内容'"
  37. :visible.sync="dialogVisible"
  38. width="50%">
  39. <div v-html="showIntroduction"></div>
  40. </el-dialog>
  41. </div>
  42. <!-- ==================== -->
  43. <div class="submitVote" v-if="votedLeader == false">
  44. <el-button class="voteSty" type="danger" @click="statistical('','4')">{{ mylocale=='zh'?'全部赞成':'Approve All'}}</el-button>
  45. <el-button type="primary" @click="submitVote" style="padding:0">{{ mylocale=='zh'?'提交投票':'Submit to vote'}}</el-button>
  46. </div>
  47. </div>
  48. </div>
  49. </template>
  50. <script>
  51. import {saveOrUpdateLeader,getCouncilVoteSituation,getMeetingGeidcoLeaders} from "@/api/vote/council";
  52. import { getDicts } from "@/api/dict";
  53. import Base from "@/views/base/Base";
  54. // import vote from "../AddFeatures/vote/vote";
  55. export default {
  56. name:'MatterVote',
  57. extends: Base,
  58. props:[
  59. // 'vote',
  60. // 'showLink'
  61. ],
  62. data () {
  63. return {
  64. mylocale:this.$i18n.locale,
  65. // positionDic:'',
  66. candidateList:[],
  67. num:0,
  68. meetingContent:'',
  69. allVoteList:new Map(),
  70. endVote:[],
  71. mattersList:[],
  72. activeIndex:{
  73. a0:[],
  74. a1:[],
  75. a2:[]
  76. },
  77. votedLeader:'',
  78. votedMatter:'',
  79. dialogVisible:false,
  80. showIntroduction:'',
  81. // showLink:'',
  82. isRefresh:'',
  83. trueVote:[],
  84. falseVote:[],
  85. flalseLength:'',
  86. meetingGeidcoMatterNumDetail:[],
  87. leaderlist:[],
  88. OverFlag:true
  89. }
  90. },
  91. mounted() {
  92. // this.getDictsList();
  93. this.getLeaders();
  94. localStorage.removeItem('Votepage')
  95. console.log('啪啪啪啪啪啪铺铺铺铺铺',this.mylocale)
  96. },
  97. destroyed(){
  98. clearInterval(this.isRefresh)
  99. },
  100. methods:{
  101. //获取字典
  102. async getDictsList(){
  103. let dicts = this.$i18n.locale=='zh'?'GEIDCO_LEADER_DICT':'GEIDCO_LEADER_DICT_EN';
  104. getDicts(dicts).then((result)=>{
  105. result.data[0].forEach((item,index)=>{
  106. if(item.value=='governing-unit'){
  107. this.positionDic.push(item);
  108. index = new Array();
  109. this.candidateList.push(index);
  110. }
  111. });
  112. this. getLeaders()
  113. })
  114. },
  115. //将投票结果统计到数组
  116. statistical(item,sta){
  117. this.VoteState = sta;
  118. this.clickId = item;
  119. let arr0 = this.activeIndex.a0
  120. let arr1 = this.activeIndex.a1
  121. let arr2 = this.activeIndex.a2
  122. let leaderId = item.id;
  123. if(sta=='0'){
  124. if(arr0.indexOf(item.id)==-1) arr0.push(item.id)
  125. if(arr1.indexOf(item.id)!=-1) arr1 = arr1.filter(ele=>{return ele!=item.id})
  126. if(arr2.indexOf(item.id)!=-1) arr2 = arr2.filter(ele=>{return ele!=item.id})
  127. this.activeIndex.a0 = arr0
  128. this.activeIndex.a1 = arr1
  129. this.activeIndex.a2 = arr2
  130. }
  131. if(sta=='1'){
  132. if(arr0.indexOf(item.id)!=-1) arr0 = arr0.filter(ele=>{return ele!=item.id})
  133. if(arr1.indexOf(item .id)==-1) arr1.push(item.id)
  134. if(arr2.indexOf(item.id)!=-1) arr2 = arr2.filter(ele=>{return ele!=item.id})
  135. this.activeIndex.a0 = arr0
  136. this.activeIndex.a1 = arr1
  137. this.activeIndex.a2 = arr2
  138. }
  139. if(sta=='2'){
  140. if(arr0.indexOf(item.id)!=-1) arr0 = arr0.filter(ele=>{return ele!=item.id})
  141. if(arr1.indexOf(item.id)!=-1) arr1 = arr1.filter(ele=>{return ele!=item.id})
  142. if(arr2.indexOf(item.id)==-1) arr2.push(item.id)
  143. this.activeIndex.a0 = arr0
  144. this.activeIndex.a1 = arr1
  145. this.activeIndex.a2 = arr2
  146. }
  147. if(sta=='4'){
  148. //加全选样式
  149. this.activeIndex.a1 = []
  150. this.activeIndex.a2 = []
  151. this.leaderlist.forEach((item)=>{
  152. arr0.push(item.id)
  153. })
  154. this.activeIndex.a0 = arr0
  155. //添加全选数据
  156. this.endVote=[];
  157. this.leaderlist.forEach((item)=>{
  158. this.allVoteList.set(item.id,'0')
  159. })
  160. this.endVote = [...this.allVoteList].map(ele=>{
  161. return {
  162. leaderId:ele[0],
  163. type:ele[1]
  164. }
  165. })
  166. }else{
  167. this.allVoteList.set(leaderId,sta)
  168. this.endVote = [...this.allVoteList].map(ele=>{
  169. return {
  170. leaderId:ele[0],
  171. type:ele[1]
  172. }
  173. })
  174. }
  175. },
  176. //查询数据
  177. getLeaders(){
  178. let params = {
  179. language: this.$i18n.locale
  180. }
  181. getMeetingGeidcoLeaders(params).then((res)=>{
  182. this.leaderlist = [];
  183. res.data.meetingGeidcoLeaders.forEach((item)=>{
  184. if(item.positionName=='governing-unit'){
  185. this.leaderlist.push(item)
  186. }
  187. })
  188. this.leaderlist.forEach((item)=>{
  189. if(this.$i18n.locale == 'en'){
  190. item.name = item.nameEn;
  191. item.positionName = item.positionNameEn;
  192. item.introduction = item.introductionEn;
  193. }
  194. if(item.voted == true){
  195. this.votedLeader = true;
  196. }else{
  197. this.votedLeader = false;
  198. }
  199. for (let i=0;i<this.candidateList.length;i++){
  200. if(item.positionName == this.positionDic[i].value){
  201. this.candidateList[i].push(item)
  202. }
  203. }
  204. });
  205. this.$emit('pushFlag',this.votedLeader);
  206. this.statistical('','4');
  207. console.log('xxxxxxxxxxxx',this.leaderlist)
  208. })
  209. },
  210. //提交投票结果
  211. submitVote(){
  212. if(this.votedLeader == false ){
  213. // if( this.isVote == false){
  214. if(this.endVote.length == this.leaderlist.length){
  215. this.submitHandler((token)=>{
  216. saveOrUpdateLeader(JSON.stringify(this.endVote),token).then((res)=>{
  217. if(res.status==200) {
  218. let msgTxt = this.$i18n.locale == 'en' ? 'Submitted successfully. Thank you for your feedback' : '投票成功';
  219. this.$message({
  220. message: msgTxt,
  221. type: 'success'
  222. });
  223. this.isVote = true;
  224. this.endVote=[];
  225. this.activeIndex.a0 = [];
  226. this.activeIndex.a1 = [];
  227. this.activeIndex.a2 = [];
  228. for(let i = 0;i<this.candidateList.length ;i++){
  229. this.candidateList[i] = [];
  230. // console.log(this.candidateList[i])
  231. }
  232. this.resetToken();
  233. this.getLeaders();
  234. }
  235. }).catch((error) => {
  236. this.endVote=[];
  237. this.activeIndex.a0 = [];
  238. this.resetToken();
  239. this.getLeaders()
  240. console.log(this.votedLeader)
  241. });
  242. })
  243. }else {
  244. let msgTxt =this.$i18n.locale == 'en' ? 'Please vote for all candidates' : '请为全部候选人投票';
  245. this.$message({
  246. message: msgTxt,
  247. type: 'warning'
  248. });
  249. // }
  250. }
  251. }else{
  252. let msgTxt = this.$i18n.locale == 'en' ? 'You have voted for the current page, please do not submit twice' : '您已为当前点击模块投过票,请勿重复提交';
  253. this.$message({
  254. message: msgTxt,
  255. type: 'warning'
  256. });
  257. }
  258. },
  259. // 查询投票状态
  260. getVoteState(){
  261. const that = this;
  262. getCouncilVoteSituation().then((res)=>{
  263. let sta = res.data.councilVoteSituation;
  264. this.votedLeader=sta.votedLeader;
  265. this.votedMatter=sta.votedMatter
  266. // this.showLink = sta.showCouncilLiveingLink;
  267. this.refreshPage()
  268. })
  269. },
  270. // 事项详情弹窗
  271. dialogVisibleChange(item){
  272. this.dialogVisible = true;
  273. this.showIntroduction = item.introduction
  274. console.log('1234321232123')
  275. },
  276. // 刷新按钮事件
  277. refreshMatter(){
  278. this.getMatters()
  279. },
  280. open() {
  281. this.$alert('这是一段内容', '标题名称', {
  282. confirmButtonText: '确定',
  283. callback: action => {
  284. this.$message({
  285. type: 'info',
  286. message: `action: ${ action }`
  287. });
  288. }
  289. });
  290. }
  291. }
  292. }
  293. </script>
  294. <style scoped>
  295. .matterVote{
  296. margin: auto;
  297. padding: 0;
  298. width: 90%;
  299. background: #fff;
  300. }
  301. .voteTable{
  302. width: 100%;
  303. padding: 42px 0 0px 0;
  304. /* background:#F0F3F7 url("../../assets/img/electionBallot/DirectorVotes/1.png") repeat; */
  305. }
  306. .matterTitle{
  307. width: 1200px;
  308. margin: auto;
  309. height: 45px;
  310. text-align: center;
  311. font-size: 28px;
  312. font-weight: 600;
  313. color: #666666;
  314. }
  315. .el-row {
  316. margin-bottom: 20px;
  317. text-align: center;
  318. line-height: 42px;
  319. }
  320. .el-col {
  321. border-radius: 4px;
  322. }
  323. .bg-purple-dark {
  324. background: #99a9bf;
  325. }
  326. .bg-purple {
  327. background: #d3dce6;
  328. font-size: 18px;
  329. }
  330. .bg-purples {
  331. background: #fff;
  332. font-size: 16px;
  333. }
  334. .bg-title{
  335. text-align: left;
  336. padding-left:10px
  337. }
  338. .bg-purple-light {
  339. background: #e5e9f2;
  340. }
  341. .grid-content {
  342. height: 42px;
  343. border-radius: 4px;
  344. min-height: 36px;
  345. }
  346. .row-bg {
  347. padding: 10px 0;
  348. background-color: #f9fafc;
  349. }
  350. .matterContent{
  351. width: 1200px;
  352. margin:20px auto;
  353. }
  354. .voteMessage{
  355. /*width: 100%;*/
  356. height: 50px;
  357. line-height: 50px;
  358. /* padding: 0 20px; */
  359. border-radius: 8px;
  360. background: #fff;
  361. /* margin-bottom: 15px; */
  362. position: relative;
  363. cursor: pointer;
  364. }
  365. /*.moreMessage{*/
  366. /* display: none;*/
  367. /*}*/
  368. /*.voteMessage:hover .moreMessage{*/
  369. /* display: block;*/
  370. /* padding: 30px;*/
  371. /* background: #ffffff;*/
  372. /* box-shadow: 0px 2px 10px 0px rgba(167, 167, 167, 0.5);*/
  373. /* width:60%;*/
  374. /* line-height: 40px;*/
  375. /* position: absolute;*/
  376. /* border-radius: 6px;*/
  377. /* left:-10%;*/
  378. /* top: 60px;*/
  379. /* z-index: 999;*/
  380. /* overflow: scroll;*/
  381. /* max-height:300px;*/
  382. /*}*/
  383. .message{
  384. width: 75%;
  385. overflow: hidden;
  386. text-overflow: ellipsis;
  387. white-space: nowrap;
  388. display: inline-block;
  389. float: left;
  390. }
  391. .voteBtn{
  392. float: right;
  393. display: inline-block;
  394. text-align: center;
  395. height: 100%;
  396. width: 100%;
  397. }
  398. .voteBtn > .el-button{
  399. border-radius: 6px;
  400. }
  401. .submitVote{
  402. height: 100px;
  403. line-height: 100px;
  404. text-align: center;
  405. }
  406. .submitVote > .el-button{
  407. width: 150px;
  408. height: 50px;
  409. border-radius: 5px;
  410. font-size: 20px;
  411. }
  412. .submitVote .el-button:nth-child(1){
  413. background-color: #6dd400;
  414. }
  415. .submitVote .el-button:nth-child(2){
  416. background-color: #6f9fe8;
  417. }
  418. .el-button{
  419. border: none;
  420. /* padding: 0; */
  421. }
  422. .active{
  423. background: #6dd400;
  424. border: none;
  425. }
  426. .refreshBtn{
  427. float: right;
  428. height: 30px;
  429. margin-top: 10px;
  430. padding: 5px 5px;
  431. border-radius: 5px;
  432. background: #409EFF;
  433. border: none;
  434. color: #ffffff;
  435. cursor: pointer;
  436. }
  437. .notActive{
  438. background: #A6A9AD;
  439. }
  440. </style>