update daftar senhitam

This commit is contained in:
Nur Izzati
2026-06-05 22:57:05 +08:00
parent 52794fb4fd
commit 79b9a8a450
+58 -35
View File
@@ -115,12 +115,19 @@ export default {
},
methods: {
toggleModal: function(){
this.showModal = !this.showModal;
this.arrayCustomer = [];
this.specCust = [];
this.showModal = !this.showModal;
this.arrayCustomer = [];
this.specCust = {};
this.nota = '';
if(this.$refs.btnDropdownRef){
this.$refs.btnDropdownRef.value = '';
}
},
async toggleDropdown() {
this.specCust = {};
await this.getData()
if(this.arrayCustomer.length > 0)
@@ -137,42 +144,52 @@ export default {
}
},
getData: function() {
async getData() {
let inputvalue = document.getElementById("frminput").value;
if(inputvalue)
if(!inputvalue)
{
if(this.hasNumber(inputvalue))
{
this.axios.get(this.$api1 + '/admin/searchByIC', {
params: {
ic: inputvalue,
kodcaw: this.$kodcaw
}
}).then(response => {
this.arrayCustomer = response.data
this.arrayCustomer = [];
return;
}
}).catch(error => {
console.log(error)
})
try {
let response;
}else{
this.axios.get(this.$api1 + '/admin/searchByName', {
params: {
nama: inputvalue,
kodcaw: this.$kodcaw
if (this.hasNumber(inputvalue)) {
response = await this.axios.get(
this.$api1 + '/admin/searchByIC',
{
params: {
ic: inputvalue,
kodcaw: this.$kodcaw
}
}
);
} else {
response = await this.axios.get(
this.$api1 + '/admin/searchByName',
{
params: {
nama: inputvalue,
kodcaw: this.$kodcaw
}
}
);
}
}).then(response => {
this.arrayCustomer = response.data
}).catch(error => {
console.log(error)
})
}
this.arrayCustomer = response.data || [];
} catch (error) {
console.log(error);
this.arrayCustomer = [];
}
},
@@ -221,6 +238,13 @@ export default {
},
kemaskinifunc: function(){
if (!this.specCust || !this.specCust.id) {
this.$toast.error(
"Sila pilih pelanggan daripada senarai carian terlebih dahulu."
);
return;
}
axios.post(this.$hostname + '/admin/AddSenaraiHitam',
{
kodcaw: this.$kodcaw,
@@ -229,19 +253,18 @@ export default {
}).then(response => {
if(response.data == 'berjaya')
if(response.data && response.data.id)
{
this.showModal = false;
this.$toast.success("Kemaskini Sudah Berjaya!")
this.$toast.success("Kemaskini Sudah Berjaya!");
// vm.$forceUpdate();
this.$emit('clickEvent_', this.pageNumber)
this.$emit('clickEvent_', this.pageNumber);
// setTimeout("window.location.reload()", 3000);
}else{
this.showModal = false;
this.$toast.error("Kemaskini tidak berjaya")
this.$toast.error("Kemaskini tidak berjaya");
}
});