Merge branch 'finadev' of https://gitlab.com/erahn/voting into Hayatie
This commit is contained in:
@@ -1,48 +1,47 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div v-for="position in positions">
|
||||
<h5>{{ position.name }}</h5>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="10%">No. Anggota</th>
|
||||
<th width="30%">Nama</th>
|
||||
<th width="20%">Partylist</th>
|
||||
<th width="20%">Unit</th>
|
||||
<th width="20%">Undian</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="result in results" v-if="result.position_id==position.id">
|
||||
<td>{{ getNominee(result.nominee_id)['student_id'] }}</td>
|
||||
<td>{{ getNominee(result.nominee_id)['name'] }}</td>
|
||||
<td>{{ getPartylist(getNominee(result.nominee_id)['partylist_id']) }}</td>
|
||||
<td>{{ getNominee(result.nominee_id)['Unit'] }}</td>
|
||||
<td>{{ result.votes}}</td>
|
||||
</tr>
|
||||
<tr v-for="no_vote in no_votes" v-if="no_vote.position_id==position.id">
|
||||
<td>{{ no_vote.student_id }}</td>
|
||||
<td>{{ no_vote.name }}</td>
|
||||
<td>{{ getPartylist(no_vote.partylist_id) }}</td>
|
||||
<td>{{ no_vote.unit }}</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div v-for="position in positions">
|
||||
<h5>{{ position.name }}</h5>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20%">No. Anggota</th>
|
||||
<th width="30%">Nama</th>
|
||||
<th width="20%">Unit</th>
|
||||
<th width="10%">Undian</th>
|
||||
<th width="20%">Peratus (%)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="result in results" v-if="result.position_id == position.id">
|
||||
<td>{{ getNominee(result.nominee_id)['no_anggota'] }}</td>
|
||||
<td>{{ getNominee(result.nominee_id)['name'] }}</td>
|
||||
<td>{{ getNominee(result.nominee_id)['unit'] }}</td>
|
||||
<td>{{ result.votes }}</td>
|
||||
<td>{{ calculatePercentage(result.votes, position.id) }}</td>
|
||||
</tr>
|
||||
<tr v-for="no_vote in no_votes" v-if="no_vote.position_id == position.id">
|
||||
<td>{{ no_vote.no_anggota }}</td>
|
||||
<td>{{ no_vote.name }}</td>
|
||||
<td>{{ no_vote.unit }}</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<hr />
|
||||
</div>
|
||||
<hr/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default{
|
||||
data: function() {
|
||||
export default {
|
||||
data: function () {
|
||||
return {
|
||||
nominees: [],
|
||||
results: [],
|
||||
@@ -66,21 +65,29 @@ export default{
|
||||
if (id == partylists[i]['id'])
|
||||
return partylists[i]['name'];
|
||||
return 'No Partylist';
|
||||
},
|
||||
|
||||
calculatePercentage(votes, positionId) {
|
||||
const totalVotes = this.results
|
||||
.filter(result => result.position_id === positionId)
|
||||
.reduce((total, result) => total + result.votes, 0);
|
||||
|
||||
return ((votes / totalVotes) * 100).toFixed(2);
|
||||
}
|
||||
},
|
||||
|
||||
created: function () {
|
||||
this.util.notify('Loading please wait...', 'loading');
|
||||
var vm = this;
|
||||
axios.get(config.API+'election/result/'+this.election_id)
|
||||
.then(response=>{
|
||||
axios.get(config.API + 'election/result/' + this.election_id)
|
||||
.then(response => {
|
||||
$.notifyClose();
|
||||
vm.nominees = response.data.nominee;
|
||||
vm.results = response.data.result;
|
||||
vm.partylists = response.data.partylist;
|
||||
vm.positions = response.data.position;
|
||||
})
|
||||
.catch(error=>{
|
||||
.catch(error => {
|
||||
$.notifyClose();
|
||||
vm.util.showResult(error, 'error');
|
||||
})
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
<template>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<h4> Undian Terkini</h4>
|
||||
<h4>Undian Terkini</h4>
|
||||
<div class="form-group">
|
||||
<button class="btn btn-success" v-if="data.election.status == 1 && data.user.role==1"
|
||||
@click="util.showModal('#start-election-modal')">Undian bermula</button>
|
||||
@click="util.showModal('#start-election-modal')">Mula Undian</button>
|
||||
|
||||
<router-link :to="{ name: 'Current Result' }" class="btn btn-info" v-if="data.election.status == 2">
|
||||
View Results
|
||||
Papar Keputusan
|
||||
</router-link>
|
||||
|
||||
<button class="btn btn-danger" v-if="data.election.status == 2"
|
||||
@click="util.showModal('#stop-election-modal')">End Election</button>
|
||||
@click="util.showModal('#stop-election-modal')">Tamat Undian</button>
|
||||
|
||||
<label v-if="data.election.status == 2">Undian bermula {{ start_date }}</label>
|
||||
<label v-if="data.election.status == 2">Undian bermula {{ start_date }}</label>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Election Name</th>
|
||||
<th>Election Start</th>
|
||||
<th>Election End</th>
|
||||
<th>View</th>
|
||||
<th>Nama Undian</th>
|
||||
<th>Undian Mula</th>
|
||||
<th>Undian Tamat</th>
|
||||
<th>Papar</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -36,7 +36,7 @@
|
||||
<td>{{ election.end }}</td>
|
||||
<td>
|
||||
<router-link :to="{ name: 'Election Result', params: { election_id: election.id } }"
|
||||
class="btn btn-info">View Result</router-link>
|
||||
class="btn btn-info">Keputusan Undian</router-link>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="data.elections.length < 1">
|
||||
|
||||
Reference in New Issue
Block a user