81 lines
2.1 KiB
Vue
81 lines
2.1 KiB
Vue
<template>
|
|
<div class="panel panel-default">
|
|
<div class="panel-body">
|
|
<h4><b>Kemaskini Maklumat</b></h4>
|
|
<form @submit.prevent="edit()" id="edit-form">
|
|
<div class="form-group">
|
|
<label for="name">Nama</label>
|
|
<input type="text" name="name" class="form-control" :value="data.voter.name" required/>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="no_kp">No. Kad Pengenalan</label>
|
|
<input type="text" name="no_kp" class="form-control" :value="data.voter.no_kp" required/>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="telefon">No. Telefon</label>
|
|
<input type="text" name="telefon" class="form-control" :value="data.voter.telefon" required/>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="Unit">Unit</label>
|
|
<input type="text" name="unit" class="form-control" :value="data.voter.unit" required/>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="saham">Saham</label>
|
|
<input type="text" name="saham" class="form-control" :value="data.voter.saham" required/>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="yuran">Yuran</label>
|
|
<input type="text" name="yuran" class="form-control" :value="data.voter.yuran" required/>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<input type="submit" value="Hantar" class="btn btn-success"/>
|
|
<router-link :to="{name: 'Manage Voter'}" class="btn btn-default">Kembali</router-link>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default{
|
|
data: function () {
|
|
return {
|
|
loading: false
|
|
}
|
|
},
|
|
|
|
created: function () {
|
|
if (!this.data.voter.id) {
|
|
this.$router.push({name:'Manage Voter'});
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
edit: function () {
|
|
if (this.loading) return;
|
|
this.loading = true;
|
|
var vm = this;
|
|
this.util.notify('Updating voter', 'loading');
|
|
axios.put(config.API+'voter/'+this.data.voter.id, $('#edit-form').serialize())
|
|
.then(response=>{
|
|
vm.loading = false;
|
|
$.notifyClose();
|
|
if (vm.util.showResult(response, 'success')) {
|
|
vm.$router.push({name:'Manage Voter'});
|
|
}
|
|
})
|
|
.catch(error=>{
|
|
$.notifyClose();
|
|
vm.loading = false;
|
|
vm.util.showResult(error);
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script> |