update
This commit is contained in:
parent
e78e1c979e
commit
e43205c08e
@ -647,7 +647,7 @@
|
||||
},
|
||||
computed: {
|
||||
groupedItems() {
|
||||
return this.items.reduce((acc, movement) => {
|
||||
let grouped = this.items.reduce((acc, movement) => {
|
||||
if (!acc[movement.itemId]) {
|
||||
acc[movement.itemId] = {
|
||||
uniqueID: movement.uniqueID,
|
||||
@ -657,6 +657,35 @@
|
||||
acc[movement.itemId].movements.push(movement);
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
// Sort items from newest to oldest & filter them
|
||||
for (let itemId in grouped) {
|
||||
let movements = grouped[itemId].movements
|
||||
.sort((a, b) => b.id - a.id); // Newest to oldest
|
||||
|
||||
// console.log(movements);
|
||||
// let stopIndex = movements.findIndex(m =>
|
||||
// m.toOther === 'Return' && m.movementComplete == 1
|
||||
// );
|
||||
|
||||
// if (stopIndex !== -1) {
|
||||
// movements = movements.slice(0, stopIndex + 1);
|
||||
// }
|
||||
|
||||
// Ensure at least 3 movements before stopping
|
||||
let stopIndex = movements.slice(3).findIndex(m =>
|
||||
m.toOther === 'Return' && m.movementComplete == 1
|
||||
);
|
||||
|
||||
if (stopIndex !== -1) {
|
||||
stopIndex += 3; // Adjust index since we sliced after the first 3
|
||||
movements = movements.slice(0, stopIndex + 1); // Keep at least 3 + the "Return" row
|
||||
}
|
||||
|
||||
grouped[itemId].movements = movements;
|
||||
}
|
||||
|
||||
return grouped;
|
||||
},
|
||||
|
||||
groupedByStation() {
|
||||
@ -725,18 +754,19 @@
|
||||
|
||||
// return sortedGrouped;
|
||||
|
||||
// <----UPDATE RETURN ITEM ONCE ---->
|
||||
let grouped = {};
|
||||
|
||||
// Process each movement and store only the latest assigned station
|
||||
// Process each movement and store only the latest assigned station
|
||||
this.items.forEach((movement) => {
|
||||
let station = null;
|
||||
|
||||
if (movement.lastStation !== null) {
|
||||
station = movement.lastStationName; // Latest assigned station
|
||||
station = movement.lastStationName;// Latest assigned station
|
||||
} else if (movement.toStation !== null) {
|
||||
station = movement.toStationName; // If no new station, use last known station
|
||||
station = movement.toStationName;// If no new station, use last known station
|
||||
} else {
|
||||
station = "Self Assigned"; // No station history
|
||||
station = "Self Assigned";// No station history
|
||||
}
|
||||
|
||||
let itemId = movement.uniqueID;
|
||||
@ -773,6 +803,8 @@
|
||||
});
|
||||
|
||||
return sortedGrouped;
|
||||
|
||||
|
||||
},
|
||||
filteredItems() {
|
||||
if (!this.searchQuery.trim()) {
|
||||
|
||||
@ -303,6 +303,37 @@
|
||||
{
|
||||
"title": "Product Name",
|
||||
"data": "productName",
|
||||
"render": function (data, type, full, meta) {
|
||||
if (!data) {
|
||||
return "No Document";
|
||||
}
|
||||
|
||||
var imageSrc = full.productImage;
|
||||
// Check if the document is an image based on file extension
|
||||
var isImage = /\.(jpeg|jpg|png|gif)$/i.test(imageSrc);
|
||||
var isPdf = /\.pdf$/i.test(imageSrc);
|
||||
// var imageSrc = full.productImage; Fallback to data if imgsrc is unavailable
|
||||
console.log(full);
|
||||
|
||||
if (isImage) {
|
||||
return ` <div class="row"><td>${data}</td></div>
|
||||
<a href="${imageSrc}" target="_blank" data-lightbox="image-1">
|
||||
<img src="${imageSrc}" alt="Image" class="img-thumbnail" style="width: 100px; height: 100px;" />
|
||||
</a>`;
|
||||
}
|
||||
else if (isPdf) {
|
||||
return `<div class="row"><td>${data}</td></div>
|
||||
<a href="${imageSrc}" target="_blank">
|
||||
<img src="https://upload.wikimedia.org/wikipedia/commons/8/87/PDF_file_icon.svg"
|
||||
alt="PDF Document" class="img-thumbnail"
|
||||
style="width: 50px; height: 50px;" />
|
||||
<br>View PDF
|
||||
</a>`;
|
||||
}
|
||||
// else {
|
||||
// return `<a href="${imageSrc}" target="_blank">Download File</a>`;
|
||||
// }
|
||||
},
|
||||
},
|
||||
{
|
||||
"title": "Requested by User",
|
||||
@ -427,6 +458,37 @@
|
||||
{
|
||||
"title": "Product Name",
|
||||
"data": "productName",
|
||||
"render": function (data, type, full, meta) {
|
||||
if (!data) {
|
||||
return "No Document";
|
||||
}
|
||||
|
||||
var imageSrc = full.productImage;
|
||||
// Check if the document is an image based on file extension
|
||||
var isImage = /\.(jpeg|jpg|png|gif)$/i.test(imageSrc);
|
||||
var isPdf = /\.pdf$/i.test(imageSrc);
|
||||
// var imageSrc = full.productImage; Fallback to data if imgsrc is unavailable
|
||||
console.log(full);
|
||||
|
||||
if (isImage) {
|
||||
return ` <div class="row"><td>${data}</td></div>
|
||||
<a href="${imageSrc}" target="_blank" data-lightbox="image-1">
|
||||
<img src="${imageSrc}" alt="Image" class="img-thumbnail" style="width: 100px; height: 100px;" />
|
||||
</a>`;
|
||||
}
|
||||
else if (isPdf) {
|
||||
return `<div class="row"><td>${data}</td></div>
|
||||
<a href="${imageSrc}" target="_blank">
|
||||
<img src="https://upload.wikimedia.org/wikipedia/commons/8/87/PDF_file_icon.svg"
|
||||
alt="PDF Document" class="img-thumbnail"
|
||||
style="width: 50px; height: 50px;" />
|
||||
<br>View PDF
|
||||
</a>`;
|
||||
}
|
||||
// else {
|
||||
// return `<a href="${imageSrc}" target="_blank">Download File</a>`;
|
||||
// }
|
||||
},
|
||||
},
|
||||
{
|
||||
"title": "Requested by User",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user