Compare commits
30 Commits
0.1.3
...
7f73251c5e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f73251c5e | ||
|
|
3112c82bb2 | ||
|
|
6088623415 | ||
|
|
7731b2fbd6 | ||
|
|
d4421aece4 | ||
|
|
1c8638b8d4 | ||
|
|
72d81bdf47 | ||
| 0ba348cc64 | |||
| 4e79ecd56b | |||
| 4a67f85dcb | |||
| 173cf3771b | |||
| 173ddfd05f | |||
| c593dd0273 | |||
| c8460c8e81 | |||
|
|
3fdfc3c883 | ||
|
|
460e213e0e | ||
|
|
e192c3778a | ||
|
|
5c594ea563 | ||
| f22fcb6f16 | |||
| 1b84c5419f | |||
| 7fe137ce4f | |||
| e2ccfbcd5f | |||
| 459a028891 | |||
| 1c294a5ba6 | |||
| 8a855be105 | |||
| d89b79bfd0 | |||
| 5860411753 | |||
| a4dd8f98d8 | |||
| ed482542a4 | |||
| 8652e4778f |
2
.env.example
Normal file
2
.env.example
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
VITE_API_IMPLEMENTATION=django
|
||||||
|
VITE_DJANGO_BASE_URL=http://localhost:7000
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,6 +5,7 @@ node_modules
|
|||||||
# local env files
|
# local env files
|
||||||
.env.local
|
.env.local
|
||||||
.env.*.local
|
.env.*.local
|
||||||
|
.env
|
||||||
|
|
||||||
# Log files
|
# Log files
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
|
|||||||
81
AGENTS.md
Normal file
81
AGENTS.md
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
# Don Confiao - Frontend
|
||||||
|
|
||||||
|
## Tech Stack
|
||||||
|
- **Framework:** Vue 3 (Composition API)
|
||||||
|
- **UI Library:** Vuetify 3
|
||||||
|
- **Routing:** Vue Router 4 (auto-routes con `unplugin-vue-router`)
|
||||||
|
- **State:** Pinia
|
||||||
|
- **HTTP:** Axios
|
||||||
|
- **Build:** Vite
|
||||||
|
- **Linting:** ESLint
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
```
|
||||||
|
src/
|
||||||
|
├── assets/ # Imágenes, iconos estáticos
|
||||||
|
├── components/ # Componentes Vue reutilizables
|
||||||
|
├── layouts/ # Layouts de página
|
||||||
|
├── pages/ # Vistas (auto-routed desde文件名)
|
||||||
|
├── plugins/ # Configuración de Vuetify, etc.
|
||||||
|
├── router/ # Configuración de rutas
|
||||||
|
├── services/ # API services (auth.js, etc.)
|
||||||
|
├── stores/ # Pinia stores
|
||||||
|
└── styles/ # SCSS settings
|
||||||
|
```
|
||||||
|
|
||||||
|
## Important Conventions
|
||||||
|
|
||||||
|
### Auto-imports
|
||||||
|
- Componentes en `src/components/` se auto-importan por nombre
|
||||||
|
- Los archivos en `src/pages/*.vue` se routing automáticamente via `unplugin-vue-router`
|
||||||
|
- Alias `@` = `src/`
|
||||||
|
|
||||||
|
### Pages (CRITICAL)
|
||||||
|
**Siempre importar componentes en los archivos de página:**
|
||||||
|
```vue
|
||||||
|
<template>
|
||||||
|
<MiComponente />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import MiComponente from '@/components/MiComponente.vue';
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Componentes
|
||||||
|
- Usar Composition API (`<script setup>` o `export default { }`)
|
||||||
|
- Naming: PascalCase (ej: `LoginDialog.vue`, `CartGrid.vue`)
|
||||||
|
- Componentes de página van en `pages/`, componentes reutilizables en `components/`
|
||||||
|
|
||||||
|
### Servicios API
|
||||||
|
- Ubicación: `src/services/`
|
||||||
|
- Usar Axios para HTTP requests
|
||||||
|
- JWT tokens en localStorage (`access_token`, `refresh_token`)
|
||||||
|
|
||||||
|
### Routing
|
||||||
|
- Rutas automáticas basadas en archivos en `src/pages/`
|
||||||
|
- No requiere configuración manual en `router/index.js`
|
||||||
|
|
||||||
|
## Environment Variables
|
||||||
|
- `VITE_DJANGO_BASE_URL` - URL del backend Django
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
```bash
|
||||||
|
npm run dev # Desarrollo (puerto 3000)
|
||||||
|
npm run build # Producción
|
||||||
|
npm run preview # Preview build
|
||||||
|
npm run lint # ESLint fix
|
||||||
|
```
|
||||||
|
|
||||||
|
## Common Issues
|
||||||
|
1. **Página en blanco:** Verificar que los componentes en `src/pages/*.vue` tengan import explícito
|
||||||
|
2. **Errores de lint:** Ejecutar `npm run lint`
|
||||||
|
|
||||||
|
## Git Commits
|
||||||
|
**Antes de hacer commit:**
|
||||||
|
1. Pedir permiso al usuario
|
||||||
|
2. Mostrar resumen de los cambios que se incluirán
|
||||||
|
|
||||||
|
**Formato de mensajes:**
|
||||||
|
- Usar prefijo `#<numero>` para referenciar el issue (ej: `#28 feat: add login` donde #28 es el número del issue en GitHub/GitLab)
|
||||||
|
- Prefijos válidos: `feat`, `fix`, `chore`, `docs`, `refactor`, `style`
|
||||||
4
Rakefile
4
Rakefile
@@ -12,12 +12,12 @@ namespace :live do
|
|||||||
|
|
||||||
desc 'monitorear salida'
|
desc 'monitorear salida'
|
||||||
task :tail do
|
task :tail do
|
||||||
compose('logs', '-f', 'django', compose: DOCKER_COMPOSE)
|
compose('logs', '-f', 'frontend', compose: DOCKER_COMPOSE)
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'monitorear salida'
|
desc 'monitorear salida'
|
||||||
task :tail_end do
|
task :tail_end do
|
||||||
compose('logs', '-f', '-n 50', 'django', compose: DOCKER_COMPOSE)
|
compose('logs', '-f', '-n 50', 'frontend', compose: DOCKER_COMPOSE)
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'iniciar entorno'
|
desc 'iniciar entorno'
|
||||||
|
|||||||
@@ -7,4 +7,7 @@ services:
|
|||||||
- ./:/app/
|
- ./:/app/
|
||||||
ports:
|
ports:
|
||||||
- "7001:3000"
|
- "7001:3000"
|
||||||
|
environment:
|
||||||
|
- VITE_DJANGO_BASE_URL=http://localhost:7000
|
||||||
|
- VITE_API_IMPLEMENTATION=django
|
||||||
|
|
||||||
|
|||||||
220
package-lock.json
generated
220
package-lock.json
generated
@@ -9,6 +9,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mdi/font": "7.4.47",
|
"@mdi/font": "7.4.47",
|
||||||
|
"axios": "^1.13.5",
|
||||||
"core-js": "^3.37.1",
|
"core-js": "^3.37.1",
|
||||||
"roboto-fontface": "*",
|
"roboto-fontface": "*",
|
||||||
"vee-validate": "^4.14.6",
|
"vee-validate": "^4.14.6",
|
||||||
@@ -1503,6 +1504,12 @@
|
|||||||
"node": ">=16.14.0"
|
"node": ">=16.14.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/asynckit": {
|
||||||
|
"version": "0.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||||
|
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/available-typed-arrays": {
|
"node_modules/available-typed-arrays": {
|
||||||
"version": "1.0.7",
|
"version": "1.0.7",
|
||||||
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz",
|
||||||
@@ -1519,6 +1526,17 @@
|
|||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/axios": {
|
||||||
|
"version": "1.13.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/axios/-/axios-1.13.5.tgz",
|
||||||
|
"integrity": "sha512-cz4ur7Vb0xS4/KUN0tPWe44eqxrIu31me+fbang3ijiNscE129POzipJJA6zniq2C/Z6sJCjMimjS8Lc/GAs8Q==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"follow-redirects": "^1.15.11",
|
||||||
|
"form-data": "^4.0.5",
|
||||||
|
"proxy-from-env": "^1.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/babel-eslint": {
|
"node_modules/babel-eslint": {
|
||||||
"version": "10.1.0",
|
"version": "10.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.1.0.tgz",
|
||||||
@@ -1667,6 +1685,19 @@
|
|||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/call-bind-apply-helpers": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
|
||||||
|
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"es-errors": "^1.3.0",
|
||||||
|
"function-bind": "^1.1.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/callsites": {
|
"node_modules/callsites": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
|
||||||
@@ -1752,6 +1783,18 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/combined-stream": {
|
||||||
|
"version": "1.0.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||||
|
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"delayed-stream": "~1.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/concat-map": {
|
"node_modules/concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||||
@@ -1941,6 +1984,15 @@
|
|||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/delayed-stream": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/doctrine": {
|
"node_modules/doctrine": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
|
||||||
@@ -1954,6 +2006,20 @@
|
|||||||
"node": ">=6.0.0"
|
"node": ">=6.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/dunder-proto": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"call-bind-apply-helpers": "^1.0.1",
|
||||||
|
"es-errors": "^1.3.0",
|
||||||
|
"gopd": "^1.2.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/entities": {
|
"node_modules/entities": {
|
||||||
"version": "4.5.0",
|
"version": "4.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
|
||||||
@@ -2028,14 +2094,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/es-define-property": {
|
"node_modules/es-define-property": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
||||||
"integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==",
|
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
|
||||||
"get-intrinsic": "^1.2.4"
|
|
||||||
},
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
}
|
}
|
||||||
@@ -2044,17 +2106,15 @@
|
|||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
|
||||||
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
|
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/es-object-atoms": {
|
"node_modules/es-object-atoms": {
|
||||||
"version": "1.0.0",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
|
||||||
"integrity": "sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==",
|
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"es-errors": "^1.3.0"
|
"es-errors": "^1.3.0"
|
||||||
@@ -2064,15 +2124,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/es-set-tostringtag": {
|
"node_modules/es-set-tostringtag": {
|
||||||
"version": "2.0.3",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
|
||||||
"integrity": "sha512-3T8uNMC3OQTHkFUsFq8r/BwAXLHvU/9O9mE0fBc/MY5iq/8H7ncvO947LmYA6ldWw9Uh8Yhf25zu6n7nML5QWQ==",
|
"integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"get-intrinsic": "^1.2.4",
|
"es-errors": "^1.3.0",
|
||||||
|
"get-intrinsic": "^1.2.6",
|
||||||
"has-tostringtag": "^1.0.2",
|
"has-tostringtag": "^1.0.2",
|
||||||
"hasown": "^2.0.1"
|
"hasown": "^2.0.2"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
@@ -2851,6 +2911,26 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
|
"node_modules/follow-redirects": {
|
||||||
|
"version": "1.15.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz",
|
||||||
|
"integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "individual",
|
||||||
|
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"debug": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/for-each": {
|
"node_modules/for-each": {
|
||||||
"version": "0.3.3",
|
"version": "0.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz",
|
||||||
@@ -2861,6 +2941,22 @@
|
|||||||
"is-callable": "^1.1.3"
|
"is-callable": "^1.1.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/form-data": {
|
||||||
|
"version": "4.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz",
|
||||||
|
"integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"asynckit": "^0.4.0",
|
||||||
|
"combined-stream": "^1.0.8",
|
||||||
|
"es-set-tostringtag": "^2.1.0",
|
||||||
|
"hasown": "^2.0.2",
|
||||||
|
"mime-types": "^2.1.12"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/fs.realpath": {
|
"node_modules/fs.realpath": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||||
@@ -2886,7 +2982,6 @@
|
|||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
||||||
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
|
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
@@ -2922,17 +3017,21 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/get-intrinsic": {
|
"node_modules/get-intrinsic": {
|
||||||
"version": "1.2.4",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
||||||
"integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==",
|
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"call-bind-apply-helpers": "^1.0.2",
|
||||||
|
"es-define-property": "^1.0.1",
|
||||||
"es-errors": "^1.3.0",
|
"es-errors": "^1.3.0",
|
||||||
|
"es-object-atoms": "^1.1.1",
|
||||||
"function-bind": "^1.1.2",
|
"function-bind": "^1.1.2",
|
||||||
"has-proto": "^1.0.1",
|
"get-proto": "^1.0.1",
|
||||||
"has-symbols": "^1.0.3",
|
"gopd": "^1.2.0",
|
||||||
"hasown": "^2.0.0"
|
"has-symbols": "^1.1.0",
|
||||||
|
"hasown": "^2.0.2",
|
||||||
|
"math-intrinsics": "^1.1.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
@@ -2941,6 +3040,19 @@
|
|||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/get-proto": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"dunder-proto": "^1.0.1",
|
||||||
|
"es-object-atoms": "^1.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/get-symbol-description": {
|
"node_modules/get-symbol-description": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.2.tgz",
|
||||||
@@ -3041,13 +3153,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/gopd": {
|
"node_modules/gopd": {
|
||||||
"version": "1.0.1",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
||||||
"integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
|
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"engines": {
|
||||||
"get-intrinsic": "^1.1.3"
|
"node": ">= 0.4"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
@@ -3107,10 +3218,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/has-symbols": {
|
"node_modules/has-symbols": {
|
||||||
"version": "1.0.3",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
|
||||||
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
|
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
@@ -3123,7 +3233,6 @@
|
|||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz",
|
||||||
"integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
|
"integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"has-symbols": "^1.0.3"
|
"has-symbols": "^1.0.3"
|
||||||
@@ -3139,7 +3248,6 @@
|
|||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
||||||
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
|
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"function-bind": "^1.1.2"
|
"function-bind": "^1.1.2"
|
||||||
@@ -3721,6 +3829,15 @@
|
|||||||
"node": ">=16.14.0"
|
"node": ">=16.14.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/math-intrinsics": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/merge2": {
|
"node_modules/merge2": {
|
||||||
"version": "1.4.1",
|
"version": "1.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
|
||||||
@@ -3745,6 +3862,27 @@
|
|||||||
"node": ">=8.6"
|
"node": ">=8.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/mime-db": {
|
||||||
|
"version": "1.52.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||||
|
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mime-types": {
|
||||||
|
"version": "2.1.35",
|
||||||
|
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||||
|
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"mime-db": "1.52.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/minimatch": {
|
"node_modules/minimatch": {
|
||||||
"version": "3.1.2",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||||
@@ -4206,6 +4344,12 @@
|
|||||||
"node": ">= 0.8.0"
|
"node": ">= 0.8.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/proxy-from-env": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/punycode": {
|
"node_modules/punycode": {
|
||||||
"version": "2.3.1",
|
"version": "2.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mdi/font": "7.4.47",
|
"@mdi/font": "7.4.47",
|
||||||
|
"axios": "^1.13.5",
|
||||||
"core-js": "^3.37.1",
|
"core-js": "^3.37.1",
|
||||||
"roboto-fontface": "*",
|
"roboto-fontface": "*",
|
||||||
"vee-validate": "^4.14.6",
|
"vee-validate": "^4.14.6",
|
||||||
|
|||||||
1
src/assets/icons/tryton-icon.svg
Normal file
1
src/assets/icons/tryton-icon.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" version="1.0"><path d="M256 196.25c0 40.122-21.534 60.038-64.603 59.747H67.495C22.498 255.997 0 236.663 0 197.994V60.184C0 20.06 22.016 0 66.049 0h124.384C234.144 0 256 20.206 256 60.62v135.63" style="text-align:start;line-height:125%;-inkscape-font-specification:Kimberley" font-size="108.872" font-weight="400" fill="#1b2019" font-family="Kimberley"/><path d="M19.006 169.515c5.949-3.124 17.076 1.966 22.115 10.12 4.518 7.31 27.406 14.114 35.516 10.558 5.412-2.372 6.779-5.378 7.202-15.844.798-19.685-3.636-35.098-17.99-62.536-7.205-13.77-14.753-29-16.775-33.835C47.052 73.14 41.601 64.6 36.961 59c-9.876-11.91-10.183-15.164-2.078-22.074C47.02 26.581 67.52 43.327 63.095 59.97c-2.178 8.191 2.003 20.14 15.85 45.295 16.431 29.85 33.084 41.94 43.03 31.243 2.57-2.763 5.759-18.178 8.698-42.04 4.421-35.889 4.399-38.037-.47-45.252-8.418-12.475-.48-25.42 12.84-20.943 13.43 4.513 22.192 22.778 13.775 28.714-3.735 2.633-4.942 10.29-6.636 42.097-2.173 40.785-.53 51.7 8.609 57.187 8.121 4.876 10.946 3.885 28.067-9.889 18.167-14.612 25.636-24.069 26.115-33.067.446-8.37 5.992-12.847 14.832-11.972 5.635.56 8.15 2.41 11.3 8.312 6.431 12.053 4.589 19.71-5.212 21.667-7.987 1.592-21.708 19.27-42.815 55.16-22.288 37.897-27.173 41.845-52.152 42.147-10.268.123-24.634-3.295-58.453-13.914-24.663-7.746-48.043-14.468-51.957-14.943-14.142-1.708-21.187-24.12-9.51-30.257z" fill="#ededed"/></svg>
|
||||||
|
After Width: | Height: | Size: 1.4 KiB |
341
src/components/AdminPurchase.vue
Normal file
341
src/components/AdminPurchase.vue
Normal file
@@ -0,0 +1,341 @@
|
|||||||
|
<template>
|
||||||
|
<v-container>
|
||||||
|
<v-form ref="purchase" v-model="valid" @change="onFormChange">
|
||||||
|
<v-row>
|
||||||
|
<v-col>
|
||||||
|
<v-autocomplete
|
||||||
|
v-model="purchase.customer"
|
||||||
|
:items="filteredClients"
|
||||||
|
:search="client_search"
|
||||||
|
no-data-text="No se hallaron clientes"
|
||||||
|
item-title="name"
|
||||||
|
item-value="id"
|
||||||
|
@update:model-value="onFormChange"
|
||||||
|
label="Cliente"
|
||||||
|
:rules="[rules.required]"
|
||||||
|
required
|
||||||
|
class="mr-4"
|
||||||
|
></v-autocomplete>
|
||||||
|
<!-- <v-btn color="primary" @click="openModal">Agregar Cliente</v-btn> -->
|
||||||
|
<CreateCustomerModal ref="customerModal" @customerCreated="handleNewCustomer"/>
|
||||||
|
</v-col>
|
||||||
|
<v-col lg="4">
|
||||||
|
<v-text-field
|
||||||
|
v-model="purchase.date"
|
||||||
|
label="Fecha"
|
||||||
|
type="datetime-local"
|
||||||
|
:rules="[rules.required]"
|
||||||
|
required
|
||||||
|
readonly
|
||||||
|
></v-text-field>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
<v-textarea
|
||||||
|
v-model="purchase.notes"
|
||||||
|
label="Notas"
|
||||||
|
rows="2"
|
||||||
|
></v-textarea>
|
||||||
|
<v-divider></v-divider>
|
||||||
|
<v-container>
|
||||||
|
<v-toolbar>
|
||||||
|
<v-toolbar-title secondary>Productos</v-toolbar-title>
|
||||||
|
p </v-toolbar>
|
||||||
|
<v-container v-for="(line, index) in purchase.saleline_set" :key="line.id">
|
||||||
|
<v-row>
|
||||||
|
<v-col
|
||||||
|
lg="9">
|
||||||
|
<v-autocomplete
|
||||||
|
v-model="line.product"
|
||||||
|
:items="filteredProducts"
|
||||||
|
:search="product_search"
|
||||||
|
@update:modelValue="onProductChange(index)"
|
||||||
|
no-data-text="No se hallaron productos"
|
||||||
|
item-title="name"
|
||||||
|
item-value="id"
|
||||||
|
item-subtitle="Price"
|
||||||
|
label="Producto"
|
||||||
|
:rules="[rules.required]"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
<template v-slot:item="{ props, item }">
|
||||||
|
<v-list-item v-bind="props" :title="item.raw.name" :subtitle="formatPrice(item.raw.price)"></v-list-item>
|
||||||
|
</template>
|
||||||
|
</v-autocomplete>
|
||||||
|
</v-col>
|
||||||
|
<v-col
|
||||||
|
lg="2"
|
||||||
|
>
|
||||||
|
<v-text-field
|
||||||
|
v-model.number="line.quantity"
|
||||||
|
label="Cantidad"
|
||||||
|
type="number"
|
||||||
|
:rules="[rules.required,rules.positive]"
|
||||||
|
required
|
||||||
|
></v-text-field>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
<v-row>
|
||||||
|
<v-col>
|
||||||
|
<v-text-field
|
||||||
|
v-model.number="line.unit_price"
|
||||||
|
label="Precio"
|
||||||
|
type="number"
|
||||||
|
:rules="[rules.required]"
|
||||||
|
prefix="$"
|
||||||
|
required
|
||||||
|
></v-text-field>
|
||||||
|
</v-col>
|
||||||
|
<v-col>
|
||||||
|
<v-text-field
|
||||||
|
v-model="line.measuring_unit"
|
||||||
|
label="UdM"
|
||||||
|
persistent-placeholder="true"
|
||||||
|
readonly
|
||||||
|
></v-text-field>
|
||||||
|
</v-col>
|
||||||
|
<v-col>
|
||||||
|
<v-text-field
|
||||||
|
type="number"
|
||||||
|
:value="calculateSubtotal(line)"
|
||||||
|
label="Subtotal"
|
||||||
|
prefix="$"
|
||||||
|
readonly
|
||||||
|
disable
|
||||||
|
persistent-placeholder="true"
|
||||||
|
></v-text-field>
|
||||||
|
</v-col>
|
||||||
|
<v-col>
|
||||||
|
<v-btn @click="removeLine(index)" color="red">Eliminar</v-btn>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
<v-alert type="warning" :duration="2000" closable v-model="show_alert_lines">
|
||||||
|
No se puede eliminar la única línea.
|
||||||
|
</v-alert>
|
||||||
|
</v-container>
|
||||||
|
<v-btn @click="addLine" color="blue">Agregar</v-btn>
|
||||||
|
</v-container>
|
||||||
|
<v-divider></v-divider>
|
||||||
|
<v-text-field
|
||||||
|
:value="calculateTotal"
|
||||||
|
label="Total"
|
||||||
|
prefix="$"
|
||||||
|
readonly
|
||||||
|
persistent-placeholder="true"
|
||||||
|
></v-text-field>
|
||||||
|
<v-container v-if="calculateTotal > 0">
|
||||||
|
<v-select
|
||||||
|
:items="payment_methods"
|
||||||
|
v-model="purchase.payment_method"
|
||||||
|
item-title="text"
|
||||||
|
item-value="value"
|
||||||
|
label="Pago en"
|
||||||
|
:rules="[rules.required]"
|
||||||
|
required
|
||||||
|
></v-select>
|
||||||
|
<v-btn @click="openCasherModal" v-if="purchase.payment_method === 'CASH'">Calcular Devuelta</v-btn>
|
||||||
|
<CasherModal :total_purchase="calculateTotal" ref="casherModal"</CasherModal>
|
||||||
|
</v-container>
|
||||||
|
<v-btn @click="submit" color="green">Comprar</v-btn>
|
||||||
|
<v-alert type="error" :duration="2000" closable v-model="show_alert_purchase">
|
||||||
|
Verifique los campos obligatorios.
|
||||||
|
</v-alert>
|
||||||
|
</v-form>
|
||||||
|
</v-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import CustomerForm from './CreateCustomerModal.vue';
|
||||||
|
import CasherModal from './CasherModal.vue';
|
||||||
|
import { inject } from 'vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'DonConfiao',
|
||||||
|
components: {
|
||||||
|
CustomerForm,
|
||||||
|
CasherModal,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
msg: String
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
api: inject('api'),
|
||||||
|
valid: false,
|
||||||
|
form_changed: false,
|
||||||
|
show_alert_lines: false,
|
||||||
|
show_alert_purchase: false,
|
||||||
|
client_search: '',
|
||||||
|
product_search: '',
|
||||||
|
payment_methods: null,
|
||||||
|
purchase: {
|
||||||
|
date: this.getCurrentDate(),
|
||||||
|
customer: null,
|
||||||
|
notes: '',
|
||||||
|
payment_method: null,
|
||||||
|
saleline_set: [{product:'', unit_price: 0, quantity: 0, unit: ''}],
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
required: value => !!value || 'Requerido.',
|
||||||
|
positive: value => value > 0 || 'La cantidad debe ser mayor que 0.',
|
||||||
|
},
|
||||||
|
menuItems: [
|
||||||
|
{ title: 'Inicio', route: '/'},
|
||||||
|
{ title: 'Compras', route:'/compras'},
|
||||||
|
],
|
||||||
|
clients: [],
|
||||||
|
products: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.fetchClients();
|
||||||
|
this.fetchProducts();
|
||||||
|
this.fetchPaymentMethods();
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
group () {
|
||||||
|
this.drawer = false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
beforeMount() {
|
||||||
|
window.addEventListener('beforeunload', this.confirmLeave);
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
window.removeEventListener('beforeunload', this.confirmLeave);
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
calculateTotal() {
|
||||||
|
return this.purchase.saleline_set.reduce((total, saleline) => {
|
||||||
|
return total + this.calculateSubtotal(saleline);
|
||||||
|
}, 0);
|
||||||
|
},
|
||||||
|
filteredClients() {
|
||||||
|
return this.clients.filter(client => {
|
||||||
|
if (this.client_search === '') {
|
||||||
|
return [];
|
||||||
|
} else {
|
||||||
|
return client.name.toLowerCase().includes(this.client_search.toLowerCase());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
filteredProducts() {
|
||||||
|
return this.products.filter(product => {
|
||||||
|
if (this.product_search === '') {
|
||||||
|
return [];
|
||||||
|
} else {
|
||||||
|
return product.name.toLowerCase().includes(this.product_search.toLowerCase());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
openModal() {
|
||||||
|
this.$refs.customerModal.openModal();
|
||||||
|
},
|
||||||
|
onFormChange() {
|
||||||
|
this.form_changed = true;
|
||||||
|
},
|
||||||
|
openCasherModal() {
|
||||||
|
this.$refs.casherModal.dialog = true
|
||||||
|
},
|
||||||
|
confirmLeave(event) {
|
||||||
|
if (this.form_changed) {
|
||||||
|
const message = '¿seguro que quieres salir? Perderas la información diligenciada';
|
||||||
|
event.preventDefault();
|
||||||
|
event.returnValue = message;
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getCurrentDate() {
|
||||||
|
const today = new Date();
|
||||||
|
const gmtOffSet = -5;
|
||||||
|
const localDate = new Date(today.getTime() + (gmtOffSet * 60 * 60 * 1000));
|
||||||
|
// Formatear la fecha y hora en el formato YYYY-MM-DDTHH:MM
|
||||||
|
const formattedDate = localDate.toISOString().slice(0,16);
|
||||||
|
return formattedDate;
|
||||||
|
},
|
||||||
|
onProductChange(index) {
|
||||||
|
const selectedProductId = this.purchase.saleline_set[index].product;
|
||||||
|
const selectedProduct = this.products.find(p => p.id == selectedProductId);
|
||||||
|
this.purchase.saleline_set[index].unit_price = selectedProduct.price;
|
||||||
|
this.purchase.saleline_set[index].measuring_unit = selectedProduct.measuring_unit;
|
||||||
|
},
|
||||||
|
fetchClients() {
|
||||||
|
this.api.getCustomers()
|
||||||
|
.then(data => {
|
||||||
|
this.clients = data;
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleNewCustomer(newCustomer){
|
||||||
|
this.clients.push(newCustomer);
|
||||||
|
this.purchase.customer = newCustomer.id;
|
||||||
|
},
|
||||||
|
fetchProducts() {
|
||||||
|
this.api.getProducts()
|
||||||
|
.then(data => {
|
||||||
|
this.products = data;
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
fetchPaymentMethods() {
|
||||||
|
this.api.getPaymentMethods()
|
||||||
|
.then(data => {
|
||||||
|
this.payment_methods = data;
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
addLine() {
|
||||||
|
this.purchase.saleline_set.push({ product: '', unit_price: 0, quantity:0, measuring_unit: ''});
|
||||||
|
},
|
||||||
|
removeLine(index) {
|
||||||
|
if (this.purchase.saleline_set.length > 1) {
|
||||||
|
this.purchase.saleline_set.splice(index, 1);
|
||||||
|
} else {
|
||||||
|
this.show_alert_lines = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
this.show_alert_lines = false;
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
calculateSubtotal(line) {
|
||||||
|
return line.unit_price * line.quantity;
|
||||||
|
},
|
||||||
|
async submit() {
|
||||||
|
this.$refs.purchase.validate();
|
||||||
|
if (this.valid) {
|
||||||
|
this.api.createPurchase(this.purchase)
|
||||||
|
.then(data => {
|
||||||
|
console.log('Compra enviada:', data);
|
||||||
|
this.$router.push({
|
||||||
|
path: "/summary_purchase",
|
||||||
|
query : {id: parseInt(data.id)}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(error => console.error('Error al enviarl la compra:', error));
|
||||||
|
} else {
|
||||||
|
this.show_alert_purchase = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
this.show_alert_purchase = false;
|
||||||
|
}, 4000);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
navigate(route) {
|
||||||
|
this.$router.push(route);
|
||||||
|
},
|
||||||
|
formatPrice(price) {
|
||||||
|
return new Intl.NumberFormat('es-ES', { style: 'currency', currency: 'COP' }).format(price);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.fetchClients();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
@@ -10,7 +10,8 @@
|
|||||||
</v-form>
|
</v-form>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<v-btn type="submit" form="code-form">Aceptar</v-btn>
|
<v-btn type="submit" form="code-form" color="green">Aceptar</v-btn>
|
||||||
|
<v-btn :to="{ path: '/' }" color="red">Cancelar</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|||||||
70
src/components/Login.vue
Normal file
70
src/components/Login.vue
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<template>
|
||||||
|
<h1>Login</h1>
|
||||||
|
|
||||||
|
<v-form ref="loginForm" @submit.prevent="onSubmit">
|
||||||
|
<v-text-field
|
||||||
|
v-model="username"
|
||||||
|
label="Usuario"
|
||||||
|
:rules="[requiredRule]"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<v-text-field
|
||||||
|
v-model="password"
|
||||||
|
label="Contraseña"
|
||||||
|
type="password"
|
||||||
|
:rules="[requiredRule]"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
|
||||||
|
<v-btn type="submit" color="primary">Entrar</v-btn>
|
||||||
|
|
||||||
|
<v-alert v-if="error" type="error" class="mt-2">{{ error }}</v-alert>
|
||||||
|
</v-form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import AuthService from '@/services/auth';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'DonConfiao',
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
username: '',
|
||||||
|
password: '',
|
||||||
|
error: '',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
requiredRule(value) {
|
||||||
|
return !!value || 'Este campo es obligatorio';
|
||||||
|
},
|
||||||
|
|
||||||
|
async onSubmit() {
|
||||||
|
this.error = '';
|
||||||
|
|
||||||
|
const form = this.$refs.loginForm;
|
||||||
|
const isValid = await form.validate();
|
||||||
|
|
||||||
|
if (!isValid) return;
|
||||||
|
|
||||||
|
if (!this.username || !this.password) {
|
||||||
|
this.error = 'Usuario y contraseña son obligatorios';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await AuthService.login({
|
||||||
|
username: this.username,
|
||||||
|
password: this.password,
|
||||||
|
});
|
||||||
|
this.$router.push({ path: '/' });
|
||||||
|
} catch (e) {
|
||||||
|
const msg = e?.response?.data?.message ?? e.message;
|
||||||
|
this.error = msg ?? 'Error al iniciar sesión';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
69
src/components/LoginDialog.vue
Normal file
69
src/components/LoginDialog.vue
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<template>
|
||||||
|
<v-dialog v-model="show" max-width="400">
|
||||||
|
<v-card>
|
||||||
|
<v-card-title class="headline">Iniciar sesión</v-card-title>
|
||||||
|
<v-card-text>
|
||||||
|
<v-form ref="form" @submit.prevent="onSubmit">
|
||||||
|
<v-text-field
|
||||||
|
v-model="username"
|
||||||
|
label="Usuario"
|
||||||
|
:rules="[required]"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<v-text-field
|
||||||
|
v-model="password"
|
||||||
|
label="Contraseña"
|
||||||
|
type="password"
|
||||||
|
:rules="[required]"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<v-alert v-if="error" type="error" class="mt-2">{{ error }}</v-alert>
|
||||||
|
</v-form>
|
||||||
|
</v-card-text>
|
||||||
|
|
||||||
|
<v-card-actions>
|
||||||
|
<v-spacer />
|
||||||
|
<v-btn text @click="show = false">Cancelar</v-btn>
|
||||||
|
<v-btn color="primary" @click="onSubmit">Entrar</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
|
</v-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import AuthService from '@/services/auth';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'LoginDialog',
|
||||||
|
data: () => ({
|
||||||
|
show: false,
|
||||||
|
username: '',
|
||||||
|
password: '',
|
||||||
|
error: '',
|
||||||
|
}),
|
||||||
|
methods: {
|
||||||
|
required(v) {
|
||||||
|
return !!v || 'Campo obligatorio';
|
||||||
|
},
|
||||||
|
async onSubmit() {
|
||||||
|
this.error = '';
|
||||||
|
const form = this.$refs.form;
|
||||||
|
if (!(await form.validate())) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await AuthService.login({
|
||||||
|
username: this.username,
|
||||||
|
password: this.password,
|
||||||
|
});
|
||||||
|
this.show = false;
|
||||||
|
this.$emit('login-success');
|
||||||
|
} catch (e) {
|
||||||
|
this.error = e.message ?? 'Error al iniciar sesión';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
open() {
|
||||||
|
this.show = true;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
32
src/components/Logout.vue
Normal file
32
src/components/Logout.vue
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<template>
|
||||||
|
<v-container class="d-flex flex-column align-center justify-center" style="height: 100vh;">
|
||||||
|
<v-progress-circular indeterminate color="primary" />
|
||||||
|
<p class="mt-4">Cerrando sesión…</p>
|
||||||
|
</v-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import AuthService from '@/services/auth';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'DonConfiao',
|
||||||
|
mounted() {
|
||||||
|
this.logout();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
logout() {
|
||||||
|
AuthService.logout();
|
||||||
|
this.$router.push({
|
||||||
|
path: '/autenticarse'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
p {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -3,46 +3,107 @@
|
|||||||
<v-app-bar-nav-icon variant="text" @click.stop="drawer = !drawer"></v-app-bar-nav-icon>
|
<v-app-bar-nav-icon variant="text" @click.stop="drawer = !drawer"></v-app-bar-nav-icon>
|
||||||
<v-toolbar-title>Menu</v-toolbar-title>
|
<v-toolbar-title>Menu</v-toolbar-title>
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
<template v-if="$vuetify.display.mdAndUp">
|
<v-btn
|
||||||
<v-btn icon="mdi-magnify" variant="text"></v-btn>
|
v-if="!isAuthenticated"
|
||||||
<v-btn icon="mdi-filter" variant="text"></v-btn>
|
prepend-icon="mdi-login"
|
||||||
</template>
|
variant="text"
|
||||||
<v-btn icon="mdi-dots-vertical" variant="text"></v-btn>
|
@click="navigate('/autenticarse')"
|
||||||
|
>
|
||||||
|
Login
|
||||||
|
</v-btn>
|
||||||
|
<v-btn
|
||||||
|
v-else
|
||||||
|
prepend-icon="mdi-logout"
|
||||||
|
variant="text"
|
||||||
|
@click="logout"
|
||||||
|
>
|
||||||
|
Logout
|
||||||
|
</v-btn>
|
||||||
</v-app-bar>
|
</v-app-bar>
|
||||||
<v-navigation-drawer v-model="drawer"
|
<v-navigation-drawer v-model="drawer"
|
||||||
:location="$vuetify.display.mobile ? 'bottom' : undefined"
|
:location="$vuetify.display.mobile ? 'bottom' : undefined"
|
||||||
temporary>
|
temporary>
|
||||||
<v-list>
|
<v-list
|
||||||
<v-list-item v-for="item in menuItems" :key="item.title" @click="navigate(item.route)">
|
density="compact"
|
||||||
<v-list-item-title>{{ item.title }}</v-list-item-title>
|
nav
|
||||||
|
>
|
||||||
|
<v-list-item
|
||||||
|
v-for="item in menuItems"
|
||||||
|
:key="item.title"
|
||||||
|
:title="item.title"
|
||||||
|
:prepend-icon="item.icon"
|
||||||
|
@click="navigate(item.route)"
|
||||||
|
></v-list-item>
|
||||||
|
<v-list-item prepend-icon="mdi-cog" title="Administracion" @click="toggleAdminMenu()"></v-list-item>
|
||||||
|
<v-list-item>
|
||||||
|
<v-list v-if="showAdminMenu">
|
||||||
|
<v-list-item
|
||||||
|
v-for="item in menuAdminItems"
|
||||||
|
:key="item.title"
|
||||||
|
:title="item.title"
|
||||||
|
:prepend-icon="item.icon"
|
||||||
|
@click="navigateAdmin(item.route)"
|
||||||
|
></v-list-item>
|
||||||
|
</v-list>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list>
|
</v-list>
|
||||||
</v-navigation-drawer>
|
</v-navigation-drawer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import trytonIcon from '../assets/icons/tryton-icon.svg';
|
||||||
|
import AuthService from '@/services/auth';
|
||||||
export default {
|
export default {
|
||||||
name: 'NavBar',
|
name: 'NavBar',
|
||||||
data: () => ({
|
data: () => ({
|
||||||
drawer: false,
|
drawer: false,
|
||||||
group: null,
|
group: null,
|
||||||
|
showAdminMenu: false,
|
||||||
|
isAuthenticated: false,
|
||||||
menuItems: [
|
menuItems: [
|
||||||
{ title: 'Inicio', route: '/'},
|
{ title: 'Inicio', route: '/', icon: 'mdi-home'},
|
||||||
{ title: 'Comprar', route:'/comprar'},
|
{ title: 'Comprar', route:'/comprar', icon: 'mdi-cart'},
|
||||||
{ title: 'Cuadrar tarro', route: '/cuadrar_tarro'},
|
],
|
||||||
{ title: 'Cuadres de tarro', route: '/cuadres_de_tarro'},
|
menuAdminItems: [
|
||||||
{ title: 'CSV Tryton', route: '/ventas_para_tryton'},
|
{ title: 'Cuadrar tarro', route: '/cuadrar_tarro', icon: 'mdi-calculator'},
|
||||||
|
{ title: 'Cuadres de tarro', route: '/cuadres_de_tarro', icon: 'mdi-chart-bar'},
|
||||||
|
{ title: 'CSV Tryton', route: '/ventas_para_tryton', icon: 'mdi-file-table'},
|
||||||
|
{ title: 'Compra adm', route: '/compra_admin', icon: 'mdi-cart'},
|
||||||
|
{ title: 'Actualizar Productos De Tryton', route: '/sincronizar_productos_tryton', icon: 'trytonIcon'},
|
||||||
|
{ title: 'Actualizar Clientes De Tryton', route: '/sincronizar_clientes_tryton', icon: 'trytonIcon'},
|
||||||
|
{ title: 'Actualizar Ventas Tryton', route: '/sincronizar_ventas_tryton', icon: 'trytonIcon'}
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
mounted() {
|
||||||
|
this.checkAuth();
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
group () {
|
group () {
|
||||||
this.drawer = false
|
this.drawer = false
|
||||||
},
|
},
|
||||||
|
$route() {
|
||||||
|
this.checkAuth();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
checkAuth() {
|
||||||
|
this.isAuthenticated = AuthService.isAuthenticated();
|
||||||
|
},
|
||||||
navigate(route) {
|
navigate(route) {
|
||||||
this.$router.push(route);
|
this.$router.push(route);
|
||||||
},
|
},
|
||||||
|
navigateAdmin(route) {
|
||||||
|
this.toggleAdminMenu();
|
||||||
|
this.navigate(route);
|
||||||
|
},
|
||||||
|
toggleAdminMenu() {
|
||||||
|
this.showAdminMenu = !this.showAdminMenu;
|
||||||
|
},
|
||||||
|
logout() {
|
||||||
|
AuthService.logout();
|
||||||
|
this.isAuthenticated = false;
|
||||||
|
this.$router.push('/');
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
required
|
required
|
||||||
class="mr-4"
|
class="mr-4"
|
||||||
></v-autocomplete>
|
></v-autocomplete>
|
||||||
<v-btn color="primary" @click="openModal">Agregar Cliente</v-btn>
|
<!--<v-btn color="primary" @click="openModal">Agregar Cliente</v-btn>-->
|
||||||
<CreateCustomerModal ref="customerModal" @customerCreated="handleNewCustomer"/>
|
<CreateCustomerModal ref="customerModal" @customerCreated="handleNewCustomer"/>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col lg="4">
|
<v-col lg="4">
|
||||||
|
|||||||
@@ -39,8 +39,26 @@
|
|||||||
{{ currencyFormat(calculateSubtotal(item.unit_price, item.quantity)) }}
|
{{ currencyFormat(calculateSubtotal(item.unit_price, item.quantity)) }}
|
||||||
</template>
|
</template>
|
||||||
</v-data-table-virtual>
|
</v-data-table-virtual>
|
||||||
|
<v-alert type="info" class="my-4">
|
||||||
|
Recuerda adicionar a la planilla física lo siguiente
|
||||||
|
<v-data-table
|
||||||
|
:headers="headersTemplate"
|
||||||
|
:items="[purchase]"
|
||||||
|
item-key="id"
|
||||||
|
hide-default-footer
|
||||||
|
>
|
||||||
|
<template v-slot:item="{ item }">
|
||||||
|
<tr>
|
||||||
|
<td>{{ item.id }}</td>
|
||||||
|
<td>{{ item.date }}</td>
|
||||||
|
<td><span v-if="item.customer">{{ item.customer.name }}</span></td>
|
||||||
|
<td><span v-if="item.lines">{{ currencyFormat(calculateTotal(item.lines)) }}</span></td>
|
||||||
|
</tr>
|
||||||
|
</template>
|
||||||
|
</v-data-table>
|
||||||
|
</v-alert>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<v-btn :to="{ path: 'comprar' }" color="green">Ir a Comprar</v-btn>
|
<v-btn :to="{ path: '/' }" color="green">Ir al inicio</v-btn>
|
||||||
</div>
|
</div>
|
||||||
</v-container>
|
</v-container>
|
||||||
</v-container>
|
</v-container>
|
||||||
@@ -65,6 +83,12 @@
|
|||||||
{ title: 'Cantidad', value: 'quantity' },
|
{ title: 'Cantidad', value: 'quantity' },
|
||||||
{ title: 'Subtotal', value: 'subtotal' },
|
{ title: 'Subtotal', value: 'subtotal' },
|
||||||
],
|
],
|
||||||
|
headersTemplate: [
|
||||||
|
{title: 'Compra', value: 'id'},
|
||||||
|
{title: 'Fecha', value: 'date'},
|
||||||
|
{title: 'Nombre', value: 'customer.name'},
|
||||||
|
{title: 'Valor', value: ''},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|||||||
7
src/pages/autenticarse.vue
Normal file
7
src/pages/autenticarse.vue
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
<Login />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
//
|
||||||
|
</script>
|
||||||
20
src/pages/compra_admin.vue
Normal file
20
src/pages/compra_admin.vue
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<CodeDialog @code-verified="(verified) => showComponent = verified"/>
|
||||||
|
</div>
|
||||||
|
<AdminPurchase v-if="showComponent"/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script >
|
||||||
|
import CodeDialog from '../components/CodeDialog.vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
showComponent: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
components: { CodeDialog },
|
||||||
|
methods: {},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
7
src/pages/salir.vue
Normal file
7
src/pages/salir.vue
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
<Logout />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
//
|
||||||
|
</script>
|
||||||
79
src/pages/sincronizar_clientes_tryton.vue
Normal file
79
src/pages/sincronizar_clientes_tryton.vue
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<CodeDialog @code-verified="(verified) => showComponent = verified"/>
|
||||||
|
</div>
|
||||||
|
<v-container class="fill-height d-flex align-center justify-center">
|
||||||
|
<v-card class="pa-6" max-width="600" elevation="4">
|
||||||
|
<v-card-title class="text-h5 font-weight-bold text-center">
|
||||||
|
🔄 Sincronización de Clientes
|
||||||
|
</v-card-title>
|
||||||
|
|
||||||
|
<v-card-text>
|
||||||
|
<p>
|
||||||
|
Esta acción sincronizará los <strong>clientes</strong> desde el sistema
|
||||||
|
<strong>Tryton</strong> hacia la plataforma.
|
||||||
|
</p>
|
||||||
|
<v-alert type="warning" dense border="start" border-color="warning">
|
||||||
|
<strong>Advertencia:</strong> Este proceso podría tardar varios minutos
|
||||||
|
y reemplazar datos existentes en la plataforma.
|
||||||
|
Asegúrese de que la información en Tryton esté actualizada antes de
|
||||||
|
continuar.
|
||||||
|
</v-alert>
|
||||||
|
<p class="mt-4">
|
||||||
|
Durante la sincronización, no se podrán modificar productos en la
|
||||||
|
plataforma para evitar conflictos.
|
||||||
|
</p>
|
||||||
|
</v-card-text>
|
||||||
|
|
||||||
|
<v-card-actions class="justify-center">
|
||||||
|
<v-btn color="primary" @click="startSync">
|
||||||
|
Iniciar Sincronización
|
||||||
|
</v-btn>
|
||||||
|
<v-btn text @click="$router.push('/')">
|
||||||
|
Cancelar
|
||||||
|
</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
|
|
||||||
|
|
||||||
|
<v-data-table :items="checked_tryton_parties"></v-data-table>
|
||||||
|
<v-data-table :items="created_customers"></v-data-table>
|
||||||
|
<v-data-table :items="failed_parties"></v-data-table>
|
||||||
|
<v-data-table :items="untouched_customers"></v-data-table>
|
||||||
|
</v-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import CodeDialog from '../components/CodeDialog.vue'
|
||||||
|
import { inject } from 'vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'CustomersFromTryton',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
api: inject('api'),
|
||||||
|
checked_tryton_parties: [],
|
||||||
|
created_customers: [],
|
||||||
|
failed_parties: [],
|
||||||
|
untouched_customers: [],
|
||||||
|
updated_customers: [],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
startSync() {
|
||||||
|
this.api.getCustomersFromTryton()
|
||||||
|
.then(response => {
|
||||||
|
// Manejar la respuesta exitosa
|
||||||
|
this.checked_tryton_parties = response.checked_tryton_parties.map(id => ({ id }));
|
||||||
|
this.created_customers = response.created_customers.map(id => ({ id }));
|
||||||
|
this.failed_parties = response.failed_parties.map(id => ({ id }));
|
||||||
|
this.untouched_customers = response.untouched_customers.map(id => ({ id }));
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
// Manejar el error
|
||||||
|
console.error("Error al sincronizar clientes:", error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
60
src/pages/sincronizar_productos_tryton.vue
Normal file
60
src/pages/sincronizar_productos_tryton.vue
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<CodeDialog @code-verified="(verified) => showComponent = verified"/>
|
||||||
|
</div>
|
||||||
|
<v-container class="fill-height d-flex align-center justify-center">
|
||||||
|
<v-card class="pa-6" max-width="600" elevation="4">
|
||||||
|
<v-card-title class="text-h5 font-weight-bold text-center">
|
||||||
|
🔄 Sincronización de Productos
|
||||||
|
</v-card-title>
|
||||||
|
|
||||||
|
<v-card-text>
|
||||||
|
<p>
|
||||||
|
Esta acción sincronizará los <strong>productos</strong> desde el sistema
|
||||||
|
<strong>Tryton</strong> hacia la plataforma.
|
||||||
|
</p>
|
||||||
|
<v-alert type="warning" dense border="start" border-color="warning">
|
||||||
|
<strong>Advertencia:</strong> Este proceso podría tardar varios minutos
|
||||||
|
y reemplazar datos existentes en la plataforma.
|
||||||
|
Asegúrese de que la información en Tryton esté actualizada antes de
|
||||||
|
continuar.
|
||||||
|
</v-alert>
|
||||||
|
<p class="mt-4">
|
||||||
|
Durante la sincronización, no se podrán modificar productos en la
|
||||||
|
plataforma para evitar conflictos.
|
||||||
|
</p>
|
||||||
|
</v-card-text>
|
||||||
|
|
||||||
|
<v-card-actions class="justify-center">
|
||||||
|
<v-btn color="primary" @click="startSync">
|
||||||
|
Iniciar Sincronización
|
||||||
|
</v-btn>
|
||||||
|
<v-btn text @click="$router.push('/')">
|
||||||
|
Cancelar
|
||||||
|
</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
|
<v-data-table :items="productos_tryton"></v-data-table>
|
||||||
|
</v-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import CodeDialog from '../components/CodeDialog.vue'
|
||||||
|
import { inject } from 'vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'ProductsFromTryton',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
api: inject('api'),
|
||||||
|
productos_tryton: [{}],
|
||||||
|
showComponent: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
startSync() {
|
||||||
|
this.productos_tryton = this.api.getProductsFromTryton()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
63
src/pages/sincronizar_ventas_tryton.vue
Normal file
63
src/pages/sincronizar_ventas_tryton.vue
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<CodeDialog @code-verified="(verified) => showComponent = verified"/>
|
||||||
|
</div>
|
||||||
|
<v-container class="fill-height d-flex align-center justify-center">
|
||||||
|
<v-card class="pa-6" max-width="600" elevation="4">
|
||||||
|
<v-card-title class="text-h5 font-weight-bold text-center">
|
||||||
|
🔄 Sincronización de Ventas
|
||||||
|
</v-card-title>
|
||||||
|
|
||||||
|
<v-card-text>
|
||||||
|
<p>
|
||||||
|
Esta acción sincronizará las <strong>ventas</strong> desde el sistema
|
||||||
|
<strong>Tryton</strong> hacia la plataforma.
|
||||||
|
</p>
|
||||||
|
<v-alert type="warning" dense border="start" border-color="warning">
|
||||||
|
<strong>Advertencia:</strong> Este proceso podría tardar varios minutos
|
||||||
|
y reemplazar datos existentes en la plataforma.
|
||||||
|
Asegúrese de que la información en Tryton esté actualizada antes de
|
||||||
|
continuar.
|
||||||
|
</v-alert>
|
||||||
|
</v-card-text>
|
||||||
|
|
||||||
|
<v-card-actions class="justify-center">
|
||||||
|
<v-btn color="primary" @click="startSync">
|
||||||
|
Iniciar Sincronización
|
||||||
|
</v-btn>
|
||||||
|
<v-btn text @click="$router.push('/')">
|
||||||
|
Cancelar
|
||||||
|
</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
|
<v-data-table :items="ventas_tryton_failed"></v-data-table>
|
||||||
|
<v-data-table :items="ventas_tryton_successful"></v-data-table>
|
||||||
|
</v-container>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import CodeDialog from '../components/CodeDialog.vue';
|
||||||
|
import { inject } from 'vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'SalesToTryton',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
api: inject('api'),
|
||||||
|
ventas_tryton: [],
|
||||||
|
showComponent: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
startSync() {
|
||||||
|
this.api.sendSalesToTryton()
|
||||||
|
.then(response => {
|
||||||
|
this.ventas_tryton_failed = response.failed.map(id => ({ id }));
|
||||||
|
this.ventas_tryton_successful = response.successful.map(id => ({ id }));
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error("Error al sincronizar las ventas", error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -3,7 +3,7 @@ import Api from './api';
|
|||||||
|
|
||||||
class ApiImplementation {
|
class ApiImplementation {
|
||||||
constructor() {
|
constructor() {
|
||||||
const implementation = process.env.API_IMPLEMENTATION;
|
const implementation = import.meta.env.VITE_API_IMPLEMENTATION;
|
||||||
let apiImplementation;
|
let apiImplementation;
|
||||||
if (implementation === 'django') {
|
if (implementation === 'django') {
|
||||||
apiImplementation = new DjangoApi();
|
apiImplementation = new DjangoApi();
|
||||||
|
|||||||
@@ -50,6 +50,18 @@ class Api {
|
|||||||
getCSVForTryton() {
|
getCSVForTryton() {
|
||||||
return this.apiImplementation.getCSVForTryton();
|
return this.apiImplementation.getCSVForTryton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getProductsFromTryton() {
|
||||||
|
return this.apiImplementation.getProductsFromTryton();
|
||||||
|
}
|
||||||
|
|
||||||
|
getCustomersFromTryton() {
|
||||||
|
return this.apiImplementation.getCustomersFromTryton();
|
||||||
|
}
|
||||||
|
|
||||||
|
sendSalesToTryton(){
|
||||||
|
return this.apiImplementation.sendSalesToTryton();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Api;
|
export default Api;
|
||||||
|
|||||||
72
src/services/auth.js
Normal file
72
src/services/auth.js
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
class AuthService {
|
||||||
|
static TOKEN_KEY = 'access_token';
|
||||||
|
static REFRESH_KEY = 'refresh_token';
|
||||||
|
|
||||||
|
static async login(credentials) {
|
||||||
|
const url = `${import.meta.env.VITE_DJANGO_BASE_URL}/api/token/`;
|
||||||
|
|
||||||
|
const resp = await fetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(credentials),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!resp.ok) {
|
||||||
|
let errMsg = resp.statusText;
|
||||||
|
try {
|
||||||
|
const errData = await resp.json();
|
||||||
|
errMsg = errData?.detail ?? errData?.message ?? errMsg;
|
||||||
|
} catch (_) { /* ignore */ }
|
||||||
|
throw new Error(errMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await resp.json();
|
||||||
|
|
||||||
|
if (data.access && data.refresh) {
|
||||||
|
localStorage.setItem(this.TOKEN_KEY, data.access);
|
||||||
|
localStorage.setItem(this.REFRESH_KEY, data.refresh);
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getAccessToken() {
|
||||||
|
return localStorage.getItem(this.TOKEN_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getRefreshToken() {
|
||||||
|
return localStorage.getItem(this.REFRESH_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
static async refresh() {
|
||||||
|
const refresh = this.getRefreshToken();
|
||||||
|
if (!refresh) throw new Error('No refresh token');
|
||||||
|
|
||||||
|
const url = `${import.meta.env.VITE_DJANGO_BASE_URL}/api/token/refresh/`;
|
||||||
|
const resp = await fetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ refresh }),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!resp.ok) {
|
||||||
|
const errData = await resp.json().catch(() => ({}));
|
||||||
|
throw new Error(errData?.detail ?? resp.statusText);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await resp.json();
|
||||||
|
localStorage.setItem(this.TOKEN_KEY, data.access);
|
||||||
|
return data.access;
|
||||||
|
}
|
||||||
|
|
||||||
|
static isAuthenticated() {
|
||||||
|
return !!this.getAccessToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
static logout() {
|
||||||
|
localStorage.removeItem(this.TOKEN_KEY);
|
||||||
|
localStorage.removeItem(this.REFRESH_KEY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AuthService;
|
||||||
@@ -1,6 +1,17 @@
|
|||||||
|
import AuthService from '@/services/auth';
|
||||||
|
import http from '@/services/http';
|
||||||
|
|
||||||
class DjangoApi {
|
class DjangoApi {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.base = process.env.DJANGO_BASE_URL;
|
this.base = import.meta.env.VITE_DJANGO_BASE_URL;
|
||||||
|
}
|
||||||
|
|
||||||
|
getRequest(url) {
|
||||||
|
return http.get(url).then(r => r.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
postRequest(url, payload) {
|
||||||
|
return http.post(url, payload).then(r => r.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
getCustomers() {
|
getCustomers() {
|
||||||
@@ -63,43 +74,19 @@ class DjangoApi {
|
|||||||
return this.getRequest(url);
|
return this.getRequest(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
getRequest(url) {
|
getProductsFromTryton(){
|
||||||
return new Promise ((resolve, reject) => {
|
const url = this.base + '/don_confiao/api/importar_productos_de_tryton';
|
||||||
fetch(url)
|
return this.postRequest(url, {});
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => {
|
|
||||||
resolve(data);
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
postRequest(url, content) {
|
getCustomersFromTryton(){
|
||||||
return new Promise((resolve, reject) => {
|
const url = this.base + '/don_confiao/api/importar_clientes_de_tryton';
|
||||||
fetch(url, {
|
return this.postRequest(url, {});
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify(content)
|
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
if (!response.ok) {
|
|
||||||
reject(new Error(`Error ${response.status}: ${response.statusText}`));
|
|
||||||
} else {
|
|
||||||
response.json().then(data => {
|
|
||||||
if (!data) {
|
|
||||||
reject(new Error('La respuesta no es un JSON válido'));
|
|
||||||
} else {
|
|
||||||
resolve(data);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
sendSalesToTryton(){
|
||||||
})
|
const url = this.base + '/don_confiao/api/enviar_ventas_a_tryton';
|
||||||
.catch(error => reject(error));
|
return this.postRequest(url, {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
44
src/services/http.js
Normal file
44
src/services/http.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
import AuthService from '@/services/auth';
|
||||||
|
|
||||||
|
const http = axios.create({
|
||||||
|
baseURL: import.meta.env.VITE_DJANGO_BASE_URL,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
http.interceptors.request.use(
|
||||||
|
config => {
|
||||||
|
const token = AuthService.getAccessToken();
|
||||||
|
if (token) {
|
||||||
|
config.headers.Authorization = `Bearer ${token}`;
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
},
|
||||||
|
error => Promise.reject(error)
|
||||||
|
);
|
||||||
|
|
||||||
|
http.interceptors.response.use(
|
||||||
|
response => response,
|
||||||
|
async error => {
|
||||||
|
const originalRequest = error.config;
|
||||||
|
|
||||||
|
if (error.response?.status === 401 && !originalRequest._retry) {
|
||||||
|
originalRequest._retry = true;
|
||||||
|
try {
|
||||||
|
const newAccess = await AuthService.refresh();
|
||||||
|
originalRequest.headers.Authorization = `Bearer ${newAccess}`;
|
||||||
|
return http.request(originalRequest);
|
||||||
|
} catch (refreshError) {
|
||||||
|
AuthService.logout();
|
||||||
|
window.location.href = '/autenticarse';
|
||||||
|
return Promise.reject(refreshError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
export default http;
|
||||||
@@ -47,12 +47,10 @@ export default defineConfig({
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
define: { 'process.env': {
|
define: { 'process.env': {
|
||||||
API_IMPLEMENTATION: 'django',
|
|
||||||
DJANGO_BASE_URL: 'http://localhost:7000'
|
|
||||||
} },
|
} },
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||||
},
|
},
|
||||||
extensions: [
|
extensions: [
|
||||||
'.js',
|
'.js',
|
||||||
|
|||||||
Reference in New Issue
Block a user