update item movement master

This commit is contained in:
ameerulrasyid 2025-03-04 14:37:23 +08:00
parent 4afac02583
commit 26aaff2d2b
4 changed files with 186 additions and 143 deletions

View File

@ -42,6 +42,11 @@
<h2>Pending Item Movement</h2> <h2>Pending Item Movement</h2>
</div> </div>
<div class="card-body"> <div class="card-body">
<div v-if="loading">
<div class="spinner-border text-info" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
<table class="table table-bordered table-hover table-striped no-wrap" id="itemMovementNotCompleteDatatable" style="width:100%;border-style: solid; border-width: 1px"></table> <table class="table table-bordered table-hover table-striped no-wrap" id="itemMovementNotCompleteDatatable" style="width:100%;border-style: solid; border-width: 1px"></table>
</div> </div>
</div> </div>
@ -51,12 +56,22 @@
<h2>Complete Item Movement</h2> <h2>Complete Item Movement</h2>
</div> </div>
<div class="card-body"> <div class="card-body">
<div v-if="loading">
<div class="spinner-border text-info" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
<table class="table table-bordered table-hover table-striped no-wrap" id="itemMovementCompleteDatatable" style="width:100%;border-style: solid; border-width: 1px"></table> <table class="table table-bordered table-hover table-striped no-wrap" id="itemMovementCompleteDatatable" style="width:100%;border-style: solid; border-width: 1px"></table>
</div> </div>
</div> </div>
</div> </div>
<div v-if="sortBy === 'logs'"> <div v-if="sortBy === 'logs'">
<div v-if="loading">
<div class="spinner-border text-info" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
<div class="row card"> <div class="row card">
<div class="card-header"> <div class="card-header">
<h2>Item Movement List</h2> <h2>Item Movement List</h2>
@ -68,6 +83,11 @@
</div> </div>
<div v-if="sortBy === 'item'"> <div v-if="sortBy === 'item'">
<div v-if="loading">
<div class="spinner-border text-info" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
<div v-for="(group, itemId) in filteredItems" :key="itemId" class="row card"> <div v-for="(group, itemId) in filteredItems" :key="itemId" class="row card">
<div class="card-header d-flex justify-content-between align-items-center"> <div class="card-header d-flex justify-content-between align-items-center">
<h2>Item : {{ group.uniqueID }}</h2> <h2>Item : {{ group.uniqueID }}</h2>
@ -432,6 +452,8 @@
initiateTable() { initiateTable() {
this.loading = true;
self = this; self = this;
this.itemDatatable = $('#itemDatatable').DataTable({ this.itemDatatable = $('#itemDatatable').DataTable({
"data": this.items, "data": this.items,
@ -518,33 +540,34 @@
self.deleteItem(itemId); self.deleteItem(itemId);
}); });
$('#itemDatatable tbody').on('click', '.print-btn', function () { // $('#itemDatatable tbody').on('click', '.print-btn', function () {
const $button = $(this); // The clicked button // const $button = $(this); The clicked button
const $row = $button.closest('tr'); // The parent row of the button // const $row = $button.closest('tr'); The parent row of the button
const itemId = $button.data('id'); // Get the item ID from the button's data attribute // const itemId = $button.data('id'); Get the item ID from the button's data attribute
let imageSrc; // let imageSrc;
// Check if the table is collapsed // Check if the table is collapsed
if ($row.hasClass('child')) { // if ($row.hasClass('child')) {
// For collapsed view: Look for the closest `.dtr-data` that contains the img // For collapsed view: Look for the closest `.dtr-data` that contains the img
imageSrc = $row.prev('tr').find('td:nth-child(1) img').attr('src'); // imageSrc = $row.prev('tr').find('td:nth-child(1) img').attr('src');
} else { // } else {
// For expanded view: Find the img in the first column of the current row // For expanded view: Find the img in the first column of the current row
imageSrc = $row.find('td:nth-child(1) img').attr('src'); // imageSrc = $row.find('td:nth-child(1) img').attr('src');
} // }
if (imageSrc) { // if (imageSrc) {
self.printItem(itemId, imageSrc); // Call the print function with the itemId and imageSrc // self.printItem(itemId, imageSrc); Call the print function with the itemId and imageSrc
} else { // } else {
console.error("Image source not found."); // console.error("Image source not found.");
} // }
}); // });
this.loading = false; this.loading = false;
}, },
async fetchItem() { async fetchItem() {
this.loading = true;
await this.fetchUser(); await this.fetchUser();
try { try {
// const token = localStorage.getItem('token'); // Get the token from localStorage // const token = localStorage.getItem('token'); // Get the token from localStorage
@ -561,6 +584,8 @@
} }
if(this.currentRole == "Super Admin"){ if(this.currentRole == "Super Admin"){
this.items = await response.json(); this.items = await response.json();
} else { } else {
const data = await response.json(); const data = await response.json();
this.items = data.filter(item => this.items = data.filter(item =>
@ -586,15 +611,10 @@
catch (error) { catch (error) {
console.error('Error fetching item:', error); console.error('Error fetching item:', error);
} }
this.loading = false;
}, },
// FRONT END FUNCTIONS // FRONT END FUNCTIONS
//----------------------// //----------------------//
//Calculate Total Price //Calculate Total Price
@ -706,6 +726,7 @@
if (roles.includes("SuperAdmin")) { if (roles.includes("SuperAdmin")) {
this.currentRole = "Super Admin"; this.currentRole = "Super Admin";
this.sortBy = 'logs';
} else if (roles.includes("Inventory Master")) { } else if (roles.includes("Inventory Master")) {
this.currentRole = "Inventory Master"; this.currentRole = "Inventory Master";
this.sortBy = "item"; this.sortBy = "item";

View File

@ -36,6 +36,7 @@
<div id="registerItemMovement" v-if="!thisItem" data-aos="fade-right"> <div id="registerItemMovement" v-if="!thisItem" data-aos="fade-right">
<p style="text-align:center; padding:10px;">Scan QR Code Here:</p> <p style="text-align:center; padding:10px;">Scan QR Code Here:</p>
<qrcode-stream :constraints="selectedConstraints" <qrcode-stream :constraints="selectedConstraints"
:formats="['qr_code']" :formats="['qr_code']"
:track="trackFunctionSelected.value" :track="trackFunctionSelected.value"
@ -44,9 +45,13 @@
v-on:error="onError"> v-on:error="onError">
</qrcode-stream> </qrcode-stream>
<!-- Debugging: Show Processed Video -->
<canvas ref="sharpenedCanvas" style="display:none;"></canvas>
<video ref="preview" autoplay style="width: 100%;"></video>
<p class="error">{{ error }}</p> <p class="error">{{ error }}</p>
</div> </div>
<p v-if="scanTime">Scan Time: {{ scanTime }} ms</p>
<div v-if="thisItem" style="display: flex; justify-content: center; align-items: center;"> <div v-if="thisItem" style="display: flex; justify-content: center; align-items: center;">
<div class="col-lg-7 col-11 border rounded p-3 shadow-sm"> <div class="col-lg-7 col-11 border rounded p-3 shadow-sm">
@ -150,6 +155,13 @@
<form v-on:submit.prevent="receiveItemMovement" data-aos="fade-right"> <form v-on:submit.prevent="receiveItemMovement" data-aos="fade-right">
<div class="row register-form"> <div class="row register-form">
<div class="form-group row">
<label class="col-sm-4 col-form-label">Remark:</label>
<div class="col-sm-8">
<input type="text" id="remark" name="remark" v-model="remark" class="form-control" required />
</div>
</div>
<div style="display: flex; justify-content: center; margin-top: 20px;"> <div style="display: flex; justify-content: center; margin-top: 20px;">
<button type="submit" class="btn btn-primary" style="width: 200px; padding: 10px; font-size: 16px;"> <button type="submit" class="btn btn-primary" style="width: 200px; padding: 10px; font-size: 16px;">
Cancel Item Movement Cancel Item Movement
@ -324,7 +336,7 @@
<label class="col-sm-4 col-form-label">To Station:</label> <label class="col-sm-4 col-form-label">To Station:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<div class="dropdown"> <div class="dropdown">
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedStation" v-on:change="handleSelection" required style="width: 100%;"> <select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedStation" required style="width: 100%;">
<option class="btn-light" value="" disabled selected>Select Station</option> <option class="btn-light" value="" disabled selected>Select Station</option>
<option class="btn-light" v-for="(station, index) in stationlist" :key="index" :value="station.stationId">{{station.stationName}}</option> <option class="btn-light" v-for="(station, index) in stationlist" :key="index" :value="station.stationId">{{station.stationName}}</option>
</select> </select>
@ -339,7 +351,7 @@
<label class="col-sm-4 col-form-label">To PIC:</label> <label class="col-sm-4 col-form-label">To PIC:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<div class="dropdown"> <div class="dropdown">
<input type="text" id="selectedStationPIC" name="selectedStationPIC" v-model="selectedStationPIC" class="form-control" readonly /> <input type="text" id="selectedStationPIC" name="selectedStationPIC" :value="selectedStationPicName" class="form-control" readonly />
</div> </div>
</div> </div>
</div> </div>
@ -584,7 +596,7 @@
supplierlist: null, supplierlist: null,
selectedUser: "", selectedUser: "",
selectedStation: "", selectedStation: "",
selectedStationPIC: "", selectedStationPIC: null,
selectedStore: "", selectedStore: "",
selectedAction: "", selectedAction: "",
assigndate: null, assigndate: null,
@ -626,6 +638,8 @@
], ],
videoInputDevices: [], videoInputDevices: [],
selectedCameraId: null, selectedCameraId: null,
scanStartTime: null,
scanTime: null
} }
}, },
mounted() { mounted() {
@ -638,15 +652,19 @@
}, },
watch: { watch: {
selectedStation(newStationId) { selectedStation(newStationId) {
console.log(newStationId);
console.log(this.selectedStation);
// Find the station object that matches the selectedStation id // Find the station object that matches the selectedStation id
const selectedStationObj = this.stationlist.find(station => station.stationId === newStationId); const selectedStationObj = this.stationlist.find(station => station.stationId === newStationId);
// Set the selectedPIC based on the stationPIC // Set the selectedPIC based on the stationPIC
this.selectedStationPIC = selectedStationObj ? selectedStationObj.stationPicID : ""; this.selectedStationPIC = selectedStationObj ? selectedStationObj.stationPicID : "";
// this.selectedStationPIC = selectedStationObj ? selectedStationObj : null;
} }
}, },
computed: { computed: {
selectedStationPicName() {
const selectedStationObj = this.stationlist.find(station => station.stationId === this.selectedStation);
return selectedStationObj ? selectedStationObj.stationPic.fullName : "";
},
filteredDepartments() { filteredDepartments() {
if (!this.selectedCompany) { if (!this.selectedCompany) {
return []; // No company selected, return empty list return []; // No company selected, return empty list
@ -667,17 +685,11 @@
}, },
}, },
methods: { methods: {
// handleSelection(event) {
// console.log("Event Target Value:", event.target.value); Debugging
// const selectedstationid = event.target.value;
// console.log(this.stationlist);
// const selectedStationObj = this.stationlist.find(station => station.stationId == selectedstationid);
// Set the selectedPIC based on the stationPIC
// this.selectedStationPIC = selectedStationObj ? selectedStationObj.stationPicID : "";
// },
// Split Url dapatkan unique ID Je // Split Url dapatkan unique ID Je
onDecode(detectedCodes) { onDecode(detectedCodes) {
// const endTime = performance.now();
// this.scanTime = Math.round(endTime - this.scanStartTime); Calculate scan time
if (detectedCodes.length > 0) { if (detectedCodes.length > 0) {
this.qrCodeResult = detectedCodes[0].rawValue; // Ambil URL dari rawValue this.qrCodeResult = detectedCodes[0].rawValue; // Ambil URL dari rawValue
this.UniqueID = this.qrCodeResult.split('/').pop(); // Ambil UniqueID dari URL this.UniqueID = this.qrCodeResult.split('/').pop(); // Ambil UniqueID dari URL
@ -702,6 +714,9 @@
//Setting Camera //Setting Camera
async onCameraReady() { async onCameraReady() {
// this.scanStartTime = performance.now(); Start timing
// this.scanTime = null; Reset previous scan time
try { try {
const devices = await navigator.mediaDevices.enumerateDevices(); const devices = await navigator.mediaDevices.enumerateDevices();
this.videoInputDevices = devices.filter(device => device.kind === 'videoinput'); this.videoInputDevices = devices.filter(device => device.kind === 'videoinput');
@ -771,7 +786,7 @@
const formData = { const formData = {
...(this.selectedAction === 'user' ? { toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedUser, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}), ...(this.selectedAction === 'user' ? { toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedUser, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}),
...(this.selectedAction === 'station' ? { toStation: this.selectedStation, toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedUser, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}), ...(this.selectedAction === 'station' ? { toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastStation: this.selectedStation, lastUser: this.selectedStationPIC, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}),
...(this.selectedAction === 'store' ? { toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedStore, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}), ...(this.selectedAction === 'store' ? { toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedStore, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}),
...(this.selectedAction === 'supplier' ? { toUser: this.currentUser.id, toOther: this.selectedOther, SendDate: this.assigndate, Remark: this.remark + '. Item sent to ' + this.selectedSupplier + ' for ' + this.selectedOther, ConsignmentNote: this.document, lastUser: this.currentUser.id, MovementComplete: false, } : {}), ...(this.selectedAction === 'supplier' ? { toUser: this.currentUser.id, toOther: this.selectedOther, SendDate: this.assigndate, Remark: this.remark + '. Item sent to ' + this.selectedSupplier + ' for ' + this.selectedOther, ConsignmentNote: this.document, lastUser: this.currentUser.id, MovementComplete: false, } : {}),
...(this.selectedAction === 'faulty' ? { toUser: this.currentUser.id,toOther: 'Faulty', Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), Remark: this.remark, ConsignmentNote: this.document, MovementComplete: true, } : {}), ...(this.selectedAction === 'faulty' ? { toUser: this.currentUser.id,toOther: 'Faulty', Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), Remark: this.remark, ConsignmentNote: this.document, MovementComplete: true, } : {}),
@ -834,6 +849,7 @@
Id: this.thisItem.movementId, Id: this.thisItem.movementId,
ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
Remark: this.thisItem.toOther === "On Delivery" ? this.thisItem.remark + ". Inventory Master cancelled delivery with remark: " + this.remark : this.thisItem.remark,
LatestStatus: this.thisItem.toOther === "Return" ? "Faulty" : (this.thisItem.toOther === "Calibration" || this.thisItem.toOther === "Repair" || this.thisItem.toOther === "On Delivery" ) ? "Ready To Deploy" : "" LatestStatus: this.thisItem.toOther === "Return" ? "Faulty" : (this.thisItem.toOther === "Calibration" || this.thisItem.toOther === "Repair" || this.thisItem.toOther === "On Delivery" ) ? "Ready To Deploy" : ""
}; };
@ -884,6 +900,7 @@
this.thisItem = await response.json(); this.thisItem = await response.json();
this.itemlateststatus = this.thisItem.latestStatus ? this.thisItem.latestStatus : this.thisItem.toOther; this.itemlateststatus = this.thisItem.latestStatus ? this.thisItem.latestStatus : this.thisItem.toOther;
this.itemassignedtouser = this.thisItem.toUser == this.currentUser.id || this.thisItem.lastUser == this.currentUser.id ? true : false; this.itemassignedtouser = this.thisItem.toUser == this.currentUser.id || this.thisItem.lastUser == this.currentUser.id ? true : false;
console.log(this.thisItem);
// if ((this.thisItem.toOther === "Repair" || this.thisItem.toOther === "Calibration" || this.thisItem.toOther === "Return" ) && this.thisItem.lastUser === this.currentUser.id && this.thisItem.movementComplete === false) { // if ((this.thisItem.toOther === "Repair" || this.thisItem.toOther === "Calibration" || this.thisItem.toOther === "Return" ) && this.thisItem.lastUser === this.currentUser.id && this.thisItem.movementComplete === false) {
@ -927,6 +944,8 @@
this.assigndate = ""; this.assigndate = "";
this.selectedStore = ""; this.selectedStore = "";
this.selectedOther = ""; this.selectedOther = "";
this.selectedStation = "";
this.selectedStationPIC = "";

View File

@ -538,6 +538,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
item.Movement?.LatestStatus, item.Movement?.LatestStatus,
item.Movement?.LastUser, item.Movement?.LastUser,
item.Movement?.MovementComplete, item.Movement?.MovementComplete,
remark = item.Movement?.Remark,
QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.UniqueID}" // Generate QR String QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.UniqueID}" // Generate QR String
}; };
return Json(singleItem); return Json(singleItem);
@ -753,6 +754,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
updatedList.LatestStatus = receiveMovement.LatestStatus; updatedList.LatestStatus = receiveMovement.LatestStatus;
updatedList.receiveDate = receiveMovement.receiveDate; updatedList.receiveDate = receiveMovement.receiveDate;
updatedList.Remark = receiveMovement.Remark;
updatedList.MovementComplete = true; updatedList.MovementComplete = true;
_centralDbContext.ItemMovements.Update(updatedList); _centralDbContext.ItemMovements.Update(updatedList);
@ -1121,7 +1123,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpPost("StationList")] [HttpPost("StationList")]
public async Task<IActionResult> StationList() public async Task<IActionResult> StationList()
{ {
var stationList = await _centralDbContext.Stations.ToListAsync(); var stationList = await _centralDbContext.Stations.Include(i => i.StationPic).ToListAsync();
return Json(stationList); return Json(stationList);
} }

View File

@ -453,8 +453,8 @@
<i class="mdi mdi-view-dashboard"></i><span class="hide-menu">Admin Dashboard</span> <i class="mdi mdi-view-dashboard"></i><span class="hide-menu">Admin Dashboard</span>
</a> </a>
</li> </li>
} } else
{
<li class="sidebar-item"> <li class="sidebar-item">
<a class="sidebar-link waves-effect waves-dark sidebar-link" <a class="sidebar-link waves-effect waves-dark sidebar-link"
asp-area="Inventory" asp-controller="ItemMovement" asp-action="UserDashboard" asp-area="Inventory" asp-controller="ItemMovement" asp-action="UserDashboard"
@ -462,6 +462,7 @@
<i class="mdi mdi-view-dashboard"></i><span class="hide-menu">User Dashboard</span> <i class="mdi mdi-view-dashboard"></i><span class="hide-menu">User Dashboard</span>
</a> </a>
</li> </li>
}
<li class="sidebar-item"> <li class="sidebar-item">
<a class="sidebar-link waves-effect waves-dark sidebar-link" <a class="sidebar-link waves-effect waves-dark sidebar-link"
asp-area="Inventory" asp-controller="InventoryMaster" asp-action="ProductRegistration" asp-area="Inventory" asp-controller="InventoryMaster" asp-action="ProductRegistration"