mudança arquivos js e user.vue e modal user
This commit is contained in:
parent
78b43d8f04
commit
fdbb7907af
@ -3,7 +3,7 @@
|
|||||||
<v-form ref="form" v-model="formValid">
|
<v-form ref="form" v-model="formValid">
|
||||||
<v-card class="pa-6 rounded-xl elevation-2 card-modal">
|
<v-card class="pa-6 rounded-xl elevation-2 card-modal">
|
||||||
<v-card-title class="text-h5 font-weight-bold pb-0">
|
<v-card-title class="text-h5 font-weight-bold pb-0">
|
||||||
<span class="text-h5">Adicionar Nova Empresa</span>
|
<span class="text-h5 font-weight-bold pb-0">Adicionar Nova Empresa</span>
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-container>
|
<v-container>
|
||||||
|
|||||||
@ -1,32 +1,112 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-dialog v-model="isOpen" max-width="500px" @close="closeModal">
|
<v-dialog v-model="isOpen" max-width="900px" @close="closeModal">
|
||||||
<v-card class="pa-6 rounded-xl elevation-2 card-modal">
|
<v-card class="pa-6 rounded-xl elevation-2 card-modal">
|
||||||
<v-card-title class="text-h5 font-weight-bold pb-0">
|
<v-card-title class="text-h5 font-weight-bold pb-0">
|
||||||
<span class="text-h5">{{ isEditMode ? 'Editar Usuário' : 'Adicionar Novo Usuário' }}</span>
|
<span class="text-h5 font-weight-bold pb-0">{{ isEditMode ? 'Editar Usuário' : 'Adicionar Novo Usuário' }}</span>
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-container>
|
<v-container>
|
||||||
<v-row>
|
<v-row>
|
||||||
|
|
||||||
|
<!-- Dados Básicos -->
|
||||||
|
<v-col cols="12">
|
||||||
|
<h3 class="text-body-1 text-grey-darken-1 pb-4">Dados Básicos</h3>
|
||||||
|
</v-col>
|
||||||
<v-col cols="12">
|
<v-col cols="12">
|
||||||
<v-text-field v-model="localUser.username" label="Usuário *" clearable
|
<v-text-field v-model="localUser.username" label="Usuário *" clearable
|
||||||
:rules="[v => !!v || 'Usuário é obrigatório']" required />
|
:rules="[v => !!v || 'Usuário é obrigatório']" required />
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="12">
|
<v-col cols="12" md="4">
|
||||||
<v-text-field v-model="localUser.email" label="Email *" type="email" clearable
|
|
||||||
:rules="[v => !!v || 'Email é obrigatório', v => /.+@.+\..+/.test(v) || 'Email inválido']" required />
|
|
||||||
</v-col>
|
|
||||||
<v-col cols="12">
|
|
||||||
<v-text-field v-model="localUser.password" label="Senha *" type="password" clearable
|
|
||||||
:rules="[v => !(!isEditMode && !v) || 'Senha é obrigatória']" :disabled="isEditMode" required />
|
|
||||||
</v-col>
|
|
||||||
<v-col cols="12">
|
|
||||||
<v-text-field v-model="localUser.birth_date" label="Data de Nascimento *" type="date" clearable
|
<v-text-field v-model="localUser.birth_date" label="Data de Nascimento *" type="date" clearable
|
||||||
:rules="[v => !!v || 'Data de nascimento é obrigatória']" required />
|
:rules="[v => !!v || 'Data de nascimento é obrigatória']" required />
|
||||||
</v-col>
|
</v-col>
|
||||||
|
<v-col cols="12" md="4">
|
||||||
|
<v-text-field v-model="localUser.cpf" label="CPF" clearable />
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="4">
|
||||||
|
<v-text-field v-model="localUser.pis" label="PIS" clearable />
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="4">
|
||||||
|
<v-text-field v-model="localUser.rg" label="RG" clearable />
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="6">
|
||||||
|
<v-text-field v-model="localUser.codigo_interno" label="Código Interno" clearable />
|
||||||
|
</v-col>
|
||||||
|
<!--Contato-->
|
||||||
<v-col cols="12">
|
<v-col cols="12">
|
||||||
|
<h3 class="text-body-1 text-grey-darken-1 pb-4">Contato</h3>
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="6">
|
||||||
|
<v-text-field v-model="localUser.email" label="Email *" type="email" clearable
|
||||||
|
:rules="[v => !!v || 'Email é obrigatório', v => /.+@.+\..+/.test(v) || 'Email inválido']" required />
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="6">
|
||||||
|
<v-text-field v-model="localUser.email_secundario" label="E-mail Secundário" type="email" clearable />
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="6">
|
||||||
<v-text-field v-model="localUser.phone" label="Telefone *" type="tel" clearable
|
<v-text-field v-model="localUser.phone" label="Telefone *" type="tel" clearable
|
||||||
:rules="[v => !!v || 'Telefone é obrigatório', v => /^[0-9]+$/.test(v) || 'Apenas números permitidos']" />
|
:rules="[v => !!v || 'Telefone é obrigatório', v => /^[0-9]+$/.test(v) || 'Apenas números permitidos']" />
|
||||||
</v-col>
|
</v-col>
|
||||||
|
<v-col cols="12" md="6">
|
||||||
|
<v-text-field v-model="localUser.telefone_secundario" label="Telefone Secundário" type="tel" clearable />
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<!--Endereço-->
|
||||||
|
<v-col cols="12">
|
||||||
|
<h3 class="text-body-1 text-grey-darken-1 pb-4">Endereço</h3>
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="4">
|
||||||
|
<v-text-field v-model="localUser.cep" label="CEP" clearable />
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="8">
|
||||||
|
<v-text-field v-model="localUser.rua" label="Rua" clearable />
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="4">
|
||||||
|
<v-text-field v-model="localUser.numero" label="Número" clearable />
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="4">
|
||||||
|
<v-text-field v-model="localUser.bairro" label="Bairro" clearable />
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="4">
|
||||||
|
<v-text-field v-model="localUser.complemento" label="Complemento" clearable />
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="6">
|
||||||
|
<v-text-field v-model="localUser.estado" label="Estado" clearable />
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="6">
|
||||||
|
<v-text-field v-model="localUser.cidade" label="Cidade" clearable />
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<!-- Informações do trabalho -->
|
||||||
|
<v-col cols="12">
|
||||||
|
<h3 class="text-body-1 text-grey-darken-1 pb-4">Informações do Trabalho</h3>
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="6">
|
||||||
|
<v-select v-model="localUser.empresa" :items="empresas" label="Empresa" clearable />
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="6">
|
||||||
|
<v-select v-model="localUser.cargo" :items="cargos" label="Cargo" clearable />
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="6">
|
||||||
|
<v-select v-model="localUser.setor" :items="setores" label="Setor" clearable />
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="6">
|
||||||
|
<v-select v-model="localUser.escala" :items="escalas" label="Escala" clearable />
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="6">
|
||||||
|
<v-select v-model="localUser.feriado" :items="feriados" label="Feriado" clearable />
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" md="6">
|
||||||
|
<v-select v-model="localUser.fuso_horario" :items="fusosHorarios" label="Fuso Horário" clearable />
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<!--Login usuario-->
|
||||||
|
|
||||||
|
|
||||||
|
<v-col cols="12">
|
||||||
|
<v-text-field v-model="localUser.password" label="Senha *" type="password" clearable
|
||||||
|
:rules="[v => !(!isEditMode && !v) || 'Senha é obrigatória']" :disabled="isEditMode" required />
|
||||||
|
</v-col>
|
||||||
<v-col cols="12">
|
<v-col cols="12">
|
||||||
<v-text-field v-model="localUser.profile_image" label="URL da Imagem de Perfil" type="url" clearable />
|
<v-text-field v-model="localUser.profile_image" label="URL da Imagem de Perfil" type="url" clearable />
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|||||||
@ -1,12 +1,24 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
import { useAuthStore } from '../stores/auth' // Importa o AuthStor
|
||||||
|
|
||||||
const API_URL = 'http://127.0.0.1:5000'
|
const API_URL = 'http://127.0.0.1:5000'
|
||||||
|
|
||||||
export const cameraService = {
|
export const cameraService = {
|
||||||
async getAllCameras() {
|
async getAllCameras() {
|
||||||
try {
|
try {
|
||||||
|
const authStore = useAuthStore();
|
||||||
|
const service_instance_id = authStore.service_instance_id; // Obtém o ID da instância de serviço do stor
|
||||||
const response = await axios.get(`${API_URL}/camera/`)
|
const response = await axios.get(`${API_URL}/camera/`)
|
||||||
return response.data.cameras
|
console.log('Câmeras recebidas:', response.data) // Exibe as câmeras recebidas no console
|
||||||
|
console.log('ID da instância de serviço:', service_instance_id) // Exibe o ID da instância de serviço no console
|
||||||
|
const filteredCameras = response.data.cameras.filter(camera => {
|
||||||
|
// Filtra câmeras que não estão deletadas
|
||||||
|
return String(camera.service_instance_id) === String(service_instance_id)
|
||||||
|
})
|
||||||
|
this.cameras = filteredCameras // Atualiza o estado com as câmeras filtradas
|
||||||
|
console.log('Câmeras filtradas:', filteredCameras) // Exibe as câmeras filtradas no console
|
||||||
|
return filteredCameras
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erro ao buscar câmeras:', error)
|
console.error('Erro ao buscar câmeras:', error)
|
||||||
throw error
|
throw error
|
||||||
|
|||||||
@ -29,7 +29,7 @@ export const useHolidayStore = defineStore('holidays', {
|
|||||||
|
|
||||||
async fetchHolidays() {
|
async fetchHolidays() {
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
const serviceInstanceId = authStore.getInstance;
|
const serviceInstanceId = authStore.service_instance_id;// Exibe o ID da instância de serviço no console
|
||||||
if (!serviceInstanceId) {
|
if (!serviceInstanceId) {
|
||||||
this.error = 'Nenhuma instância de serviço selecionada';
|
this.error = 'Nenhuma instância de serviço selecionada';
|
||||||
return;
|
return;
|
||||||
@ -37,15 +37,21 @@ export const useHolidayStore = defineStore('holidays', {
|
|||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
try {
|
try {
|
||||||
console.log('cheguei aqui3');
|
|
||||||
const response = await api.get('/holiday/', {
|
const response = await api.get('/holiday/', {
|
||||||
params: {}
|
params: {}
|
||||||
});
|
});
|
||||||
this.$patch({
|
const filteredHolidays = response.data.holiday_list.filter(holiday => {
|
||||||
holidays: response.data.holiday_list, // <- CORREÇÃO AQUI!
|
return String(holiday.service_instance_id) === String(serviceInstanceId);
|
||||||
});
|
});
|
||||||
console.log(response.data.holiday_list); // Log correto para debug
|
|
||||||
return response.data.holiday_list;
|
console.log('Requisição de feriados:', response.data);
|
||||||
|
console.log('filtrados', filteredHolidays); // Exibe os feriados filtrados no console
|
||||||
|
|
||||||
|
this.$patch({
|
||||||
|
holidays: filteredHolidays,
|
||||||
|
//holidays: response.data.holiday_list, //
|
||||||
|
});
|
||||||
|
return filteredHolidays;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const status = error?.response?.status;
|
const status = error?.response?.status;
|
||||||
if (status === 401) {
|
if (status === 401) {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { defineStore } from 'pinia';
|
|||||||
import api from '../services/api';
|
import api from '../services/api';
|
||||||
import router from '../routes/router';
|
import router from '../routes/router';
|
||||||
import { useAuthStore } from './auth';
|
import { useAuthStore } from './auth';
|
||||||
|
import { ca } from 'date-fns/locale';
|
||||||
|
|
||||||
export const useShiftStore = defineStore('shifts', {
|
export const useShiftStore = defineStore('shifts', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
@ -28,36 +29,42 @@ export const useShiftStore = defineStore('shifts', {
|
|||||||
*/
|
*/
|
||||||
async fetchShifts() {
|
async fetchShifts() {
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
const serviceInstanceId = authStore.getInstance;
|
const serviceInstanceId = authStore.service_instance_id;
|
||||||
|
|
||||||
if (!serviceInstanceId) {
|
if (!serviceInstanceId) {
|
||||||
this.error = 'Nenhuma instância de serviço selecionada';
|
this.error = 'Nenhuma instância de serviço selecionada';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await api.get('/shift/', {
|
const response = await api.get('/shift/', {
|
||||||
params: {}
|
params: {}
|
||||||
});
|
});
|
||||||
|
console.log('Requisição de turnos:', response.data);
|
||||||
|
console.log('ID da instância de serviço:', serviceInstanceId); // Exibe o ID da instância de serviço no console
|
||||||
|
// Filtra os shifts que pertencem à serviceInstanceId
|
||||||
|
const filteredShifts = response.data.filter(shift => {
|
||||||
|
return String(shift.service_instance_id) === String(serviceInstanceId);
|
||||||
|
});
|
||||||
|
console.log('Turnos filtrados:', filteredShifts); // Exibe os turnos filtrados no console
|
||||||
this.$patch({
|
this.$patch({
|
||||||
shifts: response.data,
|
shifts: filteredShifts,
|
||||||
//total: response.data,
|
//total: response.data,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(response.data);
|
console.log('Shifts filtrados:', filteredShifts);
|
||||||
return response.data;
|
return filteredShifts;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const status = error?.response?.status;
|
const status = error?.response?.status;
|
||||||
|
|
||||||
if (status === 401) {
|
if (status === 401) {
|
||||||
console.warn('Não autorizado. Redirecionando para login...');
|
console.warn('Não autorizado. Redirecionando para login...');
|
||||||
router.push('/login');
|
router.push('/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.error = error?.response?.data?.message || error.message || 'Erro ao buscar turnos';
|
this.error = error?.response?.data?.message || error.message || 'Erro ao buscar turnos';
|
||||||
console.error('Erro ao buscar turnos', error);
|
console.error('Erro ao buscar turnos', error);
|
||||||
throw error;
|
throw error;
|
||||||
@ -65,12 +72,26 @@ export const useShiftStore = defineStore('shifts', {
|
|||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/*
|
||||||
async getShifts() {
|
async getShifts() {
|
||||||
const response = await api.get('/shift/');
|
try{
|
||||||
console.log('shifts', response.data);
|
const authStore = useAuthStore();
|
||||||
return response.data;
|
const service_instance_id = authStore.service_instance_id; // Obtém o ID da instância de serviço do store
|
||||||
},
|
const response = await api.get('/shift/');
|
||||||
|
console.log('Escalas recebidas:', response.data) // Exibe as câmeras recebidas no console
|
||||||
|
console.log('ID da instância de serviço:', service_instance_id) // Exibe o ID da instância de serviço no console
|
||||||
|
|
||||||
|
const filteredShifts = response.data.filter(shift => {
|
||||||
|
// Filtra câmeras que não estão deletadas
|
||||||
|
return String(shift.service_instance_id) === String(service_instance_id)
|
||||||
|
})
|
||||||
|
this.shifts = filteredShifts // Atualiza o estado com as câmeras filtradas
|
||||||
|
return filteredShifts
|
||||||
|
}catch (error) {
|
||||||
|
console.error('Erro ao buscar turnos:', error)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
},*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Busca um turno específico pelo ID
|
* Busca um turno específico pelo ID
|
||||||
|
|||||||
@ -279,7 +279,11 @@ export default {
|
|||||||
users: [
|
users: [
|
||||||
{ title: 'ID', key: 'id' },
|
{ title: 'ID', key: 'id' },
|
||||||
{ title: 'Usuário', key: 'username' },
|
{ title: 'Usuário', key: 'username' },
|
||||||
{ title: 'Email', key: 'email' },
|
{ title: 'Empresa', key: 'empresa' },
|
||||||
|
{ title: 'Cargo', key: 'cargo' },
|
||||||
|
{ title: 'Setor', key: 'setor' },
|
||||||
|
{ title: 'Escala', key: 'escala' },
|
||||||
|
{ title: 'Feriado', key: 'feriado' },
|
||||||
{ title: 'Status', key: 'status', align: 'center' },
|
{ title: 'Status', key: 'status', align: 'center' },
|
||||||
//{ title: 'Contrato', key: 'contrato' },
|
//{ title: 'Contrato', key: 'contrato' },
|
||||||
//{ title: 'Grupo', key: 'grupo' },
|
//{ title: 'Grupo', key: 'grupo' },
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user