feat: campo reajuste usa lista fixa com opção Outro para texto livre

Adiciona select com índices pré-definidos (IPCA, IGPM, INPC, INCC,
IPC-FIPE, SELIC, IPCA-E) e opção "Outro" que revela input de texto
livre. Campo órgão passa a ser dropdown dos órgãos cadastrados.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Junior
2026-03-15 09:33:02 -03:00
parent 7c1ca6d061
commit aa9e062485

View File

@@ -71,6 +71,20 @@ const closeMenu = () => { openMenuId.value = null }
onMounted(() => document.addEventListener('click', closeMenu)) onMounted(() => document.addEventListener('click', closeMenu))
onUnmounted(() => document.removeEventListener('click', closeMenu)) onUnmounted(() => document.removeEventListener('click', closeMenu))
// --- Reajuste ---
const REAJUSTES = ['IPCA', 'IGPM', 'INPC', 'INCC', 'IPC-FIPE', 'SELIC', 'IPCA-E', 'Outro']
const createReajusteSelect = ref('')
const editReajusteSelect = ref('')
watch(createReajusteSelect, (v) => {
if (v !== 'Outro') createForm.reajuste = v
else createForm.reajuste = ''
})
watch(editReajusteSelect, (v) => {
if (v !== 'Outro') editForm.reajuste = v
else editForm.reajuste = ''
})
// --- Modal Criar --- // --- Modal Criar ---
const showCreate = ref(false) const showCreate = ref(false)
const createForm = reactive({ const createForm = reactive({
@@ -88,6 +102,7 @@ async function criarContrato() {
await apiFetch('/contracts', { method: 'POST', body: { ...createForm } }) await apiFetch('/contracts', { method: 'POST', body: { ...createForm } })
showCreate.value = false showCreate.value = false
Object.assign(createForm, { numero: '', orgao: '', objeto: '', valor: 0, data_inicio: '', data_fim: '', fiscal_contrato: '', reajuste: '', prorrogacao_maxima: '', sla: '', status: 'ativo' }) Object.assign(createForm, { numero: '', orgao: '', objeto: '', valor: 0, data_inicio: '', data_fim: '', fiscal_contrato: '', reajuste: '', prorrogacao_maxima: '', sla: '', status: 'ativo' })
createReajusteSelect.value = ''
await refresh() await refresh()
} catch (err: any) { } catch (err: any) {
createError.value = err?.data?.error || 'Erro ao criar contrato.' createError.value = err?.data?.error || 'Erro ao criar contrato.'
@@ -117,6 +132,7 @@ function abrirEditar(c: ApiContract) {
prorrogacao_maxima: c.ProrrogacaoMaxima ? c.ProrrogacaoMaxima.slice(0, 10) : '', prorrogacao_maxima: c.ProrrogacaoMaxima ? c.ProrrogacaoMaxima.slice(0, 10) : '',
sla: c.Sla, status: c.Status, sla: c.Sla, status: c.Status,
}) })
editReajusteSelect.value = REAJUSTES.includes(c.Reajuste) ? c.Reajuste : (c.Reajuste ? 'Outro' : '')
editError.value = '' editError.value = ''
showEdit.value = true showEdit.value = true
} }
@@ -321,7 +337,11 @@ async function downloadArquivo(contractId: string, fileId: string, nome: string)
</div> </div>
<div class="field"> <div class="field">
<label>Reajuste</label> <label>Reajuste</label>
<UInput v-model="createForm.reajuste" placeholder="Ex: IPCA" class="w-full" /> <select v-model="createReajusteSelect" class="field-select">
<option value="" disabled>Selecione</option>
<option v-for="r in REAJUSTES" :key="r" :value="r">{{ r }}</option>
</select>
<UInput v-if="createReajusteSelect === 'Outro'" v-model="createForm.reajuste" placeholder="Especifique o índice" class="w-full" style="margin-top:6px" />
</div> </div>
<div class="field"> <div class="field">
<label>Prorrogação Máxima</label> <label>Prorrogação Máxima</label>
@@ -386,7 +406,11 @@ async function downloadArquivo(contractId: string, fileId: string, nome: string)
</div> </div>
<div class="field"> <div class="field">
<label>Reajuste</label> <label>Reajuste</label>
<UInput v-model="editForm.reajuste" class="w-full" /> <select v-model="editReajusteSelect" class="field-select">
<option value="" disabled>Selecione</option>
<option v-for="r in REAJUSTES" :key="r" :value="r">{{ r }}</option>
</select>
<UInput v-if="editReajusteSelect === 'Outro'" v-model="editForm.reajuste" placeholder="Especifique o índice" class="w-full" style="margin-top:6px" />
</div> </div>
<div class="field"> <div class="field">
<label>Prorrogação Máxima</label> <label>Prorrogação Máxima</label>