todos cruds funcionais e com evidencias
This commit is contained in:
parent
1d05933646
commit
78b43d8f04
@ -1,149 +1,219 @@
|
||||
<template>
|
||||
<v-dialog v-model="isOpen" max-width="500px" @close="closeModal">
|
||||
<v-form>
|
||||
<v-card class="pa-6 rounded-xl elevation-2 card-modal">
|
||||
<v-card-title class="text-h5 font-weight-bold pb-0">
|
||||
<span class="text-h5">Adicionar Nova Empresa</span>
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<v-container>
|
||||
<v-row>
|
||||
<v-dialog v-model="isOpen" max-width="500px" @close="closeModal">
|
||||
<v-form ref="form" v-model="formValid">
|
||||
<v-card class="pa-6 rounded-xl elevation-2 card-modal">
|
||||
<v-card-title class="text-h5 font-weight-bold pb-0">
|
||||
<span class="text-h5">Adicionar Nova Empresa</span>
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<v-container>
|
||||
<v-row>
|
||||
<v-text class="text-h7">Dados básicos</v-text>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localCompany.name" label="Nome da Empresa *" clearable required />
|
||||
<v-text-field
|
||||
v-model="localCompany.name"
|
||||
label="Nome da Empresa *"
|
||||
clearable
|
||||
:rules="[rules.required]"
|
||||
required
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localCompany.fantasy_name" label="Nome Fantasia" clearable />
|
||||
<v-text-field
|
||||
v-model="localCompany.fantasy_name"
|
||||
label="Nome Fantasia *"
|
||||
clearable
|
||||
:rules="[rules.required]"
|
||||
required
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localCompany.cnpj" label="CNPJ *" clearable required />
|
||||
<v-text-field
|
||||
v-model="localCompany.cnpj"
|
||||
label="CNPJ *"
|
||||
clearable
|
||||
:rules="[rules.required]"
|
||||
required
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localCompany.type" label="Tipo" clearable />
|
||||
<v-text-field
|
||||
v-model="localCompany.type"
|
||||
label="Tipo *"
|
||||
clearable
|
||||
:rules="[rules.required]"
|
||||
required
|
||||
/>
|
||||
</v-col>
|
||||
<v-text class="text-h7">Contato</v-text>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localCompany.email" label="Email *" clearable required />
|
||||
<v-text-field
|
||||
v-model="localCompany.email"
|
||||
label="Email *"
|
||||
clearable
|
||||
:rules="[rules.required, rules.email]"
|
||||
required
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localCompany.email_sec" label="Email Secundário" clearable />
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localCompany.phone" label="Telefone *" clearable required />
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localCompany.phone_sec" label="Telefone Secundário" clearable />
|
||||
<v-text-field
|
||||
v-model="localCompany.phone"
|
||||
label="Telefone *"
|
||||
clearable
|
||||
:rules="[rules.required]"
|
||||
required
|
||||
/>
|
||||
</v-col>
|
||||
<v-text class="text-h7">Endereço</v-text>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localCompany.cep" label="CEP *" clearable />
|
||||
<v-text-field
|
||||
v-model="localCompany.cep"
|
||||
label="CEP *"
|
||||
clearable
|
||||
:rules="[rules.required]"
|
||||
required
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localCompany.rua" label="Rua *" clearable />
|
||||
<v-text-field
|
||||
v-model="localCompany.rua"
|
||||
label="Rua *"
|
||||
clearable
|
||||
:rules="[rules.required]"
|
||||
required
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localCompany.numero" label="Número *" clearable />
|
||||
<v-text-field
|
||||
v-model="localCompany.numero"
|
||||
label="Número *"
|
||||
clearable
|
||||
:rules="[rules.required]"
|
||||
required
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localCompany.bairro" label="Bairro *" clearable />
|
||||
<v-text-field
|
||||
v-model="localCompany.bairro"
|
||||
label="Bairro *"
|
||||
clearable
|
||||
:rules="[rules.required]"
|
||||
required
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localCompany.complemento" label="Complemento" clearable />
|
||||
<v-text-field
|
||||
v-model="localCompany.estado"
|
||||
label="Estado *"
|
||||
clearable
|
||||
:rules="[rules.required]"
|
||||
required
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localCompany.estado" label="Estado" clearable />
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localCompany.cidade" label="Cidade" clearable />
|
||||
<v-text-field
|
||||
v-model="localCompany.cidade"
|
||||
label="Cidade *"
|
||||
clearable
|
||||
:rules="[rules.required]"
|
||||
required
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<!--<FormFields :company="localCompany" />-->
|
||||
</v-container>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer />
|
||||
<v-btn text color="blue-darken-1" @click="closeModal">Cancelar</v-btn>
|
||||
<v-btn text class="text-white salvar-btn" @click="handleSave" :loading="companyStore.loading">
|
||||
Salvar
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-form>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { useCompanyStore } from '../../stores/company';
|
||||
import { useAuthStore } from '../../stores/auth';
|
||||
//import FormFields from './FormFields.vue'; // Campos de formulário extraídos (opcional)
|
||||
|
||||
const props = defineProps({
|
||||
isModalOpen: Boolean
|
||||
});
|
||||
const emit = defineEmits(['update:isModalOpen', 'company-created']);
|
||||
|
||||
const isOpen = ref(false);
|
||||
const companyStore = useCompanyStore();
|
||||
const authStore = useAuthStore();
|
||||
|
||||
const localCompany = ref({
|
||||
name: '',
|
||||
fantasy_name: '',
|
||||
type: '',
|
||||
cnpj: '',
|
||||
email: '',
|
||||
email_sec: '',
|
||||
phone: '',
|
||||
phone_sec: '',
|
||||
estado: '',
|
||||
cidade: '',
|
||||
bairro: '',
|
||||
rua: '',
|
||||
numero: '',
|
||||
complemento: '',
|
||||
cep: '',
|
||||
service_instance_id: authStore.service_instance_id || 2,
|
||||
parent_id: authStore.userId,
|
||||
});
|
||||
|
||||
watch(() => props.isModalOpen, (newVal) => {
|
||||
isOpen.value = newVal;
|
||||
if (newVal) {
|
||||
Object.assign(localCompany.value, {
|
||||
name: '',
|
||||
fantasy_name: '',
|
||||
type: '',
|
||||
cnpj: '',
|
||||
email: '',
|
||||
email_sec: '',
|
||||
phone: '',
|
||||
phone_sec: '',
|
||||
estado: '',
|
||||
cidade: '',
|
||||
bairro: '',
|
||||
rua: '',
|
||||
numero: '',
|
||||
complemento: '',
|
||||
cep: '',
|
||||
service_instance_id: authStore.service_instance_id || 2,
|
||||
parent_id: authStore.userId,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
watch(isOpen, (newVal) => {
|
||||
if (!newVal){
|
||||
emit('update:isModalOpen', false);
|
||||
}
|
||||
});
|
||||
|
||||
const closeModal = () => {
|
||||
isOpen.value = false;
|
||||
};
|
||||
|
||||
const handleSave = async (e) => {
|
||||
e.preventDefault(); // Impede o comportamento padrão do botão
|
||||
</v-container>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer />
|
||||
<v-btn text color="blue-darken-1" @click="closeModal">Cancelar</v-btn>
|
||||
<v-btn
|
||||
text
|
||||
class="text-white salvar-btn"
|
||||
:disabled="!formValid"
|
||||
@click="validateAndSave"
|
||||
:loading="companyStore.loading"
|
||||
>
|
||||
Salvar
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-form>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { useCompanyStore } from '../../stores/company';
|
||||
import { useAuthStore } from '../../stores/auth';
|
||||
|
||||
const props = defineProps({
|
||||
isModalOpen: Boolean,
|
||||
});
|
||||
const emit = defineEmits(['update:isModalOpen', 'company-created']);
|
||||
|
||||
const isOpen = ref(false);
|
||||
const companyStore = useCompanyStore();
|
||||
const authStore = useAuthStore();
|
||||
|
||||
const localCompany = ref({
|
||||
name: '',
|
||||
fantasy_name: '',
|
||||
type: '',
|
||||
cnpj: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
estado: '',
|
||||
cidade: '',
|
||||
bairro: '',
|
||||
rua: '',
|
||||
numero: '',
|
||||
cep: '',
|
||||
service_instance_id: authStore.service_instance_id || 2,
|
||||
parent_id: authStore.userId,
|
||||
});
|
||||
|
||||
const rules = {
|
||||
required: (value) => !!value || 'Campo obrigatório',
|
||||
email: (value) => /.+@.+\..+/.test(value) || 'E-mail inválido',
|
||||
};
|
||||
|
||||
const form = ref(null);
|
||||
const formValid = ref(false);
|
||||
|
||||
|
||||
watch(() => props.isModalOpen, (newVal) => {
|
||||
isOpen.value = newVal;
|
||||
if (newVal) {
|
||||
Object.assign(localCompany.value, {
|
||||
name: '',
|
||||
fantasy_name: '',
|
||||
type: '',
|
||||
cnpj: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
estado: '',
|
||||
cidade: '',
|
||||
bairro: '',
|
||||
rua: '',
|
||||
numero: '',
|
||||
cep: '',
|
||||
service_instance_id: authStore.service_instance_id || 2,
|
||||
parent_id: authStore.userId,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
watch(isOpen, (newVal) => {
|
||||
if (!newVal) {
|
||||
emit('update:isModalOpen', false);
|
||||
}
|
||||
});
|
||||
|
||||
const closeModal = () => {
|
||||
isOpen.value = false;
|
||||
};
|
||||
|
||||
const validateAndSave = async () => {
|
||||
if (form.value.validate()) {
|
||||
try {
|
||||
await companyStore.createCompany(localCompany.value);
|
||||
emit('company-created');
|
||||
@ -151,9 +221,11 @@
|
||||
} catch (error) {
|
||||
console.error('Erro ao criar empresa:', error);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.card-modal {
|
||||
background-color: #FFFFFF;
|
||||
border-radius: 16px;
|
||||
|
||||
@ -46,8 +46,8 @@
|
||||
/>-->
|
||||
<v-card-actions>
|
||||
<v-spacer />
|
||||
<v-btn text color="blue-darken-1" @click="closeModal">Cancelar</v-btn>
|
||||
<v-btn text class="text-white salvar-btn" @click="handleSave" :loading="companyStore.loading">
|
||||
<v-btn text color="blue-darken-1" @click="close">Cancelar</v-btn>
|
||||
<v-btn text class="text-white salvar-btn" @click="submit" :loading="shiftStore.loading">
|
||||
Salvar
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
@ -112,15 +112,6 @@ function submit() {
|
||||
close()
|
||||
}
|
||||
|
||||
const handleSave = async () => {
|
||||
try {
|
||||
await companyStore.createCompany(localCompany.value);
|
||||
emit('company-created');
|
||||
closeModal();
|
||||
} catch (error) {
|
||||
console.error('Erro ao criar empresa:', error);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
.card-modal {
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn text color="blue-darken-1" @click="closeModal">Cancelar</v-btn>
|
||||
<v-btn text color="blue-darken-1" @click="$emit('cancel')">Cancelar</v-btn>
|
||||
<v-btn text class="text-white salvar-btn" @click="handleSave" :loading="holidayStore.loading">
|
||||
Salvar
|
||||
</v-btn>
|
||||
|
||||
@ -1,39 +1,42 @@
|
||||
<template>
|
||||
<v-dialog :model-value="modalValue" @update:model-value="updateModalValue" max-width="500px">
|
||||
<v-card class="pa-6 rounded-xl elevation-2 card-modal">
|
||||
<v-card-title class="text-h5 font-weight-bold pb-0">
|
||||
<span class="text-h5">Adicionar Novo Feriado</span>
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<v-container>
|
||||
<v-row>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localHoliday.name" label="Feriado *" clearable required />
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localHoliday.type" label="Tipo do Feriado *" clearable required />
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localHoliday.date" label="Data do feriado *" type="date" clearable
|
||||
:rules="[v => !!v || 'Data é obrigatória']" required />
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localHoliday.municipio" label="Municipio" type="municipio" clearable />
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localHoliday.estado" label="Estado" type="estado" clearable />
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn text color="blue-darken-1" @click.prevent.stop="closeModal">Cancelar</v-btn>
|
||||
<v-btn text class="text-white salvar-btn" @click="handleSave" :loading="holidayStore.loading">
|
||||
Salvar
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
<v-form ref="form" v-model="formValid">
|
||||
<v-card class="pa-6 rounded-xl elevation-2 card-modal">
|
||||
<v-card-title class="text-h5 font-weight-bold pb-0">
|
||||
<span class="text-h5">Adicionar Novo Feriado</span>
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<v-container>
|
||||
<v-row>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localHoliday.name" label="Feriado *" clearable :rules="[rules.required]" required />
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localHoliday.type" label="Tipo do Feriado *" clearable :rules="[rules.required]" required />
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localHoliday.date" label="Data do feriado *" type="date" clearable
|
||||
:rules="[v => !!v || 'Data é obrigatória']" required />
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localHoliday.municipio" label="Municipio" type="municipio" :rules="[rules.required]" clearable required/>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-text-field v-model="localHoliday.estado" label="Estado" type="estado" clearable :rules="[rules.required]" required/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn text color="blue-darken-1" @click="$emit('cancel')">Cancelar</v-btn>
|
||||
<v-btn text class="text-white salvar-btn" :disabled="!formValid"
|
||||
@click="handleSave" :loading="holidayStore.loading">
|
||||
Salvar
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-form>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
@ -64,6 +67,12 @@ const defaultHoliday = {
|
||||
parent_id: authStore.userId,
|
||||
service_instance_id: authStore.service_instance_id || 2
|
||||
};
|
||||
const rules = {
|
||||
required: (value) => !!value || 'Campo obrigatório'
|
||||
};
|
||||
|
||||
const form = ref(null);
|
||||
const formValid = ref(false);
|
||||
|
||||
// Estado local do feriado
|
||||
const localHoliday = ref({...defaultHoliday});
|
||||
@ -107,24 +116,25 @@ const closeModal = () => {
|
||||
|
||||
// Salvar o novo feriado
|
||||
const handleSave = async (event) => {
|
||||
event.preventDefault(); // Impede o comportamento padrão do botão
|
||||
try {
|
||||
const holidayData = {
|
||||
...localHoliday.value,
|
||||
parent_id: authStore.userId,
|
||||
service_instance_id: authStore.service_instance_id || 2
|
||||
};
|
||||
|
||||
console.log('Criando novo feriado:', holidayData);
|
||||
|
||||
await holidayStore.createHoliday(holidayData);
|
||||
|
||||
emit('save', holidayData);
|
||||
emit('update:modalValue', false);
|
||||
resetLocalHoliday();
|
||||
} catch (error) {
|
||||
console.error('Erro ao criar feriado:', error);
|
||||
}
|
||||
if(form.value.validate()){
|
||||
event.preventDefault(); // Impede o comportamento padrão do botão
|
||||
try {
|
||||
const holidayData = {
|
||||
...localHoliday.value,
|
||||
parent_id: authStore.userId,
|
||||
service_instance_id: authStore.service_instance_id || 2
|
||||
};
|
||||
|
||||
console.log('Criando novo feriado:', holidayData);
|
||||
|
||||
await holidayStore.createHoliday(holidayData);
|
||||
|
||||
emit('save', holidayData);
|
||||
emit('update:modalValue', false);
|
||||
resetLocalHoliday();
|
||||
} catch (error) {
|
||||
console.error('Erro ao criar feriado:', error);
|
||||
}}
|
||||
};
|
||||
|
||||
// Inicialização do componente
|
||||
|
||||
@ -68,8 +68,8 @@ export const useCompanyStore = defineStore('company', {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
print('response.data', response.data);
|
||||
print('compony', companyData);
|
||||
//print('response.data', response.data);
|
||||
//print('compony', companyData);
|
||||
this.companys.push(response.data);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
|
||||
@ -158,7 +158,6 @@ import { useRouter } from 'vue-router';
|
||||
import cameraModal from '../components/modals/CameraModal.vue';
|
||||
import ambienteModal from '../components/modals/AmbienteModal.vue';
|
||||
import {cameraService} from '../services/camera';
|
||||
import AmbienteModal from '../components/modals/AmbienteModal.vue';
|
||||
|
||||
|
||||
export default {
|
||||
|
||||
@ -79,10 +79,12 @@
|
||||
:isEditMode="isEditing"
|
||||
:holiday="forms.holiday"
|
||||
@save="submitForm"
|
||||
/>
|
||||
<CreateHolidayModal
|
||||
v-model="dialogs.createholiday"
|
||||
@cancel="closeHolidayModal"
|
||||
/>
|
||||
<CreateHolidayModal
|
||||
v-model="dialogs.createholiday"
|
||||
@save="SubmitFormCreate"
|
||||
@cancel="closeCreateModal"
|
||||
/>
|
||||
<!-- Diálogo de Confirmação de Exclusão -->
|
||||
<v-dialog v-model="dialogs.delete" max-width="400px">
|
||||
@ -323,6 +325,12 @@
|
||||
dialogs.value.createholiday = true
|
||||
};
|
||||
|
||||
const closeHolidayModal = () => {
|
||||
dialogs.value.holiday = false;
|
||||
};
|
||||
const closeCreateModal = () => {
|
||||
dialogs.value.createholiday = false;
|
||||
};
|
||||
|
||||
const openEditPage = (type, item) => {
|
||||
console.log('Feriado que será editado:', item); // Log para depuração
|
||||
@ -495,6 +503,8 @@
|
||||
deleteItem,
|
||||
openEditPage,
|
||||
openCreateModal,
|
||||
closeHolidayModal,
|
||||
closeCreateModal,
|
||||
// filtercameras,
|
||||
//exportToCSV,
|
||||
handleholidayUpdated
|
||||
|
||||
Loading…
Reference in New Issue
Block a user