Files
admin-erahn/resources/js/Permohonan/SenaraiMohon.vue
T
hafifierahman 4322351eb0 fix skti2
2022-03-31 07:41:38 +08:00

627 lines
25 KiB
Vue

<template>
<div class="mx-auto">
<pbmodal ref="modal" @clickEvent_="getSenaraiMohon"></pbmodal>
<bankmodal ref="bankmodal" @clickEvent_="getSenaraiMohon"></bankmodal>
<div class="mx-auto flex justify-between mb-4">
<h1 class="font-bold flex flex-row justify-end">Permohonan Yang Masih Aktif</h1>
<router-link to="/permohonan/rekod">
<button class="p-2 text-white bg-blue-500 rounded">Rekod Permohonan</button>
</router-link>
</div>
<table v-if="loader == true" 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">
Cawangan
</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">
PetiBesi (RM)
</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">
No Permohonan
</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">
Tarikh Mohon
</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">
Jumlah Mohon (RM)
</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">
Semak
</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">
Jenis Permohonan
</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-if="showpermohonan.data.length === 0">
<td colspan="9" class=" px-5 py-5 border-b border-gray-200 bg-white text-sm">
<p class="text-gray-900 whitespace-no-wrap text-center mx-auto">
Tiada Rekod Diperolehi
</p>
</td>
</tr>
<tr v-for="(mohon,i) in showpermohonan.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="namacawangan(mohon.kodcaw)">
</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="formatterfunction(mohon.baki_petibesi)">
</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="mohon.nopermohonan">
</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="mohon.tarikh_permohonan">
</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="formatterfunction(mohon.amaun_mohon)">
</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">
<router-link :to="{ name: 'permohonanstatus', params: { mohonid: mohon.mohonid }}">
<div class="border border-green-600 text-green-600 font-montserrat py-2 px-4 font-medium rounded-xl hover:bg-green-600 hover:text-white transition-all duration-300">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
<path stroke-linecap="round" stroke-linejoin="round" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
</svg>
</div>
</router-link>
</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="mohon.jenismohon == 'permohonanwang' ? 'bg-yellow-500' : 'bg-gray-500'" class="text-white whitespace-no-wrap p-2 rounded" v-text="checkjenismohon(mohon.jenismohon)">
</p>
</div>
</div>
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<div v-if="userroles == 'operasi'" class="flex items-center">
<div v-if="mohon.tagoperasi == 0" class="ml-3">
<button @click="funcsetuju(mohon.mohonid)" 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">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M14 10h4.764a2 2 0 011.789 2.894l-3.5 7A2 2 0 0115.263 21h-4.017c-.163 0-.326-.02-.485-.06L7 20m7-10V5a2 2 0 00-2-2h-.095c-.5 0-.905.405-.905.905 0 .714-.211 1.412-.608 2.006L7 11v9m7-10h-2M7 20H5a2 2 0 01-2-2v-6a2 2 0 012-2h2.5" />
</svg>
</button>
<button @click="funcbatal(mohon.mohonid)" class="border border-red-600 text-red-600 font-montserrat py-2 px-4 font-medium rounded-xl hover:bg-red-600 hover:text-white transition-all duration-300">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M10 14H5.236a2 2 0 01-1.789-2.894l3.5-7A2 2 0 018.736 3h4.018a2 2 0 01.485.06l3.76.94m-7 10v5a2 2 0 002 2h.096c.5 0 .905-.405.905-.904 0-.715.211-1.413.608-2.008L17 13V4m-7 10h2m5-10h2a2 2 0 012 2v6a2 2 0 01-2 2h-2.5" />
</svg>
</button>
</div>
<div v-else class="ml-3">
<p class="text-white whitespace-no-wrap p-2 rounded bg-green-500">
Telah Lulus
</p>
</div>
</div>
<div v-if="userroles == 'akaun'" class="flex items-center">
<div v-if="mohon.tagoperasi === 0">
<p class="text-white whitespace-no-wrap p-2 rounded bg-blue-500">
DALAM PROCESS
</p>
</div>
<div v-else-if="(mohon.tagoperasi === 1 && mohon.tagakaun === 0)" class="ml-3">
<button @click="funcsetuju(mohon.mohonid)" 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">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M14 10h4.764a2 2 0 011.789 2.894l-3.5 7A2 2 0 0115.263 21h-4.017c-.163 0-.326-.02-.485-.06L7 20m7-10V5a2 2 0 00-2-2h-.095c-.5 0-.905.405-.905.905 0 .714-.211 1.412-.608 2.006L7 11v9m7-10h-2M7 20H5a2 2 0 01-2-2v-6a2 2 0 012-2h2.5" />
</svg>
</button>
<button @click="funcbatal(mohon.mohonid)" class="border border-red-600 text-red-600 font-montserrat py-2 px-4 font-medium rounded-xl hover:bg-red-600 hover:text-white transition-all duration-300">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M10 14H5.236a2 2 0 01-1.789-2.894l3.5-7A2 2 0 018.736 3h4.018a2 2 0 01.485.06l3.76.94m-7 10v5a2 2 0 002 2h.096c.5 0 .905-.405.905-.904 0-.715.211-1.413.608-2.008L17 13V4m-7 10h2m5-10h2a2 2 0 012 2v6a2 2 0 01-2 2h-2.5" />
</svg>
</button>
</div>
<div v-else-if="(mohon.tagakaun === 1 || mohon.tagakaun === 2) && mohon.tagprint === 0" class="ml-3">
<button @click="CetakanPB(mohon.kodcaw,mohon.mohonid)" 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">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z" />
</svg>
</button>
</div>
<div v-else-if="mohon.tagprint === 1 && mohon.tagakaun === 1 && mohon.tagpb === 0">
<button @click="KelulusanPB(mohon.mohonid,formatterfunction(mohon.amaun_mohon))" 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">
PB
</button>
</div>
<div v-else-if="mohon.tagpb === 1 && mohon.tagdeposit === 0">
<button @click="DepositBank(mohon.mohonid)" 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">
BANK
</button>
</div>
<div v-else>
<p class="text-white whitespace-no-wrap p-2 rounded bg-green-500">
Telah Lulus
</p>
</div>
</div>
</td>
</tr>
</tbody>
</table>
<pagination :data="paginate" @clickEvent_="getSenaraiMohon"></pagination>
</div>
</template>
<script>
import pagination from '../components/pagination.vue'
import pbmodal from '../components/util/PBmodal.vue'
import bankmodal from '../components/util/Bankmodal.vue'
const formatter = new Intl.NumberFormat('en-US', {
minimumFractionDigits: 2
});
export default {
components: {
pagination,
pbmodal,
bankmodal
},
data() {
return {
showpermohonan: {},
currentPage: 1,
paginate: {},
cawangan: {},
username: this.$username,
userroles: this.$userroles,
loader: false
}
},
created() {
this.getSenaraiMohon(this.currentPage)
this.axios.get('/api/check/cawangan').then(response => {
this.cawangan = response.data;
});
},
methods: {
getSenaraiMohon(pageNumber) {
this.axios.get(this.$hostname + '/admin/permohonan/get/admin', {
params: {
page: pageNumber
}
}).then(response => {
this.showpermohonan = response.data
this.paginate = response.data
this.currentPage = pageNumber
this.loader = true;
});
},
namacawangan(cawangannama) {
let namcaw = '';
if (this.cawangan.length > 0) {
this.cawangan.some(function (value, key) {
if (cawangannama === value.kodcaw) {
namcaw = value.details_caw
}
});
}
return namcaw;
},
formatterfunction(value) {
return formatter.format(value)
},
checkjenismohon(value) {
if (value === 'permohonanwang') {
return 'Permohonan Wang'
} else {
return 'Bayaran Balik'
}
},
async funcbatal(mohonid) {
let refer = this;
const {
value: katalaluan
} = await this.$swal({
title: 'Masukkan Katalaluan Semula',
input: 'password',
inputPlaceholder: 'Katalaluan',
confirmButtonText: 'Hantar',
showCancelButton: true,
cancelButtonText: 'Batal',
allowOutsideClick: false
})
if (katalaluan !== undefined)
await this.axios.get('/mintasemulakelulusan', {
params: {
passsemula: katalaluan
}
}).then(response => {
if (response.data === 1) {
if (this.userroles === "operasi") {
this.axios.put(this.$hostname + '/admin/permohonan/updateoperasi', {
kelulusan: "Batal",
mohonid: mohonid,
namaoperasi: this.username
}).then(response => {
if (response.data === 1) {
this.$swal({
icon: 'success',
title: 'Berjaya',
text: 'Berjaya mengemaskini maklumat pelanggan',
allowOutsideClick: false
}).then(function () {
refer.getSenaraiMohon(refer.currentPage);
});
} else {
this.$swal({
icon: 'warning',
title: 'Tidak Berjaya',
text: 'Data pelanggan tidak berjaya dikemaskini',
allowOutsideClick: false
}).then(function () {
refer.getSenaraiMohon(refer.currentPage);
});
}
});
} else if (this.userroles === "akaun") {
this.axios.put(this.$hostname + '/admin/permohonan/updateakaun', {
kelulusan: "Batal",
mohonid: mohonid,
namaakaun: this.username
}).then(response => {
if (response.data === 1) {
this.$swal({
icon: 'success',
title: 'Berjaya',
text: 'Berjaya mengemaskini maklumat pelanggan',
allowOutsideClick: false
}).then(function () {
refer.getSenaraiMohon(refer.currentPage);
});
} else {
this.$swal({
icon: 'warning',
title: 'Tidak Berjaya',
text: 'Data pelanggan tidak berjaya dikemaskini',
allowOutsideClick: false
}).then(function () {
refer.getSenaraiMohon(refer.currentPage);
});
}
});
} else {
}
} else {
this.$swal({
icon: 'warning',
title: 'Tidak Berjaya',
text: 'Kata Laluan Yang Dimasukkan Salah!!',
allowOutsideClick: false
}).then(function () {
refer.getSenaraiMohon(refer.currentPage);
});
}
});
},
async funcsetuju(mohonid) {
let refer = this;
const {
value: katalaluan
} = await this.$swal({
title: 'Masukkan Katalaluan Semula',
input: 'password',
inputPlaceholder: 'Katalaluan',
confirmButtonText: 'Hantar',
showCancelButton: true,
cancelButtonText: 'Batal',
allowOutsideClick: false
})
if (katalaluan !== undefined)
await this.axios.get('/mintasemulakelulusan', {
params: {
passsemula: katalaluan
}
}).then(response => {
if (response.data === 1) {
if (this.userroles === "operasi") {
this.axios.put(this.$hostname + '/admin/permohonan/updateoperasi', {
kelulusan: 'Lulus',
mohonid: mohonid,
namaoperasi: this.username
}).then(response => {
if (response.data === 1) {
this.$swal({
icon: 'success',
title: 'Berjaya',
text: 'Berjaya mengemaskini maklumat pelanggan',
allowOutsideClick: false
}).then(function () {
refer.getSenaraiMohon(refer.currentPage);
});
} else {
this.$swal({
icon: 'warning',
title: 'Tidak Berjaya',
text: 'Data pelanggan tidak berjaya dikemaskini',
allowOutsideClick: false
}).then(function () {
refer.getSenaraiMohon(refer.currentPage);
});
}
});
} else if (this.userroles === 'akaun') {
this.axios.put(this.$hostname + '/admin/permohonan/updateakaun', {
kelulusan: 'Lulus',
mohonid: mohonid,
namaakaun: this.username
}).then(response => {
if (response.data === 1) {
this.$swal({
icon: 'success',
title: 'Berjaya',
text: 'Berjaya mengemaskini maklumat pelanggan',
allowOutsideClick: false
}).then(function () {
refer.getSenaraiMohon(refer.currentPage);
});
} else {
this.$swal({
icon: 'warning',
title: 'Tidak Berjaya',
text: 'Data pelanggan tidak berjaya dikemaskini',
allowOutsideClick: false
}).then(function () {
refer.getSenaraiMohon(refer.currentPage);
});
}
});
} else {
}
} else {
this.$swal({
icon: 'warning',
title: 'Tidak Berjaya',
text: 'Kata Laluan Yang Dimasukkan Salah!!',
allowOutsideClick: false
}).then(function () {
getSenaraiMohon(this.currentPage);
});
}
});
},
CetakanPB: function (caw, mid) {
let refer = this;
this.axios.put(this.$hostname + '/admin/permohonan/updatecetak', {
mohonid: mid,
namaprint: this.username
}).then(response => {
if (response.data === 1) {
this.$swal({
icon: 'success',
title: 'Berjaya',
text: 'Cetakan Berjaya Dijana!',
allowOutsideClick: false
}).then(function () {
refer.getSenaraiMohon(refer.currentPage);
});
} else {
this.$swal({
icon: 'warning',
title: 'Tidak Berjaya',
text: 'Cetakan Tidak Berjaya!',
allowOutsideClick: false
}).then(function () {
refer.getSenaraiMohon(refer.currentPage);
});
}
});
let route = window.route('permohonan.cetakanpb', {
_query: {
cawangan: caw,
mohonid: mid
},
});
window.open(route, '_blank')
},
KelulusanPB: function (mid, mohon) {
this.$refs.modal.mohonid = mid;
this.$refs.modal.amaun_dimohon = mohon;
this.$refs.modal.showModal = true;
},
DepositBank: function (mid) {
this.$refs.bankmodal.mohonid = mid;
this.$refs.bankmodal.showModal = true;
}
}
}
</script>