Compare commits
1 Commits
c95279d96b
...
TrytonApiC
| Author | SHA1 | Date | |
|---|---|---|---|
| efb33ef011 |
@@ -1,2 +0,0 @@
|
|||||||
VITE_API_IMPLEMENTATION=django
|
|
||||||
VITE_DJANGO_BASE_URL=http://localhost:7000
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,7 +5,6 @@ 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
81
AGENTS.md
@@ -1,81 +0,0 @@
|
|||||||
# 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', 'frontend', compose: DOCKER_COMPOSE)
|
compose('logs', '-f', 'django', compose: DOCKER_COMPOSE)
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'monitorear salida'
|
desc 'monitorear salida'
|
||||||
task :tail_end do
|
task :tail_end do
|
||||||
compose('logs', '-f', '-n 50', 'frontend', compose: DOCKER_COMPOSE)
|
compose('logs', '-f', '-n 50', 'django', compose: DOCKER_COMPOSE)
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'iniciar entorno'
|
desc 'iniciar entorno'
|
||||||
|
|||||||
@@ -7,7 +7,4 @@ services:
|
|||||||
- ./:/app/
|
- ./:/app/
|
||||||
ports:
|
ports:
|
||||||
- "7001:3000"
|
- "7001:3000"
|
||||||
environment:
|
|
||||||
- VITE_DJANGO_BASE_URL=http://localhost:7000
|
|
||||||
- VITE_API_IMPLEMENTATION=django
|
|
||||||
|
|
||||||
|
|||||||
228
package-lock.json
generated
228
package-lock.json
generated
@@ -9,7 +9,6 @@
|
|||||||
"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",
|
||||||
@@ -32,7 +31,7 @@
|
|||||||
"unplugin-fonts": "^1.1.1",
|
"unplugin-fonts": "^1.1.1",
|
||||||
"unplugin-vue-components": "^0.27.2",
|
"unplugin-vue-components": "^0.27.2",
|
||||||
"unplugin-vue-router": "^0.10.0",
|
"unplugin-vue-router": "^0.10.0",
|
||||||
"vite": "^5.3.3",
|
"vite": "^5.4.14",
|
||||||
"vite-plugin-vue-layouts": "^0.11.0",
|
"vite-plugin-vue-layouts": "^0.11.0",
|
||||||
"vite-plugin-vuetify": "^2.0.3",
|
"vite-plugin-vuetify": "^2.0.3",
|
||||||
"vue-router": "^4.4.0"
|
"vue-router": "^4.4.0"
|
||||||
@@ -1504,12 +1503,6 @@
|
|||||||
"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",
|
||||||
@@ -1526,17 +1519,6 @@
|
|||||||
"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",
|
||||||
@@ -1685,19 +1667,6 @@
|
|||||||
"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",
|
||||||
@@ -1783,18 +1752,6 @@
|
|||||||
"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",
|
||||||
@@ -1984,15 +1941,6 @@
|
|||||||
"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",
|
||||||
@@ -2006,20 +1954,6 @@
|
|||||||
"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",
|
||||||
@@ -2094,10 +2028,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/es-define-property": {
|
"node_modules/es-define-property": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz",
|
||||||
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
|
"integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==",
|
||||||
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"get-intrinsic": "^1.2.4"
|
||||||
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
}
|
}
|
||||||
@@ -2106,15 +2044,17 @@
|
|||||||
"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.1.1",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.0.0.tgz",
|
||||||
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
|
"integrity": "sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==",
|
||||||
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"es-errors": "^1.3.0"
|
"es-errors": "^1.3.0"
|
||||||
@@ -2124,15 +2064,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/es-set-tostringtag": {
|
"node_modules/es-set-tostringtag": {
|
||||||
"version": "2.1.0",
|
"version": "2.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.3.tgz",
|
||||||
"integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
|
"integrity": "sha512-3T8uNMC3OQTHkFUsFq8r/BwAXLHvU/9O9mE0fBc/MY5iq/8H7ncvO947LmYA6ldWw9Uh8Yhf25zu6n7nML5QWQ==",
|
||||||
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"es-errors": "^1.3.0",
|
"get-intrinsic": "^1.2.4",
|
||||||
"get-intrinsic": "^1.2.6",
|
|
||||||
"has-tostringtag": "^1.0.2",
|
"has-tostringtag": "^1.0.2",
|
||||||
"hasown": "^2.0.2"
|
"hasown": "^2.0.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
@@ -2911,26 +2851,6 @@
|
|||||||
"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",
|
||||||
@@ -2941,22 +2861,6 @@
|
|||||||
"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",
|
||||||
@@ -2982,6 +2886,7 @@
|
|||||||
"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"
|
||||||
@@ -3017,21 +2922,17 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/get-intrinsic": {
|
"node_modules/get-intrinsic": {
|
||||||
"version": "1.3.0",
|
"version": "1.2.4",
|
||||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz",
|
||||||
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
|
"integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==",
|
||||||
|
"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",
|
||||||
"get-proto": "^1.0.1",
|
"has-proto": "^1.0.1",
|
||||||
"gopd": "^1.2.0",
|
"has-symbols": "^1.0.3",
|
||||||
"has-symbols": "^1.1.0",
|
"hasown": "^2.0.0"
|
||||||
"hasown": "^2.0.2",
|
|
||||||
"math-intrinsics": "^1.1.0"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
@@ -3040,19 +2941,6 @@
|
|||||||
"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",
|
||||||
@@ -3153,12 +3041,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/gopd": {
|
"node_modules/gopd": {
|
||||||
"version": "1.2.0",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
|
||||||
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
|
"integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
|
||||||
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"dependencies": {
|
||||||
"node": ">= 0.4"
|
"get-intrinsic": "^1.1.3"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
@@ -3218,9 +3107,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/has-symbols": {
|
"node_modules/has-symbols": {
|
||||||
"version": "1.1.0",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
|
||||||
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
|
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
|
||||||
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
@@ -3233,6 +3123,7 @@
|
|||||||
"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"
|
||||||
@@ -3248,6 +3139,7 @@
|
|||||||
"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"
|
||||||
@@ -3829,15 +3721,6 @@
|
|||||||
"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",
|
||||||
@@ -3862,27 +3745,6 @@
|
|||||||
"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",
|
||||||
@@ -4344,12 +4206,6 @@
|
|||||||
"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",
|
||||||
@@ -5373,9 +5229,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/vite": {
|
"node_modules/vite": {
|
||||||
"version": "5.4.4",
|
"version": "5.4.14",
|
||||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.4.tgz",
|
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.14.tgz",
|
||||||
"integrity": "sha512-RHFCkULitycHVTtelJ6jQLd+KSAAzOgEYorV32R2q++M6COBjKJR6BxqClwp5sf0XaBDjVMuJ9wnNfyAJwjMkA==",
|
"integrity": "sha512-EK5cY7Q1D8JNhSaPKVK4pwBFvaTmZxEnoKXLG/U9gmdDcihQGNzFlgIvaxezFR4glP1LsuiedwMBqCXH3wZccA==",
|
||||||
"devOptional": true,
|
"devOptional": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
},
|
},
|
||||||
"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",
|
||||||
@@ -32,7 +31,7 @@
|
|||||||
"unplugin-fonts": "^1.1.1",
|
"unplugin-fonts": "^1.1.1",
|
||||||
"unplugin-vue-components": "^0.27.2",
|
"unplugin-vue-components": "^0.27.2",
|
||||||
"unplugin-vue-router": "^0.10.0",
|
"unplugin-vue-router": "^0.10.0",
|
||||||
"vite": "^5.3.3",
|
"vite": "^5.4.14",
|
||||||
"vite-plugin-vue-layouts": "^0.11.0",
|
"vite-plugin-vue-layouts": "^0.11.0",
|
||||||
"vite-plugin-vuetify": "^2.0.3",
|
"vite-plugin-vuetify": "^2.0.3",
|
||||||
"vue-router": "^4.4.0"
|
"vue-router": "^4.4.0"
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
<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>
|
|
||||||
|
Before Width: | Height: | Size: 1.4 KiB |
@@ -1,341 +0,0 @@
|
|||||||
<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,8 +10,7 @@
|
|||||||
</v-form>
|
</v-form>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<v-btn type="submit" form="code-form" color="green">Aceptar</v-btn>
|
<v-btn type="submit" form="code-form">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>
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<v-btn @click="downloadCSV">Descargar CSV</v-btn>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import { inject } from 'vue';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'ExportPurchasesForTryton',
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
api: inject('api'),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
downloadCSV() {
|
|
||||||
this.api.getCSVForTryton()
|
|
||||||
.then(data => {
|
|
||||||
const blob = new Blob([data['csv']], {type: 'text/csv'});
|
|
||||||
const pattern = /[/: ]/g;
|
|
||||||
const datetime = new Date();
|
|
||||||
const date = datetime.toLocaleDateString().replace(pattern, '-');
|
|
||||||
const time = datetime.toLocaleTimeString().replace(pattern, '-');
|
|
||||||
const name = `VentasTryton_${date}_${time}.csv`;
|
|
||||||
const link = document.createElement('a');
|
|
||||||
|
|
||||||
link.href = URL.createObjectURL(blob);
|
|
||||||
link.download = name;
|
|
||||||
link.click();
|
|
||||||
URL.revokeObjectURL(link.href);
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error(error);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
<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>
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
<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>
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<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,107 +3,45 @@
|
|||||||
<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>
|
||||||
<v-btn
|
<template v-if="$vuetify.display.mdAndUp">
|
||||||
v-if="!isAuthenticated"
|
<v-btn icon="mdi-magnify" variant="text"></v-btn>
|
||||||
prepend-icon="mdi-login"
|
<v-btn icon="mdi-filter" variant="text"></v-btn>
|
||||||
variant="text"
|
</template>
|
||||||
@click="navigate('/autenticarse')"
|
<v-btn icon="mdi-dots-vertical" variant="text"></v-btn>
|
||||||
>
|
|
||||||
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>
|
||||||
density="compact"
|
<v-list-item v-for="item in menuItems" :key="item.title" @click="navigate(item.route)">
|
||||||
nav
|
<v-list-item-title>{{ item.title }}</v-list-item-title>
|
||||||
>
|
|
||||||
<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: '/', icon: 'mdi-home'},
|
{ title: 'Inicio', route: '/'},
|
||||||
{ title: 'Comprar', route:'/comprar', icon: 'mdi-cart'},
|
{ title: 'Comprar', route:'/comprar'},
|
||||||
],
|
{ title: 'Cuadrar tarro', route: '/cuadrar_tarro'},
|
||||||
menuAdminItems: [
|
{ title: 'Cuadres de tarro', route: '/cuadres_de_tarro'},
|
||||||
{ 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">
|
||||||
@@ -276,7 +276,14 @@
|
|||||||
fetchProducts() {
|
fetchProducts() {
|
||||||
this.api.getProducts()
|
this.api.getProducts()
|
||||||
.then(data => {
|
.then(data => {
|
||||||
this.products = data;
|
const transformed_products = data.map(item => ({
|
||||||
|
id: item.id,
|
||||||
|
name: item.name,
|
||||||
|
price: item["template."]?.list_price?.decimal,
|
||||||
|
measuring_unit: item["default_uom."]?.name,
|
||||||
|
categories: []
|
||||||
|
}));
|
||||||
|
this.products = transformed_products;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@@ -285,7 +292,7 @@
|
|||||||
fetchPaymentMethods() {
|
fetchPaymentMethods() {
|
||||||
this.api.getPaymentMethods()
|
this.api.getPaymentMethods()
|
||||||
.then(data => {
|
.then(data => {
|
||||||
this.payment_methods = data;
|
this.payment_methods = data[0]?.payment_methods;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@@ -309,8 +316,21 @@
|
|||||||
},
|
},
|
||||||
async submit() {
|
async submit() {
|
||||||
this.$refs.purchase.validate();
|
this.$refs.purchase.validate();
|
||||||
|
const tryton_sale = {
|
||||||
|
party: this.purchase.customer,
|
||||||
|
company: "1",
|
||||||
|
currency: "31",
|
||||||
|
pickup_location: "on_site",
|
||||||
|
lines: [[
|
||||||
|
"create", this.purchase.saleline_set.map(item => ({
|
||||||
|
product: item.product,
|
||||||
|
quantity: item.quantity,
|
||||||
|
unitprice: item.unit_price
|
||||||
|
})
|
||||||
|
)]]};
|
||||||
|
|
||||||
if (this.valid) {
|
if (this.valid) {
|
||||||
this.api.createPurchase(this.purchase)
|
this.api.createPurchase(tryton_sale)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log('Compra enviada:', data);
|
console.log('Compra enviada:', data);
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
|
|||||||
@@ -39,26 +39,8 @@
|
|||||||
{{ 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: '/' }" color="green">Ir al inicio</v-btn>
|
<v-btn :to="{ path: 'comprar' }" color="green">Ir a Comprar</v-btn>
|
||||||
</div>
|
</div>
|
||||||
</v-container>
|
</v-container>
|
||||||
</v-container>
|
</v-container>
|
||||||
@@ -83,12 +65,6 @@
|
|||||||
{ 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() {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import ApiImplementation from './services/api-implementation';
|
|||||||
// Composables
|
// Composables
|
||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
|
|
||||||
|
process.env.API_IMPLEMENTATION = 'tryton';
|
||||||
let apiImplementation = new ApiImplementation();
|
let apiImplementation = new ApiImplementation();
|
||||||
const api = apiImplementation.getApi();
|
const api = apiImplementation.getApi();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
<template>
|
|
||||||
<Login />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
//
|
|
||||||
</script>
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
<template>
|
|
||||||
<v-container>
|
|
||||||
<v-card>
|
|
||||||
<v-card-title>
|
|
||||||
<span class="headline">Catálogo</span>
|
|
||||||
</v-card-title>
|
|
||||||
<v-card-text>
|
|
||||||
<v-list two-line>
|
|
||||||
<v-list-item v-for="item in items" :key="item.id" class="catalog-item">
|
|
||||||
<v-row no-gutters align="center" class="w-100">
|
|
||||||
<v-col cols="12" md="3" class="d-flex">
|
|
||||||
<v-img :src="item.img" class="product-img" contain></v-img>
|
|
||||||
</v-col>
|
|
||||||
|
|
||||||
<v-col cols="12" md="6">
|
|
||||||
<v-list-item-title class="title">{{ item.name }}</v-list-item-title>
|
|
||||||
<v-list-item-subtitle class="subtitle">{{ item.description }}</v-list-item-subtitle>
|
|
||||||
<div class="prices mt-2">
|
|
||||||
<div class="price-line">Precio unitario: <strong>{{ currency(item.price) }}</strong></div>
|
|
||||||
<div class="price-line">Precio total: <strong>{{ currency(item.price * item.quantity) }}</strong></div>
|
|
||||||
</div>
|
|
||||||
</v-col>
|
|
||||||
|
|
||||||
<v-col cols="12" md="3" class="d-flex align-center justify-end">
|
|
||||||
<div class="quantity-controls">
|
|
||||||
<v-btn small text class="qty-btn" @click="decrease(item)"><v-icon small>mdi-minus</v-icon></v-btn>
|
|
||||||
<v-text-field
|
|
||||||
v-model.number="item.quantity"
|
|
||||||
type="number"
|
|
||||||
min="0"
|
|
||||||
class="quantity-input"
|
|
||||||
dense
|
|
||||||
outlined
|
|
||||||
hide-details
|
|
||||||
aria-label="Cantidad"
|
|
||||||
/>
|
|
||||||
<v-btn small text class="qty-btn" @click="increase(item)"><v-icon small>mdi-plus</v-icon></v-btn>
|
|
||||||
</div>
|
|
||||||
</v-col>
|
|
||||||
</v-row>
|
|
||||||
</v-list-item>
|
|
||||||
</v-list>
|
|
||||||
</v-card-text>
|
|
||||||
<v-card-actions>
|
|
||||||
<v-btn color="primary">Ver más</v-btn>
|
|
||||||
</v-card-actions>
|
|
||||||
</v-card>
|
|
||||||
</v-container>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
items: [
|
|
||||||
{ id: 1, name: 'Producto 1', description: 'Descripción del producto 1', img: 'https://picsum.photos/300/200?random=1', quantity: 0, price: 1200 },
|
|
||||||
{ id: 1, name: 'Producto 2', description: 'Descripción del producto 1', img: 'https://picsum.photos/300/200?random=1', quantity: 0, price: 1200 },
|
|
||||||
{ id: 1, name: 'Producto 3', description: 'Descripción del producto 1', img: 'https://picsum.photos/300/200?random=1', quantity: 0, price: 1200 },
|
|
||||||
{ id: 1, name: 'Producto 4', description: 'Descripción del producto 1', img: 'https://picsum.photos/300/200?random=1', quantity: 0, price: 1200 },
|
|
||||||
{ id: 1, name: 'Producto 5', description: 'Descripción del producto 1', img: 'https://picsum.photos/300/200?random=1', quantity: 0, price: 1200 },
|
|
||||||
{ id: 1, name: 'Producto 6', description: 'Descripción del producto 1', img: 'https://picsum.photos/300/200?random=1', quantity: 0, price: 1200 },
|
|
||||||
{ id: 1, name: 'Producto 7', description: 'Descripción del producto 1', img: 'https://picsum.photos/300/200?random=1', quantity: 0, price: 1200 },
|
|
||||||
{ id: 1, name: 'Producto 8', description: 'Descripción del producto 1', img: 'https://picsum.photos/300/200?random=1', quantity: 0, price: 1200 },
|
|
||||||
{ id: 1, name: 'Producto 9', description: 'Descripción del producto 1', img: 'https://picsum.photos/300/200?random=1', quantity: 0, price: 1200 },
|
|
||||||
{ id: 1, name: 'Producto 10', description: 'Descripción del producto 1', img: 'https://picsum.photos/300/200?random=1', quantity: 0, price: 1200 },
|
|
||||||
{ id: 1, name: 'Producto 11', description: 'Descripción del producto 1', img: 'https://picsum.photos/300/200?random=1', quantity: 0, price: 1200 },
|
|
||||||
{ id: 1, name: 'Producto 12', description: 'Descripción del producto 1', img: 'https://picsum.photos/300/200?random=1', quantity: 0, price: 1200 },
|
|
||||||
{ id: 1, name: 'Producto 13', description: 'Descripción del producto 1', img: 'https://picsum.photos/300/200?random=1', quantity: 0, price: 1200 },
|
|
||||||
{ id: 1, name: 'Producto 14', description: 'Descripción del producto 1', img: 'https://picsum.photos/300/200?random=1', quantity: 0, price: 1200 },
|
|
||||||
{ id: 1, name: 'Producto 15', description: 'Descripción del producto 1', img: 'https://picsum.photos/300/200?random=1', quantity: 0, price: 1200 },
|
|
||||||
{ id: 1, name: 'Producto 16', description: 'Descripción del producto 1', img: 'https://picsum.photos/300/200?random=1', quantity: 0, price: 1200 },
|
|
||||||
],
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
increase(item) {
|
|
||||||
item.quantity = Number(item.quantity) + 1;
|
|
||||||
},
|
|
||||||
decrease(item) {
|
|
||||||
item.quantity = Math.max(0, Number(item.quantity) - 1);
|
|
||||||
},
|
|
||||||
currency(val) {
|
|
||||||
if (val == null) return '-';
|
|
||||||
return new Intl.NumberFormat('es-CO', { style: 'currency', currency: 'COP', minimumFractionDigits: 0 }).format(val);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.headline {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
.catalog-item {
|
|
||||||
padding-top: 12px;
|
|
||||||
padding-bottom: 12px;
|
|
||||||
}
|
|
||||||
.product-img {
|
|
||||||
width: 150px;
|
|
||||||
height: 100px;
|
|
||||||
border-radius: 6px;
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
|
||||||
.quantity-controls {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
.prices .price-line {
|
|
||||||
margin-bottom: 4px;
|
|
||||||
}
|
|
||||||
.quantity-input {
|
|
||||||
max-width: 90px;
|
|
||||||
}
|
|
||||||
.quantity-input input {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.qty-btn {
|
|
||||||
min-width: 36px !important;
|
|
||||||
height: 36px !important;
|
|
||||||
border-radius: 18px !important;
|
|
||||||
}
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
.product-img {
|
|
||||||
width: 120px;
|
|
||||||
height: 80px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<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>
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<template>
|
|
||||||
<Logout />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
//
|
|
||||||
</script>
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
<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>
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
<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>
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
<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>
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<CodeDialog @code-verified="(verified) => showComponent = verified"/>
|
|
||||||
</div>
|
|
||||||
<ExportPurchasesForTryton v-if="showComponent" />
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import CodeDialog from '../components/CodeDialog.vue'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
showComponent: false,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
components: { CodeDialog },
|
|
||||||
methods: {},
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,12 +1,20 @@
|
|||||||
import DjangoApi from './django-api';
|
import DjangoApi from './django-api';
|
||||||
|
import TrytonApiClient from './tryton-api';
|
||||||
import Api from './api';
|
import Api from './api';
|
||||||
|
|
||||||
class ApiImplementation {
|
class ApiImplementation {
|
||||||
constructor() {
|
constructor() {
|
||||||
const implementation = import.meta.env.VITE_API_IMPLEMENTATION;
|
const implementation = process.env.API_IMPLEMENTATION;
|
||||||
let apiImplementation;
|
let apiImplementation;
|
||||||
if (implementation === 'django') {
|
if (implementation === 'django') {
|
||||||
apiImplementation = new DjangoApi();
|
apiImplementation = new DjangoApi();
|
||||||
|
} else if (implementation === 'tryton'){
|
||||||
|
const url = 'http://192.168.85.45:18030';
|
||||||
|
const key = '9a9ffc430146447d81e6698240199a4be2b0e774cb18474999d0f60e33b5b1eb1cfff9d9141346a98844879b5a9e787489c891ddc8fb45cc903b7244cab64fb1';
|
||||||
|
const db = 'tryton';
|
||||||
|
const applicationName = 'sale_don_confiao';
|
||||||
|
apiImplementation = new TrytonApiClient(
|
||||||
|
url, key, db, applicationName);
|
||||||
} else {
|
} else {
|
||||||
throw new Error("API implementation don't configured");
|
throw new Error("API implementation don't configured");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,22 +46,6 @@ class Api {
|
|||||||
createCustomer(customer) {
|
createCustomer(customer) {
|
||||||
return this.apiImplementation.createCustomer(customer);
|
return this.apiImplementation.createCustomer(customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
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,17 +1,6 @@
|
|||||||
import AuthService from '@/services/auth';
|
|
||||||
import http from '@/services/http';
|
|
||||||
|
|
||||||
class DjangoApi {
|
class DjangoApi {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.base = import.meta.env.VITE_DJANGO_BASE_URL;
|
this.base = 'http://localhost:7000';
|
||||||
}
|
|
||||||
|
|
||||||
getRequest(url) {
|
|
||||||
return http.get(url).then(r => r.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
postRequest(url, payload) {
|
|
||||||
return http.post(url, payload).then(r => r.data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getCustomers() {
|
getCustomers() {
|
||||||
@@ -69,24 +58,43 @@ class DjangoApi {
|
|||||||
return this.postRequest(url, customer);
|
return this.postRequest(url, customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
getCSVForTryton() {
|
getRequest(url) {
|
||||||
const url = this.base + '/don_confiao/api/sales/for_tryton';
|
return new Promise ((resolve, reject) => {
|
||||||
return this.getRequest(url);
|
fetch(url)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
resolve(data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getProductsFromTryton(){
|
postRequest(url, content) {
|
||||||
const url = this.base + '/don_confiao/api/importar_productos_de_tryton';
|
return new Promise((resolve, reject) => {
|
||||||
return this.postRequest(url, {});
|
fetch(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);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
getCustomersFromTryton(){
|
|
||||||
const url = this.base + '/don_confiao/api/importar_clientes_de_tryton';
|
|
||||||
return this.postRequest(url, {});
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
sendSalesToTryton(){
|
.catch(error => reject(error));
|
||||||
const url = this.base + '/don_confiao/api/enviar_ventas_a_tryton';
|
});
|
||||||
return this.postRequest(url, {});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
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;
|
|
||||||
@@ -46,11 +46,10 @@ export default defineConfig({
|
|||||||
vueTemplate: true,
|
vueTemplate: true,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
define: { 'process.env': {
|
define: { 'process.env': {} },
|
||||||
} },
|
|
||||||
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