add jumlah undian

This commit is contained in:
nurafrinaalimi16
2024-04-28 16:22:05 +08:00
parent aff14b29cd
commit 2a7f91199e
@@ -28,6 +28,11 @@
<td>{{ no_vote.name }}</td>
<td>{{ no_vote.unit }}</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td colspan="3"><b>Jumlah Undian</b></td>
<td><b>{{ calculateTotalVotes(position.id) }}</b></td>
</tr>
</tbody>
</table>
@@ -73,6 +78,12 @@ export default {
.reduce((total, result) => total + result.votes, 0);
return ((votes / totalVotes) * 100).toFixed(2);
},
calculateTotalVotes(positionId) {
return this.results
.filter(result => result.position_id === positionId)
.reduce((total, result) => total + result.votes, 0);
}
},