add peratus votes on final report
This commit is contained in:
@@ -1,48 +1,47 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div v-for="position in positions">
|
<div v-for="position in positions">
|
||||||
<h5>{{ position.name }}</h5>
|
<h5>{{ position.name }}</h5>
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped table-condensed">
|
<table class="table table-striped table-condensed">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="10%">No. Anggota</th>
|
<th width="10%">No. Anggota</th>
|
||||||
<th width="30%">Nama</th>
|
<th width="30%">Nama</th>
|
||||||
<th width="20%">Partylist</th>
|
<th width="20%">Unit</th>
|
||||||
<th width="20%">Unit</th>
|
<th width="20%">Undian</th>
|
||||||
<th width="20%">Undian</th>
|
<th width="20%">Peratus (%)</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="result in results" v-if="result.position_id==position.id">
|
<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)['no_anggota'] }}</td>
|
||||||
<td>{{ getNominee(result.nominee_id)['name'] }}</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>{{ getNominee(result.nominee_id)['Unit'] }}</td>
|
<td>{{ result.votes }}</td>
|
||||||
<td>{{ result.votes}}</td>
|
<td>{{ calculatePercentage(result.votes, position.id) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-for="no_vote in no_votes" v-if="no_vote.position_id==position.id">
|
<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.no_anggota }}</td>
|
||||||
<td>{{ no_vote.name }}</td>
|
<td>{{ no_vote.name }}</td>
|
||||||
<td>{{ getPartylist(no_vote.partylist_id) }}</td>
|
<td>{{ no_vote.unit }}</td>
|
||||||
<td>{{ no_vote.unit }}</td>
|
<td>0</td>
|
||||||
<td>0</td>
|
</tr>
|
||||||
</tr>
|
</tbody>
|
||||||
</tbody>
|
</table>
|
||||||
</table>
|
</div>
|
||||||
|
<hr />
|
||||||
</div>
|
</div>
|
||||||
<hr/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default{
|
export default {
|
||||||
data: function() {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
nominees: [],
|
nominees: [],
|
||||||
results: [],
|
results: [],
|
||||||
@@ -66,21 +65,29 @@ export default{
|
|||||||
if (id == partylists[i]['id'])
|
if (id == partylists[i]['id'])
|
||||||
return partylists[i]['name'];
|
return partylists[i]['name'];
|
||||||
return 'No Partylist';
|
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 () {
|
created: function () {
|
||||||
this.util.notify('Loading please wait...', 'loading');
|
this.util.notify('Loading please wait...', 'loading');
|
||||||
var vm = this;
|
var vm = this;
|
||||||
axios.get(config.API+'election/result/'+this.election_id)
|
axios.get(config.API + 'election/result/' + this.election_id)
|
||||||
.then(response=>{
|
.then(response => {
|
||||||
$.notifyClose();
|
$.notifyClose();
|
||||||
vm.nominees = response.data.nominee;
|
vm.nominees = response.data.nominee;
|
||||||
vm.results = response.data.result;
|
vm.results = response.data.result;
|
||||||
vm.partylists = response.data.partylist;
|
vm.partylists = response.data.partylist;
|
||||||
vm.positions = response.data.position;
|
vm.positions = response.data.position;
|
||||||
})
|
})
|
||||||
.catch(error=>{
|
.catch(error => {
|
||||||
$.notifyClose();
|
$.notifyClose();
|
||||||
vm.util.showResult(error, 'error');
|
vm.util.showResult(error, 'error');
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user