Merge branch 'dev' of https: refs #7553//gitea.verdnatura.es/verdnatura/salix-front into 7553_FixTicketExpedition
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
23e5072d38
|
@ -0,0 +1,33 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function getCurrentBranchName(p = process.cwd()) {
|
||||
if (!fs.existsSync(p)) return false;
|
||||
|
||||
const gitHeadPath = path.join(p, '.git', 'HEAD');
|
||||
|
||||
if (!fs.existsSync(gitHeadPath))
|
||||
return getCurrentBranchName(path.resolve(p, '..'));
|
||||
|
||||
const headContent = fs.readFileSync(gitHeadPath, 'utf-8');
|
||||
return headContent.trim().split('/')[2];
|
||||
}
|
||||
|
||||
const branchName = getCurrentBranchName();
|
||||
|
||||
if (branchName) {
|
||||
const msgPath = `.git/COMMIT_EDITMSG`;
|
||||
const msg = fs.readFileSync(msgPath, 'utf-8');
|
||||
const reference = branchName.match(/^\d+/);
|
||||
|
||||
const referenceTag = `refs #${reference}`;
|
||||
if (!msg.includes(referenceTag) && reference) {
|
||||
const splitedMsg = msg.split(':');
|
||||
|
||||
if (splitedMsg.length > 1) {
|
||||
const finalMsg = splitedMsg[0] + ': ' + referenceTag + splitedMsg.slice(1).join(':');
|
||||
fs.writeFileSync(msgPath, finalMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
echo "Running husky commit-msg hook"
|
||||
npx --no-install commitlint --edit
|
||||
echo "Adding reference tag to commit message"
|
||||
node .husky/addReferenceTag.js
|
||||
|
88
CHANGELOG.md
88
CHANGELOG.md
|
@ -1,3 +1,91 @@
|
|||
# Version 24.32 - 2024-08-06
|
||||
|
||||
### Added 🆕
|
||||
|
||||
- chore: refs #7197 drop space by:jorgep
|
||||
- chore: refs #7197 drop useless attr by:jorgep
|
||||
- chore: refs #7197 fix test by:jorgep
|
||||
- chore: refs #7197 fix tests by:jorgep
|
||||
- chore: refs #7197 fix unit tests by:jorgep
|
||||
- chore: refs #7197 idrop useless class by:jorgep
|
||||
- chore: refs #7197 improve form filling in Cypress tests by:jorgep
|
||||
- chore: refs #7197 remove unused import by:jorgep
|
||||
- feat: customerPayments card view by:alexm
|
||||
- feat: refs #6943 lock grid mode by:jorgep
|
||||
- feat: refs #6943 wip consumption filter by:jorgep
|
||||
- feat: refs #7197 add correcting filter by:jorgep
|
||||
- feat: refs #7197 add supplier activities filter option by:jorgep
|
||||
- feat: refs #7197 summary responsive by:jorgep
|
||||
- feat: refs #7323 fix descriptors, added VnTable and minor changes by:Jon
|
||||
- feat: refs #7323 fixed tests, changed calendar styles and fix workerCreate by:Jon
|
||||
- feat: refs #7356 list & weekly to VnTable and style fixes by:Jon
|
||||
- feat: refs #7401 add menu options by:pablone
|
||||
- feat: SalesClientTable by:Javier Segarra
|
||||
- feat: salesOrderTable by:Javier Segarra
|
||||
- feat: salesTicketTable by:Javier Segarra
|
||||
- feat: VnTable SalesTicketTable by:Javier Segarra
|
||||
- fix: columns style by:alexm
|
||||
|
||||
### Changed 📦
|
||||
|
||||
- perf: LeftMenu show/hide by:Javier Segarra
|
||||
- perf: refs #7356 TicketList state column by:Jon
|
||||
- perf: VnFilterPanel (origin/7323_WorkerMigration_End) by:Javier Segarra
|
||||
- perf: width SalesTicketsTable by:Javier Segarra
|
||||
- refactor: #6943 wip use vnTable CustomerCredits by:jorgep
|
||||
- refactor: CustomerNotifications use VnTable by:alexm
|
||||
- refactor: CustomerPayments use VnTable by:alexm
|
||||
- refactor: refs #7014 deleted main files and changed route files by:Jon
|
||||
- refactor: refs #7014 improved route.js & deleted RouteMain by:Jon
|
||||
- refactor: refs #7014 refactor <module>Main.vue by:Jon
|
||||
- refactor: refs #7014 refactor ZoneCard, deleted ZoneMain & created basic tests for functionality by:Jon
|
||||
- refactor: refs #7197 use invoiceInSearchbar & queryParams by:jorgep
|
||||
- refactor: refs #7323 hidden column filter proposal by:Jon
|
||||
- refactor: refs #7356 fixed VnTable filters by:Jon
|
||||
- refactor: refs #7356 requested changes by:Jon
|
||||
- refactor: wip use vnTable CustomerCredits by:jorgep
|
||||
|
||||
### Fixed 🛠️
|
||||
|
||||
- chore: refs #7197 fix test by:jorgep
|
||||
- chore: refs #7197 fix tests by:jorgep
|
||||
- chore: refs #7197 fix unit tests by:jorgep
|
||||
- feat: refs #7323 fix descriptors, added VnTable and minor changes by:Jon
|
||||
- feat: refs #7323 fixed tests, changed calendar styles and fix workerCreate by:Jon
|
||||
- feat: refs #7356 list & weekly to VnTable and style fixes by:Jon
|
||||
- fix(claim): small details (6336-claim-v6) by:alexm
|
||||
- fix: columns style by:alexm
|
||||
- fix: customer defaulter add amount order (6943-fixCustomer) by:alexm
|
||||
- fix: customerDefaulter correct functionality by:alexm
|
||||
- fix: customerNotifications filter by:alexm
|
||||
- fix: fix conflicts by:Jon
|
||||
- fix: refs #6101 fix TicketList by:Jon
|
||||
- fix: refs #6891 worker tests by:jorgep
|
||||
- fix: refs #6943 drop padding-left checkbox & create wrap mode vnRow by:jorgep
|
||||
- fix: refs #6943 prevent undefined by:jorgep
|
||||
- fix: refs #7014 fix tests by:Jon
|
||||
- fix: refs #7014 fix wagon module by:Jon
|
||||
- fix: refs #7197 add url InvoiceInSearchbar by:jorgep
|
||||
- fix: refs #7197 amount reactivity by:jorgep
|
||||
- fix: refs #7197 drop character by:jorgep
|
||||
- fix: refs #7197 reactivity invoiceCorrection by:jorgep
|
||||
- fix: refs #7197 responsive summary layout by:jorgep
|
||||
- fix: refs #7197 rollback by:jorgep
|
||||
- fix: refs #7197 rollback crudModel by:jorgep
|
||||
- fix: refs #7197 setInvoiceInCorrecition by:jorgep
|
||||
- fix: refs #7197 vat, intrastat, filter and list sections by:jorgep
|
||||
- fix: refs #7323 fix department & email table filter by:Jon
|
||||
- fix: refs #7323 fixed left filter by:Jon
|
||||
- fix: refs #7323 fix workerTimeControl form by:Jon
|
||||
- fix: refs #7401 fix routeForm by:pablone
|
||||
- fix: refs #7401 remove console.log by:pablone
|
||||
- fix: refs CAU 207504 fix itemDiary and logs by:Jon
|
||||
- fix: workerCreate form street field to be always upperCase by:Jon
|
||||
- hotfix: refs CAU #207614 fix sale.concept field by:Jon
|
||||
- refactor: refs #7356 fixed VnTable filters by:Jon
|
||||
- refs #6898 fix by:carlossa
|
||||
- Ticket expedition initial load fix by:wbuezas
|
||||
|
||||
# Version 24.28 - 2024-07-09
|
||||
|
||||
### Added 🆕
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
module.exports = { extends: ['@commitlint/config-conventional'] };
|
10
package.json
10
package.json
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "salix-front",
|
||||
"version": "24.32.0",
|
||||
"version": "24.34.0",
|
||||
"description": "Salix frontend",
|
||||
"productName": "Salix",
|
||||
"author": "Verdnatura",
|
||||
|
@ -13,7 +13,10 @@
|
|||
"test:e2e:ci": "cd ../salix && gulp docker && cd ../salix-front && cypress run",
|
||||
"test": "echo \"See package.json => scripts for available tests.\" && exit 0",
|
||||
"test:unit": "vitest",
|
||||
"test:unit:ci": "vitest run"
|
||||
"test:unit:ci": "vitest run",
|
||||
"commitlint": "commitlint --edit",
|
||||
"prepare": "npx husky install",
|
||||
"addReferenceTag": "node .husky/addReferenceTag.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@quasar/cli": "^2.3.0",
|
||||
|
@ -29,6 +32,8 @@
|
|||
"vue-router": "^4.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^19.2.1",
|
||||
"@commitlint/config-conventional": "^19.1.0",
|
||||
"@intlify/unplugin-vue-i18n": "^0.8.1",
|
||||
"@pinia/testing": "^0.1.2",
|
||||
"@quasar/app-vite": "^1.7.3",
|
||||
|
@ -41,6 +46,7 @@
|
|||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-plugin-cypress": "^2.13.3",
|
||||
"eslint-plugin-vue": "^9.14.1",
|
||||
"husky": "^8.0.0",
|
||||
"postcss": "^8.4.23",
|
||||
"prettier": "^2.8.8",
|
||||
"vitest": "^0.31.1"
|
||||
|
|
5806
pnpm-lock.yaml
5806
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -43,6 +43,15 @@ const onResponseError = (error) => {
|
|||
}
|
||||
|
||||
switch (response?.status) {
|
||||
case 422:
|
||||
if (error.name == 'ValidationError')
|
||||
message +=
|
||||
' "' +
|
||||
responseError.details.context +
|
||||
'.' +
|
||||
Object.keys(responseError.details.codes).join(',') +
|
||||
'"';
|
||||
break;
|
||||
case 500:
|
||||
message = 'errors.statusInternalServerError';
|
||||
break;
|
||||
|
|
|
@ -1,28 +1,11 @@
|
|||
import { getCurrentInstance } from 'vue';
|
||||
|
||||
const filterAvailableInput = (element) => {
|
||||
return element.classList.contains('q-field__native') && !element.disabled;
|
||||
};
|
||||
const filterAvailableText = (element) => {
|
||||
return (
|
||||
element.__vueParentComponent.type.name === 'QInput' &&
|
||||
element.__vueParentComponent?.attrs?.class !== 'vn-input-date'
|
||||
);
|
||||
};
|
||||
|
||||
export default {
|
||||
mounted: function () {
|
||||
const vm = getCurrentInstance();
|
||||
if (vm.type.name === 'QForm') {
|
||||
if (!['searchbarForm', 'filterPanelForm'].includes(this.$el?.id)) {
|
||||
// AUTOFOCUS
|
||||
const elementsArray = Array.from(this.$el.elements);
|
||||
const availableInputs = elementsArray.filter(filterAvailableInput);
|
||||
const firstInputElement = availableInputs.find(filterAvailableText);
|
||||
|
||||
if (firstInputElement) {
|
||||
firstInputElement.focus();
|
||||
}
|
||||
// TODO: AUTOFOCUS IS NOT FOCUSING
|
||||
const that = this;
|
||||
this.$el.addEventListener('keyup', function (evt) {
|
||||
if (evt.key === 'Enter') {
|
||||
|
|
|
@ -4,8 +4,8 @@ import { useI18n } from 'vue-i18n';
|
|||
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnSelectProvince from 'components/VnSelectProvince.vue';
|
||||
import VnInput from 'components/common/VnInput.vue';
|
||||
import FormModelPopup from './FormModelPopup.vue';
|
||||
|
||||
const emit = defineEmits(['onDataSaved']);
|
||||
|
@ -19,8 +19,8 @@ const cityFormData = reactive({
|
|||
|
||||
const provincesOptions = ref([]);
|
||||
|
||||
const onDataSaved = (dataSaved) => {
|
||||
emit('onDataSaved', dataSaved);
|
||||
const onDataSaved = (...args) => {
|
||||
emit('onDataSaved', ...args);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -36,7 +36,7 @@ const onDataSaved = (dataSaved) => {
|
|||
:form-initial-data="cityFormData"
|
||||
url-create="towns"
|
||||
model="city"
|
||||
@on-data-saved="onDataSaved($event)"
|
||||
@on-data-saved="onDataSaved"
|
||||
>
|
||||
<template #form-inputs="{ data, validate }">
|
||||
<VnRow>
|
||||
|
@ -45,15 +45,7 @@ const onDataSaved = (dataSaved) => {
|
|||
v-model="data.name"
|
||||
:rules="validate('city.name')"
|
||||
/>
|
||||
<VnSelect
|
||||
:label="t('Province')"
|
||||
:options="provincesOptions"
|
||||
hide-selected
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
v-model="data.provinceFk"
|
||||
:rules="validate('city.provinceFk')"
|
||||
/>
|
||||
<VnSelectProvince v-model="data.provinceFk" />
|
||||
</VnRow>
|
||||
</template>
|
||||
</FormModelPopup>
|
||||
|
|
|
@ -5,9 +5,9 @@ import { useI18n } from 'vue-i18n';
|
|||
import FetchData from 'components/FetchData.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnSelectProvince from 'src/components/VnSelectProvince.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import CreateNewCityForm from './CreateNewCityForm.vue';
|
||||
import CreateNewProvinceForm from './CreateNewProvinceForm.vue';
|
||||
import VnSelectDialog from 'components/common/VnSelectDialog.vue';
|
||||
import FormModelPopup from './FormModelPopup.vue';
|
||||
|
||||
|
@ -22,20 +22,17 @@ const postcodeFormData = reactive({
|
|||
townFk: null,
|
||||
});
|
||||
|
||||
const townsFetchDataRef = ref(null);
|
||||
const provincesFetchDataRef = ref(null);
|
||||
const countriesOptions = ref([]);
|
||||
const provincesOptions = ref([]);
|
||||
const townsLocationOptions = ref([]);
|
||||
const town = ref({});
|
||||
|
||||
const onDataSaved = (formData) => {
|
||||
function onDataSaved(formData) {
|
||||
const newPostcode = {
|
||||
...formData,
|
||||
};
|
||||
const townObject = townsLocationOptions.value.find(
|
||||
({ id }) => id === formData.townFk
|
||||
);
|
||||
newPostcode.town = townObject?.name;
|
||||
newPostcode.town = town.value.name;
|
||||
newPostcode.townFk = town.value.id;
|
||||
const provinceObject = provincesOptions.value.find(
|
||||
({ id }) => id === formData.provinceFk
|
||||
);
|
||||
|
@ -43,39 +40,41 @@ const onDataSaved = (formData) => {
|
|||
const countryObject = countriesOptions.value.find(
|
||||
({ id }) => id === formData.countryFk
|
||||
);
|
||||
newPostcode.country = countryObject?.country;
|
||||
newPostcode.country = countryObject?.name;
|
||||
emit('onDataSaved', newPostcode);
|
||||
};
|
||||
}
|
||||
|
||||
const onCityCreated = async ({ name, provinceFk }, formData) => {
|
||||
await townsFetchDataRef.value.fetch();
|
||||
formData.townFk = townsLocationOptions.value.find((town) => town.name === name).id;
|
||||
formData.provinceFk = provinceFk;
|
||||
formData.countryFk = provincesOptions.value.find(
|
||||
(province) => province.id === provinceFk
|
||||
).countryFk;
|
||||
};
|
||||
|
||||
const onProvinceCreated = async ({ name }, formData) => {
|
||||
async function onCityCreated(newTown, formData) {
|
||||
await provincesFetchDataRef.value.fetch();
|
||||
formData.provinceFk = provincesOptions.value.find(
|
||||
(province) => province.name === name
|
||||
).id;
|
||||
};
|
||||
newTown.province = provincesOptions.value.find(
|
||||
(province) => province.id === newTown.provinceFk
|
||||
);
|
||||
formData.townFk = newTown;
|
||||
setTown(newTown, formData);
|
||||
}
|
||||
|
||||
function setTown(newTown, data) {
|
||||
if (!newTown) return;
|
||||
town.value = newTown;
|
||||
data.provinceFk = newTown.provinceFk;
|
||||
data.countryFk = newTown.province.countryFk;
|
||||
}
|
||||
|
||||
async function setProvince(id, data) {
|
||||
await provincesFetchDataRef.value.fetch();
|
||||
const newProvince = provincesOptions.value.find((province) => province.id == id);
|
||||
if (!newProvince) return;
|
||||
|
||||
data.countryFk = newProvince.countryFk;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
ref="townsFetchDataRef"
|
||||
@on-fetch="(data) => (townsLocationOptions = data)"
|
||||
auto-load
|
||||
url="Towns/location"
|
||||
/>
|
||||
<FetchData
|
||||
ref="provincesFetchDataRef"
|
||||
@on-fetch="(data) => (provincesOptions = data)"
|
||||
auto-load
|
||||
url="Provinces"
|
||||
url="Provinces/location"
|
||||
/>
|
||||
<FetchData
|
||||
@on-fetch="(data) => (countriesOptions = data)"
|
||||
|
@ -88,6 +87,7 @@ const onProvinceCreated = async ({ name }, formData) => {
|
|||
:title="t('New postcode')"
|
||||
:subtitle="t('Please, ensure you put the correct data!')"
|
||||
:form-initial-data="postcodeFormData"
|
||||
:mapper="(data) => (data.townFk = data.townFk.id) && data"
|
||||
@on-data-saved="onDataSaved"
|
||||
>
|
||||
<template #form-inputs="{ data, validate }">
|
||||
|
@ -99,38 +99,43 @@ const onProvinceCreated = async ({ name }, formData) => {
|
|||
/>
|
||||
<VnSelectDialog
|
||||
:label="t('City')"
|
||||
:options="townsLocationOptions"
|
||||
url="Towns/location"
|
||||
@update:model-value="(value) => setTown(value, data)"
|
||||
v-model="data.townFk"
|
||||
hide-selected
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
:rules="validate('postcode.city')"
|
||||
:roles-allowed-to-create="['deliveryAssistant']"
|
||||
:emit-value="false"
|
||||
clearable
|
||||
>
|
||||
<template #option="{ itemProps, opt }">
|
||||
<QItem v-bind="itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel>{{ opt.name }}</QItemLabel>
|
||||
<QItemLabel caption>
|
||||
{{ opt.province.name }},
|
||||
{{ opt.province.country.name }}
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
<template #form>
|
||||
<CreateNewCityForm @on-data-saved="onCityCreated($event, data)" />
|
||||
<CreateNewCityForm
|
||||
@on-data-saved="
|
||||
(_, requestResponse) =>
|
||||
onCityCreated(requestResponse, data)
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
</VnSelectDialog>
|
||||
</VnRow>
|
||||
<VnRow class="row q-gutter-md q-mb-xl">
|
||||
<VnSelectDialog
|
||||
:label="t('Province')"
|
||||
:options="provincesOptions"
|
||||
hide-selected
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
<VnRow>
|
||||
<VnSelectProvince
|
||||
@update:model-value="(value) => setProvince(value, data)"
|
||||
v-model="data.provinceFk"
|
||||
:rules="validate('postcode.provinceFk')"
|
||||
:roles-allowed-to-create="['deliveryAssistant']"
|
||||
>
|
||||
<template #form>
|
||||
<CreateNewProvinceForm
|
||||
@on-data-saved="onProvinceCreated($event, data)"
|
||||
/>
|
||||
</template> </VnSelectDialog
|
||||
></VnRow>
|
||||
<VnRow class="row q-gutter-md q-mb-xl"
|
||||
><VnSelect
|
||||
<VnSelect
|
||||
:label="t('Country')"
|
||||
:options="countriesOptions"
|
||||
hide-selected
|
||||
|
|
|
@ -19,8 +19,11 @@ const provinceFormData = reactive({
|
|||
|
||||
const autonomiesOptions = ref([]);
|
||||
|
||||
const onDataSaved = (dataSaved) => {
|
||||
emit('onDataSaved', dataSaved);
|
||||
const onDataSaved = (dataSaved, requestResponse) => {
|
||||
requestResponse.autonomy = autonomiesOptions.value.find(
|
||||
(autonomy) => autonomy.id == requestResponse.autonomyFk
|
||||
);
|
||||
emit('onDataSaved', dataSaved, requestResponse);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -28,7 +31,7 @@ const onDataSaved = (dataSaved) => {
|
|||
<FetchData
|
||||
@on-fetch="(data) => (autonomiesOptions = data)"
|
||||
auto-load
|
||||
url="Autonomies"
|
||||
url="Autonomies/location"
|
||||
/>
|
||||
<FormModelPopup
|
||||
:title="t('New province')"
|
||||
|
@ -36,7 +39,7 @@ const onDataSaved = (dataSaved) => {
|
|||
url-create="provinces"
|
||||
model="province"
|
||||
:form-initial-data="provinceFormData"
|
||||
@on-data-saved="onDataSaved($event)"
|
||||
@on-data-saved="onDataSaved"
|
||||
>
|
||||
<template #form-inputs="{ data, validate }">
|
||||
<VnRow>
|
||||
|
@ -53,7 +56,16 @@ const onDataSaved = (dataSaved) => {
|
|||
option-value="id"
|
||||
v-model="data.autonomyFk"
|
||||
:rules="validate('province.autonomyFk')"
|
||||
/>
|
||||
>
|
||||
<template #option="{ itemProps, opt }">
|
||||
<QItem v-bind="itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel>{{ opt.name }}</QItemLabel>
|
||||
<QItemLabel caption> {{ opt.country.name }} </QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelect>
|
||||
</VnRow>
|
||||
</template>
|
||||
</FormModelPopup>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script setup>
|
||||
import axios from 'axios';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useRouter, onBeforeRouteLeave } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useValidator } from 'src/composables/useValidator';
|
||||
|
@ -97,6 +97,19 @@ defineExpose({
|
|||
vnPaginateRef,
|
||||
});
|
||||
|
||||
onBeforeRouteLeave((to, from, next) => {
|
||||
if (hasChanges.value)
|
||||
quasar.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t('globals.unsavedPopup.title'),
|
||||
message: t('globals.unsavedPopup.subtitle'),
|
||||
promise: () => next(),
|
||||
},
|
||||
});
|
||||
else next();
|
||||
});
|
||||
|
||||
async function fetch(data) {
|
||||
resetData(data);
|
||||
emit('onFetch', data);
|
||||
|
|
|
@ -87,6 +87,10 @@ const $props = defineProps({
|
|||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
defaultTrim: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
||||
const modelValue = computed(
|
||||
|
@ -100,7 +104,6 @@ const isResetting = ref(false);
|
|||
const hasChanges = ref(!$props.observeFormChanges);
|
||||
const originalData = ref({});
|
||||
const formData = computed(() => state.get(modelValue));
|
||||
const formUrl = computed(() => $props.url);
|
||||
const defaultButtons = computed(() => ({
|
||||
save: {
|
||||
color: 'primary',
|
||||
|
@ -148,19 +151,22 @@ if (!$props.url)
|
|||
(val) => updateAndEmit('onFetch', val)
|
||||
);
|
||||
|
||||
watch(formUrl, async () => {
|
||||
watch(
|
||||
() => [$props.url, $props.filter],
|
||||
async () => {
|
||||
originalData.value = null;
|
||||
reset();
|
||||
await fetch();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
onBeforeRouteLeave((to, from, next) => {
|
||||
if (hasChanges.value && $props.observeFormChanges)
|
||||
quasar.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t('Unsaved changes will be lost'),
|
||||
message: t('Are you sure exit without saving?'),
|
||||
title: t('globals.unsavedPopup.title'),
|
||||
message: t('globals.unsavedPopup.subtitle'),
|
||||
promise: () => next(),
|
||||
},
|
||||
});
|
||||
|
@ -193,6 +199,7 @@ async function save() {
|
|||
|
||||
isLoading.value = true;
|
||||
try {
|
||||
formData.value = trimData(formData.value);
|
||||
const body = $props.mapper ? $props.mapper(formData.value) : formData.value;
|
||||
const method = $props.urlCreate ? 'post' : 'patch';
|
||||
const url =
|
||||
|
@ -251,6 +258,14 @@ function updateAndEmit(evt, val, res) {
|
|||
emit(evt, state.get(modelValue), res);
|
||||
}
|
||||
|
||||
function trimData(data) {
|
||||
if (!$props.defaultTrim) return data;
|
||||
for (const key in data) {
|
||||
if (typeof data[key] == 'string') data[key] = data[key].trim();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
save,
|
||||
isLoading,
|
||||
|
@ -356,8 +371,3 @@ defineExpose({
|
|||
padding: 32px;
|
||||
}
|
||||
</style>
|
||||
<i18n>
|
||||
es:
|
||||
Unsaved changes will be lost: Los cambios que no haya guardado se perderán
|
||||
Are you sure exit without saving?: ¿Seguro que quiere salir sin guardar?
|
||||
</i18n>
|
||||
|
|
|
@ -112,6 +112,7 @@ const getCategoryClass = (category, params) => {
|
|||
|
||||
const getSelectedTagValues = async (tag) => {
|
||||
try {
|
||||
if (!tag?.selectedTag?.id) return;
|
||||
tag.value = null;
|
||||
const filter = {
|
||||
fields: ['value'],
|
||||
|
|
|
@ -7,7 +7,7 @@ import { useQuasar } from 'quasar';
|
|||
import PinnedModules from './PinnedModules.vue';
|
||||
import UserPanel from 'components/UserPanel.vue';
|
||||
import VnBreadcrumbs from './common/VnBreadcrumbs.vue';
|
||||
import VnImg from 'src/components/ui/VnImg.vue';
|
||||
import VnAvatar from './ui/VnAvatar.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const stateStore = useStateStore();
|
||||
|
@ -72,22 +72,13 @@ const pinnedModulesRef = ref();
|
|||
</QTooltip>
|
||||
<PinnedModules ref="pinnedModulesRef" />
|
||||
</QBtn>
|
||||
<QBtn
|
||||
:class="{ 'q-pa-none': quasar.platform.is.mobile }"
|
||||
rounded
|
||||
dense
|
||||
flat
|
||||
no-wrap
|
||||
id="user"
|
||||
>
|
||||
<QAvatar size="lg">
|
||||
<VnImg
|
||||
:id="user.id"
|
||||
collection="user"
|
||||
size="160x160"
|
||||
:zoom-size="null"
|
||||
<QBtn class="q-pa-none" rounded dense flat no-wrap id="user">
|
||||
<VnAvatar
|
||||
:worker-id="user.id"
|
||||
:title="user.name"
|
||||
size="lg"
|
||||
color="transparent"
|
||||
/>
|
||||
</QAvatar>
|
||||
<QTooltip bottom>
|
||||
{{ t('globals.userPanel') }}
|
||||
</QTooltip>
|
||||
|
|
|
@ -15,7 +15,7 @@ const props = defineProps({
|
|||
default: null,
|
||||
},
|
||||
warehouseFk: {
|
||||
type: Boolean,
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ const props = defineProps({
|
|||
const { t } = useI18n();
|
||||
|
||||
const regularizeFormData = reactive({
|
||||
itemFk: props.itemFk,
|
||||
itemFk: Number(props.itemFk),
|
||||
warehouseFk: props.warehouseFk,
|
||||
quantity: null,
|
||||
});
|
||||
|
@ -53,6 +53,7 @@ const onDataSaved = (data) => {
|
|||
<QInput
|
||||
:label="t('Type the visible quantity')"
|
||||
v-model.number="data.quantity"
|
||||
type="number"
|
||||
autofocus
|
||||
/>
|
||||
</VnRow>
|
||||
|
@ -60,7 +61,7 @@ const onDataSaved = (data) => {
|
|||
<div class="col">
|
||||
<VnSelect
|
||||
:label="t('Warehouse')"
|
||||
v-model="data.warehouseFk"
|
||||
v-model.number="data.warehouseFk"
|
||||
:options="warehousesOptions"
|
||||
option-value="id"
|
||||
option-label="name"
|
||||
|
|
|
@ -11,8 +11,8 @@ import VnSelect from 'src/components/common/VnSelect.vue';
|
|||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import { useClipboard } from 'src/composables/useClipboard';
|
||||
import VnImg from 'src/components/ui/VnImg.vue';
|
||||
import { useRole } from 'src/composables/useRole';
|
||||
import VnAvatar from './ui/VnAvatar.vue';
|
||||
|
||||
const state = useState();
|
||||
const session = useSession();
|
||||
|
@ -136,7 +136,7 @@ const isEmployee = computed(() => useRole().isEmployee());
|
|||
@update:model-value="saveLanguage"
|
||||
:label="t(`globals.lang['${userLocale}']`)"
|
||||
icon="public"
|
||||
color="orange"
|
||||
color="primary"
|
||||
false-value="es"
|
||||
true-value="en"
|
||||
/>
|
||||
|
@ -145,7 +145,7 @@ const isEmployee = computed(() => useRole().isEmployee());
|
|||
@update:model-value="saveDarkMode"
|
||||
:label="t(`globals.darkMode`)"
|
||||
checked-icon="dark_mode"
|
||||
color="orange"
|
||||
color="primary"
|
||||
unchecked-icon="light_mode"
|
||||
/>
|
||||
</div>
|
||||
|
@ -153,10 +153,20 @@ const isEmployee = computed(() => useRole().isEmployee());
|
|||
<QSeparator vertical inset class="q-mx-lg" />
|
||||
|
||||
<div class="col column items-center q-mb-sm">
|
||||
<QAvatar size="80px">
|
||||
<VnImg :id="user.id" collection="user" size="160x160" />
|
||||
</QAvatar>
|
||||
|
||||
<VnAvatar
|
||||
:worker-id="user.id"
|
||||
:title="user.name"
|
||||
size="xxl"
|
||||
color="transparent"
|
||||
/>
|
||||
<QBtn
|
||||
v-if="isEmployee"
|
||||
class="q-mt-sm q-px-md"
|
||||
:to="`/worker/${user.id}`"
|
||||
color="primary"
|
||||
:label="t('globals.myAccount')"
|
||||
dense
|
||||
/>
|
||||
<div class="text-subtitle1 q-mt-md">
|
||||
<strong>{{ user.nickname }}</strong>
|
||||
</div>
|
||||
|
@ -168,7 +178,7 @@ const isEmployee = computed(() => useRole().isEmployee());
|
|||
</div>
|
||||
<QBtn
|
||||
id="logout"
|
||||
color="orange"
|
||||
color="primary"
|
||||
flat
|
||||
:label="t('globals.logOut')"
|
||||
size="sm"
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { useValidator } from 'src/composables/useValidator';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import VnSelectDialog from 'components/common/VnSelectDialog.vue';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import CreateNewProvinceForm from './CreateNewProvinceForm.vue';
|
||||
|
||||
const emit = defineEmits(['onProvinceCreated']);
|
||||
const provinceFk = defineModel({ type: Number });
|
||||
watch(provinceFk, async () => await provincesFetchDataRef.value.fetch());
|
||||
|
||||
const { validate } = useValidator();
|
||||
const { t } = useI18n();
|
||||
|
||||
const provincesOptions = ref();
|
||||
const provincesFetchDataRef = ref();
|
||||
|
||||
async function onProvinceCreated(_, data) {
|
||||
await provincesFetchDataRef.value.fetch();
|
||||
provinceFk.value = data.id;
|
||||
emit('onProvinceCreated', data);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
ref="provincesFetchDataRef"
|
||||
:filter="{ include: { relation: 'country' } }"
|
||||
@on-fetch="(data) => (provincesOptions = data)"
|
||||
auto-load
|
||||
url="Provinces"
|
||||
/>
|
||||
<VnSelectDialog
|
||||
:label="t('Province')"
|
||||
:options="provincesOptions"
|
||||
hide-selected
|
||||
v-model="provinceFk"
|
||||
:rules="validate && validate('postcode.provinceFk')"
|
||||
:roles-allowed-to-create="['deliveryAssistant']"
|
||||
>
|
||||
<template #option="{ itemProps, opt }">
|
||||
<QItem v-bind="itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel>{{ opt.name }}</QItemLabel>
|
||||
<QItemLabel caption> {{ opt.country.name }} </QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
<template #form>
|
||||
<CreateNewProvinceForm @on-data-saved="onProvinceCreated" />
|
||||
</template>
|
||||
</VnSelectDialog>
|
||||
</template>
|
||||
<i18n>
|
||||
es:
|
||||
Province: Provincia
|
||||
</i18n>
|
|
@ -7,9 +7,11 @@ import { dashIfEmpty } from 'src/filters';
|
|||
import VnSelect from 'components/common/VnSelect.vue';
|
||||
import VnSelectCache from 'components/common/VnSelectCache.vue';
|
||||
import VnInput from 'components/common/VnInput.vue';
|
||||
import VnInputNumber from 'components/common/VnInputNumber.vue';
|
||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||
import VnInputTime from 'components/common/VnInputTime.vue';
|
||||
import VnComponent from 'components/common/VnComponent.vue';
|
||||
import VnUserLink from 'components/ui/VnUserLink.vue';
|
||||
|
||||
const model = defineModel(undefined, { required: true });
|
||||
const $props = defineProps({
|
||||
|
@ -66,7 +68,7 @@ const defaultComponents = {
|
|||
},
|
||||
},
|
||||
number: {
|
||||
component: markRaw(VnInput),
|
||||
component: markRaw(VnInputNumber),
|
||||
attrs: {
|
||||
disable: !$props.isEditable,
|
||||
class: 'fit',
|
||||
|
@ -98,14 +100,14 @@ const defaultComponents = {
|
|||
},
|
||||
checkbox: {
|
||||
component: markRaw(QCheckbox),
|
||||
attrs: (prop) => {
|
||||
attrs: ({ model }) => {
|
||||
const defaultAttrs = {
|
||||
disable: !$props.isEditable,
|
||||
'model-value': Boolean(prop),
|
||||
'model-value': Boolean(model),
|
||||
class: 'no-padding fit',
|
||||
};
|
||||
|
||||
if (typeof prop == 'number') {
|
||||
if (typeof model == 'number') {
|
||||
defaultAttrs['true-value'] = 1;
|
||||
defaultAttrs['false-value'] = 0;
|
||||
}
|
||||
|
@ -126,6 +128,9 @@ const defaultComponents = {
|
|||
icon: {
|
||||
component: markRaw(QIcon),
|
||||
},
|
||||
userLink: {
|
||||
component: markRaw(VnUserLink),
|
||||
},
|
||||
};
|
||||
|
||||
const value = computed(() => {
|
||||
|
@ -146,7 +151,7 @@ const col = computed(() => {
|
|||
};
|
||||
}
|
||||
if (
|
||||
(newColumn.name.startsWith('is') || newColumn.name.startsWith('has')) &&
|
||||
(/^is[A-Z]/.test(newColumn.name) || /^has[A-Z]/.test(newColumn.name)) &&
|
||||
newColumn.component == null
|
||||
)
|
||||
newColumn.component = 'checkbox';
|
||||
|
@ -163,14 +168,14 @@ const components = computed(() => $props.components ?? defaultComponents);
|
|||
v-if="col.before"
|
||||
:prop="col.before"
|
||||
:components="components"
|
||||
:value="model"
|
||||
:value="{ row, model }"
|
||||
v-model="model"
|
||||
/>
|
||||
<VnComponent
|
||||
v-if="col.component"
|
||||
:prop="col"
|
||||
:components="components"
|
||||
:value="model"
|
||||
:value="{ row, model }"
|
||||
v-model="model"
|
||||
/>
|
||||
<span :title="value" v-else>{{ value }}</span>
|
||||
|
@ -178,7 +183,7 @@ const components = computed(() => $props.components ?? defaultComponents);
|
|||
v-if="col.after"
|
||||
:prop="col.after"
|
||||
:components="components"
|
||||
:value="model"
|
||||
:value="{ row, model }"
|
||||
v-model="model"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -10,6 +10,8 @@ import VnInputDate from 'components/common/VnInputDate.vue';
|
|||
import VnInputTime from 'components/common/VnInputTime.vue';
|
||||
import VnTableColumn from 'components/VnTable/VnColumn.vue';
|
||||
|
||||
defineExpose({ addFilter });
|
||||
|
||||
const $props = defineProps({
|
||||
column: {
|
||||
type: Object,
|
||||
|
@ -32,7 +34,7 @@ const model = defineModel(undefined, { required: true });
|
|||
const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl });
|
||||
const columnFilter = computed(() => $props.column?.columnFilter);
|
||||
|
||||
const updateEvent = { 'update:modelValue': addFilter };
|
||||
const updateEvent = { 'update:modelValue': addFilter, remove: () => addFilter(null) };
|
||||
const enterEvent = {
|
||||
'keyup.enter': () => addFilter(model.value),
|
||||
remove: () => addFilter(null),
|
||||
|
@ -45,7 +47,7 @@ const defaultAttrs = {
|
|||
};
|
||||
|
||||
const forceAttrs = {
|
||||
label: $props.showTitle ? '' : $props.column.label,
|
||||
label: $props.showTitle ? '' : columnFilter.value?.label ?? $props.column.label,
|
||||
};
|
||||
|
||||
const selectComponent = {
|
||||
|
|
|
@ -112,6 +112,8 @@ const CrudModelRef = ref({});
|
|||
const showForm = ref(false);
|
||||
const splittedColumns = ref({ columns: [] });
|
||||
const columnsVisibilitySkiped = ref();
|
||||
const createForm = ref();
|
||||
|
||||
const tableModes = [
|
||||
{
|
||||
icon: 'view_column',
|
||||
|
@ -128,7 +130,7 @@ const tableModes = [
|
|||
];
|
||||
onBeforeMount(() => {
|
||||
setUserParams(route.query[$props.searchUrl]);
|
||||
hasParams.value = Object.keys(params.value).length !== 0;
|
||||
hasParams.value = params.value && Object.keys(params.value).length !== 0;
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
|
@ -143,6 +145,14 @@ onMounted(() => {
|
|||
.map((c) => c.name),
|
||||
...['tableActions'],
|
||||
];
|
||||
createForm.value = $props.create;
|
||||
if ($props.create && route?.query?.createForm) {
|
||||
showForm.value = true;
|
||||
createForm.value = {
|
||||
...createForm.value,
|
||||
...{ formInitialData: JSON.parse(route?.query?.createForm) },
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
|
@ -158,13 +168,16 @@ watch(
|
|||
|
||||
const isTableMode = computed(() => mode.value == TABLE_MODE);
|
||||
|
||||
function setUserParams(watchedParams) {
|
||||
function setUserParams(watchedParams, watchedOrder) {
|
||||
if (!watchedParams) return;
|
||||
|
||||
if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams);
|
||||
const filter = JSON.parse(watchedParams?.filter);
|
||||
const filter =
|
||||
typeof watchedParams?.filter == 'string'
|
||||
? JSON.parse(watchedParams?.filter ?? '{}')
|
||||
: watchedParams?.filter;
|
||||
const where = filter?.where;
|
||||
const order = filter?.order;
|
||||
const order = watchedOrder ?? filter?.order;
|
||||
|
||||
watchedParams = { ...watchedParams, ...where };
|
||||
delete watchedParams.filter;
|
||||
|
@ -285,6 +298,7 @@ defineExpose({
|
|||
v-model="params"
|
||||
:search-url="searchUrl"
|
||||
:redirect="!!redirect"
|
||||
@set-user-params="setUserParams"
|
||||
>
|
||||
<template #body>
|
||||
<div
|
||||
|
@ -305,7 +319,7 @@ defineExpose({
|
|||
col?.columnFilter !== false &&
|
||||
col?.name !== 'tableActions'
|
||||
"
|
||||
v-model="orders[col.name]"
|
||||
v-model="orders[col.orderBy ?? col.name]"
|
||||
:name="col.orderBy ?? col.name"
|
||||
:data-key="$attrs['data-key']"
|
||||
:search-url="searchUrl"
|
||||
|
@ -317,11 +331,6 @@ defineExpose({
|
|||
:params="params"
|
||||
:columns="splittedColumns.columns"
|
||||
/>
|
||||
<slot
|
||||
name="moreFilterPanel"
|
||||
:params="params"
|
||||
:columns="splittedColumns.columns"
|
||||
/>
|
||||
</template>
|
||||
</VnFilterPanel>
|
||||
</QScrollArea>
|
||||
|
@ -332,6 +341,7 @@ defineExpose({
|
|||
v-bind="$attrs"
|
||||
:limit="20"
|
||||
ref="CrudModelRef"
|
||||
@on-fetch="(...args) => emit('onFetch', ...args)"
|
||||
:search-url="searchUrl"
|
||||
:disable-infinite-scroll="isTableMode"
|
||||
@save-changes="reload"
|
||||
|
@ -369,7 +379,7 @@ defineExpose({
|
|||
<template #top-left v-if="!$props.withoutHeader">
|
||||
<slot name="top-left"></slot>
|
||||
</template>
|
||||
<template #top-right>
|
||||
<template #top-right v-if="!$props.withoutHeader">
|
||||
<VnVisibleColumn
|
||||
v-if="isTableMode"
|
||||
v-model="splittedColumns.columns"
|
||||
|
@ -386,7 +396,6 @@ defineExpose({
|
|||
<QBtn
|
||||
v-if="$props.rightSearch"
|
||||
icon="filter_alt"
|
||||
title="asd"
|
||||
class="bg-vn-section-color q-ml-md"
|
||||
dense
|
||||
@click="stateStore.toggleRightDrawer()"
|
||||
|
@ -402,14 +411,14 @@ defineExpose({
|
|||
<div
|
||||
class="column self-start q-ml-xs ellipsis"
|
||||
:class="`text-${col?.align ?? 'left'}`"
|
||||
style="height: 75px"
|
||||
:style="$props.columnSearch ? 'height: 75px' : ''"
|
||||
>
|
||||
<div
|
||||
class="row items-center no-wrap"
|
||||
style="height: 30px"
|
||||
>
|
||||
<VnTableOrder
|
||||
v-model="orders[col.name]"
|
||||
v-model="orders[col.orderBy ?? col.name]"
|
||||
:name="col.orderBy ?? col.name"
|
||||
:label="col?.label"
|
||||
:data-key="$attrs['data-key']"
|
||||
|
@ -443,7 +452,7 @@ defineExpose({
|
|||
</VnTableChip>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #body-cell="{ col, row }">
|
||||
<template #body-cell="{ col, row, rowIndex }">
|
||||
<!-- Columns -->
|
||||
<QTd
|
||||
auto-width
|
||||
|
@ -456,7 +465,12 @@ defineExpose({
|
|||
rowCtrlClickFunction($event, row)
|
||||
"
|
||||
>
|
||||
<slot :name="`column-${col.name}`" :col="col" :row="row">
|
||||
<slot
|
||||
:name="`column-${col.name}`"
|
||||
:col="col"
|
||||
:row="row"
|
||||
:row-index="rowIndex"
|
||||
>
|
||||
<VnTableColumn
|
||||
:column="col"
|
||||
:row="row"
|
||||
|
@ -476,7 +490,6 @@ defineExpose({
|
|||
>
|
||||
<QBtn
|
||||
v-for="(btn, index) of col.actions"
|
||||
v-show="btn.show ? btn.show(row) : true"
|
||||
:key="index"
|
||||
:title="btn.title"
|
||||
:icon="btn.icon"
|
||||
|
@ -487,6 +500,11 @@ defineExpose({
|
|||
? 'text-primary-light'
|
||||
: 'color-vn-text '
|
||||
"
|
||||
:style="`visibility: ${
|
||||
(btn.show && btn.show(row)) ?? true
|
||||
? 'visible'
|
||||
: 'hidden'
|
||||
}`"
|
||||
@click="btn.action(row)"
|
||||
/>
|
||||
</QTd>
|
||||
|
@ -547,7 +565,9 @@ defineExpose({
|
|||
:class="$props.cardClass"
|
||||
>
|
||||
<div
|
||||
v-for="col of splittedColumns.cardVisible"
|
||||
v-for="(
|
||||
col, index
|
||||
) of splittedColumns.cardVisible"
|
||||
:key="col.name"
|
||||
class="fields"
|
||||
>
|
||||
|
@ -568,6 +588,7 @@ defineExpose({
|
|||
:name="`column-${col.name}`"
|
||||
:col="col"
|
||||
:row="row"
|
||||
:row-index="index"
|
||||
>
|
||||
<VnTableColumn
|
||||
:column="col"
|
||||
|
@ -616,20 +637,26 @@ defineExpose({
|
|||
<QPageSticky v-if="create" :offset="[20, 20]" style="z-index: 2">
|
||||
<QBtn @click="showForm = !showForm" color="primary" fab icon="add" />
|
||||
<QTooltip>
|
||||
{{ create.title }}
|
||||
{{ createForm.title }}
|
||||
</QTooltip>
|
||||
</QPageSticky>
|
||||
<QDialog v-model="showForm" transition-show="scale" transition-hide="scale">
|
||||
<FormModelPopup
|
||||
v-bind="create"
|
||||
v-bind="createForm"
|
||||
:model="$attrs['data-key'] + 'Create'"
|
||||
@on-data-saved="(_, res) => create.onDataSaved(res)"
|
||||
@on-data-saved="(_, res) => createForm.onDataSaved(res)"
|
||||
>
|
||||
<template #form-inputs="{ data }">
|
||||
<div class="grid-create">
|
||||
<VnTableColumn
|
||||
<slot
|
||||
v-for="column of splittedColumns.create"
|
||||
:key="column.name"
|
||||
:name="`column-create-${column.name}`"
|
||||
:data="data"
|
||||
:column-name="column.name"
|
||||
:label="column.label"
|
||||
>
|
||||
<VnTableColumn
|
||||
:column="column"
|
||||
:row="{}"
|
||||
default="input"
|
||||
|
@ -637,6 +664,7 @@ defineExpose({
|
|||
:show-label="true"
|
||||
component-prop="columnCreate"
|
||||
/>
|
||||
</slot>
|
||||
<slot name="more-create-dialog" :data="data" />
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -65,7 +65,7 @@ async function fetchViewConfigData() {
|
|||
const userConfig = await getConfig('UserConfigViews', {
|
||||
where: {
|
||||
...defaultFilter.where,
|
||||
...{ userFk: user.id },
|
||||
...{ userFk: user.value.id },
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -81,7 +81,7 @@ async function fetchViewConfigData() {
|
|||
return;
|
||||
}
|
||||
} catch (err) {
|
||||
console.err('Error fetching config view data', err);
|
||||
console.error('Error fetching config view data', err);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ const stateStore = useStateStore();
|
|||
</div>
|
||||
</Teleport>
|
||||
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
|
||||
<QScrollArea class="fit text-grey-8">
|
||||
<QScrollArea class="fit">
|
||||
<div id="right-panel"></div>
|
||||
<slot v-if="!hasContent" name="right-panel" />
|
||||
</QScrollArea>
|
||||
|
|
|
@ -84,7 +84,7 @@ const fetchViewConfigData = async () => {
|
|||
setUserConfigViewData(defaultColumns);
|
||||
}
|
||||
} catch (err) {
|
||||
console.err('Error fetching config view data', err);
|
||||
console.error('Error fetching config view data', err);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -17,12 +17,7 @@ const props = defineProps({
|
|||
descriptor: { type: Object, required: true },
|
||||
filterPanel: { type: Object, default: undefined },
|
||||
searchDataKey: { type: String, default: undefined },
|
||||
searchUrl: { type: String, default: undefined },
|
||||
searchbarLabel: { type: String, default: '' },
|
||||
searchbarInfo: { type: String, default: '' },
|
||||
searchCustomRouteRedirect: { type: String, default: undefined },
|
||||
searchRedirect: { type: Boolean, default: true },
|
||||
searchMakeFetch: { type: Boolean, default: true },
|
||||
searchbarProps: { type: Object, default: undefined },
|
||||
});
|
||||
|
||||
const stateStore = useStateStore();
|
||||
|
@ -31,7 +26,10 @@ const url = computed(() => {
|
|||
if (props.baseUrl) return `${props.baseUrl}/${route.params.id}`;
|
||||
return props.customUrl;
|
||||
});
|
||||
|
||||
const searchRightDataKey = computed(() => {
|
||||
if (!props.searchDataKey) return route.name;
|
||||
return props.searchDataKey;
|
||||
});
|
||||
const arrayData = useArrayData(props.dataKey, {
|
||||
url: url.value,
|
||||
filter: props.filter,
|
||||
|
@ -65,19 +63,11 @@ if (props.baseUrl) {
|
|||
</QScrollArea>
|
||||
</QDrawer>
|
||||
<slot name="searchbar" v-if="props.searchDataKey">
|
||||
<VnSearchbar
|
||||
:data-key="props.searchDataKey"
|
||||
:url="props.searchUrl"
|
||||
:label="props.searchbarLabel"
|
||||
:info="props.searchbarInfo"
|
||||
:custom-route-redirect-name="searchCustomRouteRedirect"
|
||||
:redirect="searchRedirect"
|
||||
/>
|
||||
<VnSearchbar :data-key="props.searchDataKey" v-bind="props.searchbarProps" />
|
||||
</slot>
|
||||
<slot v-else name="searchbar" />
|
||||
<RightMenu>
|
||||
<template #right-panel v-if="props.filterPanel">
|
||||
<component :is="props.filterPanel" :data-key="props.searchDataKey" />
|
||||
<component :is="props.filterPanel" :data-key="searchRightDataKey" />
|
||||
</template>
|
||||
</RightMenu>
|
||||
<QPageContainer>
|
||||
|
|
|
@ -35,7 +35,7 @@ function mix(toComponent) {
|
|||
...toComponent,
|
||||
...toValueAttrs(customComponent?.forceAttrs),
|
||||
},
|
||||
event: event ?? customComponent?.event,
|
||||
event: { ...customComponent?.event, ...event },
|
||||
};
|
||||
return mixed;
|
||||
}
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useCapitalize } from 'src/composables/useCapitalize';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: { type: [String, Number], default: '' },
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
const emit = defineEmits(['update:modelValue']);
|
||||
|
||||
const amount = computed({
|
||||
get() {
|
||||
return props.modelValue;
|
||||
},
|
||||
set(val) {
|
||||
emit('update:modelValue', val);
|
||||
},
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<VnInput
|
||||
v-model="amount"
|
||||
type="number"
|
||||
step="any"
|
||||
:label="useCapitalize(t('amount'))"
|
||||
/>
|
||||
</template>
|
||||
<i18n>
|
||||
es:
|
||||
amount: importe
|
||||
</i18n>
|
|
@ -0,0 +1,8 @@
|
|||
<script setup>
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
const model = defineModel({ type: [Number, String] });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnInput v-bind="$attrs" v-model.number="model" type="number" />
|
||||
</template>
|
|
@ -50,7 +50,7 @@ const formattedTime = computed({
|
|||
}
|
||||
if (!props.timeOnly) {
|
||||
const [hh, mm] = time.split(':');
|
||||
const date = model.value ?? Date.vnNew();
|
||||
const date = new Date(model.value ? model.value : null);
|
||||
date.setHours(hh, mm, 0);
|
||||
time = date?.toISOString();
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ const formattedTime = computed({
|
|||
function dateToTime(newDate) {
|
||||
return date.formatDate(new Date(newDate), dateFormat);
|
||||
}
|
||||
const timeField = ref();
|
||||
|
||||
watch(
|
||||
() => model.value,
|
||||
(val) => (formattedTime.value = val),
|
||||
|
@ -153,4 +153,3 @@ watch(
|
|||
es:
|
||||
Open time: Abrir tiempo
|
||||
</i18n>
|
||||
, nextTick
|
||||
|
|
|
@ -1,123 +1,33 @@
|
|||
<script setup>
|
||||
import { ref, toRefs, computed, watch, onMounted } from 'vue';
|
||||
import CreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue';
|
||||
import VnSelectDialog from 'components/common/VnSelectDialog.vue';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
const emit = defineEmits(['update:modelValue', 'update:options']);
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
const { t } = useI18n();
|
||||
const postcodesOptions = ref([]);
|
||||
const postcodesRef = ref(null);
|
||||
|
||||
const $props = defineProps({
|
||||
modelValue: {
|
||||
type: [String, Number, Object],
|
||||
default: null,
|
||||
},
|
||||
options: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
optionLabel: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
optionValue: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
filterOptions: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
isClearable: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
defaultFilter: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
|
||||
const { options } = toRefs($props);
|
||||
const myOptions = ref([]);
|
||||
const myOptionsOriginal = ref([]);
|
||||
|
||||
const value = computed({
|
||||
get() {
|
||||
return $props.modelValue;
|
||||
},
|
||||
set(value) {
|
||||
emit(
|
||||
'update:modelValue',
|
||||
postcodesOptions.value.find((p) => p.code === value)
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
locationFilter($props.modelValue);
|
||||
});
|
||||
|
||||
function setOptions(data) {
|
||||
myOptions.value = JSON.parse(JSON.stringify(data));
|
||||
myOptionsOriginal.value = JSON.parse(JSON.stringify(data));
|
||||
}
|
||||
setOptions(options.value);
|
||||
|
||||
watch(options, (newValue) => {
|
||||
setOptions(newValue);
|
||||
});
|
||||
const value = defineModel({ type: [String, Number, Object] });
|
||||
|
||||
function showLabel(data) {
|
||||
return `${data.code} - ${data.town}(${data.province}), ${data.country}`;
|
||||
}
|
||||
|
||||
function locationFilter(search = '') {
|
||||
if (
|
||||
search &&
|
||||
(search.includes('undefined') || search.startsWith(`${$props.modelValue} - `))
|
||||
)
|
||||
return;
|
||||
let where = { search };
|
||||
postcodesRef.value.fetch({ filter: { where }, limit: 30 });
|
||||
}
|
||||
|
||||
function handleFetch(data) {
|
||||
postcodesOptions.value = data;
|
||||
}
|
||||
function onDataSaved(newPostcode) {
|
||||
postcodesOptions.value.push(newPostcode);
|
||||
value.value = newPostcode.code;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
ref="postcodesRef"
|
||||
url="Postcodes/filter"
|
||||
@on-fetch="(data) => handleFetch(data)"
|
||||
/>
|
||||
<VnSelectDialog
|
||||
v-if="postcodesRef"
|
||||
:option-label="(opt) => showLabel(opt) ?? 'code'"
|
||||
:option-value="(opt) => opt.code"
|
||||
v-model="value"
|
||||
:options="postcodesOptions"
|
||||
option-value="code"
|
||||
option-filter-value="search"
|
||||
:option-label="(opt) => showLabel(opt)"
|
||||
url="Postcodes/filter"
|
||||
:use-like="false"
|
||||
:label="t('Location')"
|
||||
:placeholder="t('search_by_postalcode')"
|
||||
@input-value="locationFilter"
|
||||
:default-filter="false"
|
||||
:input-debounce="300"
|
||||
:class="{ required: $attrs.required }"
|
||||
v-bind="$attrs"
|
||||
clearable
|
||||
:emit-value="false"
|
||||
>
|
||||
<template #form>
|
||||
<CreateNewPostcode
|
||||
@on-data-saved="onDataSaved"
|
||||
/>
|
||||
<CreateNewPostcode @on-data-saved="(newValue) => (value = newValue)" />
|
||||
</template>
|
||||
<template #option="{ itemProps, opt }">
|
||||
<QItem v-bind="itemProps">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script setup>
|
||||
import { ref, onUnmounted } from 'vue';
|
||||
import { ref, onUnmounted, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import { date } from 'quasar';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
|
@ -19,6 +19,7 @@ const stateStore = useStateStore();
|
|||
const validationsStore = useValidator();
|
||||
const { models } = validationsStore;
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
const props = defineProps({
|
||||
model: {
|
||||
|
@ -213,7 +214,7 @@ function getLogTree(data) {
|
|||
}
|
||||
nLogs++;
|
||||
modelLog.logs.push(log);
|
||||
|
||||
modelLog.summaryId = modelLog.logs[0].summaryId;
|
||||
// Changes
|
||||
const notDelete = log.action != 'delete';
|
||||
const olds = (notDelete ? log.oldInstance : null) || {};
|
||||
|
@ -381,6 +382,13 @@ setLogTree();
|
|||
onUnmounted(() => {
|
||||
stateStore.rightDrawer = false;
|
||||
});
|
||||
|
||||
watch(
|
||||
() => router.currentRoute.value.params.id,
|
||||
() => {
|
||||
applyFilter();
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
|
@ -399,9 +407,12 @@ onUnmounted(() => {
|
|||
@on-fetch="
|
||||
(data) =>
|
||||
(actions = data.map((item) => {
|
||||
const changedModel = item.changedModel;
|
||||
return {
|
||||
locale: useCapitalize(validations[item.changedModel].locale.name),
|
||||
value: item.changedModel,
|
||||
locale: useCapitalize(
|
||||
validations[changedModel]?.locale?.name ?? changedModel
|
||||
),
|
||||
value: changedModel,
|
||||
};
|
||||
}))
|
||||
"
|
||||
|
@ -464,12 +475,17 @@ onUnmounted(() => {
|
|||
>
|
||||
{{ t(modelLog.modelI18n) }}
|
||||
</QChip>
|
||||
<span class="model-id" v-if="modelLog.summaryId"
|
||||
>#{{ modelLog.summaryId }}</span
|
||||
>
|
||||
<span class="model-value" :title="modelLog.showValue">
|
||||
{{ modelLog.showValue }}
|
||||
</span>
|
||||
|
||||
<span
|
||||
class="model-id q-mr-xs"
|
||||
v-if="modelLog.summaryId"
|
||||
v-text="`#${modelLog.summaryId}`"
|
||||
/>
|
||||
<span
|
||||
class="model-value"
|
||||
:title="modelLog.showValue"
|
||||
v-text="modelLog.showValue"
|
||||
/>
|
||||
<QBtn
|
||||
flat
|
||||
round
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { ref, toRefs, computed, watch, onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import FetchData from 'src/components/FetchData.vue';
|
||||
const emit = defineEmits(['update:modelValue', 'update:options']);
|
||||
const emit = defineEmits(['update:modelValue', 'update:options', 'remove']);
|
||||
|
||||
const $props = defineProps({
|
||||
modelValue: {
|
||||
|
@ -25,6 +25,10 @@ const $props = defineProps({
|
|||
type: String,
|
||||
default: null,
|
||||
},
|
||||
optionFilterValue: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
default: null,
|
||||
|
@ -45,6 +49,10 @@ const $props = defineProps({
|
|||
type: Array,
|
||||
default: null,
|
||||
},
|
||||
include: {
|
||||
type: [Object, Array],
|
||||
default: null,
|
||||
},
|
||||
where: {
|
||||
type: Object,
|
||||
default: null,
|
||||
|
@ -70,7 +78,8 @@ const $props = defineProps({
|
|||
const { t } = useI18n();
|
||||
const requiredFieldRule = (val) => val ?? t('globals.fieldRequired');
|
||||
|
||||
const { optionLabel, optionValue, optionFilter, options, modelValue } = toRefs($props);
|
||||
const { optionLabel, optionValue, optionFilter, optionFilterValue, options, modelValue } =
|
||||
toRefs($props);
|
||||
const myOptions = ref([]);
|
||||
const myOptionsOriginal = ref([]);
|
||||
const vnSelectRef = ref();
|
||||
|
@ -82,6 +91,7 @@ const value = computed({
|
|||
return $props.modelValue;
|
||||
},
|
||||
set(value) {
|
||||
setOptions(myOptionsOriginal.value);
|
||||
emit('update:modelValue', value);
|
||||
},
|
||||
});
|
||||
|
@ -136,17 +146,20 @@ function filter(val, options) {
|
|||
async function fetchFilter(val) {
|
||||
if (!$props.url || !dataRef.value) return;
|
||||
|
||||
const { fields, sortBy, limit } = $props;
|
||||
let key = optionFilter.value ?? optionLabel.value;
|
||||
|
||||
if (new RegExp(/\d/g).test(val)) key = optionValue.value;
|
||||
const { fields, include, sortBy, limit } = $props;
|
||||
const key =
|
||||
optionFilterValue.value ??
|
||||
(new RegExp(/\d/g).test(val)
|
||||
? optionValue.value
|
||||
: optionFilter.value ?? optionLabel.value);
|
||||
|
||||
const defaultWhere = $props.useLike
|
||||
? { [key]: { like: `%${val}%` } }
|
||||
: { [key]: val };
|
||||
const where = { ...(val ? defaultWhere : {}), ...$props.where };
|
||||
const fetchOptions = { where, order: sortBy, limit };
|
||||
const fetchOptions = { where, include, limit };
|
||||
if (fields) fetchOptions.fields = fields;
|
||||
if (sortBy) fetchOptions.order = sortBy;
|
||||
return dataRef.value.fetch(fetchOptions);
|
||||
}
|
||||
|
||||
|
@ -159,7 +172,10 @@ async function filterHandler(val, update) {
|
|||
let newOptions;
|
||||
|
||||
if (!$props.defaultFilter) return update();
|
||||
if ($props.url) {
|
||||
if (
|
||||
$props.url &&
|
||||
($props.limit || (!$props.limit && Object.keys(myOptions.value).length === 0))
|
||||
) {
|
||||
newOptions = await fetchFilter(val);
|
||||
} else newOptions = filter(val, myOptionsOriginal.value);
|
||||
update(
|
||||
|
@ -174,6 +190,10 @@ async function filterHandler(val, update) {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
function nullishToTrue(value) {
|
||||
return value ?? true;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -192,12 +212,12 @@ async function filterHandler(val, update) {
|
|||
:option-label="optionLabel"
|
||||
:option-value="optionValue"
|
||||
v-bind="$attrs"
|
||||
emit-value
|
||||
map-options
|
||||
use-input
|
||||
@filter="filterHandler"
|
||||
hide-selected
|
||||
fill-input
|
||||
:emit-value="nullishToTrue($attrs['emit-value'])"
|
||||
:map-options="nullishToTrue($attrs['map-options'])"
|
||||
:use-input="nullishToTrue($attrs['use-input'])"
|
||||
:hide-selected="nullishToTrue($attrs['hide-selected'])"
|
||||
:fill-input="nullishToTrue($attrs['fill-input'])"
|
||||
ref="vnSelectRef"
|
||||
lazy-rules
|
||||
:class="{ required: $attrs.required }"
|
||||
|
@ -208,7 +228,12 @@ async function filterHandler(val, update) {
|
|||
<QIcon
|
||||
v-show="value"
|
||||
name="close"
|
||||
@click.stop="value = null"
|
||||
@click.stop="
|
||||
() => {
|
||||
value = null;
|
||||
emit('remove');
|
||||
}
|
||||
"
|
||||
class="cursor-pointer"
|
||||
size="xs"
|
||||
/>
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
|
||||
import { useRole } from 'src/composables/useRole';
|
||||
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
const emit = defineEmits(['update:modelValue']);
|
||||
|
||||
const value = defineModel({ type: [String, Number, Object] });
|
||||
const $props = defineProps({
|
||||
modelValue: {
|
||||
type: [String, Number, Object],
|
||||
default: null,
|
||||
},
|
||||
options: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
rolesAllowedToCreate: {
|
||||
type: Array,
|
||||
default: () => ['developer'],
|
||||
|
@ -33,15 +24,6 @@ const $props = defineProps({
|
|||
const role = useRole();
|
||||
const showForm = ref(false);
|
||||
|
||||
const value = computed({
|
||||
get() {
|
||||
return $props.modelValue;
|
||||
},
|
||||
set(value) {
|
||||
emit('update:modelValue', value);
|
||||
},
|
||||
});
|
||||
|
||||
const isAllowedToCreate = computed(() => {
|
||||
return role.hasAny($props.rolesAllowedToCreate);
|
||||
});
|
||||
|
@ -52,7 +34,11 @@ const toggleForm = () => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<VnSelect v-model="value" :options="options" v-bind="$attrs">
|
||||
<VnSelect
|
||||
v-model="value"
|
||||
v-bind="$attrs"
|
||||
@update:model-value="(...args) => emit('update:modelValue', ...args)"
|
||||
>
|
||||
<template v-if="isAllowedToCreate" #append>
|
||||
<QIcon
|
||||
@click.stop.prevent="toggleForm()"
|
||||
|
|
|
@ -7,7 +7,7 @@ defineProps({
|
|||
</script>
|
||||
<template>
|
||||
<div :class="$q.screen.gt.md ? 'q-pb-lg' : 'q-pb-md'">
|
||||
<div class="header-link">
|
||||
<div class="header-link" :style="{ cursor: url ? 'pointer' : 'default' }">
|
||||
<a :href="url" :class="url ? 'link' : 'color-vn-text'">
|
||||
{{ text }}
|
||||
<QIcon v-if="url" :name="icon" />
|
||||
|
|
|
@ -31,7 +31,7 @@ const dialog = ref(null);
|
|||
<div class="container order-catalog-item overflow-hidden">
|
||||
<QCard class="card shadow-6">
|
||||
<div class="img-wrapper">
|
||||
<VnImg :id="item.id" zoom-size="lg" class="image" />
|
||||
<VnImg :id="item.id" class="image" />
|
||||
<div v-if="item.hex && isCatalog" class="item-color-container">
|
||||
<div
|
||||
class="item-color"
|
||||
|
|
|
@ -73,8 +73,7 @@ const containerClasses = computed(() => {
|
|||
.q-calendar-month__head--workweek,
|
||||
.q-calendar-month__head--weekday,
|
||||
// .q-calendar-month__workweek.q-past-day,
|
||||
.q-calendar-month__week :nth-child(6),
|
||||
:nth-child(7) {
|
||||
.q-calendar-month__week :nth-child(n+6):nth-child(-n+7) {
|
||||
color: var(--vn-label-color);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,45 +1,62 @@
|
|||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useSession } from 'src/composables/useSession';
|
||||
import { useColor } from 'src/composables/useColor';
|
||||
import { getCssVar } from 'quasar';
|
||||
|
||||
const $props = defineProps({
|
||||
workerId: { type: Number, required: true },
|
||||
description: { type: String, default: null },
|
||||
size: { type: String, default: null },
|
||||
title: { type: String, default: null },
|
||||
color: { type: String, default: null },
|
||||
});
|
||||
|
||||
const { getTokenMultimedia } = useSession();
|
||||
const token = getTokenMultimedia();
|
||||
const { t } = useI18n();
|
||||
|
||||
const title = computed(() => $props.title ?? t('globals.system'));
|
||||
const src = computed(
|
||||
() => `/api/Images/user/160x160/${$props.workerId}/download?access_token=${token}`
|
||||
);
|
||||
const title = computed(() => $props.title?.toUpperCase() || t('globals.system'));
|
||||
const showLetter = ref(false);
|
||||
const backgroundColor = computed(() => {
|
||||
const color = $props.color || useColor(title.value);
|
||||
return getCssVar(color) || color;
|
||||
});
|
||||
|
||||
watch(src, () => (showLetter.value = false));
|
||||
</script>
|
||||
<template>
|
||||
<div class="avatar-picture column items-center">
|
||||
<div class="column items-center">
|
||||
<QAvatar
|
||||
:style="{
|
||||
backgroundColor: useColor(title),
|
||||
}"
|
||||
:size="$props.size"
|
||||
:title="title"
|
||||
:style="{ backgroundColor }"
|
||||
v-bind="$attrs"
|
||||
:title="title || t('globals.system')"
|
||||
>
|
||||
<template v-if="showLetter">{{ title.charAt(0) }}</template>
|
||||
<QImg
|
||||
v-else
|
||||
:src="`/api/Images/user/160x160/${$props.workerId}/download?access_token=${token}`"
|
||||
spinner-color="white"
|
||||
@error="showLetter = true"
|
||||
/>
|
||||
<template v-if="showLetter">
|
||||
{{ title.charAt(0) }}
|
||||
</template>
|
||||
<QImg v-else :src="src" spinner-color="white" @error="showLetter = true" />
|
||||
</QAvatar>
|
||||
<div class="description">
|
||||
<slot name="description" v-if="$props.description">
|
||||
<p>
|
||||
{{ $props.description }}
|
||||
</p>
|
||||
<slot name="description" v-if="description">
|
||||
<p v-text="description" />
|
||||
</slot>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<style lang="scss" scoped>
|
||||
[size='xxl'] {
|
||||
.q-avatar,
|
||||
.q-img {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
}
|
||||
|
||||
.q-img {
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -37,7 +37,7 @@ const $props = defineProps({
|
|||
},
|
||||
hiddenTags: {
|
||||
type: Array,
|
||||
default: () => ['filter'],
|
||||
default: () => ['filter', 'search', 'or', 'and'],
|
||||
},
|
||||
customTags: {
|
||||
type: Array,
|
||||
|
@ -57,7 +57,7 @@ const $props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
defineExpose({ search });
|
||||
defineExpose({ search, sanitizer });
|
||||
const emit = defineEmits([
|
||||
'update:modelValue',
|
||||
'refresh',
|
||||
|
@ -65,6 +65,7 @@ const emit = defineEmits([
|
|||
'search',
|
||||
'init',
|
||||
'remove',
|
||||
'setUserParams',
|
||||
]);
|
||||
|
||||
const arrayData = useArrayData($props.dataKey, {
|
||||
|
@ -81,22 +82,26 @@ onMounted(() => {
|
|||
});
|
||||
|
||||
function setUserParams(watchedParams) {
|
||||
if (!watchedParams) return;
|
||||
if (!watchedParams || Object.keys(watchedParams).length == 0) return;
|
||||
|
||||
if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams);
|
||||
if (typeof watchedParams?.filter == 'string')
|
||||
watchedParams.filter = JSON.parse(watchedParams.filter);
|
||||
|
||||
watchedParams = { ...watchedParams, ...watchedParams.filter?.where };
|
||||
const order = watchedParams.filter?.order;
|
||||
|
||||
delete watchedParams.filter;
|
||||
userParams.value = { ...userParams.value, ...watchedParams };
|
||||
userParams.value = { ...userParams.value, ...sanitizer(watchedParams) };
|
||||
emit('setUserParams', userParams.value, order);
|
||||
}
|
||||
|
||||
watch(
|
||||
() => route.query[$props.searchUrl],
|
||||
(val) => setUserParams(val)
|
||||
);
|
||||
|
||||
watch(
|
||||
() => arrayData.store.userParams,
|
||||
(val) => setUserParams(val)
|
||||
() => [route.query[$props.searchUrl], arrayData.store.userParams],
|
||||
([newSearchUrl, newUserParams], [oldSearchUrl, oldUserParams]) => {
|
||||
if (newSearchUrl || oldSearchUrl) setUserParams(newSearchUrl);
|
||||
if (newUserParams || oldUserParams) setUserParams(newUserParams);
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
|
@ -106,6 +111,7 @@ watch(
|
|||
|
||||
const isLoading = ref(false);
|
||||
async function search(evt) {
|
||||
try {
|
||||
if (evt && $props.disableSubmitEvent) return;
|
||||
|
||||
store.filter.where = {};
|
||||
|
@ -118,9 +124,10 @@ async function search(evt) {
|
|||
userParams.value = newParams;
|
||||
|
||||
if (!$props.showAll && !Object.values(filter).length) store.data = [];
|
||||
|
||||
isLoading.value = false;
|
||||
emit('search');
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function reload() {
|
||||
|
@ -135,6 +142,7 @@ async function reload() {
|
|||
}
|
||||
|
||||
async function clearFilters() {
|
||||
try {
|
||||
isLoading.value = true;
|
||||
store.userParamsChanged = true;
|
||||
arrayData.reset(['skip', 'filter.skip', 'page']);
|
||||
|
@ -154,10 +162,11 @@ async function clearFilters() {
|
|||
if (!$props.showAll) {
|
||||
store.data = [];
|
||||
}
|
||||
|
||||
isLoading.value = false;
|
||||
emit('clear');
|
||||
emit('update:modelValue', userParams.value);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const tagsList = computed(() => {
|
||||
|
@ -190,6 +199,16 @@ function formatValue(value) {
|
|||
|
||||
return `"${value}"`;
|
||||
}
|
||||
|
||||
function sanitizer(params) {
|
||||
for (const [key, value] of Object.entries(params)) {
|
||||
if (typeof value == 'object') {
|
||||
const param = Object.values(value)[0];
|
||||
if (typeof param == 'string') params[key] = param.replaceAll('%', '');
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -272,7 +291,7 @@ function formatValue(value) {
|
|||
<QSeparator />
|
||||
</QList>
|
||||
<QList dense class="list q-gutter-y-sm q-mt-sm">
|
||||
<slot name="body" :params="userParams" :search-fn="search"></slot>
|
||||
<slot name="body" :params="sanitizer(userParams)" :search-fn="search"></slot>
|
||||
</QList>
|
||||
</QForm>
|
||||
<QInnerLoading
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
import { useSession } from 'src/composables/useSession';
|
||||
import noImage from '/no-user.png';
|
||||
import { useRole } from 'src/composables/useRole';
|
||||
|
||||
const $props = defineProps({
|
||||
storage: {
|
||||
|
@ -11,14 +13,17 @@ const $props = defineProps({
|
|||
type: String,
|
||||
default: 'catalog',
|
||||
},
|
||||
size: {
|
||||
resolution: {
|
||||
type: String,
|
||||
default: '200x200',
|
||||
},
|
||||
zoomSize: {
|
||||
zoomResolution: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: 'lg',
|
||||
default: null,
|
||||
},
|
||||
zoom: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
id: {
|
||||
type: Number,
|
||||
|
@ -28,14 +33,16 @@ const $props = defineProps({
|
|||
const show = ref(false);
|
||||
const token = useSession().getTokenMultimedia();
|
||||
const timeStamp = ref(`timestamp=${Date.now()}`);
|
||||
import noImage from '/no-user.png';
|
||||
import { useRole } from 'src/composables/useRole';
|
||||
const url = computed(() => {
|
||||
const isEmployee = useRole().isEmployee();
|
||||
const isEmployee = useRole().isEmployee();
|
||||
|
||||
const getUrl = (zoom = false) => {
|
||||
const curResolution = zoom
|
||||
? $props.zoomResolution || $props.resolution
|
||||
: $props.resolution;
|
||||
return isEmployee
|
||||
? `/api/${$props.storage}/${$props.collection}/${$props.size}/${$props.id}/download?access_token=${token}&${timeStamp.value}`
|
||||
? `/api/${$props.storage}/${$props.collection}/${curResolution}/${$props.id}/download?access_token=${token}&${timeStamp.value}`
|
||||
: noImage;
|
||||
});
|
||||
};
|
||||
const reload = () => {
|
||||
timeStamp.value = `timestamp=${Date.now()}`;
|
||||
};
|
||||
|
@ -45,23 +52,21 @@ defineExpose({
|
|||
</script>
|
||||
<template>
|
||||
<QImg
|
||||
:class="{ zoomIn: $props.zoomSize }"
|
||||
:src="url"
|
||||
:class="{ zoomIn: zoom }"
|
||||
:src="getUrl()"
|
||||
v-bind="$attrs"
|
||||
@click="show = !show"
|
||||
@click.stop="show = $props.zoom ? true : false"
|
||||
spinner-color="primary"
|
||||
/>
|
||||
<QDialog v-model="show" v-if="$props.zoomSize">
|
||||
<QDialog v-if="$props.zoom" v-model="show">
|
||||
<QImg
|
||||
:src="url"
|
||||
size="full"
|
||||
class="img_zoom"
|
||||
:src="getUrl(true)"
|
||||
v-bind="$attrs"
|
||||
spinner-color="primary"
|
||||
class="img_zoom"
|
||||
/>
|
||||
</QDialog>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.q-img {
|
||||
&.zoomIn {
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
<script setup>
|
||||
import VnAvatar from 'src/components/ui/VnAvatar.vue';
|
||||
import { toDateHourMin } from 'src/filters';
|
||||
import { ref } from 'vue';
|
||||
import axios from 'axios';
|
||||
import { ref } from 'vue';
|
||||
import { onBeforeRouteLeave } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import VnPaginate from './VnPaginate.vue';
|
||||
import VnUserLink from '../ui/VnUserLink.vue';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
||||
import { toDateHourMin } from 'src/filters';
|
||||
import { useState } from 'src/composables/useState';
|
||||
|
||||
import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||
import VnUserLink from 'components/ui/VnUserLink.vue';
|
||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||
import VnAvatar from 'components/ui/VnAvatar.vue';
|
||||
|
||||
const $props = defineProps({
|
||||
url: { type: String, default: null },
|
||||
filter: { type: Object, default: () => {} },
|
||||
|
@ -17,6 +22,7 @@ const $props = defineProps({
|
|||
|
||||
const { t } = useI18n();
|
||||
const state = useState();
|
||||
const quasar = useQuasar();
|
||||
const currentUser = ref(state.getUser());
|
||||
const newNote = ref('');
|
||||
const vnPaginateRef = ref();
|
||||
|
@ -28,11 +34,24 @@ function handleKeyUp(event) {
|
|||
}
|
||||
async function insert() {
|
||||
const body = $props.body;
|
||||
Object.assign(body, { text: newNote.value });
|
||||
await axios.post($props.url, body);
|
||||
const newBody = { ...body, ...{ text: newNote.value } };
|
||||
await axios.post($props.url, newBody);
|
||||
await vnPaginateRef.value.fetch();
|
||||
newNote.value = '';
|
||||
}
|
||||
|
||||
onBeforeRouteLeave((to, from, next) => {
|
||||
if (newNote.value)
|
||||
quasar.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t('globals.unsavedPopup.title'),
|
||||
message: t('globals.unsavedPopup.subtitle'),
|
||||
promise: () => next(),
|
||||
},
|
||||
});
|
||||
else next();
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<QCard class="q-pa-xs q-mb-xl full-width" v-if="$props.addNote">
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<script setup>
|
||||
const emit = defineEmits(['submit']);
|
||||
defineProps({
|
||||
icon: { type: String, required: false, default: 'phonelink_lock' },
|
||||
title: { type: String, required: true },
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<QForm @submit="emit('submit')" class="q-gutter-y-md q-pa-lg formCard">
|
||||
<div class="column items-center">
|
||||
<QIcon v-if="icon != false" :name="icon" size="xl" color="primary" />
|
||||
<h5 class="text-center q-my-md">
|
||||
{{ title }}
|
||||
</h5>
|
||||
</div>
|
||||
<slot></slot>
|
||||
<div class="q-mt-lg">
|
||||
<slot name="buttons"></slot>
|
||||
</div>
|
||||
</QForm>
|
||||
</template>
|
||||
<style lang="scss" scoped>
|
||||
.formCard {
|
||||
max-width: 350px;
|
||||
min-width: 300px;
|
||||
}
|
||||
@media (max-width: $breakpoint-xs-max) {
|
||||
.formCard {
|
||||
min-width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -115,8 +115,8 @@ watch(
|
|||
);
|
||||
|
||||
watch(
|
||||
() => props.url,
|
||||
(url) => fetch({ url })
|
||||
() => [props.url, props.filter],
|
||||
([url, filter]) => mounted.value && fetch({ url, filter })
|
||||
);
|
||||
|
||||
const addFilter = async (filter, params) => {
|
||||
|
@ -221,7 +221,7 @@ defineExpose({ fetch, addFilter, paginate });
|
|||
>
|
||||
<slot name="body" :rows="store.data"></slot>
|
||||
<div v-if="isLoading" class="info-row q-pa-md text-center">
|
||||
<QSpinner color="orange" size="md" />
|
||||
<QSpinner color="primary" size="md" />
|
||||
</div>
|
||||
</QInfiniteScroll>
|
||||
</template>
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<script setup>
|
||||
defineProps({ wrap: { type: Boolean, default: false } });
|
||||
</script>
|
||||
<template>
|
||||
<div class="vn-row q-gutter-md q-mb-md" :class="{ wrap }">
|
||||
<slot></slot>
|
||||
<div class="vn-row q-gutter-md q-mb-md">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
<style lang="scss" scopped>
|
||||
<style lang="scss" scoped>
|
||||
.vn-row {
|
||||
display: flex;
|
||||
> * {
|
||||
> :deep(*) {
|
||||
flex: 1;
|
||||
}
|
||||
&[wrap] {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
@media screen and (max-width: 800px) {
|
||||
.vn-row {
|
||||
|
|
|
@ -67,6 +67,10 @@ const props = defineProps({
|
|||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
searchUrl: {
|
||||
type: String,
|
||||
default: 'params',
|
||||
},
|
||||
});
|
||||
|
||||
const searchText = ref('');
|
||||
|
@ -100,9 +104,7 @@ onMounted(() => {
|
|||
});
|
||||
|
||||
async function search() {
|
||||
const staticParams = Object.entries(store.userParams).filter(
|
||||
([key, value]) => value && (props.staticParams || []).includes(key)
|
||||
);
|
||||
const staticParams = Object.entries(store.userParams);
|
||||
arrayData.reset(['skip', 'page']);
|
||||
|
||||
if (props.makeFetch)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { onBeforeMount } from 'vue';
|
||||
import { watch, computed } from 'vue';
|
||||
import { date } from 'quasar';
|
||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||
import VnAvatar from '../ui/VnAvatar.vue';
|
||||
|
@ -10,7 +10,8 @@ const $props = defineProps({
|
|||
where: { type: Object, default: () => {} },
|
||||
});
|
||||
|
||||
const filter = {
|
||||
const filter = computed(() => {
|
||||
return {
|
||||
fields: ['smsFk'],
|
||||
include: {
|
||||
relation: 'sms',
|
||||
|
@ -32,9 +33,9 @@ const filter = {
|
|||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
onBeforeMount(() => (filter.where = $props.where));
|
||||
...{ where: $props.where },
|
||||
};
|
||||
});
|
||||
|
||||
function formatNumber(number) {
|
||||
if (number.length <= 10) return number;
|
||||
|
|
|
@ -43,20 +43,9 @@ onBeforeUnmount(() => stateStore.toggleSubToolbar());
|
|||
</slot>
|
||||
</QToolbar>
|
||||
</template>
|
||||
<style lang="scss">
|
||||
.q-toolbar {
|
||||
background: var(--vn-section-color);
|
||||
}
|
||||
</style>
|
||||
<style lang="scss" scoped>
|
||||
.sticky {
|
||||
position: sticky;
|
||||
top: 61px;
|
||||
z-index: 1;
|
||||
}
|
||||
@media (max-width: $breakpoint-sm) {
|
||||
.sticky {
|
||||
top: 90px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -18,4 +18,3 @@ const { t } = useI18n();
|
|||
</slot>
|
||||
<WorkerDescriptorProxy v-if="$props.workerId" :id="$props.workerId" />
|
||||
</template>
|
||||
<style scoped></style>
|
||||
|
|
|
@ -3,12 +3,14 @@ import { useRole } from './useRole';
|
|||
import { useAcl } from './useAcl';
|
||||
import { useUserConfig } from './useUserConfig';
|
||||
import axios from 'axios';
|
||||
import { useRouter } from 'vue-router';
|
||||
import useNotify from './useNotify';
|
||||
import { useTokenConfig } from './useTokenConfig';
|
||||
const TOKEN_MULTIMEDIA = 'tokenMultimedia';
|
||||
const TOKEN = 'token';
|
||||
|
||||
export function useSession() {
|
||||
const router = useRouter();
|
||||
const { notify } = useNotify();
|
||||
let isCheckingToken = false;
|
||||
let intervalId = null;
|
||||
|
@ -102,6 +104,31 @@ export function useSession() {
|
|||
startInterval();
|
||||
}
|
||||
|
||||
async function setLogin(data) {
|
||||
const {
|
||||
data: { multimediaToken },
|
||||
} = await axios.get('VnUsers/ShareToken', {
|
||||
headers: { Authorization: data.token },
|
||||
});
|
||||
|
||||
if (!multimediaToken) return;
|
||||
|
||||
await login({
|
||||
...data,
|
||||
created: Date.now(),
|
||||
tokenMultimedia: multimediaToken.id,
|
||||
});
|
||||
|
||||
notify('login.loginSuccess', 'positive');
|
||||
|
||||
const currentRoute = router.currentRoute.value;
|
||||
if (currentRoute.query?.redirect) {
|
||||
router.push(currentRoute.query.redirect);
|
||||
} else {
|
||||
router.push({ name: 'Dashboard' });
|
||||
}
|
||||
}
|
||||
|
||||
function isLoggedIn() {
|
||||
const localToken = localStorage.getItem(TOKEN);
|
||||
const sessionToken = sessionStorage.getItem(TOKEN);
|
||||
|
@ -163,6 +190,7 @@ export function useSession() {
|
|||
setToken,
|
||||
destroy,
|
||||
login,
|
||||
setLogin,
|
||||
isLoggedIn,
|
||||
checkValidity,
|
||||
setSession,
|
||||
|
|
|
@ -153,6 +153,12 @@ select:-webkit-autofill {
|
|||
background-color: var(--vn-section-color);
|
||||
}
|
||||
|
||||
.q-table td[shrink] {
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
max-width: 80px;
|
||||
}
|
||||
|
||||
.tr-header {
|
||||
color: var(--vn-label-color);
|
||||
}
|
||||
|
@ -184,15 +190,12 @@ select:-webkit-autofill {
|
|||
font-size: medium;
|
||||
}
|
||||
|
||||
.q-card__actions {
|
||||
justify-content: center;
|
||||
.q-toolbar {
|
||||
background: var(--vn-section-color);
|
||||
}
|
||||
|
||||
.q-card,
|
||||
.q-table,
|
||||
.q-table__bottom,
|
||||
.q-drawer {
|
||||
background-color: var(--vn-section-color);
|
||||
.q-card__actions {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
input[type='number'] {
|
||||
|
@ -209,27 +212,29 @@ input::-webkit-inner-spin-button {
|
|||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* ===== Scrollbar CSS ===== /
|
||||
/ Firefox */
|
||||
.q-table__container {
|
||||
/* ===== Scrollbar CSS ===== /
|
||||
/ Firefox */
|
||||
|
||||
* {
|
||||
* {
|
||||
scrollbar-width: auto;
|
||||
scrollbar-color: var(--vn-label-color) transparent;
|
||||
}
|
||||
}
|
||||
|
||||
/* Chrome, Edge, and Safari */
|
||||
*::-webkit-scrollbar {
|
||||
/* Chrome, Edge, and Safari */
|
||||
*::-webkit-scrollbar {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
*::-webkit-scrollbar-thumb {
|
||||
*::-webkit-scrollbar-thumb {
|
||||
background-color: var(--vn-label-color);
|
||||
border-radius: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
*::-webkit-scrollbar-track {
|
||||
*::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
.q-table {
|
||||
|
@ -246,6 +251,16 @@ input::-webkit-inner-spin-button {
|
|||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
tr {
|
||||
th {
|
||||
font-size: 11pt;
|
||||
}
|
||||
td {
|
||||
font-size: 11pt;
|
||||
border-top: 1px solid var(--vn-page-color);
|
||||
border-collapse: collapse;
|
||||
}
|
||||
}
|
||||
.shrink {
|
||||
max-width: 75px;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
// parsing JSON safely
|
||||
function parseJSON(str, fallback) {
|
||||
try {
|
||||
return JSON.parse(str ?? '{}');
|
||||
} catch (e) {
|
||||
console.error('Error parsing JSON:', e);
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
export default function (route, param) {
|
||||
// catch route query params
|
||||
const params = parseJSON(route?.query?.params, {});
|
||||
|
||||
// extract and parse filter from params
|
||||
const { filter: filterStr = '{}' } = params;
|
||||
const where = parseJSON(filterStr, {})?.where;
|
||||
if (where && where[param] !== undefined) {
|
||||
return where[param];
|
||||
}
|
||||
return null;
|
||||
}
|
|
@ -11,6 +11,7 @@ import dashIfEmpty from './dashIfEmpty';
|
|||
import dateRange from './dateRange';
|
||||
import toHour from './toHour';
|
||||
import dashOrCurrency from './dashOrCurrency';
|
||||
import getParamWhere from './getParamWhere';
|
||||
|
||||
export {
|
||||
toLowerCase,
|
||||
|
@ -26,4 +27,5 @@ export {
|
|||
toPercentage,
|
||||
dashIfEmpty,
|
||||
dateRange,
|
||||
getParamWhere,
|
||||
};
|
||||
|
|
|
@ -90,6 +90,10 @@ globals:
|
|||
salesPerson: SalesPerson
|
||||
send: Send
|
||||
code: Code
|
||||
since: Since
|
||||
from: From
|
||||
to: To
|
||||
notes: Notes
|
||||
pageTitles:
|
||||
logIn: Login
|
||||
summary: Summary
|
||||
|
@ -246,6 +250,11 @@ globals:
|
|||
mailForwarding: Mail forwarding
|
||||
mailAlias: Mail alias
|
||||
privileges: Privileges
|
||||
ldap: LDAP
|
||||
samba: Samba
|
||||
twoFactor: Two factor
|
||||
recoverPassword: Recover password
|
||||
resetPassword: Reset password
|
||||
created: Created
|
||||
worker: Worker
|
||||
now: Now
|
||||
|
@ -254,6 +263,11 @@ globals:
|
|||
comment: Comment
|
||||
observations: Observations
|
||||
goToModuleIndex: Go to module index
|
||||
unsavedPopup:
|
||||
title: Unsaved changes will be lost
|
||||
subtitle: Are you sure exit without saving?
|
||||
createInvoiceIn: Create invoice in
|
||||
myAccount: My account
|
||||
errors:
|
||||
statusUnauthorized: Access denied
|
||||
statusInternalServerError: An internal server error has ocurred
|
||||
|
@ -279,14 +293,17 @@ twoFactor:
|
|||
explanation: >-
|
||||
Please, enter the verification code that we have sent to your email in the
|
||||
next 5 minutes
|
||||
pageTitles:
|
||||
twoFactor: Two-Factor
|
||||
verifyEmail:
|
||||
pageTitles:
|
||||
verifyEmail: Email verification
|
||||
dashboard:
|
||||
pageTitles:
|
||||
|
||||
recoverPassword:
|
||||
userOrEmail: User or recovery email
|
||||
explanation: >-
|
||||
We will sent you an email to recover your password
|
||||
resetPassword:
|
||||
repeatPassword: Repeat password
|
||||
passwordNotMatch: Passwords don't match
|
||||
passwordChanged: Password changed
|
||||
customer:
|
||||
list:
|
||||
phone: Phone
|
||||
|
@ -386,8 +403,8 @@ customer:
|
|||
extendedList:
|
||||
tableVisibleColumns:
|
||||
id: Identifier
|
||||
name: Comercial name
|
||||
socialName: Business name
|
||||
name: Name
|
||||
socialName: Social name
|
||||
fi: Tax number
|
||||
salesPersonFk: Salesperson
|
||||
credit: Credit
|
||||
|
@ -1003,18 +1020,6 @@ route:
|
|||
shipped: Preparation date
|
||||
viewCmr: View CMR
|
||||
downloadCmrs: Download CMRs
|
||||
columnLabels:
|
||||
Id: Id
|
||||
vehicle: Vehicle
|
||||
description: Description
|
||||
isServed: Served
|
||||
worker: Worker
|
||||
date: Date
|
||||
started: Started
|
||||
actions: Actions
|
||||
agency: Agency
|
||||
volume: Volume
|
||||
finished: Finished
|
||||
supplier:
|
||||
list:
|
||||
payMethod: Pay method
|
||||
|
|
|
@ -90,6 +90,10 @@ globals:
|
|||
salesPerson: Comercial
|
||||
send: Enviar
|
||||
code: Código
|
||||
since: Desde
|
||||
from: Desde
|
||||
to: Hasta
|
||||
notes: Notas
|
||||
pageTitles:
|
||||
logIn: Inicio de sesión
|
||||
summary: Resumen
|
||||
|
@ -248,6 +252,11 @@ globals:
|
|||
components: Componentes
|
||||
pictures: Fotos
|
||||
packages: Bultos
|
||||
ldap: LDAP
|
||||
samba: Samba
|
||||
twoFactor: Doble factor
|
||||
recoverPassword: Recuperar contraseña
|
||||
resetPassword: Restablecer contraseña
|
||||
created: Fecha creación
|
||||
worker: Trabajador
|
||||
now: Ahora
|
||||
|
@ -256,6 +265,11 @@ globals:
|
|||
comment: Comentario
|
||||
observations: Observaciones
|
||||
goToModuleIndex: Ir al índice del módulo
|
||||
unsavedPopup:
|
||||
title: Los cambios que no haya guardado se perderán
|
||||
subtitle: ¿Seguro que quiere salir sin guardar?
|
||||
createInvoiceIn: Crear factura recibida
|
||||
myAccount: Mi cuenta
|
||||
errors:
|
||||
statusUnauthorized: Acceso denegado
|
||||
statusInternalServerError: Ha ocurrido un error interno del servidor
|
||||
|
@ -279,14 +293,17 @@ twoFactor:
|
|||
validate: Validar
|
||||
insert: Introduce el código de verificación
|
||||
explanation: Por favor introduce el código de verificación que te hemos enviado a tu email en los próximos 5 minutos
|
||||
pageTitles:
|
||||
twoFactor: Doble factor
|
||||
verifyEmail:
|
||||
pageTitles:
|
||||
verifyEmail: Verificación de correo
|
||||
dashboard:
|
||||
pageTitles:
|
||||
|
||||
recoverPassword:
|
||||
userOrEmail: Usuario o correo de recuperación
|
||||
explanation: >-
|
||||
Te enviaremos un correo para restablecer tu contraseña
|
||||
resetPassword:
|
||||
repeatPassword: Repetir contraseña
|
||||
passwordNotMatch: Las contraseñas no coinciden
|
||||
passwordChanged: Contraseña cambiada
|
||||
customer:
|
||||
list:
|
||||
phone: Teléfono
|
||||
|
@ -385,7 +402,7 @@ customer:
|
|||
extendedList:
|
||||
tableVisibleColumns:
|
||||
id: Identificador
|
||||
name: Nombre Comercial
|
||||
name: Nombre
|
||||
socialName: Razón social
|
||||
fi: NIF / CIF
|
||||
salesPersonFk: Comercial
|
||||
|
@ -698,8 +715,6 @@ invoiceOut:
|
|||
percentageText: '{getPercentage}% {getAddressNumber} de {getNAddresses}'
|
||||
pdfsNumberText: '{nPdfs} de {totalPdfs} PDFs'
|
||||
negativeBases:
|
||||
from: Desde
|
||||
to: Hasta
|
||||
company: Empresa
|
||||
country: País
|
||||
clientId: Id cliente
|
||||
|
@ -874,7 +889,7 @@ worker:
|
|||
card:
|
||||
workerId: ID Trabajador
|
||||
name: Nombre
|
||||
email: Email
|
||||
email: Correo personal
|
||||
phone: Teléfono
|
||||
mobile: Móvil
|
||||
active: Activo
|
||||
|
@ -984,18 +999,6 @@ route:
|
|||
shipped: Fecha preparación
|
||||
viewCmr: Ver CMR
|
||||
downloadCmrs: Descargar CMRs
|
||||
columnLabels:
|
||||
Id: Id
|
||||
vehicle: Vehículo
|
||||
description: Descripción
|
||||
isServed: Servida
|
||||
worker: Trabajador
|
||||
date: Fecha
|
||||
started: Iniciada
|
||||
actions: Acciones
|
||||
agency: Agencia
|
||||
volume: Volumen
|
||||
finished: Finalizada
|
||||
supplier:
|
||||
list:
|
||||
payMethod: Método de pago
|
||||
|
@ -1253,8 +1256,6 @@ components:
|
|||
# LatestBuysFilter
|
||||
salesPersonFk: Comprador
|
||||
supplierFk: Proveedor
|
||||
from: Desde
|
||||
to: Hasta
|
||||
active: Activo
|
||||
visible: Visible
|
||||
floramondo: Floramondo
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
<script setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import FormModel from 'components/FormModel.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
||||
import axios from 'axios';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
<script setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ref } from 'vue';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
|
||||
import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||
import CardList from 'src/components/ui/CardList.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import AclFilter from './Acls/AclFilter.vue';
|
||||
import AclFormView from './Acls/AclFormView.vue';
|
||||
|
||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||
import { ref, computed } from 'vue';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import axios from 'axios';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||
|
||||
defineProps({
|
||||
id: {
|
||||
|
@ -25,10 +21,9 @@ defineProps({
|
|||
const { notify } = useNotify();
|
||||
const { t } = useI18n();
|
||||
const stateStore = useStateStore();
|
||||
const { openConfirmationModal } = useVnConfirm();
|
||||
const quasar = useQuasar();
|
||||
|
||||
const paginateRef = ref();
|
||||
const formDialog = ref(false);
|
||||
const tableRef = ref();
|
||||
const rolesOptions = ref([]);
|
||||
|
||||
const exprBuilder = (param, value) => {
|
||||
|
@ -40,32 +35,94 @@ const exprBuilder = (param, value) => {
|
|||
}
|
||||
};
|
||||
|
||||
const deleteAcl = async (id) => {
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
name: 'id',
|
||||
label: t('id'),
|
||||
isId: true,
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'model',
|
||||
label: t('model'),
|
||||
cardVisible: true,
|
||||
create: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'principalId',
|
||||
label: t('principalId'),
|
||||
cardVisible: true,
|
||||
component: 'select',
|
||||
attrs: {
|
||||
url: 'VnRoles',
|
||||
optionLabel: 'name',
|
||||
optionValue: 'name',
|
||||
},
|
||||
create: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'property',
|
||||
label: t('property'),
|
||||
cardVisible: true,
|
||||
create: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'accessType',
|
||||
label: t('accessType'),
|
||||
component: 'select',
|
||||
attrs: {
|
||||
options: ['READ', 'WRITE', '*'],
|
||||
},
|
||||
cardVisible: true,
|
||||
create: true,
|
||||
},
|
||||
{
|
||||
align: 'right',
|
||||
label: '',
|
||||
name: 'tableActions',
|
||||
actions: [
|
||||
{
|
||||
title: t('Delete'),
|
||||
icon: 'delete',
|
||||
action: deleteAcl,
|
||||
isPrimary: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
const deleteAcl = async ({ id }) => {
|
||||
try {
|
||||
await new Promise((resolve) => {
|
||||
quasar
|
||||
.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t('Remove ACL'),
|
||||
message: t('Do you want to remove this ACL?'),
|
||||
},
|
||||
})
|
||||
.onOk(() => {
|
||||
resolve(true);
|
||||
})
|
||||
.onCancel(() => {
|
||||
resolve(false);
|
||||
});
|
||||
});
|
||||
await axios.delete(`ACLs/${id}`);
|
||||
paginateRef.value.fetch();
|
||||
tableRef.value.reload();
|
||||
notify('ACL removed', 'positive');
|
||||
} catch (error) {
|
||||
console.error('Error deleting Acl: ', error);
|
||||
}
|
||||
};
|
||||
function showFormDialog(data) {
|
||||
formDialog.value = {
|
||||
show: true,
|
||||
formInitialData: { ...data },
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
url="VnRoles"
|
||||
:filter="{ fields: ['name'], order: 'name ASC' }"
|
||||
@on-fetch="(data) => (rolesOptions = data)"
|
||||
auto-load
|
||||
/>
|
||||
<template v-if="stateStore.isHeaderMounted()">
|
||||
<Teleport to="#searchbar">
|
||||
<VnSearchbar
|
||||
data-key="AccountAcls"
|
||||
url="ACLs"
|
||||
|
@ -73,73 +130,25 @@ function showFormDialog(data) {
|
|||
:label="t('acls.search')"
|
||||
:info="t('acls.searchInfo')"
|
||||
/>
|
||||
</Teleport>
|
||||
</template>
|
||||
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
|
||||
<QScrollArea class="fit text-grey-8">
|
||||
<AclFilter data-key="AccountAcls" />
|
||||
</QScrollArea>
|
||||
</QDrawer>
|
||||
|
||||
<QPage class="flex justify-center q-pa-md">
|
||||
<div class="vn-card-list">
|
||||
<VnPaginate
|
||||
ref="paginateRef"
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="AccountAcls"
|
||||
url="ACLs"
|
||||
:expr-builder="exprBuilder"
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
<CardList
|
||||
v-for="row of rows"
|
||||
:id="row.id"
|
||||
:key="row.id"
|
||||
:title="`${row.model}.${row.property}`"
|
||||
@click="showFormDialog(row)"
|
||||
>
|
||||
<template #list-items>
|
||||
<VnLv :label="t('acls.role')" :value="row.principalId" />
|
||||
<VnLv :label="t('acls.accessType')" :value="row.accessType" />
|
||||
<VnLv
|
||||
:label="t('acls.permissions')"
|
||||
:value="row.permission"
|
||||
:url="`ACLs`"
|
||||
:create="{
|
||||
urlCreate: 'ACLs',
|
||||
title: 'Create ACL',
|
||||
onDataSaved: () => tableRef.reload(),
|
||||
formInitialData: {},
|
||||
}"
|
||||
order="id DESC"
|
||||
:columns="columns"
|
||||
default-mode="table"
|
||||
:right-search="true"
|
||||
:is-editable="true"
|
||||
:use-model="true"
|
||||
/>
|
||||
</template>
|
||||
<template #actions>
|
||||
<QBtn
|
||||
:label="t('globals.delete')"
|
||||
@click.stop="
|
||||
openConfirmationModal(
|
||||
t('ACL will be removed'),
|
||||
t('Are you sure you want to continue?'),
|
||||
() => deleteAcl(row.id)
|
||||
)
|
||||
"
|
||||
color="primary"
|
||||
style="margin-top: 15px"
|
||||
/>
|
||||
</template>
|
||||
</CardList>
|
||||
</template>
|
||||
</VnPaginate>
|
||||
</div>
|
||||
<QDialog
|
||||
v-model="formDialog.show"
|
||||
transition-show="scale"
|
||||
transition-hide="scale"
|
||||
>
|
||||
<AclFormView
|
||||
:form-initial-data="formDialog.formInitialData"
|
||||
@on-data-change="paginateRef.fetch()"
|
||||
:roles-options="rolesOptions"
|
||||
/>
|
||||
</QDialog>
|
||||
<QPageSticky position="bottom-right" :offset="[18, 18]">
|
||||
<QBtn fab icon="add" color="primary" @click="showFormDialog()">
|
||||
<QTooltip class="text-no-wrap">{{ t('New ACL') }}</QTooltip>
|
||||
</QBtn>
|
||||
</QPageSticky>
|
||||
</QPage>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
|
@ -148,4 +157,17 @@ es:
|
|||
ACL removed: ACL eliminado
|
||||
ACL will be removed: El ACL será eliminado
|
||||
Are you sure you want to continue?: ¿Seguro que quieres continuar?
|
||||
Remove ACL: Eliminar Acl
|
||||
Do you want to remove this ACL?: ¿Quieres eliminar este ACL?
|
||||
principalId: Rol
|
||||
model: Modelo
|
||||
en:
|
||||
New ACL: New ACL
|
||||
ACL removed: ACL removed
|
||||
ACL will be removed: ACL will be removed
|
||||
Are you sure you want to continue?: Are you sure you want to continue?
|
||||
Remove ACL: Remove ACL
|
||||
Do you want to remove this ACL?: Do you want to remove this ACL?
|
||||
principalId: Rol
|
||||
model: Models
|
||||
</i18n>
|
||||
|
|
|
@ -1,30 +1,13 @@
|
|||
<script setup>
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ref } from 'vue';
|
||||
|
||||
import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||
import { ref, computed } from 'vue';
|
||||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||
import CardList from 'src/components/ui/CardList.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import AliasSummary from './Alias/Card/AliasSummary.vue';
|
||||
import AliasCreateForm from './Alias/AliasCreateForm.vue';
|
||||
|
||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
|
||||
defineProps({
|
||||
id: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
});
|
||||
|
||||
const tableRef = ref();
|
||||
const { t } = useI18n();
|
||||
const { viewSummary } = useSummaryDialog();
|
||||
const router = useRouter();
|
||||
const stateStore = useStateStore();
|
||||
const aliasCreateDialogRef = ref(null);
|
||||
|
||||
const exprBuilder = (param, value) => {
|
||||
switch (param) {
|
||||
|
@ -34,10 +17,32 @@ const exprBuilder = (param, value) => {
|
|||
: { alias: { like: `%${value}%` } };
|
||||
}
|
||||
};
|
||||
|
||||
const navigate = (id) => router.push({ name: 'AliasSummary', params: { id } });
|
||||
|
||||
const openCreateModal = () => aliasCreateDialogRef.value.show();
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
name: 'id',
|
||||
label: t('id'),
|
||||
isId: true,
|
||||
field: 'id',
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'alias',
|
||||
label: t('alias'),
|
||||
field: 'alias',
|
||||
cardVisible: true,
|
||||
create: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'description',
|
||||
label: t('description'),
|
||||
field: 'description',
|
||||
cardVisible: true,
|
||||
create: true,
|
||||
},
|
||||
]);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -52,54 +57,21 @@ const openCreateModal = () => aliasCreateDialogRef.value.show();
|
|||
/>
|
||||
</Teleport>
|
||||
</template>
|
||||
<QPage class="flex justify-center q-pa-md">
|
||||
<div class="vn-card-list">
|
||||
<VnPaginate
|
||||
ref="paginateRef"
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="AccountAliasList"
|
||||
url="MailAliases"
|
||||
:expr-builder="exprBuilder"
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
<CardList
|
||||
v-for="row of rows"
|
||||
:id="row.id"
|
||||
:key="row.id"
|
||||
:title="row.alias"
|
||||
@click="navigate(row.id)"
|
||||
>
|
||||
<template #list-items>
|
||||
<VnLv :label="t('mailAlias.alias')" :value="row.alias">
|
||||
</VnLv>
|
||||
<VnLv
|
||||
:label="t('mailAlias.description')"
|
||||
:value="row.description"
|
||||
>
|
||||
</VnLv>
|
||||
</template>
|
||||
<template #actions>
|
||||
<QBtn
|
||||
:label="t('components.smartCard.openSummary')"
|
||||
@click.stop="viewSummary(row.id, AliasSummary)"
|
||||
color="primary"
|
||||
style="margin-top: 15px"
|
||||
:create="{
|
||||
urlCreate: 'MailAliases',
|
||||
title: 'Create MailAlias',
|
||||
onDataSaved: ({ id }) => tableRef.redirect(id),
|
||||
formInitialData: {},
|
||||
}"
|
||||
order="id DESC"
|
||||
:columns="columns"
|
||||
default-mode="table"
|
||||
redirect="account/alias"
|
||||
:is-editable="true"
|
||||
:use-model="true"
|
||||
/>
|
||||
</template>
|
||||
</CardList>
|
||||
</template>
|
||||
</VnPaginate>
|
||||
</div>
|
||||
<QDialog
|
||||
ref="aliasCreateDialogRef"
|
||||
transition-show="scale"
|
||||
transition-hide="scale"
|
||||
>
|
||||
<AliasCreateForm />
|
||||
</QDialog>
|
||||
<QPageSticky position="bottom-right" :offset="[18, 18]">
|
||||
<QBtn fab icon="add" color="primary" @click="openCreateModal()">
|
||||
<QTooltip class="text-no-wrap">{{ t('mailAlias.newAlias') }}</QTooltip>
|
||||
</QBtn>
|
||||
</QPageSticky>
|
||||
</QPage>
|
||||
</template>
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||
import CardList from 'src/components/ui/CardList.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
|
||||
import { toDateTimeFormat } from 'src/filters/date.js';
|
||||
import axios from 'axios';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
import { reactive, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import FormModelPopup from 'components/FormModelPopup.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
|
@ -15,7 +14,6 @@ const newAccountForm = reactive({
|
|||
active: true,
|
||||
});
|
||||
const rolesOptions = ref([]);
|
||||
|
||||
const redirectToAccountBasicData = (_, { id }) => {
|
||||
router.push({ name: 'AccountBasicData', params: { id } });
|
||||
};
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
|
||||
import VnSelect from 'components/common/VnSelect.vue';
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
<script setup>
|
||||
import { ref, onMounted, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import FormModel from 'components/FormModel.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import axios from 'axios';
|
||||
|
@ -15,7 +13,6 @@ const { t } = useI18n();
|
|||
const { notify } = useNotify();
|
||||
|
||||
const arrayData = useArrayData('AccountLdap');
|
||||
|
||||
const URL_UPDATE = `LdapConfigs/${1}`;
|
||||
const URL_CREATE = `LdapConfigs`;
|
||||
const DEFAULT_DATA = {
|
||||
|
@ -27,11 +24,9 @@ const DEFAULT_DATA = {
|
|||
server: null,
|
||||
userDn: null,
|
||||
};
|
||||
|
||||
const initialData = ref({
|
||||
...DEFAULT_DATA,
|
||||
});
|
||||
|
||||
const hasData = computed({
|
||||
get: () => initialData.value.hasData,
|
||||
set: (val) => {
|
||||
|
@ -40,12 +35,10 @@ const hasData = computed({
|
|||
else formCustomFn.value = null;
|
||||
},
|
||||
});
|
||||
|
||||
const initialDataLoaded = ref(false);
|
||||
const formUrlCreate = ref(null);
|
||||
const formUrlUpdate = ref(null);
|
||||
const formCustomFn = ref(null);
|
||||
|
||||
const onTestConection = async () => {
|
||||
try {
|
||||
await axios.get(`LdapConfigs/test`);
|
||||
|
@ -54,7 +47,6 @@ const onTestConection = async () => {
|
|||
console.error('Error testing connection', error);
|
||||
}
|
||||
};
|
||||
|
||||
const getInitialLdapConfig = async () => {
|
||||
try {
|
||||
initialDataLoaded.value = false;
|
||||
|
@ -79,7 +71,6 @@ const getInitialLdapConfig = async () => {
|
|||
initialDataLoaded.value = true;
|
||||
}
|
||||
};
|
||||
|
||||
const deleteMailForward = async () => {
|
||||
try {
|
||||
await axios.delete(URL_UPDATE);
|
||||
|
|
|
@ -1,33 +1,74 @@
|
|||
<script setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||
import { ref, computed } from 'vue';
|
||||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import CardList from 'src/components/ui/CardList.vue';
|
||||
import AccountSummary from './Card/AccountSummary.vue';
|
||||
import AccountFilter from './AccountFilter.vue';
|
||||
import AccountCreate from './AccountCreate.vue';
|
||||
|
||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { useRole } from 'src/composables/useRole';
|
||||
import { QDialog } from 'quasar';
|
||||
|
||||
const stateStore = useStateStore();
|
||||
const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
const { viewSummary } = useSummaryDialog();
|
||||
const accountCreateDialogRef = ref(null);
|
||||
const showNewUserBtn = computed(() => useRole().hasAny(['itManagement']));
|
||||
|
||||
const filter = {
|
||||
fields: ['id', 'nickname', 'name', 'role'],
|
||||
include: { relation: 'role', scope: { fields: ['id', 'name'] } },
|
||||
};
|
||||
const tableRef = ref();
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
name: 'id',
|
||||
label: t('id'),
|
||||
isId: true,
|
||||
field: 'id',
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'username',
|
||||
label: t('nickname'),
|
||||
isTitle: true,
|
||||
component: 'input',
|
||||
columnField: {
|
||||
component: null,
|
||||
},
|
||||
columnFilter: {
|
||||
inWhere: true,
|
||||
},
|
||||
cardVisible: true,
|
||||
create: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'name',
|
||||
label: t('name'),
|
||||
component: 'input',
|
||||
columnField: {
|
||||
component: null,
|
||||
},
|
||||
columnFilter: {
|
||||
inWhere: true,
|
||||
},
|
||||
cardVisible: true,
|
||||
create: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'email',
|
||||
label: t('email'),
|
||||
component: 'input',
|
||||
create: true,
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
align: 'right',
|
||||
label: '',
|
||||
name: 'tableActions',
|
||||
actions: [
|
||||
{
|
||||
title: t('View Summary'),
|
||||
icon: 'preview',
|
||||
action: (row) => viewSummary(row.id, AccountSummary),
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
const exprBuilder = (param, value) => {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
|
@ -46,99 +87,24 @@ const exprBuilder = (param, value) => {
|
|||
return { [param]: value };
|
||||
}
|
||||
};
|
||||
|
||||
const getApiUrl = () => new URL(window.location).origin;
|
||||
|
||||
const navigate = (event, id) => {
|
||||
if (event.ctrlKey || event.metaKey)
|
||||
return window.open(`${getApiUrl()}/#/account/${id}/summary`);
|
||||
router.push({ path: `/account/${id}` });
|
||||
};
|
||||
|
||||
const openCreateModal = () => accountCreateDialogRef.value.show();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-if="stateStore.isHeaderMounted()">
|
||||
<Teleport to="#searchbar">
|
||||
<VnSearchbar
|
||||
data-key="AccountList"
|
||||
url="VnUsers/preview"
|
||||
data-key="AccountUsers"
|
||||
:expr-builder="exprBuilder"
|
||||
:label="t('account.search')"
|
||||
:info="t('account.searchInfo')"
|
||||
/>
|
||||
</Teleport>
|
||||
<Teleport to="#actions-append">
|
||||
<div class="row q-gutter-x-sm">
|
||||
<QBtn
|
||||
flat
|
||||
@click="stateStore.toggleRightDrawer()"
|
||||
round
|
||||
dense
|
||||
icon="menu"
|
||||
>
|
||||
<QTooltip bottom anchor="bottom right">
|
||||
{{ t('globals.collapseMenu') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
|
||||
<QScrollArea class="fit text-grey-8">
|
||||
<AccountFilter data-key="AccountList" :expr-builder="exprBuilder" />
|
||||
</QScrollArea>
|
||||
</QDrawer>
|
||||
<QPage class="column items-center q-pa-md">
|
||||
<div class="vn-card-list">
|
||||
<VnPaginate
|
||||
:filter="filter"
|
||||
data-key="AccountList"
|
||||
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="AccountUsers"
|
||||
url="VnUsers/preview"
|
||||
auto-load
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
<CardList
|
||||
v-for="row of rows"
|
||||
:id="row.id"
|
||||
:key="row.id"
|
||||
:title="row.nickname"
|
||||
@click="navigate($event, row.id)"
|
||||
>
|
||||
<template #list-items>
|
||||
<VnLv :label="t('account.card.name')" :value="row.nickname">
|
||||
</VnLv>
|
||||
<VnLv
|
||||
:label="t('account.card.nickname')"
|
||||
:value="row.username"
|
||||
>
|
||||
</VnLv>
|
||||
</template>
|
||||
<template #actions>
|
||||
<QBtn
|
||||
:label="t('components.smartCard.openSummary')"
|
||||
@click.stop="viewSummary(row.id, AccountSummary)"
|
||||
color="primary"
|
||||
style="margin-top: 15px"
|
||||
order="id DESC"
|
||||
:columns="columns"
|
||||
default-mode="table"
|
||||
redirect="account"
|
||||
:use-model="true"
|
||||
/>
|
||||
</template>
|
||||
</CardList>
|
||||
</template>
|
||||
</VnPaginate>
|
||||
</div>
|
||||
<QDialog
|
||||
ref="accountCreateDialogRef"
|
||||
transition-hide="scale"
|
||||
transition-show="scale"
|
||||
>
|
||||
<AccountCreate />
|
||||
</QDialog>
|
||||
<QPageSticky :offset="[20, 20]" v-if="showNewUserBtn">
|
||||
<QBtn @click="openCreateModal" color="primary" fab icon="add" />
|
||||
<QTooltip class="text-no-wrap">
|
||||
{{ t('account.card.newUser') }}
|
||||
</QTooltip>
|
||||
</QPageSticky>
|
||||
</QPage>
|
||||
</template>
|
||||
|
|
|
@ -1,23 +1,18 @@
|
|||
<script setup>
|
||||
import { ref, onMounted, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import FormModel from 'components/FormModel.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import axios from 'axios';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { notify } = useNotify();
|
||||
|
||||
const arrayData = useArrayData('AccountSamba');
|
||||
|
||||
const formModel = ref(null);
|
||||
|
||||
const URL_UPDATE = `SambaConfigs/${1}`;
|
||||
const URL_CREATE = `SambaConfigs`;
|
||||
|
||||
|
|
|
@ -1,22 +1,8 @@
|
|||
<script setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import VnCard from 'components/common/VnCard.vue';
|
||||
import AliasDescriptor from './AliasDescriptor.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
||||
const routeName = computed(() => route.name);
|
||||
const customRouteRedirectName = computed(() => {
|
||||
return routeName.value;
|
||||
});
|
||||
const searchBarDataKeys = {
|
||||
AliasBasicData: 'AliasBasicData',
|
||||
AliasUsers: 'AliasUsers',
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -24,10 +10,12 @@ const searchBarDataKeys = {
|
|||
data-key="Alias"
|
||||
base-url="MailAliases"
|
||||
:descriptor="AliasDescriptor"
|
||||
:search-data-key="searchBarDataKeys[routeName]"
|
||||
:search-custom-route-redirect="customRouteRedirectName"
|
||||
:search-redirect="!!customRouteRedirectName"
|
||||
:searchbar-label="t('mailAlias.search')"
|
||||
:searchbar-info="t('mailAlias.searchInfo')"
|
||||
search-data-key="AccountAliasList"
|
||||
:searchbar-props="{
|
||||
url: 'MailAliases',
|
||||
info: t('mailAlias.searchInfo'),
|
||||
label: t('mailAlias.search'),
|
||||
searchUrl: 'table',
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -28,6 +28,7 @@ const entityId = computed(() => $props.id || route.params.id);
|
|||
ref="summary"
|
||||
:url="`MailAliases/${entityId}`"
|
||||
@on-fetch="(data) => (alias = data)"
|
||||
data-key="MailAliasesSummary"
|
||||
>
|
||||
<template #header> {{ alias.id }} - {{ alias.alias }} </template>
|
||||
<template #body>
|
||||
|
|
|
@ -37,9 +37,11 @@ watch(
|
|||
<VnInput v-model="data.nickname" :label="t('account.card.alias')" />
|
||||
<VnInput v-model="data.email" :label="t('account.card.email')" />
|
||||
<VnSelect
|
||||
url="Languages"
|
||||
v-model="data.lang"
|
||||
:options="['es', 'en']"
|
||||
:label="t('account.card.lang')"
|
||||
option-value="code"
|
||||
option-label="code"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -1,34 +1,21 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import VnCard from 'components/common/VnCard.vue';
|
||||
import AccountDescriptor from './AccountDescriptor.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
||||
const routeName = computed(() => route.name);
|
||||
const customRouteRedirectName = computed(() => routeName.value);
|
||||
const searchBarDataKeys = {
|
||||
AccountSummary: 'AccountSummary',
|
||||
AccountInheritedRoles: 'AccountInheritedRoles',
|
||||
AccountMailForwarding: 'AccountMailForwarding',
|
||||
AccountMailAlias: 'AccountMailAlias',
|
||||
AccountPrivileges: 'AccountPrivileges',
|
||||
AccountLog: 'AccountLog',
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnCard
|
||||
data-key="Account"
|
||||
:descriptor="AccountDescriptor"
|
||||
:search-data-key="searchBarDataKeys[routeName]"
|
||||
:search-custom-route-redirect="customRouteRedirectName"
|
||||
:search-redirect="!!customRouteRedirectName"
|
||||
:searchbar-label="t('account.search')"
|
||||
:searchbar-info="t('account.searchInfo')"
|
||||
search-data-key="AccountUsers"
|
||||
:searchbar-props="{
|
||||
url: 'VnUsers/preview',
|
||||
label: t('account.search'),
|
||||
info: t('account.searchInfo'),
|
||||
searchUrl: 'table',
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -54,7 +54,7 @@ const hasAccount = ref(false);
|
|||
</template>
|
||||
<template #before>
|
||||
<!-- falla id :id="entityId.value" collection="user" size="160x160" -->
|
||||
<VnImg :id="entityId" collection="user" size="160x160" class="photo">
|
||||
<VnImg :id="entityId" collection="user" resolution="160x160" class="photo">
|
||||
<template #error>
|
||||
<div
|
||||
class="absolute-full picture text-center q-pa-md flex flex-center"
|
||||
|
|
|
@ -8,7 +8,7 @@ import { useRoute } from 'vue-router';
|
|||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import CustomerChangePassword from 'src/pages/Customer/components/CustomerChangePassword.vue';
|
||||
import VnConfirm from 'src/components/ui/VnConfirm.vue';
|
||||
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
const quasar = useQuasar();
|
||||
const $props = defineProps({
|
||||
hasAccount: {
|
||||
|
@ -21,7 +21,7 @@ const { t } = useI18n();
|
|||
const { hasAccount } = toRefs($props);
|
||||
const { openConfirmationModal } = useVnConfirm();
|
||||
const route = useRoute();
|
||||
|
||||
const { notify } = useNotify();
|
||||
const account = computed(() => useArrayData('AccountId').store.data[0]);
|
||||
account.value.hasAccount = hasAccount.value;
|
||||
const entityId = computed(() => +route.params.id);
|
||||
|
@ -71,6 +71,15 @@ async function sync() {
|
|||
type: 'positive',
|
||||
});
|
||||
}
|
||||
|
||||
const removeAccount = async () => {
|
||||
try {
|
||||
await axios.delete(`VnUsers/${account.value.id}`);
|
||||
notify(t('Account removed'), 'positive');
|
||||
} catch (error) {
|
||||
console.error('Error deleting user', error);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<VnConfirm
|
||||
|
@ -103,7 +112,7 @@ async function sync() {
|
|||
/>
|
||||
</template>
|
||||
</VnConfirm>
|
||||
<QItem v-ripple clickable @click="setPassword">
|
||||
<!-- <QItem v-ripple clickable @click="setPassword">
|
||||
<QItemSection>{{ t('account.card.actions.setPassword') }}</QItemSection>
|
||||
</QItem>
|
||||
<QItem
|
||||
|
@ -119,7 +128,8 @@ async function sync() {
|
|||
"
|
||||
>
|
||||
<QItemSection>{{ t('account.card.actions.enableAccount.name') }}</QItemSection>
|
||||
</QItem>
|
||||
</QItem> -->
|
||||
|
||||
<QItem
|
||||
v-if="account.hasAccount"
|
||||
v-ripple
|
||||
|
@ -168,20 +178,10 @@ async function sync() {
|
|||
</QItem>
|
||||
|
||||
<QSeparator />
|
||||
<QItem
|
||||
@click="
|
||||
openConfirmationModal(
|
||||
t('account.card.actions.delete.title'),
|
||||
t('account.card.actions.delete.subTitle'),
|
||||
removeAccount
|
||||
)
|
||||
"
|
||||
v-ripple
|
||||
clickable
|
||||
>
|
||||
<!-- <QItem @click="removeAccount(id)" v-ripple clickable>
|
||||
<QItemSection avatar>
|
||||
<QIcon name="delete" />
|
||||
</QItemSection>
|
||||
<QItemSection>{{ t('account.card.actions.delete.name') }}</QItemSection>
|
||||
</QItem>
|
||||
</QItem> -->
|
||||
</template>
|
||||
|
|
|
@ -85,7 +85,7 @@ const fetchMailAliases = async () => {
|
|||
paginateRef.value.fetch();
|
||||
};
|
||||
|
||||
const getAccountData = async () => {
|
||||
const getAccountData = async (reload = true) => {
|
||||
loading.value = true;
|
||||
hasAccount.value = await fetchAccountExistence();
|
||||
if (!hasAccount.value) {
|
||||
|
@ -93,7 +93,7 @@ const getAccountData = async () => {
|
|||
store.data = [];
|
||||
return;
|
||||
}
|
||||
await fetchMailAliases();
|
||||
reload && (await fetchMailAliases());
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
|
@ -102,13 +102,11 @@ const openCreateMailAliasForm = () => createMailAliasDialogRef.value.show();
|
|||
watch(
|
||||
() => route.params.id,
|
||||
() => {
|
||||
store.url = urlPath;
|
||||
store.filter = filter.value;
|
||||
getAccountData();
|
||||
}
|
||||
);
|
||||
|
||||
onMounted(async () => await getAccountData());
|
||||
onMounted(async () => await getAccountData(false));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -14,16 +14,11 @@ const rolesOptions = ref([]);
|
|||
const formModelRef = ref();
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
url="VnRoles"
|
||||
:filter="{ fields: ['id', 'name'], order: 'name ASC' }"
|
||||
auto-load
|
||||
@on-fetch="(data) => (rolesOptions = data)"
|
||||
/>
|
||||
<FetchData url="VnRoles" auto-load @on-fetch="(data) => (rolesOptions = data)" />
|
||||
<FormModel
|
||||
ref="formModelRef"
|
||||
model="AccountPrivileges"
|
||||
:url="`VnUsers/${route.params.id}`"
|
||||
:url="`VnUsers/${route.params.id}/privileges`"
|
||||
:url-create="`VnUsers/${route.params.id}/privileges`"
|
||||
auto-load
|
||||
@on-data-saved="formModelRef.fetch()"
|
||||
|
|
|
@ -1,23 +1,17 @@
|
|||
<script setup>
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
|
||||
const props = defineProps({
|
||||
dataKey: { type: String, required: true },
|
||||
});
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const paginateRef = ref(null);
|
||||
|
||||
const arrayData = useArrayData(props.dataKey);
|
||||
const store = arrayData.store;
|
||||
|
||||
const data = computed(() => {
|
||||
const dataCopy = store.data;
|
||||
return dataCopy.sort((a, b) => a.role?.name.localeCompare(b.role?.name));
|
||||
|
@ -37,7 +31,6 @@ const filter = computed(() => ({
|
|||
}));
|
||||
|
||||
const urlPath = 'RoleMappings';
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
name: 'name',
|
||||
|
|
|
@ -1,26 +1,62 @@
|
|||
<script setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ref } from 'vue';
|
||||
|
||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import CardList from 'src/components/ui/CardList.vue';
|
||||
import RoleSummary from './Card/RoleSummary.vue';
|
||||
import RoleForm from './Card/RoleForm.vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||
import AccountRolesFilter from './AccountRolesFilter.vue';
|
||||
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||
|
||||
import RoleSummary from './Card/RoleSummary.vue';
|
||||
const route = useRoute();
|
||||
const stateStore = useStateStore();
|
||||
const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
const $props = defineProps({
|
||||
id: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
});
|
||||
const tableRef = ref();
|
||||
const entityId = computed(() => $props.id || route.params.id);
|
||||
const { viewSummary } = useSummaryDialog();
|
||||
|
||||
const roleCreateDialogRef = ref(null);
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
name: 'id',
|
||||
label: t('id'),
|
||||
isId: true,
|
||||
columnFilter: {
|
||||
inWhere: true,
|
||||
},
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'name',
|
||||
label: t('name'),
|
||||
cardVisible: true,
|
||||
create: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'description',
|
||||
label: t('description'),
|
||||
cardVisible: true,
|
||||
create: true,
|
||||
},
|
||||
{
|
||||
align: 'right',
|
||||
label: '',
|
||||
name: 'tableActions',
|
||||
actions: [
|
||||
{
|
||||
title: t('View Summary'),
|
||||
icon: 'preview',
|
||||
action: (row) => viewSummary(row.id, RoleSummary),
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
const exprBuilder = (param, value) => {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
|
@ -37,95 +73,30 @@ const exprBuilder = (param, value) => {
|
|||
return { [param]: { like: `%${value}%` } };
|
||||
}
|
||||
};
|
||||
|
||||
const openCreateModal = () => roleCreateDialogRef.value.show();
|
||||
|
||||
const getApiUrl = () => new URL(window.location).origin;
|
||||
|
||||
const navigate = (event, id) => {
|
||||
if (event.ctrlKey || event.metaKey)
|
||||
return window.open(`${getApiUrl()}/#/account/role/${id}/summary`);
|
||||
router.push({ name: 'RoleSummary', params: { id } });
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-if="stateStore.isHeaderMounted()">
|
||||
<Teleport to="#searchbar">
|
||||
<VnSearchbar
|
||||
data-key="RolesList"
|
||||
url="VnRoles"
|
||||
data-key="Roles"
|
||||
:expr-builder="exprBuilder"
|
||||
:label="t('role.searchRoles')"
|
||||
:info="t('role.searchInfo')"
|
||||
/>
|
||||
</Teleport>
|
||||
<Teleport to="#actions-append">
|
||||
<div class="row q-gutter-x-sm">
|
||||
<QBtn
|
||||
flat
|
||||
@click="stateStore.toggleRightDrawer()"
|
||||
round
|
||||
dense
|
||||
icon="menu"
|
||||
>
|
||||
<QTooltip bottom anchor="bottom right">
|
||||
{{ t('globals.collapseMenu') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
|
||||
<QScrollArea class="fit text-grey-8">
|
||||
<AccountRolesFilter data-key="RolesList" :expr-builder="exprBuilder" />
|
||||
</QScrollArea>
|
||||
</QDrawer>
|
||||
<QPage class="column items-center q-pa-md">
|
||||
<div class="vn-card-list">
|
||||
<VnPaginate data-key="RolesList" url="VnRoles">
|
||||
<template #body="{ rows }">
|
||||
<CardList
|
||||
:id="row.id"
|
||||
:key="row.id"
|
||||
:title="row.name"
|
||||
@click="navigate($event, row.id)"
|
||||
v-for="row of rows"
|
||||
>
|
||||
<template #list-items>
|
||||
<div style="flex-direction: column; width: 100%">
|
||||
<VnLv :label="t('role.card.name')" :value="row.name">
|
||||
</VnLv>
|
||||
<VnLv
|
||||
:label="t('role.card.description')"
|
||||
:value="row.description"
|
||||
>
|
||||
</VnLv>
|
||||
</div>
|
||||
</template>
|
||||
<template #actions>
|
||||
<QBtn
|
||||
:label="t('components.smartCard.openSummary')"
|
||||
@click.stop="viewSummary(row.id, RoleSummary)"
|
||||
color="primary"
|
||||
style="margin-top: 15px"
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="Roles"
|
||||
:url="`VnRoles`"
|
||||
:create="{
|
||||
urlCreate: 'VnRoles',
|
||||
title: t('Create rol'),
|
||||
onDataSaved: ({ id }) => tableRef.redirect(id),
|
||||
formInitialData: {
|
||||
editorFk: entityId,
|
||||
},
|
||||
}"
|
||||
order="id ASC"
|
||||
:columns="columns"
|
||||
default-mode="table"
|
||||
redirect="account/role"
|
||||
/>
|
||||
</template>
|
||||
</CardList>
|
||||
</template>
|
||||
</VnPaginate>
|
||||
</div>
|
||||
<QDialog
|
||||
ref="roleCreateDialogRef"
|
||||
transition-show="scale"
|
||||
transition-hide="scale"
|
||||
>
|
||||
<RoleForm />
|
||||
</QDialog>
|
||||
<QPageSticky :offset="[20, 20]">
|
||||
<QBtn fab icon="add" color="primary" @click="openCreateModal()" />
|
||||
<QTooltip>
|
||||
{{ t('role.newRole') }}
|
||||
</QTooltip>
|
||||
</QPageSticky>
|
||||
</QPage>
|
||||
</template>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<script setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
||||
|
|
|
@ -23,11 +23,6 @@ const { t } = useI18n();
|
|||
/>
|
||||
</div>
|
||||
</VnRow>
|
||||
<VnRow>
|
||||
<div class="col">
|
||||
<QCheckbox :label="t('mailAlias.isPublic')" v-model="data.isPublic" />
|
||||
</div>
|
||||
</VnRow>
|
||||
</template>
|
||||
</FormModel>
|
||||
</template>
|
||||
|
|
|
@ -1,32 +1,20 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import VnCard from 'components/common/VnCard.vue';
|
||||
import RoleDescriptor from './RoleDescriptor.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
||||
const routeName = computed(() => route.name);
|
||||
const customRouteRedirectName = computed(() => routeName.value);
|
||||
const searchBarDataKeys = {
|
||||
RoleSummary: 'RoleSummary',
|
||||
RoleBasicData: 'RoleBasicData',
|
||||
SubRoles: 'SubRoles',
|
||||
InheritedRoles: 'InheritedRoles',
|
||||
RoleLog: 'RoleLog',
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<VnCard
|
||||
data-key="Role"
|
||||
:descriptor="RoleDescriptor"
|
||||
:search-data-key="searchBarDataKeys[routeName]"
|
||||
:search-custom-route-redirect="customRouteRedirectName"
|
||||
:search-redirect="!!customRouteRedirectName"
|
||||
:searchbar-label="t('role.searchRoles')"
|
||||
:searchbar-info="t('role.searchInfo')"
|
||||
search-data-key="AccountRoles"
|
||||
:searchbar-props="{
|
||||
url: 'VnRoles',
|
||||
label: t('role.searchRoles'),
|
||||
info: t('role.searchInfo'),
|
||||
searchUrl: 'table',
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import useCardDescription from 'src/composables/useCardDescription';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
||||
import axios from 'axios';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
const $props = defineProps({
|
||||
|
@ -23,9 +21,6 @@ const $props = defineProps({
|
|||
|
||||
const route = useRoute();
|
||||
|
||||
const quasar = useQuasar();
|
||||
const router = useRouter();
|
||||
|
||||
const { notify } = useNotify();
|
||||
const { t } = useI18n();
|
||||
const entityId = computed(() => {
|
||||
|
@ -36,29 +31,13 @@ const setData = (entity) => (data.value = useCardDescription(entity.name, entity
|
|||
const filter = {
|
||||
where: { id: entityId },
|
||||
};
|
||||
const removeRole = () => {
|
||||
quasar
|
||||
.dialog({
|
||||
title: 'Are you sure you want to delete it?',
|
||||
message: 'Delete department',
|
||||
ok: {
|
||||
push: true,
|
||||
color: 'primary',
|
||||
},
|
||||
cancel: true,
|
||||
})
|
||||
.onOk(async () => {
|
||||
const removeRole = async () => {
|
||||
try {
|
||||
await axios.post(
|
||||
`/Departments/${entityId.value}/removeChild`,
|
||||
entityId.value
|
||||
);
|
||||
router.push({ name: 'WorkerDepartment' });
|
||||
notify('department.departmentRemoved', 'positive');
|
||||
} catch (err) {
|
||||
console.error('Error removing department');
|
||||
await axios.delete(`VnRoles/${entityId.value}`);
|
||||
notify(t('Role removed'), 'positive');
|
||||
} catch (error) {
|
||||
console.error('Error deleting role', error);
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<script setup>
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import FormModelPopup from 'components/FormModelPopup.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
|
|
@ -2,17 +2,14 @@
|
|||
import { reactive, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import FormPopup from 'components/FormPopup.vue';
|
||||
|
||||
const emit = defineEmits(['onSubmitCreateSubrole']);
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
||||
const subRoleFormData = reactive({
|
||||
inheritsFrom: null,
|
||||
role: route.params.id,
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||
import SubRoleCreateForm from './SubRoleCreateForm.vue';
|
||||
|
||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
|
@ -16,10 +14,8 @@ const route = useRoute();
|
|||
const router = useRouter();
|
||||
const { openConfirmationModal } = useVnConfirm();
|
||||
const { notify } = useNotify();
|
||||
|
||||
const paginateRef = ref(null);
|
||||
const createSubRoleDialogRef = ref(null);
|
||||
|
||||
const arrayData = useArrayData('SubRoles');
|
||||
const store = arrayData.store;
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ account:
|
|||
delete:
|
||||
name: Delete
|
||||
title: The account will be deleted
|
||||
subtitle: Are you sure you want to continue?
|
||||
subTitle: Are you sure you want to continue?
|
||||
success: ''
|
||||
search: Search user
|
||||
searchInfo: You can search by id, name or nickname
|
||||
|
|
|
@ -67,7 +67,7 @@ account:
|
|||
delete:
|
||||
name: Eliminar
|
||||
title: El usuario será eliminado
|
||||
subtitle: ¿Seguro que quieres continuar?
|
||||
subTitle: ¿Seguro que quieres continuar?
|
||||
success: ''
|
||||
search: Buscar usuario
|
||||
searchInfo: Puedes buscar por id, nombre o usuario
|
||||
|
|
|
@ -31,7 +31,7 @@ const destinationTypes = ref([]);
|
|||
const totalClaimed = ref(null);
|
||||
const DEFAULT_MAX_RESPONSABILITY = 5;
|
||||
const DEFAULT_MIN_RESPONSABILITY = 1;
|
||||
const arrayData = useArrayData('claimData');
|
||||
const arrayData = useArrayData('Claim');
|
||||
const marker_labels = [
|
||||
{ value: DEFAULT_MIN_RESPONSABILITY, label: t('claim.company') },
|
||||
{ value: DEFAULT_MAX_RESPONSABILITY, label: t('claim.person') },
|
||||
|
|
|
@ -10,13 +10,10 @@ import VnInput from 'src/components/common/VnInput.vue';
|
|||
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||
|
||||
import axios from 'axios';
|
||||
// import { useSession } from 'src/composables/useSession';
|
||||
import VnImg from 'src/components/ui/VnImg.vue';
|
||||
import VnAvatar from 'src/components/ui/VnAvatar.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
// const { getTokenMultimedia } = useSession();
|
||||
// const token = getTokenMultimedia();
|
||||
|
||||
const claimStates = ref([]);
|
||||
const claimStatesCopy = ref([]);
|
||||
|
@ -94,15 +91,14 @@ const statesFilter = {
|
|||
:rules="validate('claim.claimStateFk')"
|
||||
>
|
||||
<template #before>
|
||||
<QAvatar color="orange">
|
||||
<VnImg
|
||||
v-if="data.workerFk"
|
||||
:size="'160x160'"
|
||||
:id="data.workerFk"
|
||||
collection="user"
|
||||
spinner-color="white"
|
||||
<VnAvatar
|
||||
:worker-id="data.workerFk"
|
||||
size="md"
|
||||
:title="
|
||||
workersOptions.find(({ id }) => id == data.workerFk)?.name
|
||||
"
|
||||
color="primary"
|
||||
/>
|
||||
</QAvatar>
|
||||
</template>
|
||||
</VnSelect>
|
||||
<QSelect
|
||||
|
|
|
@ -11,9 +11,11 @@ import filter from './ClaimFilter.js';
|
|||
:descriptor="ClaimDescriptor"
|
||||
:filter-panel="ClaimFilter"
|
||||
search-data-key="ClaimList"
|
||||
search-url="Claims/filter"
|
||||
searchbar-label="Search claim"
|
||||
searchbar-info="You can search by claim id or customer name"
|
||||
:filter="filter"
|
||||
:searchbar-props="{
|
||||
url: 'Claims/filter',
|
||||
label: 'Search claim',
|
||||
info: 'You can search by claim id or customer name',
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -20,7 +20,8 @@ const workers = ref([]);
|
|||
const selected = ref([]);
|
||||
const saveButtonRef = ref();
|
||||
|
||||
const developmentsFilter = {
|
||||
const developmentsFilter = computed(() => {
|
||||
return {
|
||||
fields: [
|
||||
'id',
|
||||
'claimFk',
|
||||
|
@ -33,7 +34,8 @@ const developmentsFilter = {
|
|||
where: {
|
||||
claimFk: route.params.id,
|
||||
},
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
|
@ -142,9 +144,9 @@ const columns = computed(() => [
|
|||
ref="claimDevelopmentForm"
|
||||
:data-required="{ claimFk: route.params.id }"
|
||||
v-model:selected="selected"
|
||||
auto-load
|
||||
@save-changes="$router.push(`/claim/${route.params.id}/action`)"
|
||||
:default-save="false"
|
||||
auto-load
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
<QTable
|
||||
|
|
|
@ -14,7 +14,8 @@ const $props = defineProps({
|
|||
});
|
||||
const claimId = computed(() => $props.id || route.params.id);
|
||||
|
||||
const claimFilter = {
|
||||
const claimFilter = computed(() => {
|
||||
return {
|
||||
where: { claimFk: claimId.value },
|
||||
fields: ['id', 'created', 'workerFk', 'text'],
|
||||
include: {
|
||||
|
@ -29,7 +30,8 @@ const claimFilter = {
|
|||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
const body = {
|
||||
claimFk: claimId.value,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
import axios from 'axios';
|
||||
import { ref, computed } from 'vue';
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
@ -22,10 +22,8 @@ const claimDms = ref([
|
|||
},
|
||||
]);
|
||||
const client = ref({});
|
||||
|
||||
const inputFile = ref();
|
||||
const files = ref({});
|
||||
|
||||
const spinnerRef = ref();
|
||||
const claimDmsRef = ref();
|
||||
const dmsType = ref({});
|
||||
|
@ -58,6 +56,14 @@ const claimDmsFilter = ref({
|
|||
const multimediaDialog = ref();
|
||||
const multimediaSlide = ref();
|
||||
|
||||
watch(
|
||||
() => router.currentRoute.value.params.id,
|
||||
() => {
|
||||
claimDmsFilter.value.where.id = router.currentRoute.value.params.id;
|
||||
claimDmsRef.value.fetch();
|
||||
}
|
||||
);
|
||||
|
||||
function openDialog(dmsId) {
|
||||
multimediaSlide.value = dmsId;
|
||||
multimediaDialog.value = true;
|
||||
|
|
|
@ -279,7 +279,7 @@ async function changeState(value) {
|
|||
<ClaimNotes
|
||||
:id="entityId"
|
||||
:add-note="false"
|
||||
class="max-container-height"
|
||||
style="max-height: 300px"
|
||||
order="created ASC"
|
||||
/>
|
||||
</QCard>
|
||||
|
@ -330,7 +330,7 @@ async function changeState(value) {
|
|||
<QTable
|
||||
:columns="detailsColumns"
|
||||
:rows="salesClaimed"
|
||||
flat
|
||||
separator="horizontal"
|
||||
dense
|
||||
:rows-per-page-options="[0]"
|
||||
hide-bottom
|
||||
|
@ -344,7 +344,7 @@ async function changeState(value) {
|
|||
</template>
|
||||
<template #body="props">
|
||||
<QTr :props="props">
|
||||
<QTh v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<QTd v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<span v-if="col.name != 'description'">{{
|
||||
t(col.value)
|
||||
}}</span>
|
||||
|
@ -359,7 +359,7 @@ async function changeState(value) {
|
|||
:id="props.row.sale.itemFk"
|
||||
:sale-fk="props.row.saleFk"
|
||||
></ItemDescriptorProxy>
|
||||
</QTh>
|
||||
</QTd>
|
||||
</QTr>
|
||||
</template>
|
||||
</QTable>
|
||||
|
@ -384,7 +384,7 @@ async function changeState(value) {
|
|||
<template #body-cell-worker="props">
|
||||
<QTd :props="props" class="link">
|
||||
{{ props.value }}
|
||||
<WorkerDescriptorProxy :id="props.row.worker.id" />
|
||||
<WorkerDescriptorProxy :id="props.row.worker?.id" />
|
||||
</QTd>
|
||||
</template>
|
||||
</QTable>
|
||||
|
|
|
@ -100,6 +100,7 @@ defineExpose({ states });
|
|||
url="Items/withName"
|
||||
option-value="id"
|
||||
option-label="name"
|
||||
:use-like="false"
|
||||
sort-by="id DESC"
|
||||
outlined
|
||||
rounded
|
||||
|
|
|
@ -50,7 +50,7 @@ const columns = computed(() => [
|
|||
align: 'left',
|
||||
label: t('claim.attendedBy'),
|
||||
name: 'attendedBy',
|
||||
cardVisible: true,
|
||||
orderBy: 'workerFk',
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
attrs: {
|
||||
|
@ -63,6 +63,7 @@ const columns = computed(() => [
|
|||
optionFilter: 'firstName',
|
||||
},
|
||||
},
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -125,7 +126,7 @@ const STATE_COLOR = {
|
|||
<VnTable
|
||||
data-key="ClaimList"
|
||||
url="Claims/filter"
|
||||
:order="['priority ASC', 'created DESC']"
|
||||
:order="['priority ASC', 'created ASC']"
|
||||
:columns="columns"
|
||||
redirect="claim"
|
||||
:right-search="false"
|
||||
|
|
|
@ -1,120 +1,171 @@
|
|||
<script setup>
|
||||
import { computed, onBeforeMount, ref, watch } from 'vue';
|
||||
import { computed, onBeforeMount, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { useRole } from 'src/composables/useRole';
|
||||
import axios from 'axios';
|
||||
import { QCheckbox, QBtn, useQuasar } from 'quasar';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
||||
import { toCurrency, toDate, toDateHourMin } from 'src/filters';
|
||||
import { useState } from 'src/composables/useState';
|
||||
import { useState } from 'composables/useState';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { useValidator } from 'src/composables/useValidator';
|
||||
import { usePrintService } from 'src/composables/usePrintService';
|
||||
import { useSession } from 'src/composables/useSession';
|
||||
import { usePrintService } from 'composables/usePrintService';
|
||||
import { useSession } from 'composables/useSession';
|
||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||
|
||||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
import VnInput from 'components/common/VnInput.vue';
|
||||
import VnSubToolbar from 'components/ui/VnSubToolbar.vue';
|
||||
import VnFilter from 'components/VnTable/VnFilter.vue';
|
||||
|
||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import CustomerNewPayment from 'src/pages/Customer/components/CustomerNewPayment.vue';
|
||||
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
|
||||
import InvoiceOutDescriptorProxy from 'src/pages/InvoiceOut/Card/InvoiceOutDescriptorProxy.vue';
|
||||
const session = useSession();
|
||||
|
||||
const tokenMultimedia = session.getTokenMultimedia();
|
||||
|
||||
const { openConfirmationModal } = useVnConfirm();
|
||||
const { sendEmail } = usePrintService();
|
||||
const { t } = useI18n();
|
||||
const { validate } = useValidator();
|
||||
const { hasAny } = useRole();
|
||||
|
||||
const session = useSession();
|
||||
const tokenMultimedia = session.getTokenMultimedia();
|
||||
const quasar = useQuasar();
|
||||
const route = useRoute();
|
||||
const state = useState();
|
||||
const stateStore = useStateStore();
|
||||
const user = state.getUser();
|
||||
|
||||
const clientRisks = ref(null);
|
||||
const clientRisksRef = ref(null);
|
||||
const companiesOptions = ref([]);
|
||||
const companyId = ref(null);
|
||||
const receiptsRef = ref(null);
|
||||
const receiptsData = ref([]);
|
||||
|
||||
const filterCompanies = { order: ['code'] };
|
||||
const userParams = {
|
||||
const clientRisk = ref([]);
|
||||
const tableRef = ref();
|
||||
const companyId = ref();
|
||||
const companyLastId = ref(user.value.companyFk);
|
||||
const balances = ref([]);
|
||||
const vnFilterRef = ref({});
|
||||
const filter = computed(() => {
|
||||
return {
|
||||
clientId: route.params.id,
|
||||
companyId: user.value.companyFk,
|
||||
};
|
||||
const filter = {
|
||||
include: { relation: 'company', scope: { fields: ['code'] } },
|
||||
where: { clientFk: route.params.id, companyFk: user.value.companyFk },
|
||||
companyId: companyId.value ?? user.value.companyFk,
|
||||
};
|
||||
});
|
||||
|
||||
const companyFilterColumn = {
|
||||
align: 'left',
|
||||
name: 'companyId',
|
||||
label: t('Company'),
|
||||
component: 'select',
|
||||
attrs: {
|
||||
url: 'Companies',
|
||||
optionLabel: 'code',
|
||||
sortBy: 'code',
|
||||
limit: 0,
|
||||
},
|
||||
columnFilter: {
|
||||
event: {
|
||||
remove: () => (companyId.value = null),
|
||||
'update:modelValue': (newCompanyFk) => {
|
||||
if (!newCompanyFk) return;
|
||||
vnFilterRef.value.addFilter(newCompanyFk);
|
||||
companyLastId.value = newCompanyFk;
|
||||
},
|
||||
blur: () =>
|
||||
!companyId.value &&
|
||||
(companyId.value = companyLastId.value ?? user.value.companyFk),
|
||||
},
|
||||
},
|
||||
visible: false,
|
||||
};
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
field: 'payed',
|
||||
format: (value) => toDate(value),
|
||||
name: 'payed',
|
||||
label: t('Date'),
|
||||
name: 'date',
|
||||
format: ({ payed }) => toDate(payed),
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'created',
|
||||
format: (value) => toDateHourMin(value),
|
||||
name: 'created',
|
||||
label: t('Creation date'),
|
||||
name: 'creationDate',
|
||||
format: ({ created }) => toDateHourMin(created),
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'userName',
|
||||
name: 'workerFk',
|
||||
label: t('Employee'),
|
||||
name: 'employee',
|
||||
columnField: {
|
||||
component: 'userLink',
|
||||
attrs: ({ row }) => {
|
||||
return {
|
||||
workerId: row.workerFk,
|
||||
name: row.userName,
|
||||
};
|
||||
},
|
||||
},
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'description',
|
||||
name: 'description',
|
||||
label: t('Reference'),
|
||||
name: 'reference',
|
||||
isTitle: true,
|
||||
class: 'extend',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'bankFk',
|
||||
align: 'right',
|
||||
name: 'bankFk',
|
||||
label: t('Bank'),
|
||||
name: 'bank',
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'right',
|
||||
field: 'debit',
|
||||
format: (value) => value && toCurrency(value),
|
||||
label: t('Debit'),
|
||||
name: 'debit',
|
||||
label: t('Debit'),
|
||||
format: ({ debit }) => debit && toCurrency(debit),
|
||||
isId: true,
|
||||
},
|
||||
{
|
||||
align: 'right',
|
||||
field: 'credit',
|
||||
format: (value) => value && toCurrency(value),
|
||||
name: 'credit',
|
||||
label: t('Havings'),
|
||||
name: 'havings',
|
||||
format: ({ credit }) => credit && toCurrency(credit),
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'right',
|
||||
field: 'balance',
|
||||
format: (value) => value && toCurrency(value),
|
||||
label: t('Balance'),
|
||||
name: 'balance',
|
||||
label: t('Balance'),
|
||||
format: ({ balance }) => toCurrency(balance),
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'isConciliate',
|
||||
name: 'isConciliate',
|
||||
label: t('Conciliated'),
|
||||
name: 'conciliated',
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'totalWithVat',
|
||||
label: '',
|
||||
name: 'actions',
|
||||
name: 'tableActions',
|
||||
actions: [
|
||||
{
|
||||
title: t('globals.downloadPdf'),
|
||||
icon: 'cloud_download',
|
||||
show: (row) => row.isInvoice,
|
||||
action: (row) => showBalancePdf(row),
|
||||
},
|
||||
{
|
||||
title: t('Send compensation'),
|
||||
icon: 'outgoing_mail',
|
||||
show: (row) => !!row.isCompensation,
|
||||
action: ({ id }) =>
|
||||
openConfirmationModal(
|
||||
t('Send compensation'),
|
||||
t('Do you want to report compensation to the client by mail?'),
|
||||
() => sendEmail(`Receipts/${id}/balance-compensation-email`)
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
|
@ -123,249 +174,124 @@ onBeforeMount(() => {
|
|||
companyId.value = user.value.companyFk;
|
||||
});
|
||||
|
||||
watch(
|
||||
() => route.params.id,
|
||||
(newValue) => {
|
||||
if (!newValue) return;
|
||||
userParams.clientId = newValue;
|
||||
filter.where.clientFk = newValue;
|
||||
getData();
|
||||
}
|
||||
);
|
||||
async function getClientRisk() {
|
||||
const { data } = await axios.get(`clientRisks`, {
|
||||
params: {
|
||||
filter: JSON.stringify({
|
||||
include: { relation: 'company', scope: { fields: ['code'] } },
|
||||
where: { clientFk: route.params.id, companyFk: user.value.companyFk },
|
||||
}),
|
||||
},
|
||||
});
|
||||
clientRisk.value = data;
|
||||
return clientRisk.value;
|
||||
}
|
||||
|
||||
const getData = () => {
|
||||
receiptsRef.value?.fetch();
|
||||
clientRisksRef.value?.fetch();
|
||||
};
|
||||
|
||||
const getCurrentBalance = () => {
|
||||
const currentBalance = clientRisks.value.find((balance) => {
|
||||
async function getCurrentBalance() {
|
||||
const currentBalance = (await getClientRisk()).find((balance) => {
|
||||
return balance.companyFk === companyId.value;
|
||||
});
|
||||
return currentBalance && currentBalance.amount;
|
||||
};
|
||||
}
|
||||
|
||||
const onFetch = (balances) => {
|
||||
balances.forEach((balance, index) => {
|
||||
async function onFetch(data) {
|
||||
balances.value = [];
|
||||
for (const [index, balance] of data.entries()) {
|
||||
if (index === 0) {
|
||||
balance.balance = getCurrentBalance();
|
||||
} else {
|
||||
let previousBalance = balances[index - 1];
|
||||
balance.balance =
|
||||
previousBalance.balance -
|
||||
(previousBalance.debit - previousBalance.credit);
|
||||
balance.balance = await getCurrentBalance();
|
||||
continue;
|
||||
}
|
||||
});
|
||||
|
||||
receiptsData.value = balances;
|
||||
};
|
||||
const previousBalance = data[index - 1];
|
||||
balance.balance =
|
||||
previousBalance?.balance - (previousBalance?.debit - previousBalance?.credit);
|
||||
}
|
||||
balances.value = data;
|
||||
}
|
||||
|
||||
const showNewPaymentDialog = () => {
|
||||
quasar.dialog({
|
||||
component: CustomerNewPayment,
|
||||
componentProps: {
|
||||
companyId: companyId.value,
|
||||
totalCredit: clientRisks.value[0]?.amount,
|
||||
promise: getData,
|
||||
totalCredit: clientRisk.value[0]?.amount,
|
||||
promise: () => tableRef.value.reload(),
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const updateCompanyId = (id) => {
|
||||
if (id) {
|
||||
companyId.value = id;
|
||||
userParams.companyId = id;
|
||||
filter.where.companyFk = id;
|
||||
}
|
||||
getData();
|
||||
};
|
||||
|
||||
const saveFieldValue = async (row) => {
|
||||
try {
|
||||
const payload = { description: row.description };
|
||||
await axios.patch(`Receipts/${row.id}`, payload);
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
};
|
||||
|
||||
const sendEmailAction = () => {
|
||||
sendEmail(`Suppliers/${route.params.id}/campaign-metrics-email`);
|
||||
};
|
||||
|
||||
const showBalancePdf = (balance) => {
|
||||
const url = `api/InvoiceOuts/${balance.id}/download?access_token=${tokenMultimedia}`;
|
||||
const showBalancePdf = ({ id }) => {
|
||||
const url = `api/InvoiceOuts/${id}/download?access_token=${tokenMultimedia}`;
|
||||
window.open(url, '_blank');
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
:filter="filter"
|
||||
@on-fetch="(data) => (clientRisks = data)"
|
||||
auto-load
|
||||
ref="clientRisksRef"
|
||||
url="ClientRisks"
|
||||
<VnSubToolbar class="q-mb-md">
|
||||
<template #st-data>
|
||||
<div class="column justify-center q-px-md q-py-sm">
|
||||
<span class="text-bold">{{ t('Total by company') }}</span>
|
||||
<div class="row justify-center" v-if="clientRisk?.length">
|
||||
{{ clientRisk[0].company.code }}:
|
||||
{{ toCurrency(clientRisk[0].amount) }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #st-actions>
|
||||
<div>
|
||||
<VnFilter
|
||||
ref="vnFilterRef"
|
||||
v-model="companyId"
|
||||
data-key="CustomerBalance"
|
||||
:column="companyFilterColumn"
|
||||
search-url="balance"
|
||||
/>
|
||||
<FetchData
|
||||
:filter="filterCompanies"
|
||||
@on-fetch="(data) => (companiesOptions = data)"
|
||||
auto-load
|
||||
url="Companies"
|
||||
/>
|
||||
|
||||
<VnPaginate
|
||||
auto-load
|
||||
</div>
|
||||
</template>
|
||||
</VnSubToolbar>
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="CustomerBalance"
|
||||
url="Receipts/filter"
|
||||
:user-params="userParams"
|
||||
ref="receiptsRef"
|
||||
@on-fetch="onFetch"
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
<QTable
|
||||
search-url="balance"
|
||||
:user-params="filter"
|
||||
:columns="columns"
|
||||
:no-data-label="t('globals.noResults')"
|
||||
:rows-per-page-options="[0]"
|
||||
:rows="rows"
|
||||
class="full-width q-mt-md"
|
||||
row-key="id"
|
||||
:right-search="false"
|
||||
:is-editable="false"
|
||||
:column-search="false"
|
||||
@on-fetch="onFetch"
|
||||
auto-load
|
||||
>
|
||||
<template #body-cell-employee="{ row }">
|
||||
<QTd auto-width @click.stop>
|
||||
<QBtn color="blue" flat no-caps>{{ row.userName }}</QBtn>
|
||||
<WorkerDescriptorProxy :id="row.workerFk" />
|
||||
</QTd>
|
||||
<template #column-balance="{ rowIndex }">
|
||||
{{ toCurrency(balances[rowIndex]?.balance) }}
|
||||
</template>
|
||||
|
||||
<template #body-cell-reference="{ row }">
|
||||
<QTd auto-width @click.stop v-if="row.isInvoice">
|
||||
<QBtn color="blue" dense flat>
|
||||
{{ t('bill', { ref: row.description }) }}
|
||||
</QBtn>
|
||||
<InvoiceOutDescriptorProxy :id="row.id" />
|
||||
</QTd>
|
||||
<QTd v-else>
|
||||
<VnInput
|
||||
@keyup.enter="saveFieldValue(row)"
|
||||
autofocus
|
||||
clearable
|
||||
dense
|
||||
v-model="row.description"
|
||||
/>
|
||||
</QTd>
|
||||
</template>
|
||||
|
||||
<template #body-cell-conciliated="{ row }">
|
||||
<QTd align="center">
|
||||
<QCheckbox :model-value="row.isConciliate === 1" disable />
|
||||
</QTd>
|
||||
</template>
|
||||
|
||||
<template #body-cell-actions="{ row }">
|
||||
<QTd align="center">
|
||||
<QIcon
|
||||
@click.stop="showDialog = true"
|
||||
class="q-ml-md fill-icon"
|
||||
color="primary"
|
||||
name="outgoing_mail"
|
||||
size="sm"
|
||||
v-if="row.isCompensation"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('Send compensation') }}
|
||||
</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon
|
||||
@click="showBalancePdf(row)"
|
||||
class="q-ml-md fill-icon"
|
||||
color="primary"
|
||||
name="cloud_download"
|
||||
size="sm"
|
||||
v-if="row.hasPdf"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('globals.downloadPdf') }}
|
||||
</QTooltip>
|
||||
</QIcon>
|
||||
|
||||
<QDialog v-model="showDialog">
|
||||
<QCard class="q-pa-sm">
|
||||
<QCardSection>
|
||||
<span
|
||||
ref="closeButton"
|
||||
class="flex justify-end color-vn-label"
|
||||
v-close-popup
|
||||
>
|
||||
<QIcon name="close" size="sm" />
|
||||
<template #column-description="{ row }">
|
||||
<div class="link" v-if="row.isInvoice">
|
||||
{{ row.description }}
|
||||
<InvoiceOutDescriptorProxy :id="row.description" />
|
||||
</div>
|
||||
<span v-else class="q-pa-xs dotted rounded-borders" :title="row.description">
|
||||
{{ row.description }}
|
||||
</span>
|
||||
<div class="text-h6">
|
||||
{{ t('Send compensation') }}
|
||||
</div>
|
||||
</QCardSection>
|
||||
<QCardSection>
|
||||
<div>
|
||||
{{
|
||||
t(
|
||||
'Do you want to report compensation to the client by mail?'
|
||||
)
|
||||
}}
|
||||
</div>
|
||||
</QCardSection>
|
||||
<QCardActions class="flex justify-end q-mb-sm">
|
||||
<QBtn
|
||||
:label="t('globals.cancel')"
|
||||
color="primary"
|
||||
flat
|
||||
v-close-popup
|
||||
<QPopupEdit
|
||||
v-model="row.description"
|
||||
v-slot="scope"
|
||||
@save="
|
||||
(value) =>
|
||||
value != row.description &&
|
||||
axios.patch(`Receipts/${row.id}`, { description: value })
|
||||
"
|
||||
auto-save
|
||||
>
|
||||
<VnInput
|
||||
v-model="scope.value"
|
||||
:disable="!hasAny(['administrative'])"
|
||||
@keypress.enter="scope.set"
|
||||
autofocus
|
||||
/>
|
||||
<QBtn
|
||||
:label="t('globals.save')"
|
||||
@click="sendEmailAction"
|
||||
class="q-ml-sm"
|
||||
color="primary"
|
||||
/>
|
||||
</QCardActions>
|
||||
</QCard>
|
||||
</QDialog>
|
||||
</QTd>
|
||||
</QPopupEdit>
|
||||
</template>
|
||||
</QTable>
|
||||
</template>
|
||||
</VnPaginate>
|
||||
|
||||
<QDrawer :width="256" show-if-above side="right" v-model="stateStore.rightDrawer">
|
||||
<div class="q-mt-xl q-px-md">
|
||||
<VnSelect
|
||||
:label="t('Company')"
|
||||
:options="companiesOptions"
|
||||
@update:model-value="updateCompanyId($event)"
|
||||
hide-selected
|
||||
option-label="code"
|
||||
option-value="id"
|
||||
v-model="companyId"
|
||||
:rules="validate('entry.companyFk')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<QCard class="q-ma-md q-pa-md q-mt-lg" v-if="receiptsData?.length">
|
||||
<QCardSection>
|
||||
<div class="flex justify-center text-subtitle1 text-bold">
|
||||
{{ t('Total by company') }}
|
||||
</div>
|
||||
<div class="flex justify-center">
|
||||
<div class="q-mr-sm" v-if="clientRisks?.length">
|
||||
{{ clientRisks[0].company.code }}:
|
||||
</div>
|
||||
<div v-if="clientRisks?.length">
|
||||
{{ toCurrency(clientRisks[0].amount) }}
|
||||
</div>
|
||||
</div>
|
||||
</QCardSection>
|
||||
</QCard>
|
||||
</QDrawer>
|
||||
|
||||
<QPageSticky :offset="[18, 18]">
|
||||
</VnTable>
|
||||
<QPageSticky :offset="[18, 18]" style="z-index: 2">
|
||||
<QBtn @click.stop="showNewPaymentDialog()" color="primary" fab icon="add" />
|
||||
<QTooltip>
|
||||
{{ t('New payment') }}
|
||||
|
@ -393,3 +319,12 @@ es:
|
|||
Send compensation: Enviar compensación
|
||||
Do you want to report compensation to the client by mail?: ¿Desea informar de la compensación al cliente por correo?
|
||||
</i18n>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.dotted {
|
||||
border: 1px dotted var(--vn-header-color);
|
||||
}
|
||||
.dotted:hover {
|
||||
border: 1px dotted $primary;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -7,66 +7,29 @@ import FetchData from 'components/FetchData.vue';
|
|||
import FormModel from 'components/FormModel.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnImg from 'src/components/ui/VnImg.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnAvatar from 'src/components/ui/VnAvatar.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
|
||||
const workers = ref([]);
|
||||
const workersCopy = ref([]);
|
||||
const businessTypes = ref([]);
|
||||
const contactChannels = ref([]);
|
||||
|
||||
function setWorkers(data) {
|
||||
workers.value = data;
|
||||
workersCopy.value = data;
|
||||
}
|
||||
|
||||
const filterOptions = {
|
||||
options: workers,
|
||||
filterFn: (options, value) => {
|
||||
const search = value.toLowerCase();
|
||||
|
||||
if (value === '') return workersCopy.value;
|
||||
|
||||
return options.value.filter((row) => {
|
||||
const id = row.id;
|
||||
const name = row.name.toLowerCase();
|
||||
|
||||
const idMatches = id === search;
|
||||
const nameMatches = name.indexOf(search) > -1;
|
||||
|
||||
return idMatches || nameMatches;
|
||||
});
|
||||
},
|
||||
};
|
||||
const title = ref();
|
||||
</script>
|
||||
<template>
|
||||
<fetch-data
|
||||
url="Workers/activeWithInheritedRole"
|
||||
:filter="{ where: { role: 'salesPerson' } }"
|
||||
@on-fetch="setWorkers"
|
||||
auto-load
|
||||
/>
|
||||
<fetch-data
|
||||
<FetchData
|
||||
url="ContactChannels"
|
||||
@on-fetch="(data) => (contactChannels = data)"
|
||||
auto-load
|
||||
/>
|
||||
<fetch-data
|
||||
<FetchData
|
||||
url="BusinessTypes"
|
||||
@on-fetch="(data) => (businessTypes = data)"
|
||||
auto-load
|
||||
/>
|
||||
<fetch-data
|
||||
:filter="filter"
|
||||
@on-fetch="(data) => (clients = data)"
|
||||
auto-load
|
||||
url="Clients"
|
||||
/>
|
||||
|
||||
<FormModel :url="`Clients/${route.params.id}`" auto-load model="customer">
|
||||
<template #form="{ data, validate, filter }">
|
||||
<template #form="{ data, validate }">
|
||||
<VnRow>
|
||||
<VnInput
|
||||
:label="t('globals.name')"
|
||||
|
@ -75,7 +38,6 @@ const filterOptions = {
|
|||
clearable
|
||||
v-model="data.name"
|
||||
/>
|
||||
|
||||
<QSelect
|
||||
:input-debounce="0"
|
||||
:label="t('customer.basicData.businessType')"
|
||||
|
@ -126,30 +88,25 @@ const filterOptions = {
|
|||
/>
|
||||
</VnRow>
|
||||
<VnRow>
|
||||
<QSelect
|
||||
:input-debounce="0"
|
||||
:label="t('customer.basicData.salesPerson')"
|
||||
:options="workers"
|
||||
:rules="validate('client.salesPersonFk')"
|
||||
@filter="(value, update) => filter(value, update, filterOptions)"
|
||||
emit-value
|
||||
map-options
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
use-input
|
||||
<VnSelect
|
||||
url="Workers/activeWithInheritedRole"
|
||||
:filter="{ where: { role: 'salesPerson' } }"
|
||||
option-filter="firstName"
|
||||
v-model="data.salesPersonFk"
|
||||
:label="t('customer.basicData.salesPerson')"
|
||||
:rules="validate('client.salesPersonFk')"
|
||||
:use-like="false"
|
||||
:emit-value="false"
|
||||
@update:model-value="(val) => (title = val?.nickname)"
|
||||
>
|
||||
<template #prepend>
|
||||
<QAvatar color="orange">
|
||||
<VnImg
|
||||
v-if="data.salesPersonFk"
|
||||
:id="user.id"
|
||||
collection="user"
|
||||
spinner-color="white"
|
||||
<VnAvatar
|
||||
:worker-id="data.salesPersonFk"
|
||||
color="primary"
|
||||
:title="title"
|
||||
/>
|
||||
</QAvatar>
|
||||
</template>
|
||||
</QSelect>
|
||||
</VnSelect>
|
||||
<QSelect
|
||||
v-model="data.contactChannelFk"
|
||||
:options="contactChannels"
|
||||
|
|
|
@ -10,8 +10,10 @@ import CustomerFilter from '../CustomerFilter.vue';
|
|||
:descriptor="CustomerDescriptor"
|
||||
:filter-panel="CustomerFilter"
|
||||
search-data-key="CustomerList"
|
||||
search-url="Clients/extendedListFilter"
|
||||
searchbar-label="Search customer"
|
||||
searchbar-info="You can search by customer id or name"
|
||||
:searchbar-props="{
|
||||
url: 'Clients/extendedListFilter',
|
||||
label: 'Search customer',
|
||||
info: 'You can search by customer id or name',
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { QBtn } from 'quasar';
|
||||
import { toCurrency, toDateHourMin } from 'src/filters';
|
||||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
import VnUserLink from 'src/components/ui/VnUserLink.vue';
|
||||
|
@ -10,7 +9,8 @@ import VnUserLink from 'src/components/ui/VnUserLink.vue';
|
|||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
||||
const filter = {
|
||||
const filter = computed(() => {
|
||||
return {
|
||||
include: [
|
||||
{
|
||||
relation: 'worker',
|
||||
|
@ -21,10 +21,11 @@ const filter = {
|
|||
},
|
||||
],
|
||||
where: { clientFk: +route.params.id },
|
||||
order: ['created DESC'],
|
||||
limit: 20,
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
const tableRef = ref();
|
||||
const tableData = ref([]);
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -43,39 +44,44 @@ const columns = computed(() => [
|
|||
name: 'amount',
|
||||
format: ({ amount }) => toCurrency(amount),
|
||||
},
|
||||
{
|
||||
label: t('Credit'),
|
||||
name: 'credit',
|
||||
create: true,
|
||||
visible: false,
|
||||
attrs: {
|
||||
autofocus: true,
|
||||
},
|
||||
},
|
||||
]);
|
||||
</script>
|
||||
<template>
|
||||
<!-- Column titles are missing -->
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="ClientCredit"
|
||||
url="ClientCredits"
|
||||
search-url="credits"
|
||||
:filter="filter"
|
||||
:order="['created DESC']"
|
||||
:columns="columns"
|
||||
default-mode="table"
|
||||
auto-load
|
||||
:right-search="false"
|
||||
:is-editable="false"
|
||||
:use-model="true"
|
||||
:column-search="false"
|
||||
:disable-option="{ card: true }"
|
||||
@on-fetch="(data) => (tableData = data)"
|
||||
:create="{
|
||||
urlUpdate: `Clients/${route.params.id}`,
|
||||
title: t('New credit'),
|
||||
onDataSaved: () => tableRef.reload(),
|
||||
formInitialData: { credit: tableData.at(0)?.amount },
|
||||
}"
|
||||
>
|
||||
<template #column-employee="{ row }">
|
||||
<VnUserLink :name="row?.worker?.user?.name" :worker-id="row.worker?.id" />
|
||||
</template>
|
||||
</VnTable>
|
||||
<QPageSticky :offset="[18, 18]">
|
||||
<QBtn
|
||||
@click.stop="$router.push({ name: 'CustomerCreditCreate' })"
|
||||
color="primary"
|
||||
fab
|
||||
icon="add"
|
||||
/>
|
||||
<QTooltip>
|
||||
{{ t('New credit') }}
|
||||
</QTooltip>
|
||||
</QPageSticky>
|
||||
</template>
|
||||
<i18n>
|
||||
es:
|
||||
|
|
|
@ -139,7 +139,7 @@ const setData = (entity) => (data.value = useCardDescription(entity?.name, entit
|
|||
<QBtn
|
||||
:to="{
|
||||
name: 'TicketList',
|
||||
query: { params: JSON.stringify({ clientFk: entity.id }) },
|
||||
query: { table: JSON.stringify({ clientFk: entity.id }) },
|
||||
}"
|
||||
size="md"
|
||||
icon="vn:ticket"
|
||||
|
@ -150,7 +150,7 @@ const setData = (entity) => (data.value = useCardDescription(entity?.name, entit
|
|||
<QBtn
|
||||
:to="{
|
||||
name: 'InvoiceOutList',
|
||||
query: { params: JSON.stringify({ clientFk: entity.id }) },
|
||||
query: { table: JSON.stringify({ clientFk: entity.id }) },
|
||||
}"
|
||||
size="md"
|
||||
icon="vn:invoice-out"
|
||||
|
@ -161,7 +161,7 @@ const setData = (entity) => (data.value = useCardDescription(entity?.name, entit
|
|||
<QBtn
|
||||
:to="{
|
||||
name: 'OrderCreate',
|
||||
query: { clientFk: entity.id },
|
||||
query: { clientId: entity.id },
|
||||
}"
|
||||
size="md"
|
||||
icon="vn:basketadd"
|
||||
|
@ -169,8 +169,19 @@ const setData = (entity) => (data.value = useCardDescription(entity?.name, entit
|
|||
>
|
||||
<QTooltip>{{ t('New order') }}</QTooltip>
|
||||
</QBtn>
|
||||
<QBtn size="md" icon="face" color="primary">
|
||||
<!-- TODO:: Redirigir a la vista de usuario cuando exista -->
|
||||
<QBtn
|
||||
:to="{
|
||||
name: 'AccountList',
|
||||
query: {
|
||||
table: JSON.stringify({
|
||||
filter: { where: { id: entity.id } },
|
||||
}),
|
||||
},
|
||||
}"
|
||||
size="md"
|
||||
icon="face"
|
||||
color="primary"
|
||||
>
|
||||
<QTooltip>{{ t('Go to user') }}</QTooltip>
|
||||
</QBtn>
|
||||
</QCardActions>
|
||||
|
|
|
@ -15,7 +15,6 @@ const route = useRoute();
|
|||
|
||||
const typesTaxes = ref([]);
|
||||
const typesTransactions = ref([]);
|
||||
const postcodesOptions = ref([]);
|
||||
|
||||
function handleLocation(data, location) {
|
||||
const { town, code, provinceFk, countryFk } = location ?? {};
|
||||
|
@ -95,18 +94,14 @@ function handleLocation(data, location) {
|
|||
<VnLocation
|
||||
:rules="validate('Worker.postcode')"
|
||||
:roles-allowed-to-create="['deliveryAssistant']"
|
||||
:options="postcodesOptions"
|
||||
v-model="data.postcode"
|
||||
@update:model-value="(location) => handleLocation(data, location)"
|
||||
>
|
||||
</VnLocation>
|
||||
/>
|
||||
</VnRow>
|
||||
|
||||
<VnRow>
|
||||
<QCheckbox :label="t('Active')" v-model="data.isActive" />
|
||||
<QCheckbox :label="t('Frozen')" v-model="data.isFreezed" />
|
||||
</VnRow>
|
||||
|
||||
<VnRow>
|
||||
<QCheckbox :label="t('Has to invoice')" v-model="data.hasToInvoice" />
|
||||
<div>
|
||||
|
|
|
@ -2,20 +2,17 @@
|
|||
import { ref, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { QBtn } from 'quasar';
|
||||
import { useStateStore } from 'src/stores/useStateStore';
|
||||
import { toCurrency } from 'src/filters';
|
||||
import { toDateTimeFormat } from 'src/filters/date';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
|
||||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const stateStore = computed(() => useStateStore());
|
||||
const rows = ref([]);
|
||||
const totalAmount = ref();
|
||||
|
||||
const filter = {
|
||||
const tableRef = ref();
|
||||
const filter = computed(() => {
|
||||
return {
|
||||
include: [
|
||||
{
|
||||
relation: 'greugeType',
|
||||
|
@ -30,73 +27,61 @@ const filter = {
|
|||
},
|
||||
},
|
||||
],
|
||||
order: 'shipped DESC, amount',
|
||||
where: {
|
||||
clientFk: `${route.params.id}`,
|
||||
clientFk: route.params.id,
|
||||
},
|
||||
limit: 20,
|
||||
};
|
||||
|
||||
const tableColumnComponents = {
|
||||
date: {
|
||||
component: 'span',
|
||||
props: () => {},
|
||||
event: () => {},
|
||||
},
|
||||
createdBy: {
|
||||
component: QBtn,
|
||||
props: () => ({ flat: true, color: 'blue', noCaps: true }),
|
||||
event: () => {},
|
||||
},
|
||||
comment: {
|
||||
component: 'span',
|
||||
props: () => {},
|
||||
event: () => {},
|
||||
},
|
||||
type: {
|
||||
component: 'span',
|
||||
props: () => {},
|
||||
event: () => {},
|
||||
},
|
||||
amount: {
|
||||
component: 'span',
|
||||
props: () => {},
|
||||
event: () => {},
|
||||
},
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
field: 'shipped',
|
||||
label: t('Date'),
|
||||
name: 'date',
|
||||
format: (value) => toDateTimeFormat(value),
|
||||
name: 'shipped',
|
||||
format: ({ shipped }) => toDateTimeFormat(shipped),
|
||||
create: true,
|
||||
columnCreate: {
|
||||
component: 'date',
|
||||
autofocus: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: (value) => value?.user?.name,
|
||||
name: 'userFk',
|
||||
label: t('Created by'),
|
||||
name: 'createdBy',
|
||||
component: 'userLink',
|
||||
attrs: ({ row }) => {
|
||||
return {
|
||||
defaultName: true,
|
||||
workerId: row.user?.id,
|
||||
name: row.user?.name,
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'description',
|
||||
name: 'description',
|
||||
label: t('Comment'),
|
||||
name: 'comment',
|
||||
create: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: (value) => value?.greugeType?.name,
|
||||
name: 'greugeTypeFk',
|
||||
format: ({ greugeType }) => greugeType?.name,
|
||||
label: t('Type'),
|
||||
name: 'type',
|
||||
create: true,
|
||||
columnCreate: {
|
||||
component: 'select',
|
||||
url: 'greugeTypes',
|
||||
limit: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'amount',
|
||||
label: t('Amount'),
|
||||
name: 'amount',
|
||||
format: (value) => toCurrency(value),
|
||||
label: t('Amount'),
|
||||
format: ({ amount }) => toCurrency(amount),
|
||||
create: true,
|
||||
},
|
||||
]);
|
||||
|
||||
|
@ -107,60 +92,33 @@ const setRows = (data) => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData :filter="filter" @on-fetch="setRows" auto-load url="greuges" />
|
||||
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="300" show-if-above>
|
||||
<QCard class="full-width q-pa-sm">
|
||||
<h6 class="flex justify-end q-my-lg q-pr-lg" v-if="totalAmount !== undefined">
|
||||
<span class="color-vn-label q-mr-md">{{ t('Total') }}:</span>
|
||||
{{ toCurrency(totalAmount) }}
|
||||
</h6>
|
||||
<QSkeleton v-else type="QInput" square />
|
||||
</QCard>
|
||||
</QDrawer>
|
||||
<div class="full-width flex justify-center">
|
||||
<QPage class="card-width q-pa-lg">
|
||||
<QCard class="q-pa-sm q-mt-md">
|
||||
<QTable
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="Greuges"
|
||||
url="Greuges"
|
||||
search-url="greuges"
|
||||
:filter="filter"
|
||||
:order="['shipped DESC', 'amount']"
|
||||
:columns="columns"
|
||||
:no-data-label="t('globals.noResults')"
|
||||
:pagination="{ rowsPerPage: 12 }"
|
||||
:rows="rows"
|
||||
class="full-width q-mt-md"
|
||||
row-key="id"
|
||||
:right-search="false"
|
||||
:is-editable="false"
|
||||
:use-model="true"
|
||||
:column-search="false"
|
||||
@on-fetch="(data) => setRows(data)"
|
||||
:create="{
|
||||
urlCreate: `Greuges`,
|
||||
title: t('New credit'),
|
||||
onDataSaved: () => tableRef.reload(),
|
||||
formInitialData: { shipped: new Date(), clientFk: route.params.id },
|
||||
}"
|
||||
auto-load
|
||||
>
|
||||
<template #body-cell="props">
|
||||
<QTd :props="props">
|
||||
<QTr :props="props" class="cursor-pointer">
|
||||
<component
|
||||
:is="tableColumnComponents[props.col.name].component"
|
||||
class="col-content"
|
||||
v-bind="
|
||||
tableColumnComponents[props.col.name].props(props)
|
||||
"
|
||||
@click="
|
||||
tableColumnComponents[props.col.name].event(props)
|
||||
"
|
||||
>
|
||||
{{ props.value }}
|
||||
<WorkerDescriptorProxy
|
||||
:id="props.row.userFk"
|
||||
v-if="props.col.name === 'createdBy'"
|
||||
/>
|
||||
</component>
|
||||
</QTr>
|
||||
</QTd>
|
||||
</template>
|
||||
</QTable>
|
||||
<template #top-left>
|
||||
<QCard class="q-px-md q-py-sm">
|
||||
{{ t('Total') }}: {{ toCurrency(totalAmount) }}
|
||||
</QCard>
|
||||
</QPage>
|
||||
</div>
|
||||
|
||||
<QPageSticky :offset="[18, 18]">
|
||||
<QBtn color="primary" fab icon="add" :to="{ name: 'CustomerGreugeCreate' }" />
|
||||
<QTooltip>
|
||||
{{ t('New greuge') }}
|
||||
</QTooltip>
|
||||
</QPageSticky>
|
||||
</template>
|
||||
</VnTable>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
|
|
|
@ -1,262 +1,6 @@
|
|||
<script setup>
|
||||
import { onBeforeMount, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const stateStore = useStateStore();
|
||||
|
||||
const clientLogs = ref(null);
|
||||
const urlClientLogsEditors = ref(null);
|
||||
const urlClientLogsModels = ref(null);
|
||||
const clientLogsModelsOptions = ref([]);
|
||||
const clientLogsOptions = ref([]);
|
||||
const clientLogsEditorsOptions = ref([]);
|
||||
const radioButtonValue = ref('all');
|
||||
const insert = ref(false);
|
||||
const update = ref(false);
|
||||
const deletes = ref(false);
|
||||
const select = ref(false);
|
||||
const neq = ref(null);
|
||||
const inq = ref([]);
|
||||
|
||||
const filterClientLogs = {
|
||||
fields: [
|
||||
'id',
|
||||
'originFk',
|
||||
'userFk',
|
||||
'action',
|
||||
'changedModel',
|
||||
'oldInstance',
|
||||
'newInstance',
|
||||
'creationDate',
|
||||
'changedModel',
|
||||
'changedModelId',
|
||||
'changedModelValue',
|
||||
'description',
|
||||
],
|
||||
include: [
|
||||
{
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['nickname', 'name', 'image'],
|
||||
include: { relation: 'worker', scope: { fields: ['id'] } },
|
||||
},
|
||||
},
|
||||
],
|
||||
order: ['creationDate DESC', 'id DESC'],
|
||||
limit: 20,
|
||||
};
|
||||
const filterClientLogsEditors = {
|
||||
fields: ['id', 'nickname', 'name', 'image'],
|
||||
order: 'nickname',
|
||||
limit: 30,
|
||||
};
|
||||
const filterClientLogsModels = { order: ['changedModel'] };
|
||||
const urlBase = `ClientLogs/${route.params.id}`;
|
||||
|
||||
onBeforeMount(() => {
|
||||
stateStore.rightDrawer = true;
|
||||
filterClientLogs.where = {
|
||||
and: [
|
||||
{ originFk: `${route.params.id}` },
|
||||
{ userFk: { neq: radioButtonValue.value } },
|
||||
{ action: { inq: inq.value } },
|
||||
],
|
||||
};
|
||||
urlClientLogsEditors.value = `${urlBase}/editors`;
|
||||
urlClientLogsModels.value = `${urlBase}/models`;
|
||||
});
|
||||
|
||||
const getClientLogs = async (value, status) => {
|
||||
if (status === 'neq') {
|
||||
neq.value = value;
|
||||
} else {
|
||||
setInq(value, status);
|
||||
}
|
||||
filterClientLogs.where = {
|
||||
and: [
|
||||
{ originFk: `${route.params.id}` },
|
||||
{ userFk: { neq: neq.value } },
|
||||
{ action: { inq: inq.value } },
|
||||
],
|
||||
};
|
||||
clientLogs.value?.fetch();
|
||||
};
|
||||
|
||||
const setInq = (value, status) => {
|
||||
if (status) {
|
||||
if (!inq.value.includes(value)) {
|
||||
inq.value.push(value);
|
||||
}
|
||||
} else {
|
||||
inq.value = inq.value.filter((item) => item !== value);
|
||||
}
|
||||
};
|
||||
import VnLog from 'src/components/common/VnLog.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
:filter="filterClientLogs"
|
||||
@on-fetch="(data) => (clientLogsOptions = data)"
|
||||
auto-load
|
||||
url="ClientLogs"
|
||||
ref="clientLogs"
|
||||
/>
|
||||
<FetchData
|
||||
:filter="filterClientLogsEditors"
|
||||
@on-fetch="(data) => (clientLogsEditorsOptions = data)"
|
||||
auto-load
|
||||
:url="urlClientLogsEditors"
|
||||
/>
|
||||
<FetchData
|
||||
:filter="filterClientLogsModels"
|
||||
@on-fetch="(data) => (clientLogsModelsOptions = data)"
|
||||
auto-load
|
||||
:url="urlClientLogsModels"
|
||||
/>
|
||||
|
||||
<h5 class="flex justify-center color-vn-label">
|
||||
{{ t('globals.noResults') }}
|
||||
</h5>
|
||||
|
||||
<QDrawer :width="256" show-if-above side="right" v-model="stateStore.rightDrawer">
|
||||
<div class="q-mt-sm q-px-md">
|
||||
<VnInput :label="t('Search')" clearable>
|
||||
<template #append>
|
||||
<QIcon name="info" class="cursor-pointer">
|
||||
<QTooltip>
|
||||
{{ t('Search by id or concept') }}
|
||||
</QTooltip>
|
||||
</QIcon>
|
||||
</template>
|
||||
</VnInput>
|
||||
<VnSelect
|
||||
:label="t('Entity')"
|
||||
:options="[]"
|
||||
class="q-mt-md"
|
||||
hide-selected
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
/>
|
||||
|
||||
<div class="q-mt-lg">
|
||||
<QRadio
|
||||
:dark="true"
|
||||
:label="t('All')"
|
||||
@update:model-value="getClientLogs($event, 'neq')"
|
||||
dense
|
||||
v-model="radioButtonValue"
|
||||
val="all"
|
||||
/>
|
||||
</div>
|
||||
<div class="q-mt-md">
|
||||
<QRadio
|
||||
:dark="true"
|
||||
:label="t('User')"
|
||||
@update:model-value="getClientLogs($event, 'neq')"
|
||||
dense
|
||||
v-model="radioButtonValue"
|
||||
val="user"
|
||||
/>
|
||||
</div>
|
||||
<div class="q-mt-md">
|
||||
<QRadio
|
||||
:dark="true"
|
||||
:label="t('System')"
|
||||
@update:model-value="getClientLogs($event, 'neq')"
|
||||
dense
|
||||
v-model="radioButtonValue"
|
||||
val="system"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<VnSelect
|
||||
:label="t('User')"
|
||||
:options="[]"
|
||||
class="q-mt-sm"
|
||||
hide-selected
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
/>
|
||||
<VnInput :label="t('Changes')" clearable class="q-mt-sm">
|
||||
<template #append>
|
||||
<QIcon name="info" class="cursor-pointer">
|
||||
<QTooltip>
|
||||
{{ t('Search by changes') }}
|
||||
</QTooltip>
|
||||
</QIcon>
|
||||
</template>
|
||||
</VnInput>
|
||||
|
||||
<div class="q-mt-md">
|
||||
<QCheckbox
|
||||
:label="t('Creates')"
|
||||
@update:model-value="getClientLogs('insert', $event)"
|
||||
v-model="insert"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<QCheckbox
|
||||
:label="t('Edits')"
|
||||
@update:model-value="getClientLogs('update', $event)"
|
||||
v-model="update"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<QCheckbox
|
||||
:label="t('Deletes')"
|
||||
@update:model-value="getClientLogs('delete', $event)"
|
||||
v-model="deletes"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<QCheckbox
|
||||
:label="t('Accesses')"
|
||||
@update:model-value="getClientLogs('select', $event)"
|
||||
v-model="select"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<VnInputDate :label="t('Date')" class="q-mt-sm" />
|
||||
<VnInput :label="t('To')" clearable class="q-mt-md" />
|
||||
</div>
|
||||
</QDrawer>
|
||||
|
||||
<QPageSticky
|
||||
:offset="[18, 18]"
|
||||
v-if="radioButtonValue !== 'all' || insert || update || deletes || select"
|
||||
>
|
||||
<QBtn color="primary" fab icon="filter_alt_off" />
|
||||
<QTooltip>
|
||||
{{ t('Quit filter') }}
|
||||
</QTooltip>
|
||||
</QPageSticky>
|
||||
<VnLog model="Client" />
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
Search: Buscar
|
||||
Search by id or concept: xxx
|
||||
Entity: Entidad
|
||||
All: Todo
|
||||
User: Usuario
|
||||
System: Sistema
|
||||
Changes: Cambios
|
||||
Search by changes: xxx
|
||||
Creates: Crea
|
||||
Edits: Modifica
|
||||
Deletes: Elimina
|
||||
Accesses: Accede
|
||||
Date: Fecha
|
||||
To: Hasta
|
||||
Quit filter: Quitar filtro
|
||||
</i18n>
|
||||
|
|
|
@ -1,83 +1,26 @@
|
|||
<script setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { computed } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import VnNotes from 'src/components/ui/VnNotes.vue';
|
||||
|
||||
import { toDateTimeFormat } from 'src/filters/date';
|
||||
|
||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const noteFilter = {
|
||||
const noteFilter = computed(() => {
|
||||
return {
|
||||
order: 'created DESC',
|
||||
where: {
|
||||
clientFk: `${route.params.id}`,
|
||||
},
|
||||
};
|
||||
|
||||
const toCustomerNoteCreate = () => {
|
||||
router.push({ name: 'CustomerNoteCreate' });
|
||||
};
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="full-width flex justify-center">
|
||||
<QCard class="card-width q-pa-lg">
|
||||
<VnPaginate
|
||||
data-key="CustomerNotes"
|
||||
<VnNotes
|
||||
url="clientObservations"
|
||||
auto-load
|
||||
:add-note="true"
|
||||
:filter="noteFilter"
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
<div v-if="rows.length">
|
||||
<QCard
|
||||
v-for="(item, index) in rows"
|
||||
:key="index"
|
||||
class="q-pa-md q-rounded custom-border"
|
||||
:class="{ 'q-mb-md': index < rows.length - 1 }"
|
||||
>
|
||||
<div class="flex justify-between">
|
||||
<p class="color-vn-label">
|
||||
{{ item.worker.user.nickname }}
|
||||
</p>
|
||||
<p class="color-vn-label">
|
||||
{{ toDateTimeFormat(item?.created) }}
|
||||
</p>
|
||||
</div>
|
||||
<h6 class="q-mt-xs q-mb-none">{{ item.text }}</h6>
|
||||
</QCard>
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<h5 class="flex justify-center color-vn-label">
|
||||
{{ t('globals.noResults') }}
|
||||
</h5>
|
||||
</div>
|
||||
</template>
|
||||
</VnPaginate>
|
||||
</QCard>
|
||||
</div>
|
||||
|
||||
<QPageSticky :offset="[18, 18]">
|
||||
<QBtn @click.stop="toCustomerNoteCreate()" color="primary" fab icon="add" />
|
||||
<QTooltip>
|
||||
{{ t('New note') }}
|
||||
</QTooltip>
|
||||
</QPageSticky>
|
||||
:body="{ clientFk: route.params.id }"
|
||||
style="overflow-y: auto"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
.custom-border {
|
||||
border: 2px solid var(--vn-accent-color);
|
||||
border-radius: 10px;
|
||||
padding: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
New note: Nueva nota
|
||||
</i18n>
|
||||
|
|
|
@ -1,146 +1,107 @@
|
|||
<script setup>
|
||||
import axios from 'axios';
|
||||
import { ref, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
import { useRoute } from 'vue-router';
|
||||
import { toCurrency, toDate } from 'src/filters';
|
||||
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const rows = ref([]);
|
||||
|
||||
const filter = {
|
||||
const tableRef = ref();
|
||||
const filter = computed(() => {
|
||||
return {
|
||||
where: { clientFk: route.params.id },
|
||||
order: ['started DESC'],
|
||||
limit: 20,
|
||||
};
|
||||
});
|
||||
const componentColumn = (type) => {
|
||||
return {
|
||||
columnFilter: {
|
||||
component: type,
|
||||
},
|
||||
columnCreate: {
|
||||
component: type,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const tableColumnComponents = {
|
||||
since: {
|
||||
component: 'span',
|
||||
props: () => {},
|
||||
event: () => {},
|
||||
},
|
||||
to: {
|
||||
component: 'span',
|
||||
props: () => {},
|
||||
event: () => {},
|
||||
},
|
||||
amount: {
|
||||
component: 'span',
|
||||
props: () => {},
|
||||
event: () => {},
|
||||
},
|
||||
period: {
|
||||
component: 'span',
|
||||
props: () => {},
|
||||
event: () => {},
|
||||
},
|
||||
};
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
field: 'started',
|
||||
label: t('Since'),
|
||||
name: 'since',
|
||||
format: (value) => toDate(value),
|
||||
label: t('globals.since'),
|
||||
name: 'started',
|
||||
format: ({ started }) => toDate(started),
|
||||
create: true,
|
||||
...componentColumn('date'),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'finished',
|
||||
label: t('To'),
|
||||
name: 'to',
|
||||
format: (value) => toDate(value),
|
||||
name: 'finished',
|
||||
label: t('globals.to'),
|
||||
format: ({ finished }) => toDate(finished),
|
||||
create: true,
|
||||
...componentColumn('date'),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'amount',
|
||||
label: t('Amount'),
|
||||
name: 'amount',
|
||||
format: (value) => toCurrency(value),
|
||||
label: t('globals.amount'),
|
||||
format: ({ amount }) => toCurrency(amount),
|
||||
create: true,
|
||||
...componentColumn('number'),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'period',
|
||||
label: t('Period'),
|
||||
name: 'period',
|
||||
label: t('Period'),
|
||||
create: true,
|
||||
...componentColumn('number'),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'tableActions',
|
||||
actions: [
|
||||
{
|
||||
title: t('Finish that recovery period'),
|
||||
icon: 'lock',
|
||||
show: (row) => !row.finished,
|
||||
action: ({ id }) => setFinished(id),
|
||||
isPrimary: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
const toCustomerRecoverieCreate = () => {
|
||||
router.push({ name: 'CustomerRecoverieCreate' });
|
||||
};
|
||||
function setFinished(id) {
|
||||
axios.patch(`Recoveries/${id}`, { finished: Date.vnNow() });
|
||||
tableRef.value.reload();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
:filter="filter"
|
||||
@on-fetch="(data) => (rows = data)"
|
||||
auto-load
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="Recoveries"
|
||||
url="Recoveries"
|
||||
/>
|
||||
|
||||
<div class="full-width flex justify-center">
|
||||
<QPage class="card-width q-pa-lg">
|
||||
<QTable
|
||||
search-url="recoveries"
|
||||
:filter="filter"
|
||||
order="started DESC"
|
||||
:columns="columns"
|
||||
:no-data-label="t('globals.noResults')"
|
||||
:pagination="{ rowsPerPage: 12 }"
|
||||
:rows="rows"
|
||||
class="full-width q-mt-md"
|
||||
row-key="id"
|
||||
>
|
||||
<template #body-cell="props">
|
||||
<QTd :props="props">
|
||||
<QTr :props="props" class="cursor-pointer">
|
||||
<component
|
||||
:is="tableColumnComponents[props.col.name].component"
|
||||
class="col-content"
|
||||
v-bind="
|
||||
tableColumnComponents[props.col.name].props(props)
|
||||
"
|
||||
@click="
|
||||
tableColumnComponents[props.col.name].event(props)
|
||||
"
|
||||
>
|
||||
{{ props.value }}
|
||||
</component>
|
||||
</QTr>
|
||||
</QTd>
|
||||
</template>
|
||||
</QTable>
|
||||
</QPage>
|
||||
</div>
|
||||
|
||||
<QPageSticky :offset="[18, 18]">
|
||||
<QBtn @click.stop="toCustomerRecoverieCreate()" color="primary" fab icon="add" />
|
||||
<QTooltip>
|
||||
{{ t('New recoverie') }}
|
||||
</QTooltip>
|
||||
</QPageSticky>
|
||||
:use-model="true"
|
||||
:right-search="false"
|
||||
:create="{
|
||||
urlCreate: 'Recoveries',
|
||||
title: 'New recovery',
|
||||
onDataSaved: () => tableRef.reload(),
|
||||
formInitialData: { clientFk: route.params.id, started: Date.vnNew() },
|
||||
}"
|
||||
auto-load
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
.consignees-card {
|
||||
border: 2px solid var(--vn-accent-color);
|
||||
border-radius: 10px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.label-color {
|
||||
color: var(--vn-label-color);
|
||||
}
|
||||
</style>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
Since: Desde
|
||||
To: Hasta
|
||||
Amount: Importe
|
||||
Period: Periodo
|
||||
New recoverie: Nuevo recobro
|
||||
New recovery: Nuevo recobro
|
||||
Finish that recovery period: Terminar recobro
|
||||
</i18n>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue