Skip to content

Commit

Permalink
RED-12 fechamento vencimento limite
Browse files Browse the repository at this point in the history
  • Loading branch information
sombriks committed Sep 8, 2023
1 parent fc749ea commit a2c80b8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
27 changes: 25 additions & 2 deletions web-app-vue/src/components/conta/detalhe-conta.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,29 @@
<v-text-field
:rules="[requiredRule]"
v-model="contaEdit.descricao"
label="Nome"
label="Descrição"
></v-text-field>
<v-text-field
v-if="contaEdit.tipo_conta_id == 3"
:rules="[dayOfMonthRule]"
v-model="contaEdit.dia_fechamento"
label="Fechamento"
prepend-inner-icon="mdi-calendar-check"
></v-text-field>
<v-text-field
v-if="contaEdit.tipo_conta_id == 3"
:rules="[dayOfMonthRule]"
v-model="contaEdit.dia_vencimento"
label="Vencimento"
prepend-inner-icon="mdi-calendar-alert"
></v-text-field>
<v-text-field
v-if="contaEdit.tipo_conta_id == 3"
:rules="[numberRule]"
type="number"
v-model="contaEdit.limite"
label="Limite"
prepend-inner-icon="mdi-cash-100"
></v-text-field>
<v-container>
<v-row align="center">
Expand Down Expand Up @@ -71,7 +93,7 @@
<script setup>
import { computed, reactive, ref } from 'vue'
import { useContaStore } from '@/stores/contaStore'
import { requiredRule } from '@/form-rules/basic-rules'
import { dayOfMonthRule, numberRule, requiredRule } from "@/form-rules/basic-rules";
const cState = useContaStore()
Expand All @@ -92,6 +114,7 @@ const contaIcon = computed(() => {
})
const doUpdate = async () => {
if(!valid.value) return
emit('onSave', contaEdit)
edit.value = !edit.value
}
Expand Down
17 changes: 14 additions & 3 deletions web-app-vue/src/form-rules/basic-rules.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
export const requiredRule = (value) => {
return !!value || 'Required field'
}

const dayOfMonth = [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31
]

export const dayOfMonthRule = (value) => {
return dayOfMonth.includes(parseInt(value)) || 'Must provide a valid day'
}

export const requiredRule = value => {
if(value) return true
return "Required field"
export const numberRule = (value) => {
return !value || !isNaN(value) || "Provide a valid number"
}

0 comments on commit a2c80b8

Please sign in to comment.