sort tables ok
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
:background-color="sidebarBackground"
|
:background-color="sidebarBackground"
|
||||||
short-title="MD"
|
short-title="MD"
|
||||||
title="Finanzas"
|
title="Finanzas"
|
||||||
|
|
||||||
>
|
>
|
||||||
<notifications></notifications>
|
<notifications></notifications>
|
||||||
<template slot-scope="props" slot="links">
|
<template slot-scope="props" slot="links">
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ export default {
|
|||||||
// Axios module configuration (https://go.nuxtjs.dev/config-axios)
|
// Axios module configuration (https://go.nuxtjs.dev/config-axios)
|
||||||
axios: {
|
axios: {
|
||||||
//baseURL: "http://192.168.1.111:4000/api"
|
//baseURL: "http://192.168.1.111:4000/api"
|
||||||
baseURL:"http://localhost:4000/api"
|
// baseURL:"http://localhost:4000/api"
|
||||||
//baseURL:"https://finanzasm.herokuapp.com/api"
|
baseURL:"https://finanzasm.herokuapp.com/api"
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
icon
|
icon
|
||||||
size="sm"
|
size="sm"
|
||||||
class="btn-link"
|
class="btn-link"
|
||||||
@click="updateCompraClic($index)"
|
@click="updateCompraClic(row._id)"
|
||||||
>
|
>
|
||||||
<i class="el-icon-edit"></i>
|
<i class="el-icon-edit"></i>
|
||||||
</base-button>
|
</base-button>
|
||||||
@@ -134,6 +134,7 @@ export default {
|
|||||||
const axiosHeader = {
|
const axiosHeader = {
|
||||||
headers: {
|
headers: {
|
||||||
token: this.$store.state.auth.token,
|
token: this.$store.state.auth.token,
|
||||||
|
filtro:this.$store.state.filtro.fechas
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
this.$axios
|
this.$axios
|
||||||
@@ -183,9 +184,10 @@ export default {
|
|||||||
},
|
},
|
||||||
updateCompraClic(id) {
|
updateCompraClic(id) {
|
||||||
this.isUpdate = true;
|
this.isUpdate = true;
|
||||||
this.newCompra = JSON.parse(JSON.stringify(this.compras[id]));
|
var reg_edit = this.compras.filter((ic) => ic._id===id)[0];
|
||||||
|
this.newCompra = JSON.parse(JSON.stringify(reg_edit));
|
||||||
this.openForm = true;
|
this.openForm = true;
|
||||||
console.log("SJS")
|
console.log(reg_edit)
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteCompra(id) {
|
deleteCompra(id) {
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
<card title='Filtro general'>
|
||||||
|
<base-input label="Filtro de fechas" v-model="filtro.fechas"></base-input>
|
||||||
|
<base-input label="Número de presupuestos" type="number" v-model="filtro.npresupuesto"></base-input>
|
||||||
|
<base-button @click='guardarFiltro()' type="info">Guardar</base-button>
|
||||||
|
</card>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<card title="Categorias">
|
<card title="Categorias">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -123,7 +128,6 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { Table, TableColumn } from "element-ui";
|
import { Table, TableColumn } from "element-ui";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
middleware: "authenticated",
|
middleware: "authenticated",
|
||||||
components: {
|
components: {
|
||||||
@@ -133,6 +137,7 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
this.getCategorias();
|
this.getCategorias();
|
||||||
this.getMetodos();
|
this.getMetodos();
|
||||||
|
this.filtro=this.$store.state.filtro
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -178,9 +183,16 @@ export default {
|
|||||||
],
|
],
|
||||||
categorias: [],
|
categorias: [],
|
||||||
metodos: [],
|
metodos: [],
|
||||||
|
filtro:{
|
||||||
|
fechas:this.$store.state.filtro.fechas,
|
||||||
|
npresupuesto:this.$store.state.filtro.npresupuesto
|
||||||
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
guardarFiltro(){
|
||||||
|
this.$store.commit("actualizarFiltro",this.filtro)
|
||||||
|
},
|
||||||
enviarCategoria() {
|
enviarCategoria() {
|
||||||
const axiosHeader = {
|
const axiosHeader = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
middleware: 'authenticated',
|
middleware: 'authenticated',
|
||||||
|
mounted(){
|
||||||
|
$nuxt.$router.push("/compras")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
icon
|
icon
|
||||||
size="sm"
|
size="sm"
|
||||||
class="btn-link"
|
class="btn-link"
|
||||||
@click="updateIngresoClic($index)"
|
@click="updateIngresoClic(row._id)"
|
||||||
>
|
>
|
||||||
<i class="el-icon-edit"></i>
|
<i class="el-icon-edit"></i>
|
||||||
</base-button>
|
</base-button>
|
||||||
@@ -109,6 +109,7 @@ export default {
|
|||||||
const axiosHeader = {
|
const axiosHeader = {
|
||||||
headers: {
|
headers: {
|
||||||
token: this.$store.state.auth.token,
|
token: this.$store.state.auth.token,
|
||||||
|
filtro:this.$store.state.filtro.fechas
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
this.$axios
|
this.$axios
|
||||||
@@ -158,7 +159,8 @@ export default {
|
|||||||
},
|
},
|
||||||
updateIngresoClic(id) {
|
updateIngresoClic(id) {
|
||||||
this.isUpdate = true;
|
this.isUpdate = true;
|
||||||
this.newIngreso = JSON.parse(JSON.stringify(this.ingresos[id]));
|
var reg_edit = this.ingresos.filter((ic) => ic._id===id)[0];
|
||||||
|
this.newIngreso = JSON.parse(JSON.stringify(reg_edit));
|
||||||
this.openForm = !this.openForm;
|
this.openForm = !this.openForm;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -261,6 +261,7 @@ export default {
|
|||||||
const axiosHeader = {
|
const axiosHeader = {
|
||||||
headers: {
|
headers: {
|
||||||
token: this.$store.state.auth.token,
|
token: this.$store.state.auth.token,
|
||||||
|
limite:this.$store.state.filtro.npresupuesto
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
export const state = () => ({
|
export const state = () => ({
|
||||||
auth: null,
|
auth: null,
|
||||||
notifications: [],
|
notifications: [],
|
||||||
|
filtro: {fechas:fechaString().slice(0, 7),npresupuesto:5},
|
||||||
fecha: fechaString(),
|
fecha: fechaString(),
|
||||||
categorias:[],
|
categorias: [],
|
||||||
metodos_de_pago:[]
|
metodos_de_pago: []
|
||||||
});
|
});
|
||||||
|
|
||||||
export const mutations = {
|
|
||||||
|
|
||||||
|
export const mutations = {
|
||||||
setAuth(state, auth) {
|
setAuth(state, auth) {
|
||||||
state.auth = auth;
|
state.auth = auth;
|
||||||
},
|
},
|
||||||
@@ -23,23 +23,24 @@ export const state = () => ({
|
|||||||
setMetodos(state, metodos) {
|
setMetodos(state, metodos) {
|
||||||
state.metodos_de_pago = metodos;
|
state.metodos_de_pago = metodos;
|
||||||
},
|
},
|
||||||
|
actualizarFiltro(state,filtro) {
|
||||||
|
|
||||||
|
state.filtro=filtro
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
};
|
function fechaString() {
|
||||||
|
|
||||||
function fechaString(){
|
|
||||||
let data = new Date();
|
let data = new Date();
|
||||||
let year= data.getFullYear();
|
let year = data.getFullYear();
|
||||||
let month = (data.getMonth() + 1)<9?"0"+(data.getMonth() + 1):(data.getMonth() + 1)
|
let month =
|
||||||
let day = data.getDate()<9?"0"+data.getDate():data.getDate()
|
data.getMonth() + 1 < 9 ? "0" + (data.getMonth() + 1) : data.getMonth() + 1;
|
||||||
let dataF=`${year}-${month}-${day}`
|
let day = data.getDate() < 9 ? "0" + data.getDate() : data.getDate();
|
||||||
|
let dataF = `${year}-${month}-${day}`;
|
||||||
return dataF;
|
return dataF;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
|
|
||||||
readToken() {
|
readToken() {
|
||||||
let auth = null;
|
let auth = null;
|
||||||
try {
|
try {
|
||||||
@@ -51,44 +52,34 @@ export const actions = {
|
|||||||
this.commit("setAuth", auth);
|
this.commit("setAuth", auth);
|
||||||
},
|
},
|
||||||
getCategorias() {
|
getCategorias() {
|
||||||
|
|
||||||
const axiosHeader = {
|
const axiosHeader = {
|
||||||
headers: {
|
headers: {
|
||||||
token: this.state.auth.token
|
token: this.state.auth.token
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.$axios
|
||||||
this.$axios.get("/categoria", axiosHeader)
|
.get("/categoria", axiosHeader)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
|
||||||
this.commit("setCategorias", res.data.data);
|
this.commit("setCategorias", res.data.data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
}).catch(error => {
|
|
||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getMetodos() {
|
getMetodos() {
|
||||||
|
|
||||||
const axiosHeader = {
|
const axiosHeader = {
|
||||||
headers: {
|
headers: {
|
||||||
token: this.state.auth.token,
|
token: this.state.auth.token
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
this.$axios
|
this.$axios
|
||||||
.get("/metodo", axiosHeader)
|
.get("/metodo", axiosHeader)
|
||||||
.then((res) => {
|
.then(res => {
|
||||||
|
|
||||||
this.commit("setMetodos", res.data.data);
|
this.commit("setMetodos", res.data.data);
|
||||||
})
|
})
|
||||||
.catch((e) => console.log(e));
|
.catch(e => console.log(e));
|
||||||
|
},
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|||||||
@@ -5,8 +5,12 @@ const { checkAuth } = require("../middlewares/authentication");
|
|||||||
|
|
||||||
router.get("/compras", checkAuth, async (req, res) => {
|
router.get("/compras", checkAuth, async (req, res) => {
|
||||||
var compras;
|
var compras;
|
||||||
|
let miFiltro = req.get('filtro');
|
||||||
|
const filtros = {
|
||||||
|
fecha: { $regex: miFiltro, $options: "i" },
|
||||||
|
};
|
||||||
|
|
||||||
compras = await Compra.find({ user: req.userData._id }).sort({
|
compras = await Compra.find({$and:[{ user: req.userData._id },filtros]}).sort({
|
||||||
fecha: "desc",
|
fecha: "desc",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ const { checkAuth } = require("../middlewares/authentication");
|
|||||||
|
|
||||||
router.get("/ingreso", checkAuth, async (req, res) => {
|
router.get("/ingreso", checkAuth, async (req, res) => {
|
||||||
var Ingresos;
|
var Ingresos;
|
||||||
Ingresos = await Ingreso.find({ user: req.userData._id }).sort({
|
let miFiltro = req.get('filtro');
|
||||||
|
const filtros = {
|
||||||
|
fecha: { $regex: miFiltro, $options: "i" },
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Ingresos = await Ingreso.find({$and:[{ user: req.userData._id },filtros]}).sort({
|
||||||
fecha: "desc",
|
fecha: "desc",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ const { checkAuth } = require("../middlewares/authentication");
|
|||||||
|
|
||||||
router.get("/presupuesto", checkAuth, async (req, res) => {
|
router.get("/presupuesto", checkAuth, async (req, res) => {
|
||||||
var presupuestos;
|
var presupuestos;
|
||||||
|
let limite = req.get('limite');
|
||||||
presupuestos = await presupuesto.find({ user: req.userData._id }).sort({
|
presupuestos = await presupuesto.find({ user: req.userData._id }).sort({
|
||||||
date: "desc",
|
date: "desc",
|
||||||
});
|
}).limit(parseInt(limite));
|
||||||
|
|
||||||
|
|
||||||
return res.send({
|
return res.send({
|
||||||
status: "ok",
|
status: "ok",
|
||||||
|
|||||||
Reference in New Issue
Block a user