cambios del 24 de abril

This commit is contained in:
2021-04-25 15:55:18 -05:00
parent 2b01e58388
commit 48dfb5e64f
19 changed files with 542 additions and 6462 deletions

View File

@@ -2,7 +2,7 @@
<auth-layout class="not-found-page">
<div class="centered">
<h1><i class="not-found-icon nc-icon nc-puzzle-10"></i>404</h1>
<p>The page you requested could not be found.</p>
<p>The page you requested ccc could not be found.</p>
</div>
</auth-layout>
</template>

View File

@@ -1,6 +1,5 @@
<template>
<div>
<div class="row">
<card class="col-12">
<el-table
@@ -10,7 +9,7 @@
!search ||
data.detalle.toLowerCase().includes(search.toLowerCase()) ||
data.fecha.toLowerCase().includes(search.toLowerCase()) ||
data.metodo_pago.toLowerCase().includes(search.toLowerCase()) ||
data.metodopago.toLowerCase().includes(search.toLowerCase()) ||
data.categoria.toLowerCase().includes(search.toLowerCase())
)
"
@@ -22,7 +21,7 @@
</el-TableColumn>
<el-TableColumn prop="valor" label="Valor" sortable> </el-TableColumn>
<el-TableColumn prop="metodo_pago" label="Metodo de pago" sortable>
<el-TableColumn prop="metodopago" label="Metodo de pago" sortable>
</el-TableColumn>
<el-TableColumn prop="categoria" label="Categoria" sortable>
@@ -35,7 +34,7 @@
icon
size="sm"
class="btn-link"
@click="deleteCompra($index)"
@click="deleteCompra(row._id)"
>
<i class="el-icon-delete-solid"></i>
</base-button>
@@ -46,7 +45,7 @@
icon
size="sm"
class="btn-link"
@click="deleteCompra($index)"
@click="deleteCompra($_id)"
>
<i class="el-icon-edit"></i>
</base-button>
@@ -64,22 +63,20 @@
</el-table>
</card>
<Fcompras
<Fcompras
:categorias="categorias"
:metodos_pago="metodos_pago"
:newCompra="newCompra"
:saveCompra="saveCompra"
/>
/>
</div>
</div>
</template>
<script>
import { Table, TableColumn } from "element-ui";
import { Select, Option } from "element-ui";
export default {
middleware: "authenticated",
components: {
[Table.name]: Table,
[TableColumn.name]: TableColumn,
@@ -89,10 +86,10 @@ export default {
data() {
return {
newCompra: {
fecha:"",
fecha: "",
detalle: "",
valor: 0,
metodo_pago: "",
metodopago: "",
categoria: "",
},
compras: [],
@@ -122,27 +119,63 @@ export default {
};
},
mounted() {
this.getDate()
this.newCompra.fecha = this.$store.state.fecha;
this.getCompras();
},
methods: {
getCompras() {
const axiosHeader = {
headers: {
token: this.$store.state.auth.token,
},
};
this.$axios
.get("/compras", axiosHeader)
.then((res) => {
console.log(res.data.data);
this.compras = res.data.data;
})
.catch((e) => console.log(e));
},
saveCompra() {
var compra = JSON.stringify(this.newCompra);
this.compras.push(JSON.parse(compra));
console.log(compra);
const axiosHeader = {
headers: {
token: this.$store.state.auth.token,
},
};
const toSend = this.newCompra;
console.log(axiosHeader.data);
this.$axios
.post("/compra", toSend, axiosHeader)
.then((res) => {
this.clearFormCompra();
console.log(res.data.status);
this.getCompras();
})
.catch((e) => console.log(e));
},
deleteCompra(index) {
this.compras.splice(index, 1);
//console.log(index)
deleteCompra(id) {
const axiosHeader={
headers:{
token: this.$store.state.auth.token,
},
params:{
id:id
}
}
this.$axios.delete("/compra",axiosHeader).then(res=>{
console.log(res.data);
this.getCompras();
}).catch(e => console.log(e))
},
clearFormCompra() {
this.newCompra.detalle = "";
this.newCompra.valor = 0;
this.newCompra.metodopago = "";
this.newCompra.categoria = "";
},
getDate(){
let data = new Date();
let year= data.getFullYear();
let month = (data.getMonth() + 1)<9?"0"+(data.getMonth() + 1):(data.getMonth() + 1)
let day = data.getDate()<9?"0"+data.getDate():data.getDate()
let dataF=`${year}-${month}-${day}`
this.newCompra.fecha=dataF;
}
},
};
</script>

15
APP/pages/index.vue Normal file
View File

@@ -0,0 +1,15 @@
<template>
<div>
<Prueba />
</div>
</template>
<script>
export default {
middleware: 'authenticated',
}
</script>
<style>
</style>

View File

@@ -7,6 +7,7 @@
<script>
export default {
middleware: 'authenticated',
}
</script>

107
APP/pages/login.vue Normal file
View File

@@ -0,0 +1,107 @@
<template>
<div class="container login-page">
<div class="col-lg-4 col-md-6 ml-auto mr-auto">
<card class="card-login card-white">
<template slot="header">
<img src="img//card-info.png" alt="" />
<h1 class="card-title">Finanzas APP</h1>
</template>
<div>
<base-input
name="email"
v-model="user.email"
placeholder="Email"
addon-left-icon="tim-icons icon-email-85"
>
</base-input>
<base-input
name="password"
v-model="user.password"
type="password"
placeholder="Password"
addon-left-icon="tim-icons icon-lock-circle"
>
</base-input>
</div>
<div slot="footer">
<base-button
native-type="submit"
type="info"
class="mb-3"
size="lg"
@click="login()"
block
>
Login
</base-button>
</div>
</card>
</div>
</div>
</template>
<script>
const Cookie = process.client ? require("js-cookie") : undefined;
export default {
middleware: 'notAuthenticated',
name: "login-page",
layout: "auth",
data() {
return {
user: {
email: "",
password: ""
}
};
},
mounted() {
},
methods: {
login() {
this.$axios
.post("/login", this.user)
.then(res => {
//success! - Usuario creado.
//if (res.data.status == "success") {
this.$notify({
type: "success",
icon: "tim-icons icon-check-2",
message: "Success! Welcome " + res.data.userData.name
});
console.log(res.data)
const auth = {
token: res.data.token,
userData: res.data.userData
}
//token to de store - token a la tienda
this.$store.commit('setAuth', auth);
//set auth object in localStorage - Grabamos el token en localStorage
localStorage.setItem('auth', JSON.stringify(auth));
$nuxt.$router.push('/compras');
return;
//}
})
.catch(e => {
this.$notify({
type: "danger",
icon: "tim-icons icon-alert-circle-exc",
message: "Credenciales invalidas :("
});
return;
});
}
}
};
</script>
<style>
.navbar-nav .nav-item p {
line-height: inherit;
margin-left: 5px;
}
</style>

View File

@@ -4,6 +4,7 @@
<script>
export default {
middleware: 'authenticated',
}
</script>

105
APP/pages/register.vue Normal file
View File

@@ -0,0 +1,105 @@
<template>
<div class="container login-page">
<div class="col-lg-4 col-md-6 ml-auto mr-auto">
<card class="card-login card-white">
<template slot="header">
<img src="img//card-info.png" alt="" />
<h1 class="card-title">Finanzas APP</h1>
</template>
<div>
<base-input
name="name"
v-model="user.name"
placeholder="Name"
addon-left-icon="tim-icons icon-badge"
>
</base-input>
<base-input
name="email"
v-model="user.email"
placeholder="Email"
addon-left-icon="tim-icons icon-email-85"
>
</base-input>
<base-input
name="password"
v-model="user.password"
type="password"
placeholder="Password"
addon-left-icon="tim-icons icon-lock-circle"
>
</base-input>
</div>
<div slot="footer">
<base-button
native-type="submit"
type="info"
class="mb-3"
size="lg"
@click="register()"
block
>
Register
</base-button>
<div class="pull-left">
<h6>
<nuxt-link class="link footer-link" to="/login">
login
</nuxt-link>
</h6>
</div>
</div>
</card>
</div>
</div>
</template>
<script>
export default {
middleware: "notAuthenticated",
layout: "auth",
data() {
return {
user: {
name: "",
email: "",
password: "",
},
};
},
methods: {
register() {
this.$axios
.post("/register", this.user)
.then((res) => {
this.$notify({
type: "success",
icon: "tim-icons icon-check-2",
message: "Success! Now you can login...",
});
this.user.name = "";
this.user.password = "";
this.user.email = "";
})
.catch((e) => {
this.$notify({
type: "danger",
icon: "tim-icons icon-alert-circle-exc",
message: "User already exists :(",
});
});
},
},
};
</script>
<style>
.navbar-nav .nav-item p {
line-height: inherit;
margin-left: 5px;
}
</style>