refactor: update validation logic in StockVerifyRequest to prevent exceeding original cutting results and enhance StockVerifyDialog with direct value updates for good and reject inputs
This commit is contained in:
parent
e4e17e32ec
commit
39fa697df8
@ -81,8 +81,8 @@ public function withValidator(Validator $validator): void
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($good + $reject) !== (int) $originalResult->cutting_result) {
|
if (($good + $reject) > (int) $originalResult->cutting_result) {
|
||||||
$validator->errors()->add("results.{$index}.good", "Total jumlah (bagus + reject) harus sama dengan hasil cutting asli ({$originalResult->cutting_result} pcs).");
|
$validator->errors()->add("results.{$index}.good", "Total jumlah (bagus + reject) tidak boleh melebihi hasil cutting asli ({$originalResult->cutting_result} pcs).");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,6 +87,16 @@ interface VariantPriceRow {
|
|||||||
prices: Record<string, string>;
|
prices: Record<string, string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onGoodChange(result: any, value: string | number) {
|
||||||
|
const val = Number(value) || 0;
|
||||||
|
result.good = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onRejectChange(result: any, value: string | number) {
|
||||||
|
const val = Number(value) || 0;
|
||||||
|
result.reject = val;
|
||||||
|
}
|
||||||
|
|
||||||
const verifyForm = useForm({
|
const verifyForm = useForm({
|
||||||
verification_note: '',
|
verification_note: '',
|
||||||
results: props.cutting.results.map(res => ({
|
results: props.cutting.results.map(res => ({
|
||||||
@ -227,13 +237,15 @@ function submitVerify() {
|
|||||||
<label :for="`stock-good-${index}`"
|
<label :for="`stock-good-${index}`"
|
||||||
class="text-[10px] text-muted-foreground block mb-0.5">Bagus</label>
|
class="text-[10px] text-muted-foreground block mb-0.5">Bagus</label>
|
||||||
<NumberInput :id="`stock-good-${index}`" :model-value="result.good"
|
<NumberInput :id="`stock-good-${index}`" :model-value="result.good"
|
||||||
class="h-7 w-20 px-1.5 text-xs text-center" />
|
class="h-7 w-20 px-1.5 text-xs text-center"
|
||||||
|
@update:model-value="val => onGoodChange(result, val)" />
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<label :for="`stock-reject-${index}`"
|
<label :for="`stock-reject-${index}`"
|
||||||
class="text-[10px] text-muted-foreground block mb-0.5">Reject</label>
|
class="text-[10px] text-muted-foreground block mb-0.5">Reject</label>
|
||||||
<NumberInput :id="`stock-reject-${index}`" :model-value="result.reject"
|
<NumberInput :id="`stock-reject-${index}`" :model-value="result.reject"
|
||||||
class="h-7 w-20 px-1.5 text-xs text-center" />
|
class="h-7 w-20 px-1.5 text-xs text-center"
|
||||||
|
@update:model-value="val => onRejectChange(result, val)" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user