|
@@ -75,8 +75,10 @@
|
|
|
<ProposalPricingTab
|
|
<ProposalPricingTab
|
|
|
v-model="form.pavao"
|
|
v-model="form.pavao"
|
|
|
v-model:enabled="form.pavao_enabled"
|
|
v-model:enabled="form.pavao_enabled"
|
|
|
|
|
+ field-prefix="pavao"
|
|
|
:product-options="productOptions"
|
|
:product-options="productOptions"
|
|
|
section-label="Pavão"
|
|
section-label="Pavão"
|
|
|
|
|
+ :validation-errors="validationErrors"
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
@@ -87,9 +89,11 @@
|
|
|
<ProposalPricingTab
|
|
<ProposalPricingTab
|
|
|
v-model="form.irrecusavel"
|
|
v-model="form.irrecusavel"
|
|
|
v-model:enabled="form.irrecusavel_enabled"
|
|
v-model:enabled="form.irrecusavel_enabled"
|
|
|
|
|
+ field-prefix="irrecusavel"
|
|
|
:product-options="productOptions"
|
|
:product-options="productOptions"
|
|
|
section-label="Irrecusável"
|
|
section-label="Irrecusável"
|
|
|
show-condition
|
|
show-condition
|
|
|
|
|
+ :validation-errors="validationErrors"
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
</q-card-section>
|
|
</q-card-section>
|
|
@@ -329,32 +333,44 @@ const onOKClick = async () => {
|
|
|
quantity_classes: form.quantity_classes,
|
|
quantity_classes: form.quantity_classes,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- await execute(() => {
|
|
|
|
|
- if (props.package?.id) {
|
|
|
|
|
- const updated = {
|
|
|
|
|
- ...getUpdatedFields.value,
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ await execute(() => {
|
|
|
|
|
+ if (props.package?.id) {
|
|
|
|
|
+ const updated = {
|
|
|
|
|
+ ...getUpdatedFields.value,
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
- if (updated.class_duration_hours !== undefined) {
|
|
|
|
|
- updated.class_duration_minutes = payload.class_duration_minutes;
|
|
|
|
|
|
|
+ if (updated.class_duration_hours !== undefined) {
|
|
|
|
|
+ updated.class_duration_minutes = payload.class_duration_minutes;
|
|
|
|
|
|
|
|
- delete updated.class_duration_hours;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ delete updated.class_duration_hours;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // Pavão/Irrecusável têm validação cruzada entre campos (par exclusivo
|
|
|
|
|
- // de checkbox) e um sinal explícito de "removido" (null) — não é
|
|
|
|
|
- // seguro fatiar isso num diff parcial, vão sempre inteiros.
|
|
|
|
|
- updated.pavao = payload.pavao;
|
|
|
|
|
- updated.irrecusavel = payload.irrecusavel;
|
|
|
|
|
|
|
+ // Pavão/Irrecusável têm validação cruzada entre campos (par exclusivo
|
|
|
|
|
+ // de checkbox) e um sinal explícito de "removido" (null) — não é
|
|
|
|
|
+ // seguro fatiar isso num diff parcial, vão sempre inteiros.
|
|
|
|
|
+ updated.pavao = payload.pavao;
|
|
|
|
|
+ updated.irrecusavel = payload.irrecusavel;
|
|
|
|
|
|
|
|
- delete updated.pavao_enabled;
|
|
|
|
|
- delete updated.irrecusavel_enabled;
|
|
|
|
|
|
|
+ delete updated.pavao_enabled;
|
|
|
|
|
+ delete updated.irrecusavel_enabled;
|
|
|
|
|
|
|
|
- return updatePackage(props.package.id, updated);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return updatePackage(props.package.id, updated);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return createPackage(payload);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ return createPackage(payload);
|
|
|
|
|
+ });
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ // Se o erro veio de dentro de Pavão/Irrecusável, troca pra aba certa —
|
|
|
|
|
+ // senão a mensagem fica escondida numa tab que não está visível.
|
|
|
|
|
+ const errorKeys = Object.keys(validationErrors);
|
|
|
|
|
+
|
|
|
|
|
+ if (errorKeys.some((key) => key.startsWith("pavao."))) {
|
|
|
|
|
+ currentTab.value = "pavao";
|
|
|
|
|
+ } else if (errorKeys.some((key) => key.startsWith("irrecusavel."))) {
|
|
|
|
|
+ currentTab.value = "irrecusavel";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
onMounted(loadData);
|
|
onMounted(loadData);
|