This commit is contained in:
ArifHilmi 2025-02-27 16:32:42 +08:00
commit 0ff7592b01
7 changed files with 345 additions and 202 deletions

View File

@ -19,18 +19,27 @@
@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartial.cshtml");
<div id="registerItem" class="row">
<div class="row card">
<div class="card-header">
<div v-if="thisItem" class="card-header">
<button v-on:click="resetScanner" class="btn btn-secondary">
<i class="fas fa-arrow-left"></i> Back to Scanner
</button>
</div>
<div class="card-body">
<div data-aos="fade-right"></div>
<div id="app" data-aos="fade-right">
<div v-if="thisItem == null">
<h1 data-aos="fade-right">QR & Barcode Scanner</h1>
<div id="reader" data-aos="fade-right"></div>
</div>
<div v-if="thisItem" id="qrCodeResult" style="text-align: center; margin: 20px 0; padding: 20px;">
<h2>Scan Result:</h2>
</div>
</div>
<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">
<!-- Item Name -->
@ -107,33 +116,131 @@
</div>
</div>
<div class=" register" data-aos="fade-right">
<div v-if="thisItem" class=" register" data-aos="fade-right">
<div class="row" data-aos="fade-right">
<form v-on:submit.prevent="addItemMovement" data-aos="fade-right">
@*Right Side*@
<div class="col-md-12">
<div class="tab-content" id="myTabContent">
<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;">
<h2 class="register-heading">Add Item Movement</h2>
<div v-if="itemlateststatus == 'On Delivery' && this.itemassignedtouser">
<h2 class="register-heading">Item is on Delivery</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;">
Cancel Item Movement
</button>
</div>
</div>
</form>
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label"></label>
<div class="col-sm-6">
<div v-if="(itemlateststatus == 'Repair' || itemlateststatus == 'Calibration') && this.itemassignedtouser">
<h2 class="register-heading">Receive Repair / Calibration</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
</button>
</div>
</div>
</form>
</div>
</div>
<div v-if="itemlateststatus == 'Delivered'">
<h2 class="register-heading">Item has been Delivered</h2>
<div class="col-sm-3"></div>
<div class="col-sm-6 offset-sm-3">
</div>
</div>
<div v-if="itemlateststatus == 'Return' && this.itemassignedtouser">
<h2 class="register-heading">Receive Item Return</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
</button>
</div>
</div>
</form>
</div>
</div>
@* <div v-if=""> *@
@* <h2 class="register-heading">Item is not assigned to user to make movement</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 *@
@* </button> *@
@* </div> *@
@* zx </div> *@
@* </fzxorm> *@
@* </div> zx*@
@* </div> *@
zx <div v-if="itemlateststatus == 'Faulty'">
<h2 class="register-heading">Add Item Movement</h2>
<div class="col-sm-3"></div>
<div class="col-sm-6 offset-sm-3">
<div class="dropdown">
<select class="btn btn-primary dropdown-toggle col-md-10 offset-sm-1" v-model="selectedAction" required>
<select class="btn btn-primary dropdown-toggle col-md-10 " v-model="selectedAction" required>
<option class="btn-light" value="" disabled selected>Select Action</option>
<option class="btn-light" value="user">Assign to User</option>
<option class="btn-light" value="store">Assign to Store</option>
<option class="btn-light" value="supplier">Assign to Supplier</option>
<option class="btn-light" value="faulty">Faulty</option>
<option class="btn-light" value="receive" hidden>Receive</option>
</select>
</div>
</div>
</div>
<div v-if="itemlateststatus == 'Ready To Deploy'">
<h2 class="register-heading">Add Item Movement</h2>
<div class="col-sm-3"></div>
<div class="col-sm-6 offset-sm-3">
<div class="dropdown">
<select class="btn btn-primary dropdown-toggle col-md-10 " v-model="selectedAction" required>
<option class="btn-light" value="" disabled selected>Select Action</option>
@* <option class="btn-light" value="user" v-if="itemlateststatus == 'Ready To Deploy'">Assign to User</option> *@
@* <option class="btn-light" value="store" v-if="itemlateststatus == 'Ready To Deploy'">Assign to Store</option> *@
@* <option class="btn-light" value="supplier" v-if="itemlateststatus != 'Delivered'">Assign to Supplier</option> *@
@* <option class="btn-light" value="faulty" v-if="itemlateststatus != 'Delivered'">Faulty</option> *@
<option class="btn-light" value="user" >Assign to User</option>
<option class="btn-light" value="store">Assign to Store</option>
<option class="btn-light" value="supplier">Assign to Supplier</option>
<option class="btn-light" value="faulty">Faulty</option>
</select>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label"></label>
</div>
<form v-on:submit.prevent="addItemMovement" data-aos="fade-right">
<div v-if="selectedAction === 'user'">
<div class="row register-form">
@ -145,7 +252,7 @@
<label class="col-sm-4 col-form-label">To User:</label>
<div class="col-sm-8">
<div class="dropdown">
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedUser" required>
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedUser" required style="width: 100%;">
<option class="btn-light" value="" disabled selected>Select User</option>
<option class="btn-light" v-for="(user, index) in userlist" :key="index" :value="user.id">{{user.fullName}}</option>
</select>
@ -183,7 +290,7 @@
<div class="form-group row">
<label class="col-sm-4 col-form-label">To Store:</label>
<div class="col-sm-8">
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedStore">
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedStore" style="width: 100%;">
<option class="btn-light" value="" disabled selected>Select Store</option>
<option class="btn-light" v-for="(store, index) in storelist" :key="index" :value="store.id">{{ store.storeName}}</option>
</select>
@ -222,7 +329,7 @@
<label class="col-sm-4 col-form-label">To Supplier:</label>
<div class="col-sm-8">
<div class="dropdown">
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedSupplier" required>
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedSupplier" required style="width: 100%;">
<option class="btn-light" value="" disabled selected>Select Supplier</option>
<option class="btn-light" v-for="(supplier, index) in supplierlist" :key="index" :value="supplier.supplierCompName">{{supplier.supplierCompName}}</option>
</select>
@ -234,7 +341,7 @@
<label class="col-sm-4 col-form-label">To Other:</label>
<div class="col-sm-8">
<div class="dropdown">
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedOther" required>
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedOther" required style="width: 100%;">
<option class="btn-light" value="" disabled selected>Select</option>
<option class="btn-light" value="Repair">Repair</option>
<option class="btn-light" value="Calibration">Calibration</option>
@ -302,30 +409,26 @@
</div>
</div>
</div>
</div>
</div>
</div>
</form>
<div v-if="selectedAction === 'receive'">
<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
</button>
</div>
</div>
</form>
</div>
</div>
</div>
@* <div v-if="selectedAction === 'receive'"> *@
@* <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 *@
@* </button> *@
@* </div> *@
@* </div> *@
@* </form> *@
@* </div> *@
</div>
</div>
</div>
</div>
</div>
@ -385,6 +488,7 @@
// company: "",
currentUser: null,
currentUserCompanyDept: null,
itemlateststatus: "",
}
},
mounted() {
@ -416,6 +520,11 @@
},
},
methods: {
resetScanner(){
this.thisItem = null;
this.resetForm();
this.startScanner();
},
handleFileUpload(event) {
const file = event.target.files[0];
@ -490,12 +599,18 @@
this.serialNumber = "";
}
if(this.thisItem.toOther === "On Delivery"){
if(!window.confirm("Are you sure you want to cancel item delivery?")){
return;
}
}
const now = new Date();
const formData = {
Id: this.thisItem.movementId,
ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
LatestStatus: this.thisItem.toOther === "Return" ? "Faulty" : (this.thisItem.toOther === "Calibration" || this.thisItem.toOther === "Repair" || this.thisItem.toOther === "On Delivery" ) ? "Ready To Deploy" : ""
};
@ -540,33 +655,52 @@
qrbox: 400
};
navigator.mediaDevices.getUserMedia({
video: {
width: { ideal: 1920 }, // Higher resolution
height: { ideal: 1080 },
}
})
// navigator.mediaDevices.getUserMedia({
// video: {
// width: { ideal: 1920 }, Higher resolution
// height: { ideal: 1080 },
// }
// })
.catch((err) => {
console.error("Error accessing camera:", err);
});
// .catch((err) => {
// console.error("Error accessing camera:", err);
// });
this.html5QrCodeScanner = new Html5QrcodeScanner(
"reader", config, false
);
// this.html5QrCodeScanner = new Html5QrcodeScanner(
// "reader", config, false
// );
this.html5QrCodeScanner.render(
(decodedText, decodedResult) => {
// this.html5QrCodeScanner.render(
// (decodedText, decodedResult) => {
// if (!this.debounceTimeout) {
// this.debounceTimeout = setTimeout(() => {
// this.qrCodeResult = decodedText;
// this.sendDataToBackend(decodedText);
// this.fetchItem(decodedText.split('/').pop());
// this.fetchItem('ARA00500008'); for testing only. clear
// this.debounceTimeout = null;
// }, this.debounceTime);
// }
// }
// );
navigator.mediaDevices.getUserMedia({ video: true })
.then(() => {
this.html5QrCodeScanner = new Html5QrcodeScanner("reader", config, false);
this.html5QrCodeScanner.render((decodedText) => {
if (!this.debounceTimeout) {
this.debounceTimeout = setTimeout(() => {
this.qrCodeResult = decodedText;
// this.sendDataToBackend(decodedText);
// this.UniqueID = decodedText.split('/').pop();
this.fetchItem(decodedText.split('/').pop());
this.debounceTimeout = null;
}, this.debounceTime);
}
}
);
});
})
.catch((err) => {
console.error("Error accessing camera:", err);
});
},
async fetchItem(itemid) {
try {
@ -577,12 +711,18 @@
// this.thisItem = await response.json();
this.thisItem = await response.json();
console.log(this.thisItem);
if (this.thisItem.toOther === "Return" && this.thisItem.lastUser == this.currentUserId) {
this.selectedAction = "receive";
}
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;
// if ((this.thisItem.toOther === "Repair" || this.thisItem.toOther === "Calibration" || this.thisItem.toOther === "Return" ) && this.thisItem.lastUser === this.currentUser.id && this.thisItem.movementComplete === false) {
// this.selectedAction = "receive";
// }
// if ((this.itemlateststatus === "Repair" || this.itemlateststatus === "Calibration" || this.itemlateststatus === "Return" ) && this.thisItem.lastUser === this.currentUser.id && this.thisItem.movementComplete === false) {
// this.selectedAction = "receive";
// }
} else {
console.error('Failed to fetch item information');
this.responseMessage = await response.text();
@ -636,6 +776,7 @@
this.selectedCompany = companyDeptData?.companyId || "";
this.selectedDepartment = companyDeptData?.departmentId || "";
}
else {
console.error(`Failed to fetch user: ${response.statusText}`);

View File

@ -535,6 +535,8 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
ToStationName = item.Movement?.NextStation?.StationName,
item.Movement?.ToOther,
item.Movement?.LatestStatus,
item.Movement?.LastUser,
item.Movement?.MovementComplete,
QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.UniqueID}" // Generate QR String
};
return Json(singleItem);
@ -693,7 +695,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
return NotFound("Item movement record not found.");
}
updatedList.LatestStatus = "Delivered";
updatedList.LatestStatus = receiveMovement.LatestStatus;
updatedList.receiveDate = receiveMovement.receiveDate;
updatedList.MovementComplete = true;

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB