182 lines
7.4 KiB
Vue
182 lines
7.4 KiB
Vue
<template>
|
|
<div>
|
|
|
|
<h1 class="font-bold p-2">Tetapan Ubah Margin</h1>
|
|
|
|
<div id="tabs-1" v-if="this.showprofile">
|
|
|
|
<table class="min-w-full leading-normal">
|
|
<thead class="text-center">
|
|
<tr>
|
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
|
Bil
|
|
</th>
|
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
|
Pengguna
|
|
</th>
|
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
|
Margin %
|
|
</th>
|
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
|
Tindakan
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
|
|
<tr v-for="(margin,i) in datamargin.data" :key="i">
|
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
|
<div class="flex items-center">
|
|
<div class="ml-3">
|
|
<p class="text-gray-900 whitespace-no-wrap" v-text="(datamargin.from + i)">
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
|
<div class="flex items-center">
|
|
<div class="ml-3">
|
|
<p class="text-gray-900 whitespace-no-wrap" v-text="margin.user_type">
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
|
<div class="flex items-center">
|
|
<div class="ml-3">
|
|
<p class="text-gray-900 whitespace-no-wrap" v-text="formatexchange(margin.max)">
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
|
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
|
<div class="flex items-center ml-3">
|
|
|
|
<button @click="ubahmargin(margin.id)" class="border border-blue-600 text-blue-600 font-montserrat py-2 px-4 font-medium rounded-xl hover:bg-blue-600 hover:text-white transition-all duration-300 mr-1">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-square" viewBox="0 0 16 16">
|
|
<path d="M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z"/>
|
|
<path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z"/>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import pagination from '../components/pagination.vue'
|
|
|
|
const formatter = new Intl.NumberFormat('en-US', {
|
|
minimumFractionDigits: 2
|
|
});
|
|
|
|
export default {
|
|
components: {
|
|
pagination,
|
|
},
|
|
data() {
|
|
return {
|
|
showprofile: true,
|
|
showsag: false,
|
|
datamargin: {},
|
|
currentPage: 1,
|
|
}
|
|
},
|
|
mounted() {
|
|
this.getMarginData(this.currentPage);
|
|
},
|
|
methods: {
|
|
formatexchange: function(value){
|
|
return formatter.format(value)
|
|
},
|
|
getMarginData: function (pageNumber) {
|
|
this.axios.get(this.$hostname + '/admin/tetapan/penggunamargin', {
|
|
|
|
}).then(response => {
|
|
this.datamargin = response.data;
|
|
});
|
|
},
|
|
|
|
|
|
async ubahmargin(id) {
|
|
|
|
let refer = this;
|
|
const {
|
|
value: max
|
|
} = await this.$swal({
|
|
title: 'Masukkan Nilai Margin',
|
|
input: 'number',
|
|
inputPlaceholder: 'Margin',
|
|
confirmButtonText: 'Hantar',
|
|
showCancelButton: true,
|
|
cancelButtonText: 'Batal',
|
|
allowOutsideClick: false,
|
|
inputValidator: (value) => {
|
|
if (!value) {
|
|
return 'Isikan nilai margin diatas!'
|
|
}
|
|
}
|
|
});
|
|
|
|
if(max !== undefined){
|
|
|
|
|
|
this.axios.put(this.$hostname + '/admin/tetapan/penggunamargin/update', {
|
|
id: id,
|
|
max: max
|
|
|
|
}).then(response => {
|
|
|
|
if(response.data ==1){
|
|
|
|
this.$swal({
|
|
icon: 'success',
|
|
title: 'Berjaya',
|
|
text: 'Berjaya mengemaskini',
|
|
allowOutsideClick: false
|
|
}).then(function () {
|
|
refer.getMarginData(refer.currentPage);
|
|
|
|
});
|
|
}
|
|
else{
|
|
|
|
this.$swal({
|
|
icon: 'error',
|
|
title: 'Tidak Berjaya',
|
|
text: 'Sila Cuba Semula',
|
|
allowOutsideClick: false
|
|
}).then(function () {
|
|
refer.getMarginData(refer.currentPage);
|
|
|
|
});
|
|
|
|
|
|
}
|
|
});
|
|
} else{
|
|
|
|
(function () {
|
|
refer.getMarginData(refer.currentPage);
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
}
|
|
|
|
}
|
|
</script>
|
|
|