fix qrmaster
This commit is contained in:
parent
31254a6460
commit
e28117b578
@ -223,6 +223,10 @@
|
|||||||
"title": "Request ID",
|
"title": "Request ID",
|
||||||
"data": "requestId",
|
"data": "requestId",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"title": "User ID",
|
||||||
|
"data": "userId",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"title": "Product ID",
|
"title": "Product ID",
|
||||||
"data": "productId",
|
"data": "productId",
|
||||||
@ -268,10 +272,10 @@
|
|||||||
"title": "User Remark",
|
"title": "User Remark",
|
||||||
"data": "remarkUser",
|
"data": "remarkUser",
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
"title": "InvMaster Remark",
|
// "title": "InvMaster Remark",
|
||||||
"data": "remarkMasterInv",
|
// "data": "remarkMasterInv",
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
"title": "Status",
|
"title": "Status",
|
||||||
"data": "status",
|
"data": "status",
|
||||||
|
|||||||
@ -128,6 +128,7 @@
|
|||||||
<option class="btn-light" value="store">Assign to Store</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="supplier">Assign to Supplier</option>
|
||||||
<option class="btn-light" value="faulty">Faulty</option>
|
<option class="btn-light" value="faulty">Faulty</option>
|
||||||
|
<option class="btn-light" value="receive" hidden>Receive</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -301,10 +302,28 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -374,7 +393,7 @@
|
|||||||
this.startScanner();
|
this.startScanner();
|
||||||
this.fetchUsers();
|
this.fetchUsers();
|
||||||
this.fetchStores();
|
this.fetchStores();
|
||||||
this.fetchItem('ARA00500008'); // for testing only. clear this
|
//this.fetchItem('ARA00500008'); // for testing only. clear this
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
filteredDepartments() {
|
filteredDepartments() {
|
||||||
@ -397,19 +416,19 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleFileUpload(event) {
|
handleFileUpload(event) {
|
||||||
const file = event.target.files[0];
|
const file = event.target.files[0];
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
this.document = e.target.result.split(',')[1]; // Get Base64 string (remove metadata)
|
this.document = e.target.result.split(',')[1]; // Get Base64 string (remove metadata)
|
||||||
};
|
};
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
} else {
|
} else {
|
||||||
this.document = null;
|
this.document = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async addItemMovement() {
|
async addItemMovement() {
|
||||||
|
|
||||||
if (this.showProduct.category == "Disposable") {
|
if (this.showProduct.category == "Disposable") {
|
||||||
@ -419,18 +438,18 @@
|
|||||||
const now = new Date();
|
const now = new Date();
|
||||||
const formData = {
|
const formData = {
|
||||||
|
|
||||||
...(this.selectedAction === 'user' ? { toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedUser, MovementComplete: false, } : {}),
|
...(this.selectedAction === 'user' ? { toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedUser, MovementComplete: false,} : {}),
|
||||||
...(this.selectedAction === 'store' ? { toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedStore, MovementComplete: false,} : {}),
|
...(this.selectedAction === 'store' ? { toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedStore, MovementComplete: false, ItemId: this.thisItem.itemID, Action: 'Stock Out', Quantity: 1,} : {}),
|
||||||
...(this.selectedAction === 'supplier' ? { toUser: this.currentUser.id, toOther: this.selectedOther, SendDate: this.assigndate, Remark: this.remark + '. Item sent to ' + this.selectedSupplier + ' for ' + this.selectedOther,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,lastUser: this.currentUser.id, MovementComplete: false, ItemId: this.thisItem.itemID, Action: 'Stock Out', Quantity: 1, } : {}),
|
||||||
...(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, ItemId: this.thisItem.itemID, Action: 'Stock Out', Quantity: 1,} : {}),
|
||||||
|
|
||||||
ItemId: this.thisItem.itemID,
|
|
||||||
Action: 'Stock Out',
|
|
||||||
Quantity: 1,
|
|
||||||
|
|
||||||
|
|
||||||
|
ItemId: this.thisItem.itemID,
|
||||||
|
Action: 'Stock Out',
|
||||||
|
Quantity: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// Proceed to send the data to the API
|
// Proceed to send the data to the API
|
||||||
@ -451,7 +470,7 @@
|
|||||||
|
|
||||||
// Reset the form
|
// Reset the form
|
||||||
this.resetForm();
|
this.resetForm();
|
||||||
// window.location.href = '/Inventory/InventoryMaster/ItemMovement';
|
window.location.href = '/Inventory/InventoryMaster/ItemMovement';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Failed to submit form.');
|
throw new Error('Failed to submit form.');
|
||||||
@ -464,11 +483,64 @@
|
|||||||
alert('Inventory PSTW Error', `An error occurred: ${error.message}`, 'error');
|
alert('Inventory PSTW Error', `An error occurred: ${error.message}`, 'error');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
async receiveItemMovement() {
|
||||||
|
|
||||||
|
if (this.showProduct.category == "Disposable") {
|
||||||
|
this.serialNumber = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
const now = new Date();
|
||||||
|
const formData = {
|
||||||
|
|
||||||
|
Id: this.thisItem.movementId,
|
||||||
|
// LastStation: this.selectedStation,
|
||||||
|
// LatestStatus: "Delivered",
|
||||||
|
// ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
|
||||||
|
// MovementComplete: true
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
// Proceed to send the data to the API
|
||||||
|
const response = await fetch('/InvMainAPI/UpdateItemMovementMaster', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
// 'Authorization': `Bearer ${this.token}`
|
||||||
|
},
|
||||||
|
body: JSON.stringify(formData)
|
||||||
|
});
|
||||||
|
if (response.ok) {
|
||||||
|
// If the form submission was successful, display a success message
|
||||||
|
alert('Success!', 'Item form has been successfully submitted.', 'success');
|
||||||
|
const updatedItem = await response.json();
|
||||||
|
// this.items.push(updatedItem);
|
||||||
|
console.log(updatedItem);
|
||||||
|
|
||||||
|
// Reset the form
|
||||||
|
this.resetForm();
|
||||||
|
window.location.href = '/Inventory/InventoryMaster/ItemMovement';
|
||||||
|
|
||||||
|
} else {
|
||||||
|
throw new Error('Failed to submit form.');
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error:', error);
|
||||||
|
|
||||||
|
// Displaying error message
|
||||||
|
alert('Inventory PSTW Error', `An error occurred: ${error.message}`, 'error');
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
startScanner() {
|
startScanner() {
|
||||||
const config = {
|
const config = {
|
||||||
fps: 60,
|
fps: 60,
|
||||||
qrbox: 200
|
qrbox: 400
|
||||||
};
|
};
|
||||||
|
|
||||||
navigator.mediaDevices.getUserMedia({
|
navigator.mediaDevices.getUserMedia({
|
||||||
@ -505,7 +577,13 @@
|
|||||||
method: 'POST',}
|
method: 'POST',}
|
||||||
);
|
);
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
|
// this.thisItem = await response.json();
|
||||||
|
|
||||||
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";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -670,13 +670,13 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (itemmovement.ToUser == null)
|
//if (itemmovement.ToUser == null)
|
||||||
{
|
//{
|
||||||
throw new Exception("itemmovement.ToUser is null");
|
// throw new Exception("itemmovement.ToUser is null");
|
||||||
}
|
//}
|
||||||
|
|
||||||
//var inventoryMaster = await _centralDbContext.InventoryMasters.Include("User").FirstOrDefaultAsync(i => i.UserId == itemmovement.ToUser) ?? new InventoryMasterModel { UserId = itemmovement.ToUser };
|
//var inventoryMaster = await _centralDbContext.InventoryMasters.Include("User").FirstOrDefaultAsync(i => i.UserId == itemmovement.ToUser) ?? new InventoryMasterModel { UserId = itemmovement.ToUser };
|
||||||
var inventoryMaster = await _centralDbContext.InventoryMasters.FirstOrDefaultAsync(i => i.UserId == itemmovement.ToUser);
|
var inventoryMaster = await _centralDbContext.InventoryMasters.Include("User").FirstOrDefaultAsync(i => i.UserId == itemmovement.ToUser);
|
||||||
if (inventoryMaster != null)
|
if (inventoryMaster != null)
|
||||||
{
|
{
|
||||||
itemmovement.ToStore = inventoryMaster.StoreId;
|
itemmovement.ToStore = inventoryMaster.StoreId;
|
||||||
@ -729,17 +729,41 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
|||||||
updateItem.ItemStatus = 8;
|
updateItem.ItemStatus = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("updateItem.MovementId" + updateItem.MovementId);
|
//Console.WriteLine("updateItem.MovementId" + updateItem.MovementId);
|
||||||
Console.WriteLine("itemmovement.Id" + itemmovement.Id);
|
//Console.WriteLine("itemmovement.Id" + itemmovement.Id);
|
||||||
|
|
||||||
updateItem.MovementId = itemmovement.Id;
|
updateItem.MovementId = itemmovement.Id;
|
||||||
_centralDbContext.Items.Update(updateItem);
|
_centralDbContext.Items.Update(updateItem);
|
||||||
|
await _centralDbContext.SaveChangesAsync(); // save changes for table item - movementid
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return Json(new
|
||||||
|
{
|
||||||
|
itemmovement.Id,
|
||||||
|
itemmovement.ItemId,
|
||||||
|
itemmovement.ToStation,
|
||||||
|
itemmovement.ToStore,
|
||||||
|
itemmovement.ToUser,
|
||||||
|
itemmovement.ToOther,
|
||||||
|
itemmovement.sendDate,
|
||||||
|
itemmovement.Action,
|
||||||
|
itemmovement.Quantity,
|
||||||
|
itemmovement.Remark,
|
||||||
|
itemmovement.ConsignmentNote,
|
||||||
|
itemmovement.Date,
|
||||||
|
itemmovement.LastUser,
|
||||||
|
itemmovement.LastStore,
|
||||||
|
itemmovement.LastStation,
|
||||||
|
itemmovement.LatestStatus,
|
||||||
|
itemmovement.receiveDate,
|
||||||
|
itemmovement.MovementComplete
|
||||||
|
});
|
||||||
|
|
||||||
await _centralDbContext.SaveChangesAsync(); // save changes for table item - movementid
|
|
||||||
|
|
||||||
return Json(itemmovement);
|
|
||||||
|
|
||||||
|
//return Json(itemmovement);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -748,6 +772,44 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("UpdateItemMovementMaster")]
|
||||||
|
public async Task<IActionResult> UpdateItemMovementMaster([FromBody] ItemMovementModel receiveMovement)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
var updatedList = await _centralDbContext.ItemMovements.FindAsync(receiveMovement.Id);
|
||||||
|
|
||||||
|
if (updatedList == null)
|
||||||
|
{
|
||||||
|
return NotFound("Item movement record not found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
updatedList.LatestStatus = "Delivered";
|
||||||
|
updatedList.MovementComplete = true;
|
||||||
|
|
||||||
|
_centralDbContext.ItemMovements.Update(updatedList);
|
||||||
|
await _centralDbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
//var receiveItems = await _centralDbContext.Items.FindAsync(receiveMovement.ItemId);
|
||||||
|
|
||||||
|
//if (receiveItems != null)
|
||||||
|
//{
|
||||||
|
// receiveItems.ItemStatus = 3;
|
||||||
|
// _centralDbContext.Items.Update(receiveItems);
|
||||||
|
|
||||||
|
// await _centralDbContext.SaveChangesAsync(); // Simpan perubahan
|
||||||
|
//}
|
||||||
|
|
||||||
|
return Json(updatedList);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return BadRequest(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion ItemMovement
|
#endregion ItemMovement
|
||||||
|
|
||||||
#region ItemMovementUser
|
#region ItemMovementUser
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
Loading…
Reference in New Issue
Block a user