refactor: simplify onGoodChange and onRejectChange functions in StockVerifyDialog to directly update results by index for improved clarity and maintainability
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (8.3) (push) Waiting to run
tests / ci (8.4) (push) Waiting to run
tests / ci (8.5) (push) Waiting to run

This commit is contained in:
Yoga Pangestu 2026-07-05 16:38:23 +07:00
parent 87adc68376
commit 1253711147

View File

@ -128,18 +128,6 @@ watch(open, (isOpen) => {
}
});
function onGoodChange(result: any, value: string | number) {
const val = Number(value) || 0;
result.good = val;
result.reject = Math.max(0, result.cutting_result - val);
}
function onRejectChange(result: any, value: string | number) {
const val = Number(value) || 0;
result.reject = val;
result.good = Math.max(0, result.cutting_result - val);
}
function setSharedPrice(type: string, value: string) {
verifyForm.shared_prices[type] = value;
verifyForm.variant_prices = verifyForm.variant_prices.map((row) => ({
@ -239,15 +227,13 @@ function submitVerify() {
<label :for="`stock-good-${index}`"
class="text-[10px] text-muted-foreground block mb-0.5">Bagus</label>
<NumberInput :id="`stock-good-${index}`" :model-value="result.good"
class="h-7 w-20 px-1.5 text-xs text-center"
@update:model-value="val => onGoodChange(result, val)" />
class="h-7 w-20 px-1.5 text-xs text-center" />
</div>
<div class="text-center">
<label :for="`stock-reject-${index}`"
class="text-[10px] text-muted-foreground block mb-0.5">Reject</label>
<NumberInput :id="`stock-reject-${index}`" :model-value="result.reject"
class="h-7 w-20 px-1.5 text-xs text-center"
@update:model-value="val => onRejectChange(result, val)" />
class="h-7 w-20 px-1.5 text-xs text-center" />
</div>
</div>
</div>