Merge branch 'Dev2' of https://git.pstw.com.my/catalyx/PSTW_CentralizeSystem into Dev2
This commit is contained in:
commit
2d474477fa
@ -40,6 +40,10 @@
|
||||
color: brown;
|
||||
}
|
||||
|
||||
.text-weird {
|
||||
color: purple;
|
||||
}
|
||||
|
||||
|
||||
.ms-auto {
|
||||
margin-left: auto !important; /* Push Complete/Incomplete to right */
|
||||
@ -143,10 +147,11 @@
|
||||
<!-- Movement Type -->
|
||||
<h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return',
|
||||
'text-success': movement.toStation !== null, 'text-info': movement.action === 'Assign' && movement.toStation === null,
|
||||
'text-numb': movement.toOther === 'Faulty' || movement.toOther === 'Calibration' || movement.toOther === 'Repair'}"
|
||||
'text-numb': movement.toOther === 'Faulty' || movement.toOther === 'Calibration' || movement.toOther === 'Repair',
|
||||
'text-weird': movement.action === 'Register'}"
|
||||
class="flex-shrink-0 text-nowrap" style="max-width:140px; min-width:90px;">
|
||||
|
||||
{{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : ( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther : 'Assign'))) }}
|
||||
{{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : ( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther : ( movement.action == 'Register' ? 'Register' : 'Assign')))) }}
|
||||
|
||||
</h3>
|
||||
|
||||
@ -180,9 +185,9 @@
|
||||
</button>
|
||||
|
||||
<!-- Completion Status -->
|
||||
<h4 :class="movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'text-success' : movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'text-success' :'text-danger'"
|
||||
<h4 :class="movement.action == 'Register' ? 'text-success' : movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'text-success' : movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'text-success' :'text-danger'"
|
||||
class="text-nowrap ms-3">
|
||||
{{ movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'Complete' : ( movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'Complete' : (movement.latestStatus === 'Ready To Deploy' ? 'Canceled' : 'Incomplete')) }}
|
||||
{{ movement.action == 'Register' ? 'Complete' : (movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'Complete' : ( movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'Complete' : (movement.latestStatus === 'Ready To Deploy' ? 'Canceled' : 'Incomplete'))) }}
|
||||
</h4>
|
||||
|
||||
</div>
|
||||
@ -241,11 +246,11 @@
|
||||
<!-- Movement Type -->
|
||||
<h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return',
|
||||
'text-success': movement.toStation !== null, 'text-info': movement.action === 'Assign' && movement.toStation === null,
|
||||
'text-numb': movement.toOther === 'Faulty' || movement.toOther === 'Calibration' || movement.toOther === 'Repair'}"
|
||||
'text-numb': movement.toOther === 'Faulty' || movement.toOther === 'Calibration' || movement.toOther === 'Repair',
|
||||
'text-weird': movement.action === 'Register'}"
|
||||
class="flex-shrink-0 text-nowrap" style="max-width:140px; min-width:90px;">
|
||||
|
||||
{{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : ( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther : 'Assign'))) }}
|
||||
|
||||
{{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : ( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther : ( movement.action == 'Register' ? 'Register' : 'Assign')))) }}
|
||||
</h3>
|
||||
|
||||
<!-- Send Date -->
|
||||
@ -278,9 +283,9 @@
|
||||
</button>
|
||||
|
||||
<!-- Completion Status -->
|
||||
<h4 :class="movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'text-success' : movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'text-success' :'text-danger'"
|
||||
<h4 :class="movement.action == 'Register' ? 'text-success' : movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'text-success' : movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'text-success' :'text-danger'"
|
||||
class="text-nowrap ms-3">
|
||||
{{ movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'Complete' : ( movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'Complete' : (movement.latestStatus === 'Ready To Deploy' ? 'Canceled' : 'Incomplete')) }}
|
||||
{{ movement.action == 'Register' ? 'Complete' : (movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'Complete' : ( movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'Complete' : (movement.latestStatus === 'Ready To Deploy' ? 'Canceled' : 'Incomplete'))) }}
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
@ -364,10 +369,11 @@
|
||||
<div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom">
|
||||
<h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return',
|
||||
'text-success': movement.toStation !== null, 'text-info': movement.action === 'Assign' && movement.toStation === null,
|
||||
'text-numb': movement.toOther === 'Faulty' || movement.toOther === 'Calibration' || movement.toOther === 'Repair'}"
|
||||
'text-numb': movement.toOther === 'Faulty' || movement.toOther === 'Calibration' || movement.toOther === 'Repair',
|
||||
'text-weird': movement.action === 'Register'}"
|
||||
class="flex-shrink-0 text-nowrap" style="max-width:140px; min-width:90px;">
|
||||
|
||||
{{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : ( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther : 'Assign'))) }}
|
||||
{{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : ( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther : ( movement.action == 'Register' ? 'Register' : 'Assign')))) }}
|
||||
|
||||
</h3>
|
||||
|
||||
@ -401,9 +407,9 @@
|
||||
</button>
|
||||
|
||||
<!-- Completion Status -->
|
||||
<h4 :class="movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'text-success' : movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'text-success' :'text-danger'"
|
||||
<h4 :class="movement.action == 'Register' ? 'text-success' : movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'text-success' : movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'text-success' :'text-danger'"
|
||||
class="text-nowrap ms-3">
|
||||
{{ movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'Complete' : ( movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'Complete' : (movement.latestStatus === 'Ready To Deploy' ? 'Canceled' : 'Incomplete')) }}
|
||||
{{ movement.action == 'Register' ? 'Complete' : (movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'Complete' : ( movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'Complete' : (movement.latestStatus === 'Ready To Deploy' ? 'Canceled' : 'Incomplete'))) }}
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
@ -457,10 +463,11 @@
|
||||
<!-- Movement Type -->
|
||||
<h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return',
|
||||
'text-success': movement.toStation !== null, 'text-info': movement.action === 'Assign' && movement.toStation === null,
|
||||
'text-numb': movement.toOther === 'Faulty' || movement.toOther === 'Calibration' || movement.toOther === 'Repair'}"
|
||||
'text-numb': movement.toOther === 'Faulty' || movement.toOther === 'Calibration' || movement.toOther === 'Repair',
|
||||
'text-weird': movement.action === 'Register'}"
|
||||
class="flex-shrink-0 text-nowrap" style="max-width:140px; min-width:90px;">
|
||||
|
||||
{{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : ( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther : 'Assign'))) }}
|
||||
{{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : ( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther : ( movement.action == 'Register' ? 'Register' : 'Assign')))) }}
|
||||
|
||||
</h3>
|
||||
|
||||
@ -494,9 +501,9 @@
|
||||
</button>
|
||||
|
||||
<!-- Completion Status -->
|
||||
<h4 :class="movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'text-success' : movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'text-success' :'text-danger'"
|
||||
<h4 :class="movement.action == 'Register' ? 'text-success' : movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'text-success' : movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'text-success' :'text-danger'"
|
||||
class="text-nowrap ms-3">
|
||||
{{ movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'Complete' : ( movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'Complete' : (movement.latestStatus === 'Ready To Deploy' ? 'Canceled' : 'Incomplete')) }}
|
||||
{{ movement.action == 'Register' ? 'Complete' : (movement.movementComplete == 1 && movement.latestStatus !== 'Ready To Deploy' ? 'Complete' : ( movement.toOther === 'Repair' || movement.toOther === 'Calibration' && movement.latestStatus === 'Ready To Deploy' ? 'Complete' : (movement.latestStatus === 'Ready To Deploy' ? 'Canceled' : 'Incomplete'))) }}
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
@ -642,7 +649,6 @@
|
||||
},
|
||||
mounted() {
|
||||
this.fetchItem();
|
||||
console.log("Filtered Station:", this.filteredStation);
|
||||
|
||||
},
|
||||
computed: {
|
||||
@ -658,6 +664,8 @@
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
console.log(grouped);
|
||||
|
||||
// Sort items from newest to oldest & filter them
|
||||
for (let itemId in grouped) {
|
||||
let movements = grouped[itemId].movements
|
||||
@ -689,122 +697,63 @@
|
||||
},
|
||||
|
||||
groupedByStation() {
|
||||
// let grouped = {};
|
||||
// this.items.forEach((movement) => {
|
||||
|
||||
// if (movement.toStation !== null) {
|
||||
// let station = movement.toStationName;
|
||||
// let itemId = movement.uniqueID;
|
||||
let groupedByItem = this.items.reduce((acc, movement) => {
|
||||
if (!acc[movement.uniqueID]) {
|
||||
acc[movement.uniqueID] = {
|
||||
uniqueID: movement.uniqueID,
|
||||
movements: [],
|
||||
};
|
||||
}
|
||||
acc[movement.uniqueID].movements.push(movement);
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
// if (!grouped[station]) {
|
||||
// grouped[station] = {};
|
||||
// }
|
||||
let groupedByStation = {};
|
||||
|
||||
// if (!grouped[station][itemId]) {
|
||||
// grouped[station][itemId] = { uniqueID: itemId, movements: [] };
|
||||
// }
|
||||
Object.keys(groupedByItem).forEach(itemId => {
|
||||
let movements = groupedByItem[itemId].movements
|
||||
.sort((a, b) => b.id - a.id); // Newest → Oldest
|
||||
|
||||
// grouped[station][itemId].movements.push(movement);
|
||||
// }
|
||||
// Ensure at least 3 movements before stopping
|
||||
let stopIndex = movements.slice(3).findIndex(m =>
|
||||
m.toOther === 'Return' && m.movementComplete == 1
|
||||
);
|
||||
|
||||
// if (movement.lastStation !== null) {
|
||||
// let station = movement.lastStationName;
|
||||
// let itemId = movement.uniqueID;
|
||||
|
||||
// if (!grouped[station]) {
|
||||
// grouped[station] = {};
|
||||
// }
|
||||
|
||||
// if (!grouped[station][itemId]) {
|
||||
// grouped[station][itemId] = { uniqueID: itemId, movements: [] };
|
||||
// }
|
||||
|
||||
// grouped[station][itemId].movements.push(movement);
|
||||
// }
|
||||
// if (movement.lastStation == null && movement.toStation == null) {
|
||||
|
||||
// let station = "Self Assigned";
|
||||
// let itemId = movement.uniqueID;
|
||||
|
||||
// if (!grouped[station]) {
|
||||
// grouped[station] = {};
|
||||
// }
|
||||
|
||||
// if (!grouped[station][itemId]) {
|
||||
// grouped[station][itemId] = { uniqueID: itemId, movements: [] };
|
||||
// }
|
||||
|
||||
// grouped[station][itemId].movements.push(movement);
|
||||
// }
|
||||
|
||||
// });
|
||||
|
||||
// Sort stations and move "Unassign Station" to the last position
|
||||
// let sortedKeys = Object.keys(grouped).sort((a, b) => {
|
||||
// if (a === "Unassign Station") return 1;
|
||||
// if (b === "Unassign Station") return -1;
|
||||
// return a.localeCompare(b);
|
||||
// });
|
||||
|
||||
// let sortedGrouped = {};
|
||||
// sortedKeys.forEach((key) => {
|
||||
// sortedGrouped[key] = grouped[key];
|
||||
// });
|
||||
|
||||
|
||||
// return sortedGrouped;
|
||||
|
||||
// <----UPDATE RETURN ITEM ONCE ---->
|
||||
let grouped = {};
|
||||
|
||||
// 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
|
||||
} else if (movement.toStation !== null) {
|
||||
station = movement.toStationName;// If no new station, use last known station
|
||||
} else {
|
||||
station = "Self Assigned";// No station history
|
||||
// Remove older movements
|
||||
if (stopIndex !== -1) {
|
||||
stopIndex += 3; // Adjust index since we sliced after the first 3
|
||||
movements = movements.slice(0, stopIndex);
|
||||
}
|
||||
|
||||
let itemId = movement.uniqueID;
|
||||
if (movements.length > 0) {
|
||||
let latestMovement = movements[0];
|
||||
let station = latestMovement.lastStationName || latestMovement.toStationName || "Not Assigned";
|
||||
|
||||
// Ensure only the latest assigned station keeps the item
|
||||
if (!grouped[itemId]) {
|
||||
grouped[itemId] = { uniqueID: itemId, station: station, movements: [] };
|
||||
if (!groupedByStation[station]) {
|
||||
groupedByStation[station] = {};
|
||||
}
|
||||
|
||||
// Always update the latest station for this item
|
||||
grouped[itemId].station = station;
|
||||
grouped[itemId].movements.push(movement);
|
||||
groupedByStation[station][itemId] = { uniqueID: itemId, movements };
|
||||
}
|
||||
});
|
||||
|
||||
// Convert to station-based grouping
|
||||
let stationGrouped = {};
|
||||
Object.values(grouped).forEach(({ uniqueID, station, movements }) => {
|
||||
if (!stationGrouped[station]) {
|
||||
stationGrouped[station] = {};
|
||||
}
|
||||
stationGrouped[station][uniqueID] = { uniqueID, movements };
|
||||
});
|
||||
|
||||
// Sort stations and move "Unassign Station" last
|
||||
let sortedKeys = Object.keys(stationGrouped).sort((a, b) => {
|
||||
// 4️⃣ **Sort stations & move 'Unassign Station' to last**
|
||||
let sortedKeys = Object.keys(groupedByStation).sort((a, b) => {
|
||||
if (a === "Unassign Station") return 1;
|
||||
if (b === "Unassign Station") return -1;
|
||||
return a.localeCompare(b);
|
||||
});
|
||||
|
||||
let sortedGrouped = {};
|
||||
sortedKeys.forEach((key) => {
|
||||
sortedGrouped[key] = stationGrouped[key];
|
||||
sortedKeys.forEach(key => {
|
||||
sortedGrouped[key] = groupedByStation[key];
|
||||
});
|
||||
|
||||
return sortedGrouped;
|
||||
|
||||
|
||||
|
||||
},
|
||||
filteredItems() {
|
||||
if (!this.searchQuery.trim()) {
|
||||
@ -995,7 +944,7 @@
|
||||
if(this.currentRole == "Super Admin"){
|
||||
this.items = await response.json();
|
||||
|
||||
// console.log(this.items);
|
||||
console.log(this.items);
|
||||
this.initAllTables();
|
||||
|
||||
} else {
|
||||
@ -1245,7 +1194,6 @@
|
||||
// },
|
||||
handleSorting() {
|
||||
this.renderTables();
|
||||
console.log(this.sortBy);
|
||||
},
|
||||
renderTables() {
|
||||
// if (this.sortBy === "logs") {
|
||||
@ -1424,8 +1372,9 @@
|
||||
this.historyVisible = {};
|
||||
},
|
||||
toggleHistory(itemId) {
|
||||
this.historyVisible = {};
|
||||
|
||||
this.historyVisible[itemId] = !this.historyVisible[itemId];
|
||||
// this.historyVisible = {};
|
||||
|
||||
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user