fix : auto clear is added (working)
This commit is contained in:
parent
3baed644a1
commit
9451abf500
@ -627,11 +627,17 @@ if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
|
|||||||
if (this.selectedLabel === 'WSP') {
|
if (this.selectedLabel === 'WSP') {
|
||||||
this.wspTicketStage = 0; // Reset stage if WSP
|
this.wspTicketStage = 0; // Reset stage if WSP
|
||||||
}
|
}
|
||||||
else if (/[0-9]/.test(key)) {
|
|
||||||
const currentValue = parseInt(this.padValue + key) || 0;
|
// Clear the current row to reset any invalid state
|
||||||
if (currentValue > 100) return;
|
this.selectionService.updatePartial({
|
||||||
this.padValue += key;
|
label: this.selectedLabel || '',
|
||||||
}
|
numbers: [...this.selectedNumbers],
|
||||||
|
value: 0,
|
||||||
|
total: 0,
|
||||||
|
isBoxed: this.isBoxed
|
||||||
|
});
|
||||||
|
this.updateCanPrint();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/[0-9]/.test(key)) {
|
if (/[0-9]/.test(key)) {
|
||||||
@ -640,37 +646,74 @@ if (this.twoGroupLabels.includes(this.selectedLabel || '')) {
|
|||||||
this.padValue += key;
|
this.padValue += key;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateCanPrint();
|
this.updateCanPrint();
|
||||||
|
|
||||||
const value = parseFloat(this.padValue) || 0;
|
const value = parseFloat(this.padValue) || 0;
|
||||||
|
|
||||||
if (this.selectedLabel === 'WSP') {
|
if (this.selectedLabel === 'WSP') {
|
||||||
const labels = ['WIN', 'SHP', 'PLC'];
|
const labels = ['WIN', 'SHP', 'PLC'];
|
||||||
const targetLabel = labels[this.wspTicketStage];
|
const targetLabel = labels[this.wspTicketStage];
|
||||||
|
|
||||||
const updatedSelections = this.selectionService.getSelections().map(sel => {
|
const updatedSelections = this.selectionService.getSelections().map(sel => {
|
||||||
if (sel.label === targetLabel && JSON.stringify(sel.numbers) === JSON.stringify(this.selectedNumbers)) {
|
if (sel.label === targetLabel && JSON.stringify(sel.numbers) === JSON.stringify(this.selectedNumbers)) {
|
||||||
const total = value * (sel.numbers?.length || 0) * 10;
|
const total = value * (sel.numbers?.length || 0) * 10;
|
||||||
return {
|
return {
|
||||||
...sel,
|
...sel,
|
||||||
value,
|
value,
|
||||||
total
|
total
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return sel;
|
return sel;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.selectionService.setSelections(updatedSelections);
|
||||||
|
|
||||||
|
// Check if total is 0 for WSP (indicating invalid row)
|
||||||
|
const currentTotal = updatedSelections.find(sel => sel.label === targetLabel)?.total || 0;
|
||||||
|
if (currentTotal === 0 && value > 0) {
|
||||||
|
console.log('[DEBUG] WSP row invalid (total = 0), clearing row');
|
||||||
|
this.selectionService.setSelections(
|
||||||
|
updatedSelections.filter(sel => sel.label !== targetLabel || sel.numbers.length > 0)
|
||||||
|
);
|
||||||
|
this.wspTicketStage = 0;
|
||||||
|
this.padValue = '';
|
||||||
|
this.selectedNumbers = [];
|
||||||
|
this.selectionService.updatePartial({
|
||||||
|
label: '',
|
||||||
|
numbers: [],
|
||||||
|
value: 0,
|
||||||
|
total: 0,
|
||||||
|
isBoxed: false
|
||||||
});
|
});
|
||||||
|
|
||||||
this.selectionService.setSelections(updatedSelections);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 🔵 Default path for non-WSP
|
// Default path for non-WSP
|
||||||
this.selectionService.updatePartial({
|
this.selectionService.updatePartial({
|
||||||
value,
|
value,
|
||||||
isBoxed: this.isBoxed,
|
isBoxed: this.isBoxed,
|
||||||
label: this.selectedLabel || '',
|
label: this.selectedLabel || '',
|
||||||
numbers: [...this.selectedNumbers]
|
numbers: [...this.selectedNumbers]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Check if total is 0 after updating (indicating invalid mathematical logic)
|
||||||
|
const currentRow = this.selectionService.getCurrentRow();
|
||||||
|
if (currentRow.total === 0 && value > 0 && currentRow.numbers.length > 0) {
|
||||||
|
console.log('[DEBUG] Row invalid (total = 0), auto-clearing current row');
|
||||||
|
this.selectionService.updatePartial({
|
||||||
|
label: '',
|
||||||
|
numbers: [],
|
||||||
|
value: 0,
|
||||||
|
total: 0,
|
||||||
|
isBoxed: false
|
||||||
|
});
|
||||||
|
this.selectedLabel = null;
|
||||||
|
this.selectedNumbers = [];
|
||||||
|
this.padValue = '';
|
||||||
|
this.isBoxed = false;
|
||||||
|
this.updateCanPrint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user