From dac5a0b4e19cbc99360b719cc159f50fd1436218 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 20 Oct 2022 13:42:49 +0200 Subject: [PATCH] Customer basic data & skeleton --- src/components/SkeletonForm.vue | 30 +++ src/composables/useValidator.js | 13 +- src/filters/index.js | 4 +- src/filters/toCurrency.js | 21 ++ src/i18n/en/index.js | 49 +++- src/i18n/es/index.js | 15 ++ src/pages/Claim/Card/ClaimBasicData.vue | 6 +- src/pages/Claim/Card/ClaimCard.vue | 6 +- src/pages/Claim/Card/ClaimSummary.vue | 2 +- src/pages/Claim/ClaimList.vue | 3 +- src/pages/Customer/Card/CustomerBasicData.vue | 245 +++++++++++++++++- src/pages/Customer/Card/CustomerCard.vue | 153 +++++++---- src/pages/Customer/Card/CustomerSummary.vue | 188 ++++++++++++++ src/pages/Customer/CustomerList.vue | 18 +- src/router/modules/customer.js | 11 +- 15 files changed, 692 insertions(+), 72 deletions(-) create mode 100644 src/components/SkeletonForm.vue create mode 100644 src/filters/toCurrency.js create mode 100644 src/pages/Customer/Card/CustomerSummary.vue diff --git a/src/components/SkeletonForm.vue b/src/components/SkeletonForm.vue new file mode 100644 index 000000000..179744c26 --- /dev/null +++ b/src/components/SkeletonForm.vue @@ -0,0 +1,30 @@ + diff --git a/src/composables/useValidator.js b/src/composables/useValidator.js index 8fbacb790..16f6239f9 100644 --- a/src/composables/useValidator.js +++ b/src/composables/useValidator.js @@ -33,13 +33,24 @@ export function useValidator() { return validations(validation)[validation.validation]; }); + if (property === 'socialName') { + console.log(modelValidations[property]) + } + return rules; } const { t } = useI18n(); const validations = function (validation) { + return { - presence: (value) => !validator.isEmpty(value ? String(value) : '') || t(validation.message), + presence: (value) => { + let message = `Value can't be empty`; + if (validation.message) + message = t(validation.message) || validation.message + + return !validator.isEmpty(value ? String(value) : '') || message + }, length: (value) => { const options = { min: validation.min || validation.is, diff --git a/src/filters/index.js b/src/filters/index.js index 004d1e4ec..cbe044219 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -1,7 +1,9 @@ import toLowerCase from './toLowerCase'; import toDate from './toDate'; +import toCurrency from './toCurrency'; export { toLowerCase, - toDate + toDate, + toCurrency, }; diff --git a/src/filters/toCurrency.js b/src/filters/toCurrency.js new file mode 100644 index 000000000..34586b5db --- /dev/null +++ b/src/filters/toCurrency.js @@ -0,0 +1,21 @@ +import { useI18n } from 'vue-i18n'; + +export default function (value, symbol = 'EUR', fractionSize = 2) { + if (!value) return; + + const { locale } = useI18n(); + + const options = { + style: 'currency', + currency: symbol, + minimumFractionDigits: fractionSize, + maximumFractionDigits: fractionSize + }; + + const lang = locale.value == 'es' ? 'de' : locale.value; + + return new Intl.NumberFormat(lang, options) + .format(value); + + +} \ No newline at end of file diff --git a/src/i18n/en/index.js b/src/i18n/en/index.js index 0f3abd37f..dd69cafe7 100644 --- a/src/i18n/en/index.js +++ b/src/i18n/en/index.js @@ -13,7 +13,8 @@ export default { logOut: 'Log out', dataSaved: 'Data saved', save: 'Save', - reset: 'Reset' + reset: 'Reset', + noChanges: 'No changes to save' }, moduleIndex: { allModules: 'All modules' @@ -50,6 +51,34 @@ export default { email: 'Email', customerOrders: 'Display customer orders', moreOptions: 'More options' + }, + card: { + customerId: 'Claim ID', + salesPerson: 'Sales person', + credit: 'Credit', + securedCredit: 'Secured credit', + payMethod: 'Pay method', + debt: 'Debt' + }, + summary: { + customerId: 'Customer ID', + socialName: 'Social name', + contact: 'Contact', + phone: 'Phone', + mobile: 'Mobile', + email: 'Email', + salesPerson: 'Sales person', + contactChannel: 'Contact channel', + }, + basicData: { + socialName: 'Fiscal name', + businessType: 'Business type', + contact: 'Contact', + email: 'Email', + phone: 'Phone', + mobile: 'Mobile', + salesPerson: 'Sales person', + contactChannel: 'Contact channel' } }, ticket: { @@ -83,14 +112,6 @@ export default { customerSummary: 'Customer summary', claimedTicket: 'Claimed ticket' }, - basicData: { - customer: 'Customer', - assignedTo: 'Assigned', - created: 'Created', - state: 'State', - packages: 'Packages', - picked: 'Picked', - }, summary: { customer: 'Customer', assignedTo: 'Assigned', @@ -105,7 +126,15 @@ export default { quantity: 'Quantity' } }, - } + }, + basicData: { + customer: 'Customer', + assignedTo: 'Assigned', + created: 'Created', + state: 'State', + packages: 'Packages', + picked: 'Picked', + }, }, components: { topbar: {}, diff --git a/src/i18n/es/index.js b/src/i18n/es/index.js index 286f0bff6..ec4420ba4 100644 --- a/src/i18n/es/index.js +++ b/src/i18n/es/index.js @@ -51,6 +51,21 @@ export default { email: 'Email', customerOrders: 'Mostrar órdenes del cliente', moreOptions: 'Más opciones' + }, + card: { + customerId: 'ID cliente', + credit: 'Crédito', + securedCredit: 'Crédito asegurado' + }, + basicData: { + socialName: 'Nombre fiscal', + businessType: 'Tipo de negocio', + contact: 'Contacto', + email: 'Email', + phone: 'Teléfono', + mobile: 'Móvil', + salesPerson: 'Comercial', + contactChannel: 'Canal de contacto' } }, ticket: { diff --git a/src/pages/Claim/Card/ClaimBasicData.vue b/src/pages/Claim/Card/ClaimBasicData.vue index e54dc8e4a..acfb7a320 100644 --- a/src/pages/Claim/Card/ClaimBasicData.vue +++ b/src/pages/Claim/Card/ClaimBasicData.vue @@ -6,6 +6,7 @@ import { useQuasar } from 'quasar'; import axios from 'axios'; import { useSession } from 'src/composables/useSession'; import { useValidator } from 'src/composables/useValidator'; +import SkeletonForm from 'src/components/SkeletonForm.vue'; onMounted(() => { fetch(); @@ -50,7 +51,7 @@ const workersCopy = ref([]); function fetchWorkers() { const filter = { where: { - role: 'employee', + role: 'salesPerson', }, }; const options = { params: { filter } }; @@ -134,13 +135,14 @@ function onReset() {
+
- +