@@ -144,7 +239,7 @@
-
+
@@ -205,6 +300,8 @@
assign: "",
productName: null,
+ searchQuery: "",
+ dropdownOpen: false,
stations: [],
selectedProduct: "",
selectedStation: "",
@@ -236,8 +333,25 @@
return product ? product : {};
},
+ filteredProducts() {
+ return this.products.filter(item =>
+ item.productName.toLowerCase().includes(this.searchQuery.toLowerCase()) ||
+ item.modelNo.toLowerCase().includes(this.searchQuery.toLowerCase())
+ );
+ }
},
methods: {
+ closeDropdown() {
+ this.dropdownOpen = false; // Tutup dropdown
+ },
+
+ selectProduct(item) {
+ this.selectedProduct = item;
+ this.productId = item.productId;
+ this.searchQuery = item.productName + " (" + item.modelNo + ")";
+ this.dropdownOpen = false;
+ },
+
handleFileUpload(event) {
const file = event.target.files[0];
@@ -251,6 +365,7 @@
this.document = null;
}
},
+
async addRequest() {
try {
const requiredFields = ['productId', 'quantity', 'assign'];
@@ -308,11 +423,11 @@
});
if (response.ok) {
+ this.resetForm();
alert('Success!', 'Request form has been successfully submitted.', 'success');
const requestItem = await response.json();
this.request.push(requestItem);
this.fetchRequest();
- this.resetForm();
} else {
throw new Error('Failed to submit form.');
}
@@ -337,6 +452,15 @@
$(td).attr('id', `qr${cellData}`);
},
},
+ { "title": "Product Image",
+ "data": "productPicture",
+ "render": function (data, type, full, meta) {
+ var image = `
+
+ `;
+ return image;
+ },
+ },
{
"title": "Product Id",
"data": "productName",
@@ -432,6 +556,19 @@
$(td).attr('id', `qr${cellData}`);
},
},
+ {
+ "title": "Status",
+ "data": "status",
+ },
+ { "title": "Product Image",
+ "data": "productPicture",
+ "render": function (data, type, full, meta) {
+ var image = `
+
+ `;
+ return image;
+ },
+ },
{
"title": "Product Id",
"data": "productName",
@@ -494,10 +631,6 @@
{
"title": "Approval Date",
"data": "approvalDate",
- },
- {
- "title": "Status",
- "data": "status",
}
],
@@ -605,6 +738,7 @@
},
resetForm() {
+ this.searchQuery = "";
this.stationId = "";
this.productId = "";
this.remark = "";
@@ -660,6 +794,22 @@
},
},
+ directives: {
+ clickOutside: {
+ beforeMount(el, binding) {
+ el.clickOutsideEvent = (event) => {
+ if (!(el.contains(event.target))) {
+ binding.value?.(); // Guna optional chaining untuk elak error
+ }
+ };
+ document.body.addEventListener("click", el.clickOutsideEvent);
+ },
+ unmounted(el) {
+ document.body.removeEventListener("click", el.clickOutsideEvent);
+ }
+ }
+ }
+
});
}
\ No newline at end of file
diff --git a/Controllers/API/Inventory/InvMainAPI.cs b/Controllers/API/Inventory/InvMainAPI.cs
index 50fb2b6..eb6ae9a 100644
--- a/Controllers/API/Inventory/InvMainAPI.cs
+++ b/Controllers/API/Inventory/InvMainAPI.cs
@@ -945,6 +945,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
i.requestID,
i.ProductId,
productName = i.Product?.ProductName,
+ productPicture = i.Product?.ImageProduct,
i.UserId,
i.status,
i.StationId,
@@ -962,13 +963,20 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpDelete("DeleteRequest/{requestId}")]
public async Task
DeleteRequest(int requestId)
{
- var request = await _centralDbContext.Requests.FindAsync(requestId);
- if (request == null)
+ var requestApprove = _centralDbContext.Requests.FirstOrDefault(r => r.requestID == requestId && r.approvalDate != null);
+ var requestDelete = _centralDbContext.Requests.FirstOrDefault(r => r.requestID == requestId);
+
+ if (requestApprove != null)
+ {
+ return NotFound(new { success = false, message = "Request not found Or Admin Already Approve or Reject" });
+ }
+
+ if (requestDelete == null)
{
return NotFound(new { success = false, message = "Request not found" });
}
- _centralDbContext.Requests.Remove(request);
+ _centralDbContext.Requests.Remove(requestDelete);
await _centralDbContext.SaveChangesAsync();
return Ok(new { success = true, message = "Request deleted successfully" });