This commit is contained in:
ArifHilmi 2025-03-10 22:28:56 +08:00
commit bf6e53b56e
2 changed files with 48 additions and 14 deletions

View File

@ -145,7 +145,7 @@
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
<div style="text-align: center; margin: 20px 0; padding: 20px;">
<div v-if="itemlateststatus == 'On Delivery' && this.itemassignedtouser">
<div v-if="itemlateststatus == 'On Delivery' && this.thisItem.toUser == this.currentUser.id">
<h2 class="register-heading">Item is on Delivery</h2>
<div class="col-sm-3"></div>
<div class="col-sm-6 offset-sm-3">
@ -169,6 +169,23 @@
</div>
</div>
<div v-if="itemlateststatus == 'On Delivery' && thisItem.lastStore == currentUser.store">
<h2 class="register-heading">Receive Item</h2>
<div class="col-sm-3"></div>
<div class="col-sm-6 offset-sm-3">
<form v-on:submit.prevent="receiveItemMovement" data-aos="fade-right">
<div class="row register-form">
<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;">
Receive Item
</button>
</div>
</div>
</form>
</div>
</div>
<div v-if="(itemlateststatus == 'Repair' || itemlateststatus == 'Calibration') && this.itemassignedtouser">
<h2 class="register-heading">Receive Repair / Calibration</h2>
<div class="col-sm-3"></div>
@ -226,7 +243,7 @@
@* </div> *@
@* </div> *@
<div v-if="itemlateststatus == 'Faulty'">
<div v-if="itemlateststatus == 'Faulty' && this.itemassignedtouser">
<h2 class="register-heading">Add Item Movement</h2>
<div class="col-sm-3"></div>
<div class="col-sm-6 offset-sm-3">
@ -240,7 +257,7 @@
</div>
</div>
<div v-if="itemlateststatus == 'Ready To Deploy'">
<div v-if="itemlateststatus == 'Ready To Deploy' && this.itemassignedtouser">
<h2 class="register-heading">Add Item Movement</h2>
<div class="col-sm-3"></div>
<div class="col-sm-6 offset-sm-3">
@ -730,8 +747,9 @@
})
.then(() => { console.log("📷 Applied Constraintsss:", track.getSettings());
}).catch(err =>
// console.error("❌ Failed to apply constraints:", err)
})
.catch(err =>
console.error("❌ Failed to apply constraints:", err)
);
} else {
@ -812,9 +830,9 @@
...(this.selectedAction === 'user' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedUser, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}),
...(this.selectedAction === 'station' ? { toStore: this.currentUser.store, 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' ? { toStore: this.currentUser.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' ? { toStore: this.currentUser.store, 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' ? { toStore: this.currentUser.store, 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 === 'store' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastStore: this.selectedStore, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}),
...(this.selectedAction === 'supplier' ? { toStore: this.currentUser.store, 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, lastStore: this.currentUser.store, MovementComplete: false, } : {}),
...(this.selectedAction === 'faulty' ? { toStore: this.currentUser.store, toUser: this.currentUser.id,toOther: 'Faulty', SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), Remark: this.remark, ConsignmentNote: this.document, MovementComplete: true, } : {}),
ItemId: this.thisItem.itemID,
Action: 'Stock Out',
@ -863,19 +881,23 @@
this.serialNumber = "";
}
if(this.thisItem.toOther === "On Delivery"){
if(this.thisItem.toOther === "On Delivery" && this.thisItem.toUser == this.currentUser.id){
if(!window.confirm("Are you sure you want to cancel item delivery?")){
return;
}
}
const now = new Date();
console.log('currentuser'+this.currentUser.id);
console.log('lastuser'+this.thisItem.lastuser);
const formData = {
Id: this.thisItem.movementId,
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" : ""
Remark: this.thisItem.toOther === "On Delivery" && this.thisItem.toUser == this.currentUser.id ? this.thisItem.remark + ". Inventory Master cancelled delivery with remark: " + this.remark : this.thisItem.remark,
LastUser: this.thisItem.lastuser == null ? this.currentUser.id : this.thisItem.lastuser,
LatestStatus: this.thisItem.toOther === "Return" ? "Faulty" : (this.thisItem.toOther === "Calibration" || this.thisItem.toOther === "Repair" || this.thisItem.toOther === "On Delivery" ) ? "Ready To Deploy" : (this.itemlateststatus == 'On Delivery' && this.thisItem.lastStore == this.currentUser.store ? "Delivered" : "")
};
@ -923,9 +945,19 @@
// this.thisItem = await response.json();
this.thisItem = await response.json();
console.log('last store'+this.thisItem.lastStore);
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 ) && this.thisItem.lastStore === this.currentUser.store ? true : false;
// console.log(this.thisItem);
// console.log(this.itemassignedtouser);
console.log(this.thisItem.lastStore);
console.log( this.thisItem.lastStore == this.currentUser.store? true : false);
console.log(this.thisItem.toUser == this.currentUser.id? true : false);
console.log( this.thisItem.lastUser == this.currentUser.id ? true : false);
console.log(((this.thisItem.toUser == this.currentUser.id) || ( this.thisItem.lastUser == this.currentUser.id)) ? true : false);
console.log('currentuser store'+this.currentUser.store);
} else {
console.error('Failed to fetch item information');

View File

@ -538,6 +538,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
item.Movement?.ToOther,
item.Movement?.LatestStatus,
item.Movement?.LastUser,
item.Movement?.LastStore,
item.Movement?.MovementComplete,
remark = item.Movement?.Remark,
QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.UniqueID}" // Generate QR String
@ -736,6 +737,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
return NotFound("Item movement record not found.");
}
updatedList.LastUser = receiveMovement.LastUser;
updatedList.LatestStatus = receiveMovement.LatestStatus;
updatedList.receiveDate = receiveMovement.receiveDate;
updatedList.Remark = receiveMovement.Remark;
@ -1304,7 +1306,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
{
return NotFound("Item movement record not found.");
}
updatedList.MovementComplete = receiveMovement.MovementComplete;
updatedList.LatestStatus = receiveMovement.LatestStatus;
updatedList.receiveDate = receiveMovement.receiveDate;
updatedList.MovementComplete = receiveMovement.MovementComplete;