Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 6564-enhanceTicketAdvance
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
5325095297
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "salix-front",
|
"name": "salix-front",
|
||||||
"version": "25.06.0",
|
"version": "25.08.0",
|
||||||
"description": "Salix frontend",
|
"description": "Salix frontend",
|
||||||
"productName": "Salix",
|
"productName": "Salix",
|
||||||
"author": "Verdnatura",
|
"author": "Verdnatura",
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
export const langs = ['en', 'es'];
|
||||||
|
export const decimalPlaces = 2;
|
|
@ -1,6 +1,6 @@
|
||||||
export default {
|
export default {
|
||||||
mounted: function (el, binding) {
|
mounted(el, binding) {
|
||||||
const shortcut = binding.value ?? '+';
|
const shortcut = binding.value || '+';
|
||||||
|
|
||||||
const { key, ctrl, alt, callback } =
|
const { key, ctrl, alt, callback } =
|
||||||
typeof shortcut === 'string'
|
typeof shortcut === 'string'
|
||||||
|
@ -8,25 +8,24 @@ export default {
|
||||||
key: shortcut,
|
key: shortcut,
|
||||||
ctrl: true,
|
ctrl: true,
|
||||||
alt: true,
|
alt: true,
|
||||||
callback: () =>
|
callback: () => el?.click(),
|
||||||
document
|
|
||||||
.querySelector(`button[shortcut="${shortcut}"]`)
|
|
||||||
?.click(),
|
|
||||||
}
|
}
|
||||||
: binding.value;
|
: binding.value;
|
||||||
|
|
||||||
|
if (!el.hasAttribute('shortcut')) {
|
||||||
|
el.setAttribute('shortcut', key);
|
||||||
|
}
|
||||||
|
|
||||||
const handleKeydown = (event) => {
|
const handleKeydown = (event) => {
|
||||||
if (event.key === key && (!ctrl || event.ctrlKey) && (!alt || event.altKey)) {
|
if (event.key === key && (!ctrl || event.ctrlKey) && (!alt || event.altKey)) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Attach the event listener to the window
|
|
||||||
window.addEventListener('keydown', handleKeydown);
|
window.addEventListener('keydown', handleKeydown);
|
||||||
|
|
||||||
el._handleKeydown = handleKeydown;
|
el._handleKeydown = handleKeydown;
|
||||||
},
|
},
|
||||||
unmounted: function (el) {
|
unmounted(el) {
|
||||||
if (el._handleKeydown) {
|
if (el._handleKeydown) {
|
||||||
window.removeEventListener('keydown', el._handleKeydown);
|
window.removeEventListener('keydown', el._handleKeydown);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ const { t } = useI18n();
|
||||||
const bicInputRef = ref(null);
|
const bicInputRef = ref(null);
|
||||||
const state = useState();
|
const state = useState();
|
||||||
|
|
||||||
const customer = computed(() => state.get('customer'));
|
const customer = computed(() => state.get('Customer'));
|
||||||
|
|
||||||
const countriesFilter = {
|
const countriesFilter = {
|
||||||
fields: ['id', 'name', 'code'],
|
fields: ['id', 'name', 'code'],
|
||||||
|
|
|
@ -84,7 +84,7 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
reload: {
|
reload: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: true,
|
||||||
},
|
},
|
||||||
defaultTrim: {
|
defaultTrim: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -97,7 +97,7 @@ const $props = defineProps({
|
||||||
});
|
});
|
||||||
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
||||||
const modelValue = computed(
|
const modelValue = computed(
|
||||||
() => $props.model ?? `formModel_${route?.meta?.title ?? route.name}`
|
() => $props.model ?? `formModel_${route?.meta?.title ?? route.name}`,
|
||||||
).value;
|
).value;
|
||||||
const componentIsRendered = ref(false);
|
const componentIsRendered = ref(false);
|
||||||
const arrayData = useArrayData(modelValue);
|
const arrayData = useArrayData(modelValue);
|
||||||
|
@ -105,8 +105,8 @@ const isLoading = ref(false);
|
||||||
// Si elegimos observar los cambios del form significa que inicialmente las actions estaran deshabilitadas
|
// Si elegimos observar los cambios del form significa que inicialmente las actions estaran deshabilitadas
|
||||||
const isResetting = ref(false);
|
const isResetting = ref(false);
|
||||||
const hasChanges = ref(!$props.observeFormChanges);
|
const hasChanges = ref(!$props.observeFormChanges);
|
||||||
const originalData = ref({});
|
const originalData = computed(() => state.get(modelValue));
|
||||||
const formData = computed(() => state.get(modelValue));
|
const formData = ref({});
|
||||||
const defaultButtons = computed(() => ({
|
const defaultButtons = computed(() => ({
|
||||||
save: {
|
save: {
|
||||||
dataCy: 'saveDefaultBtn',
|
dataCy: 'saveDefaultBtn',
|
||||||
|
@ -127,8 +127,6 @@ const defaultButtons = computed(() => ({
|
||||||
}));
|
}));
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
originalData.value = JSON.parse(JSON.stringify($props.formInitialData ?? {}));
|
|
||||||
|
|
||||||
nextTick(() => (componentIsRendered.value = true));
|
nextTick(() => (componentIsRendered.value = true));
|
||||||
|
|
||||||
// Podemos enviarle al form la estructura de data inicial sin necesidad de fetchearla
|
// Podemos enviarle al form la estructura de data inicial sin necesidad de fetchearla
|
||||||
|
@ -148,7 +146,7 @@ onMounted(async () => {
|
||||||
JSON.stringify(newVal) !== JSON.stringify(originalData.value);
|
JSON.stringify(newVal) !== JSON.stringify(originalData.value);
|
||||||
isResetting.value = false;
|
isResetting.value = false;
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -156,16 +154,24 @@ onMounted(async () => {
|
||||||
if (!$props.url)
|
if (!$props.url)
|
||||||
watch(
|
watch(
|
||||||
() => arrayData.store.data,
|
() => arrayData.store.data,
|
||||||
(val) => updateAndEmit('onFetch', val)
|
(val) => updateAndEmit('onFetch', val),
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
originalData,
|
||||||
|
(val) => {
|
||||||
|
if (val) formData.value = JSON.parse(JSON.stringify(val));
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [$props.url, $props.filter],
|
() => [$props.url, $props.filter],
|
||||||
async () => {
|
async () => {
|
||||||
originalData.value = null;
|
state.set(modelValue, null);
|
||||||
reset();
|
reset();
|
||||||
await fetch();
|
await fetch();
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
onBeforeRouteLeave((to, from, next) => {
|
onBeforeRouteLeave((to, from, next) => {
|
||||||
|
@ -197,7 +203,6 @@ async function fetch() {
|
||||||
updateAndEmit('onFetch', data);
|
updateAndEmit('onFetch', data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
state.set(modelValue, {});
|
state.set(modelValue, {});
|
||||||
originalData.value = {};
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,6 +241,7 @@ async function saveAndGo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
|
formData.value = JSON.parse(JSON.stringify(originalData.value));
|
||||||
updateAndEmit('onFetch', originalData.value);
|
updateAndEmit('onFetch', originalData.value);
|
||||||
if ($props.observeFormChanges) {
|
if ($props.observeFormChanges) {
|
||||||
hasChanges.value = false;
|
hasChanges.value = false;
|
||||||
|
@ -254,13 +260,12 @@ function filter(value, update, filterOptions) {
|
||||||
(ref) => {
|
(ref) => {
|
||||||
ref.setOptionIndex(-1);
|
ref.setOptionIndex(-1);
|
||||||
ref.moveOptionSelection(1, true);
|
ref.moveOptionSelection(1, true);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateAndEmit(evt, val, res) {
|
function updateAndEmit(evt, val, res) {
|
||||||
state.set(modelValue, val);
|
state.set(modelValue, val);
|
||||||
originalData.value = val && JSON.parse(JSON.stringify(val));
|
|
||||||
if (!$props.url) arrayData.store.data = val;
|
if (!$props.url) arrayData.store.data = val;
|
||||||
|
|
||||||
emit(evt, state.get(modelValue), res);
|
emit(evt, state.get(modelValue), res);
|
||||||
|
|
|
@ -282,7 +282,7 @@ const setCategoryList = (data) => {
|
||||||
<QItem class="q-mt-lg">
|
<QItem class="q-mt-lg">
|
||||||
<QBtn
|
<QBtn
|
||||||
icon="add_circle"
|
icon="add_circle"
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
flat
|
flat
|
||||||
class="fill-icon-on-hover q-px-xs"
|
class="fill-icon-on-hover q-px-xs"
|
||||||
color="primary"
|
color="primary"
|
||||||
|
|
|
@ -41,7 +41,6 @@ const filteredItems = computed(() => {
|
||||||
return locale.includes(normalizedSearch);
|
return locale.includes(normalizedSearch);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const filteredPinnedModules = computed(() => {
|
const filteredPinnedModules = computed(() => {
|
||||||
if (!search.value) return pinnedModules.value;
|
if (!search.value) return pinnedModules.value;
|
||||||
const normalizedSearch = search.value
|
const normalizedSearch = search.value
|
||||||
|
@ -72,7 +71,7 @@ watch(
|
||||||
items.value = [];
|
items.value = [];
|
||||||
getRoutes();
|
getRoutes();
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
function findMatches(search, item) {
|
function findMatches(search, item) {
|
||||||
|
@ -104,12 +103,22 @@ function addChildren(module, route, parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRoutes() {
|
function getRoutes() {
|
||||||
if (props.source === 'main') {
|
const handleRoutes = {
|
||||||
|
main: getMainRoutes,
|
||||||
|
card: getCardRoutes,
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
handleRoutes[props.source]();
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(`Method is not defined`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function getMainRoutes() {
|
||||||
const modules = Object.assign([], navigation.getModules().value);
|
const modules = Object.assign([], navigation.getModules().value);
|
||||||
|
|
||||||
for (const item of modules) {
|
for (const item of modules) {
|
||||||
const moduleDef = routes.find(
|
const moduleDef = routes.find(
|
||||||
(route) => toLowerCamel(route.name) === item.module
|
(route) => toLowerCamel(route.name) === item.module,
|
||||||
);
|
);
|
||||||
if (!moduleDef) continue;
|
if (!moduleDef) continue;
|
||||||
item.children = [];
|
item.children = [];
|
||||||
|
@ -120,18 +129,15 @@ function getRoutes() {
|
||||||
items.value = modules;
|
items.value = modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.source === 'card') {
|
function getCardRoutes() {
|
||||||
const currentRoute = route.matched[1];
|
const currentRoute = route.matched[1];
|
||||||
const currentModule = toLowerCamel(currentRoute.name);
|
const currentModule = toLowerCamel(currentRoute.name);
|
||||||
let moduleDef = routes.find(
|
let moduleDef = routes.find((route) => toLowerCamel(route.name) === currentModule);
|
||||||
(route) => toLowerCamel(route.name) === currentModule
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!moduleDef) return;
|
if (!moduleDef) return;
|
||||||
if (!moduleDef?.menus) moduleDef = betaGetRoutes();
|
if (!moduleDef?.menus) moduleDef = betaGetRoutes();
|
||||||
addChildren(currentModule, moduleDef, items.value);
|
addChildren(currentModule, moduleDef, items.value);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function betaGetRoutes() {
|
function betaGetRoutes() {
|
||||||
let menuRoute;
|
let menuRoute;
|
||||||
|
@ -223,9 +229,16 @@ const searchModule = () => {
|
||||||
</template>
|
</template>
|
||||||
<template v-for="(item, index) in filteredItems" :key="item.name">
|
<template v-for="(item, index) in filteredItems" :key="item.name">
|
||||||
<template
|
<template
|
||||||
v-if="search ||item.children && !filteredPinnedModules.has(item.name)"
|
v-if="
|
||||||
|
search ||
|
||||||
|
(item.children && !filteredPinnedModules.has(item.name))
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<LeftMenuItem
|
||||||
|
:item="item"
|
||||||
|
group="modules"
|
||||||
|
:class="search && index === 0 ? 'searched' : ''"
|
||||||
>
|
>
|
||||||
<LeftMenuItem :item="item" group="modules" :class="search && index === 0 ? 'searched' : ''">
|
|
||||||
<template #side>
|
<template #side>
|
||||||
<QBtn
|
<QBtn
|
||||||
v-if="item.isPinned === true"
|
v-if="item.isPinned === true"
|
||||||
|
|
|
@ -2,26 +2,9 @@
|
||||||
defineProps({ row: { type: Object, required: true } });
|
defineProps({ row: { type: Object, required: true } });
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<span>
|
<span class="q-gutter-x-xs">
|
||||||
<QIcon
|
<QIcon
|
||||||
v-if="row.isTaxDataChecked === 0"
|
v-if="row?.risk"
|
||||||
name="vn:no036"
|
|
||||||
color="primary"
|
|
||||||
size="xs"
|
|
||||||
>
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.noVerifiedData') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.hasTicketRequest" name="vn:buyrequest" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.purchaseRequest') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.itemShortage" name="vn:unavailable" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.notVisible') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon v-if="row.isFreezed" name="vn:frozen" color="primary" size="xs">
|
|
||||||
<QTooltip>{{ $t('salesTicketsTable.clientFrozen') }}</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
<QIcon
|
|
||||||
v-if="row.risk"
|
|
||||||
name="vn:risk"
|
name="vn:risk"
|
||||||
:color="row.hasHighRisk ? 'negative' : 'primary'"
|
:color="row.hasHighRisk ? 'negative' : 'primary'"
|
||||||
size="xs"
|
size="xs"
|
||||||
|
@ -30,10 +13,57 @@ defineProps({ row: { type: Object, required: true } });
|
||||||
{{ $t('salesTicketsTable.risk') }}: {{ row.risk - row.credit }}
|
{{ $t('salesTicketsTable.risk') }}: {{ row.risk - row.credit }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon v-if="row.hasComponentLack" name="vn:components" color="primary" size="xs">
|
<QIcon
|
||||||
|
v-if="row?.hasComponentLack"
|
||||||
|
name="vn:components"
|
||||||
|
color="primary"
|
||||||
|
size="xs"
|
||||||
|
>
|
||||||
<QTooltip>{{ $t('salesTicketsTable.componentLack') }}</QTooltip>
|
<QTooltip>{{ $t('salesTicketsTable.componentLack') }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon v-if="row.isTooLittle" name="vn:isTooLittle" color="primary" size="xs">
|
<QIcon v-if="row?.hasItemDelay" color="primary" size="xs" name="vn:hasItemDelay">
|
||||||
|
<QTooltip>
|
||||||
|
{{ $t('ticket.summary.hasItemDelay') }}
|
||||||
|
</QTooltip>
|
||||||
|
</QIcon>
|
||||||
|
<QIcon v-if="row?.hasItemLost" color="primary" size="xs" name="vn:hasItemLost">
|
||||||
|
<QTooltip>
|
||||||
|
{{ $t('salesTicketsTable.hasItemLost') }}
|
||||||
|
</QTooltip>
|
||||||
|
</QIcon>
|
||||||
|
<QIcon
|
||||||
|
v-if="row?.hasItemShortage"
|
||||||
|
name="vn:unavailable"
|
||||||
|
color="primary"
|
||||||
|
size="xs"
|
||||||
|
>
|
||||||
|
<QTooltip>{{ $t('salesTicketsTable.notVisible') }}</QTooltip>
|
||||||
|
</QIcon>
|
||||||
|
<QIcon v-if="row?.hasRounding" color="primary" name="sync_problem" size="xs">
|
||||||
|
<QTooltip>
|
||||||
|
{{ $t('ticketList.rounding') }}
|
||||||
|
</QTooltip>
|
||||||
|
</QIcon>
|
||||||
|
<QIcon
|
||||||
|
v-if="row?.hasTicketRequest"
|
||||||
|
name="vn:buyrequest"
|
||||||
|
color="primary"
|
||||||
|
size="xs"
|
||||||
|
>
|
||||||
|
<QTooltip>{{ $t('salesTicketsTable.purchaseRequest') }}</QTooltip>
|
||||||
|
</QIcon>
|
||||||
|
<QIcon
|
||||||
|
v-if="!row?.isTaxDataChecked === 0"
|
||||||
|
name="vn:no036"
|
||||||
|
color="primary"
|
||||||
|
size="xs"
|
||||||
|
>
|
||||||
|
<QTooltip>{{ $t('salesTicketsTable.noVerifiedData') }}</QTooltip>
|
||||||
|
</QIcon>
|
||||||
|
<QIcon v-if="row?.isFreezed" name="vn:frozen" color="primary" size="xs">
|
||||||
|
<QTooltip>{{ $t('salesTicketsTable.clientFrozen') }}</QTooltip>
|
||||||
|
</QIcon>
|
||||||
|
<QIcon v-if="row?.isTooLittle" name="vn:isTooLittle" color="primary" size="xs">
|
||||||
<QTooltip>{{ $t('salesTicketsTable.tooLittle') }}</QTooltip>
|
<QTooltip>{{ $t('salesTicketsTable.tooLittle') }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -629,7 +629,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
||||||
size="md"
|
size="md"
|
||||||
round
|
round
|
||||||
flat
|
flat
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
:disabled="!disabledAttr"
|
:disabled="!disabledAttr"
|
||||||
/>
|
/>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
|
@ -647,7 +647,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
||||||
color="primary"
|
color="primary"
|
||||||
fab
|
fab
|
||||||
icon="add"
|
icon="add"
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
data-cy="vnTableCreateBtn"
|
data-cy="vnTableCreateBtn"
|
||||||
/>
|
/>
|
||||||
<QTooltip self="top right">
|
<QTooltip self="top right">
|
||||||
|
|
|
@ -27,7 +27,7 @@ function columnName(col) {
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VnFilterPanel v-bind="$attrs" :search-button="true" :disable-submit-event="true">
|
<VnFilterPanel v-bind="$attrs" :search-button="true" :disable-submit-event="true">
|
||||||
<template #body="{ params, orders }">
|
<template #body="{ params, orders, searchFn }">
|
||||||
<div
|
<div
|
||||||
class="row no-wrap flex-center"
|
class="row no-wrap flex-center"
|
||||||
v-for="col of columns.filter((c) => c.columnFilter ?? true)"
|
v-for="col of columns.filter((c) => c.columnFilter ?? true)"
|
||||||
|
@ -52,6 +52,7 @@ function columnName(col) {
|
||||||
<slot
|
<slot
|
||||||
name="moreFilterPanel"
|
name="moreFilterPanel"
|
||||||
:params="params"
|
:params="params"
|
||||||
|
:search-fn="searchFn"
|
||||||
:orders="orders"
|
:orders="orders"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -93,7 +93,7 @@ describe('FormModel', () => {
|
||||||
|
|
||||||
it('should call axios.patch with the right data', async () => {
|
it('should call axios.patch with the right data', async () => {
|
||||||
const spy = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
const spy = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
||||||
const { vm } = mount({ propsData: { url, model, formInitialData } });
|
const { vm } = mount({ propsData: { url, model } });
|
||||||
vm.formData.mockKey = 'newVal';
|
vm.formData.mockKey = 'newVal';
|
||||||
await vm.$nextTick();
|
await vm.$nextTick();
|
||||||
await vm.save();
|
await vm.save();
|
||||||
|
@ -106,6 +106,7 @@ describe('FormModel', () => {
|
||||||
const { vm } = mount({
|
const { vm } = mount({
|
||||||
propsData: { url, model, formInitialData, urlCreate: 'mockUrlCreate' },
|
propsData: { url, model, formInitialData, urlCreate: 'mockUrlCreate' },
|
||||||
});
|
});
|
||||||
|
await vm.$nextTick();
|
||||||
vm.formData.mockKey = 'newVal';
|
vm.formData.mockKey = 'newVal';
|
||||||
await vm.$nextTick();
|
await vm.$nextTick();
|
||||||
await vm.save();
|
await vm.save();
|
||||||
|
@ -119,7 +120,7 @@ describe('FormModel', () => {
|
||||||
});
|
});
|
||||||
const spyPatch = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
const spyPatch = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
||||||
const spySaveFn = vi.spyOn(vm.$props, 'saveFn');
|
const spySaveFn = vi.spyOn(vm.$props, 'saveFn');
|
||||||
|
await vm.$nextTick();
|
||||||
vm.formData.mockKey = 'newVal';
|
vm.formData.mockKey = 'newVal';
|
||||||
await vm.$nextTick();
|
await vm.$nextTick();
|
||||||
await vm.save();
|
await vm.save();
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
import { vi, describe, expect, it, beforeAll } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vitest';
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||||
import Leftmenu from 'components/LeftMenu.vue';
|
import Leftmenu from 'components/LeftMenu.vue';
|
||||||
|
import * as vueRouter from 'vue-router';
|
||||||
import { useNavigationStore } from 'src/stores/useNavigationStore';
|
import { useNavigationStore } from 'src/stores/useNavigationStore';
|
||||||
|
|
||||||
|
let vm;
|
||||||
|
let navigation;
|
||||||
|
|
||||||
vi.mock('src/router/modules', () => ({
|
vi.mock('src/router/modules', () => ({
|
||||||
default: [
|
default: [
|
||||||
{
|
{
|
||||||
|
@ -21,6 +24,16 @@ vi.mock('src/router/modules', () => ({
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
name: 'CustomerMain',
|
name: 'CustomerMain',
|
||||||
|
meta: {
|
||||||
|
menu: 'Customer',
|
||||||
|
menuChildren: [
|
||||||
|
{
|
||||||
|
name: 'CustomerCreditContracts',
|
||||||
|
title: 'creditContracts',
|
||||||
|
icon: 'vn:solunion',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'list',
|
path: 'list',
|
||||||
|
@ -28,6 +41,13 @@ vi.mock('src/router/modules', () => ({
|
||||||
meta: {
|
meta: {
|
||||||
title: 'list',
|
title: 'list',
|
||||||
icon: 'view_list',
|
icon: 'view_list',
|
||||||
|
menuChildren: [
|
||||||
|
{
|
||||||
|
name: 'CustomerCreditContracts',
|
||||||
|
title: 'creditContracts',
|
||||||
|
icon: 'vn:solunion',
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -44,20 +64,59 @@ vi.mock('src/router/modules', () => ({
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}));
|
}));
|
||||||
|
vi.spyOn(vueRouter, 'useRoute').mockReturnValue({
|
||||||
describe('Leftmenu', () => {
|
matched: [
|
||||||
let vm;
|
{
|
||||||
let navigation;
|
path: '/',
|
||||||
beforeAll(() => {
|
redirect: {
|
||||||
|
name: 'Dashboard',
|
||||||
|
},
|
||||||
|
name: 'Main',
|
||||||
|
meta: {},
|
||||||
|
props: {
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '/dashboard',
|
||||||
|
name: 'Dashboard',
|
||||||
|
meta: {
|
||||||
|
title: 'dashboard',
|
||||||
|
icon: 'dashboard',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/customer',
|
||||||
|
redirect: {
|
||||||
|
name: 'CustomerMain',
|
||||||
|
},
|
||||||
|
name: 'Customer',
|
||||||
|
meta: {
|
||||||
|
title: 'customers',
|
||||||
|
icon: 'vn:client',
|
||||||
|
moduleName: 'Customer',
|
||||||
|
keyBinding: 'c',
|
||||||
|
menu: 'customer',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
query: {},
|
||||||
|
params: {},
|
||||||
|
meta: { moduleName: 'mockName' },
|
||||||
|
path: 'mockName/1',
|
||||||
|
name: 'Customer',
|
||||||
|
});
|
||||||
|
function mount(source = 'main') {
|
||||||
vi.spyOn(axios, 'get').mockResolvedValue({
|
vi.spyOn(axios, 'get').mockResolvedValue({
|
||||||
data: [],
|
data: [],
|
||||||
});
|
});
|
||||||
|
const wrapper = createWrapper(Leftmenu, {
|
||||||
vm = createWrapper(Leftmenu, {
|
|
||||||
propsData: {
|
propsData: {
|
||||||
source: 'main',
|
source,
|
||||||
},
|
},
|
||||||
}).vm;
|
});
|
||||||
|
|
||||||
navigation = useNavigationStore();
|
navigation = useNavigationStore();
|
||||||
navigation.fetchPinned = vi.fn().mockReturnValue(Promise.resolve(true));
|
navigation.fetchPinned = vi.fn().mockReturnValue(Promise.resolve(true));
|
||||||
|
@ -71,24 +130,259 @@ describe('Leftmenu', () => {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('getRoutes', () => {
|
||||||
|
afterEach(() => vi.clearAllMocks());
|
||||||
|
const getRoutes = vi.fn().mockImplementation((props, getMethodA, getMethodB) => {
|
||||||
|
const handleRoutes = {
|
||||||
|
methodA: getMethodA,
|
||||||
|
methodB: getMethodB,
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
handleRoutes[props.source]();
|
||||||
|
} catch (error) {
|
||||||
|
throw Error('Method not defined');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a proper formated object with two child items', async () => {
|
const getMethodA = vi.fn();
|
||||||
const expectedMenuItem = [
|
const getMethodB = vi.fn();
|
||||||
{
|
const fn = (props) => getRoutes(props, getMethodA, getMethodB);
|
||||||
children: null,
|
|
||||||
name: 'CustomerList',
|
it('should call getMethodB when source is card', () => {
|
||||||
title: 'globals.pageTitles.list',
|
let props = { source: 'methodB' };
|
||||||
icon: 'view_list',
|
fn(props);
|
||||||
},
|
|
||||||
{
|
expect(getMethodB).toHaveBeenCalled();
|
||||||
children: null,
|
expect(getMethodA).not.toHaveBeenCalled();
|
||||||
name: 'CustomerCreate',
|
});
|
||||||
title: 'globals.pageTitles.createCustomer',
|
it('should call getMethodA when source is main', () => {
|
||||||
icon: 'vn:addperson',
|
let props = { source: 'methodA' };
|
||||||
},
|
fn(props);
|
||||||
|
|
||||||
|
expect(getMethodA).toHaveBeenCalled();
|
||||||
|
expect(getMethodB).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call getMethodA when source is not exists or undefined', () => {
|
||||||
|
let props = { source: 'methodC' };
|
||||||
|
expect(() => fn(props)).toThrowError('Method not defined');
|
||||||
|
|
||||||
|
expect(getMethodA).not.toHaveBeenCalled();
|
||||||
|
expect(getMethodB).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Leftmenu as card', () => {
|
||||||
|
beforeAll(() => {
|
||||||
|
vm = mount('card').vm;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should get routes for card source', async () => {
|
||||||
|
vm.getRoutes();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('Leftmenu as main', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vm = mount().vm;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should initialize with default props', () => {
|
||||||
|
expect(vm.source).toBe('main');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should filter items based on search input', async () => {
|
||||||
|
vm.search = 'cust';
|
||||||
|
await vm.$nextTick();
|
||||||
|
expect(vm.filteredItems[0].name).toEqual('customer');
|
||||||
|
expect(vm.filteredItems[0].module).toEqual('customer');
|
||||||
|
});
|
||||||
|
it('should filter items based on search input', async () => {
|
||||||
|
vm.search = 'Rou';
|
||||||
|
await vm.$nextTick();
|
||||||
|
expect(vm.filteredItems).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return pinned items', () => {
|
||||||
|
vm.items = [
|
||||||
|
{ name: 'Item 1', isPinned: false },
|
||||||
|
{ name: 'Item 2', isPinned: true },
|
||||||
];
|
];
|
||||||
const firstMenuItem = vm.items[0];
|
expect(vm.pinnedModules).toEqual(
|
||||||
expect(firstMenuItem.children).toEqual(expect.arrayContaining(expectedMenuItem));
|
new Map([['Item 2', { name: 'Item 2', isPinned: true }]]),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should find matches in routes', () => {
|
||||||
|
const search = 'child1';
|
||||||
|
const item = {
|
||||||
|
children: [
|
||||||
|
{ name: 'child1', children: [] },
|
||||||
|
{ name: 'child2', children: [] },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
const matches = vm.findMatches(search, item);
|
||||||
|
expect(matches).toEqual([{ name: 'child1', children: [] }]);
|
||||||
|
});
|
||||||
|
it('should not proceed if event is already prevented', async () => {
|
||||||
|
const item = { module: 'testModule', isPinned: false };
|
||||||
|
const event = {
|
||||||
|
preventDefault: vi.fn(),
|
||||||
|
stopPropagation: vi.fn(),
|
||||||
|
defaultPrevented: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
await vm.togglePinned(item, event);
|
||||||
|
|
||||||
|
expect(event.preventDefault).not.toHaveBeenCalled();
|
||||||
|
expect(event.stopPropagation).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call quasar.notify with success message', async () => {
|
||||||
|
const item = { module: 'testModule', isPinned: false };
|
||||||
|
const event = {
|
||||||
|
preventDefault: vi.fn(),
|
||||||
|
stopPropagation: vi.fn(),
|
||||||
|
defaultPrevented: false,
|
||||||
|
};
|
||||||
|
const response = { data: { id: 1 } };
|
||||||
|
|
||||||
|
vi.spyOn(axios, 'post').mockResolvedValue(response);
|
||||||
|
vi.spyOn(vm.quasar, 'notify');
|
||||||
|
|
||||||
|
await vm.togglePinned(item, event);
|
||||||
|
|
||||||
|
expect(vm.quasar.notify).toHaveBeenCalledWith({
|
||||||
|
message: 'Data saved',
|
||||||
|
type: 'positive',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle a single matched route with a menu', () => {
|
||||||
|
const route = {
|
||||||
|
matched: [{ meta: { menu: 'customer' } }],
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = vm.betaGetRoutes();
|
||||||
|
|
||||||
|
expect(result.meta.menu).toEqual(route.matched[0].meta.menu);
|
||||||
|
});
|
||||||
|
it('should get routes for main source', () => {
|
||||||
|
vm.props.source = 'main';
|
||||||
|
vm.getRoutes();
|
||||||
|
expect(navigation.getModules).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should find direct child matches', () => {
|
||||||
|
const search = 'child1';
|
||||||
|
const item = {
|
||||||
|
children: [{ name: 'child1' }, { name: 'child2' }],
|
||||||
|
};
|
||||||
|
const result = vm.findMatches(search, item);
|
||||||
|
expect(result).toEqual([{ name: 'child1' }]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should find nested child matches', () => {
|
||||||
|
const search = 'child3';
|
||||||
|
const item = {
|
||||||
|
children: [
|
||||||
|
{ name: 'child1' },
|
||||||
|
{
|
||||||
|
name: 'child2',
|
||||||
|
children: [{ name: 'child3' }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
const result = vm.findMatches(search, item);
|
||||||
|
expect(result).toEqual([{ name: 'child3' }]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('normalize', () => {
|
||||||
|
beforeAll(() => {
|
||||||
|
vm = mount('card').vm;
|
||||||
|
});
|
||||||
|
it('should normalize and lowercase text', () => {
|
||||||
|
const input = 'ÁÉÍÓÚáéíóú';
|
||||||
|
const expected = 'aeiouaeiou';
|
||||||
|
expect(vm.normalize(input)).toBe(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle empty string', () => {
|
||||||
|
const input = '';
|
||||||
|
const expected = '';
|
||||||
|
expect(vm.normalize(input)).toBe(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle text without diacritics', () => {
|
||||||
|
const input = 'hello';
|
||||||
|
const expected = 'hello';
|
||||||
|
expect(vm.normalize(input)).toBe(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle mixed text', () => {
|
||||||
|
const input = 'Héllo Wórld!';
|
||||||
|
const expected = 'hello world!';
|
||||||
|
expect(vm.normalize(input)).toBe(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addChildren', () => {
|
||||||
|
const module = 'testModule';
|
||||||
|
beforeEach(() => {
|
||||||
|
vm = mount().vm;
|
||||||
|
vi.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add menu items to parent if matches are found', () => {
|
||||||
|
const parent = 'testParent';
|
||||||
|
const route = {
|
||||||
|
meta: {
|
||||||
|
menu: 'testMenu',
|
||||||
|
},
|
||||||
|
children: [{ name: 'child1' }, { name: 'child2' }],
|
||||||
|
};
|
||||||
|
vm.addChildren(module, route, parent);
|
||||||
|
|
||||||
|
expect(navigation.addMenuItem).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle routes with no meta menu', () => {
|
||||||
|
const route = {
|
||||||
|
meta: {},
|
||||||
|
menus: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
const parent = [];
|
||||||
|
|
||||||
|
vm.addChildren(module, route, parent);
|
||||||
|
expect(navigation.addMenuItem).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle empty parent array', () => {
|
||||||
|
const parent = [];
|
||||||
|
const route = {
|
||||||
|
meta: {
|
||||||
|
menu: 'child11',
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'child1',
|
||||||
|
meta: {
|
||||||
|
menuChildren: [
|
||||||
|
{
|
||||||
|
name: 'CustomerCreditContracts',
|
||||||
|
title: 'creditContracts',
|
||||||
|
icon: 'vn:solunion',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
vm.addChildren(module, route, parent);
|
||||||
|
expect(navigation.addMenuItem).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,11 +10,11 @@ import LeftMenu from 'components/LeftMenu.vue';
|
||||||
import RightMenu from 'components/common/RightMenu.vue';
|
import RightMenu from 'components/common/RightMenu.vue';
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
dataKey: { type: String, required: true },
|
dataKey: { type: String, required: true },
|
||||||
baseUrl: { type: String, default: undefined },
|
url: { type: String, default: undefined },
|
||||||
customUrl: { type: String, default: undefined },
|
|
||||||
filter: { type: Object, default: () => {} },
|
filter: { type: Object, default: () => {} },
|
||||||
descriptor: { type: Object, required: true },
|
descriptor: { type: Object, required: true },
|
||||||
filterPanel: { type: Object, default: undefined },
|
filterPanel: { type: Object, default: undefined },
|
||||||
|
idInWhere: { type: Boolean, default: false },
|
||||||
searchDataKey: { type: String, default: undefined },
|
searchDataKey: { type: String, default: undefined },
|
||||||
searchbarProps: { type: Object, default: undefined },
|
searchbarProps: { type: Object, default: undefined },
|
||||||
redirectOnError: { type: Boolean, default: false },
|
redirectOnError: { type: Boolean, default: false },
|
||||||
|
@ -23,25 +23,20 @@ const props = defineProps({
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const url = computed(() => {
|
|
||||||
if (props.baseUrl) {
|
|
||||||
return `${props.baseUrl}/${route.params.id}`;
|
|
||||||
}
|
|
||||||
return props.customUrl;
|
|
||||||
});
|
|
||||||
const searchRightDataKey = computed(() => {
|
const searchRightDataKey = computed(() => {
|
||||||
if (!props.searchDataKey) return route.name;
|
if (!props.searchDataKey) return route.name;
|
||||||
return props.searchDataKey;
|
return props.searchDataKey;
|
||||||
});
|
});
|
||||||
|
|
||||||
const arrayData = useArrayData(props.dataKey, {
|
const arrayData = useArrayData(props.dataKey, {
|
||||||
url: url.value,
|
url: props.url,
|
||||||
filter: props.filter,
|
userFilter: props.filter,
|
||||||
|
oneRecord: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
try {
|
try {
|
||||||
if (!props.baseUrl) arrayData.store.filter.where = { id: route.params.id };
|
await fetch(route.params.id);
|
||||||
await arrayData.fetch({ append: false, updateRouter: false });
|
|
||||||
} catch {
|
} catch {
|
||||||
const { matched: matches } = router.currentRoute.value;
|
const { matched: matches } = router.currentRoute.value;
|
||||||
const { path } = matches.at(-1);
|
const { path } = matches.at(-1);
|
||||||
|
@ -49,13 +44,17 @@ onBeforeMount(async () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (props.baseUrl) {
|
|
||||||
onBeforeRouteUpdate(async (to, from) => {
|
onBeforeRouteUpdate(async (to, from) => {
|
||||||
if (to.params.id !== from.params.id) {
|
const id = to.params.id;
|
||||||
arrayData.store.url = `${props.baseUrl}/${to.params.id}`;
|
if (id !== from.params.id) await fetch(id, true);
|
||||||
await arrayData.fetch({ append: false, updateRouter: false });
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function fetch(id, append = false) {
|
||||||
|
const regex = /\/(\d+)/;
|
||||||
|
if (props.idInWhere) arrayData.store.filter.where = { id };
|
||||||
|
else if (!regex.test(props.url)) arrayData.store.url = `${props.url}/${id}`;
|
||||||
|
else arrayData.store.url = props.url.replace(regex, `/${id}`);
|
||||||
|
await arrayData.fetch({ append, updateRouter: false });
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
@ -83,7 +82,7 @@ if (props.baseUrl) {
|
||||||
<QPage>
|
<QPage>
|
||||||
<VnSubToolbar />
|
<VnSubToolbar />
|
||||||
<div :class="[useCardSize(), $attrs.class]">
|
<div :class="[useCardSize(), $attrs.class]">
|
||||||
<RouterView :key="route.path" />
|
<RouterView :key="$route.path" />
|
||||||
</div>
|
</div>
|
||||||
</QPage>
|
</QPage>
|
||||||
</QPageContainer>
|
</QPageContainer>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onBeforeMount, computed } from 'vue';
|
import { onBeforeMount } from 'vue';
|
||||||
import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router';
|
import { useRouter, onBeforeRouteUpdate } from 'vue-router';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import useCardSize from 'src/composables/useCardSize';
|
import useCardSize from 'src/composables/useCardSize';
|
||||||
|
@ -9,10 +9,9 @@ import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
dataKey: { type: String, required: true },
|
dataKey: { type: String, required: true },
|
||||||
baseUrl: { type: String, default: undefined },
|
url: { type: String, default: undefined },
|
||||||
customUrl: { type: String, default: undefined },
|
idInWhere: { type: Boolean, default: false },
|
||||||
filter: { type: Object, default: () => {} },
|
filter: { type: Object, default: () => {} },
|
||||||
userFilter: { type: Object, default: () => {} },
|
|
||||||
descriptor: { type: Object, required: true },
|
descriptor: { type: Object, required: true },
|
||||||
filterPanel: { type: Object, default: undefined },
|
filterPanel: { type: Object, default: undefined },
|
||||||
searchDataKey: { type: String, default: undefined },
|
searchDataKey: { type: String, default: undefined },
|
||||||
|
@ -21,39 +20,35 @@ const props = defineProps({
|
||||||
});
|
});
|
||||||
|
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const route = useRoute();
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const url = computed(() => {
|
|
||||||
if (props.baseUrl) {
|
|
||||||
return `${props.baseUrl}/${route.params.id}`;
|
|
||||||
}
|
|
||||||
return props.customUrl;
|
|
||||||
});
|
|
||||||
|
|
||||||
const arrayData = useArrayData(props.dataKey, {
|
const arrayData = useArrayData(props.dataKey, {
|
||||||
url: url.value,
|
url: props.url,
|
||||||
filter: props.filter,
|
userFilter: props.filter,
|
||||||
userFilter: props.userFilter,
|
oneRecord: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
|
const route = router.currentRoute.value;
|
||||||
try {
|
try {
|
||||||
if (!props.baseUrl) arrayData.store.filter.where = { id: route.params.id };
|
await fetch(route.params.id);
|
||||||
await arrayData.fetch({ append: false, updateRouter: false });
|
|
||||||
} catch {
|
} catch {
|
||||||
const { matched: matches } = router.currentRoute.value;
|
const { matched: matches } = route;
|
||||||
const { path } = matches.at(-1);
|
const { path } = matches.at(-1);
|
||||||
router.push({ path: path.replace(/:id.*/, '') });
|
router.push({ path: path.replace(/:id.*/, '') });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (props.baseUrl) {
|
|
||||||
onBeforeRouteUpdate(async (to, from) => {
|
onBeforeRouteUpdate(async (to, from) => {
|
||||||
if (to.params.id !== from.params.id) {
|
const id = to.params.id;
|
||||||
arrayData.store.url = `${props.baseUrl}/${to.params.id}`;
|
if (id !== from.params.id) await fetch(id, true);
|
||||||
await arrayData.fetch({ append: false, updateRouter: false });
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function fetch(id, append = false) {
|
||||||
|
const regex = /\/(\d+)/;
|
||||||
|
if (props.idInWhere) arrayData.store.filter.where = { id };
|
||||||
|
else if (!regex.test(props.url)) arrayData.store.url = `${props.url}/${id}`;
|
||||||
|
else arrayData.store.url = props.url.replace(regex, `/${id}`);
|
||||||
|
await arrayData.fetch({ append, updateRouter: false });
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
@ -64,6 +59,6 @@ if (props.baseUrl) {
|
||||||
</Teleport>
|
</Teleport>
|
||||||
<VnSubToolbar />
|
<VnSubToolbar />
|
||||||
<div :class="[useCardSize(), $attrs.class]">
|
<div :class="[useCardSize(), $attrs.class]">
|
||||||
<RouterView :key="route.path" />
|
<RouterView :key="$route.path" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { useSession } from 'src/composables/useSession';
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const rows = ref();
|
const rows = ref([]);
|
||||||
const dmsRef = ref();
|
const dmsRef = ref();
|
||||||
const formDialog = ref({});
|
const formDialog = ref({});
|
||||||
const token = useSession().getTokenMultimedia();
|
const token = useSession().getTokenMultimedia();
|
||||||
|
@ -389,6 +389,14 @@ defineExpose({
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</QTable>
|
</QTable>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="info-row q-pa-md text-center"
|
||||||
|
>
|
||||||
|
<h5>
|
||||||
|
{{ t('No data to display') }}
|
||||||
|
</h5>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</VnPaginate>
|
</VnPaginate>
|
||||||
<QDialog v-model="formDialog.show">
|
<QDialog v-model="formDialog.show">
|
||||||
|
@ -405,7 +413,7 @@ defineExpose({
|
||||||
fab
|
fab
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="add"
|
icon="add"
|
||||||
shortcut="+"
|
v-shortcut
|
||||||
@click="showFormDialog()"
|
@click="showFormDialog()"
|
||||||
class="fill-icon"
|
class="fill-icon"
|
||||||
>
|
>
|
||||||
|
|
|
@ -268,7 +268,7 @@ async function applyFilter() {
|
||||||
filter.where.and.push(selectedFilters.value);
|
filter.where.and.push(selectedFilters.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
paginate.value.fetch(filter);
|
paginate.value.fetch({ filter });
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDate(type) {
|
function setDate(type) {
|
||||||
|
@ -404,7 +404,7 @@ watch(
|
||||||
ref="paginate"
|
ref="paginate"
|
||||||
:data-key="`${model}Log`"
|
:data-key="`${model}Log`"
|
||||||
:url="`${model}Logs`"
|
:url="`${model}Logs`"
|
||||||
:filter="filter"
|
:user-filter="filter"
|
||||||
:skeleton="false"
|
:skeleton="false"
|
||||||
auto-load
|
auto-load
|
||||||
@on-fetch="setLogTree"
|
@on-fetch="setLogTree"
|
||||||
|
|
|
@ -106,7 +106,14 @@ function checkIsMain() {
|
||||||
:data-key="dataKey"
|
:data-key="dataKey"
|
||||||
:array-data="arrayData"
|
:array-data="arrayData"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
|
>
|
||||||
|
<template #moreFilterPanel="{ params, orders, searchFn }">
|
||||||
|
<slot
|
||||||
|
name="moreFilterPanel"
|
||||||
|
v-bind="{ params, orders, searchFn }"
|
||||||
/>
|
/>
|
||||||
|
</template>
|
||||||
|
</VnTableFilter>
|
||||||
</slot>
|
</slot>
|
||||||
</template>
|
</template>
|
||||||
</RightAdvancedMenu>
|
</RightAdvancedMenu>
|
||||||
|
|
|
@ -1,51 +1,78 @@
|
||||||
import { describe, it, expect, vi, beforeAll, afterEach, beforeEach } from 'vitest';
|
import {
|
||||||
|
describe,
|
||||||
|
it,
|
||||||
|
expect,
|
||||||
|
vi,
|
||||||
|
beforeAll,
|
||||||
|
afterEach,
|
||||||
|
beforeEach,
|
||||||
|
afterAll,
|
||||||
|
} from 'vitest';
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||||
import VnNotes from 'src/components/ui/VnNotes.vue';
|
import VnNotes from 'src/components/ui/VnNotes.vue';
|
||||||
|
import vnDate from 'src/boot/vnDate';
|
||||||
|
|
||||||
describe('VnNotes', () => {
|
describe('VnNotes', () => {
|
||||||
let vm;
|
let vm;
|
||||||
let wrapper;
|
let wrapper;
|
||||||
let spyFetch;
|
let spyFetch;
|
||||||
let postMock;
|
let postMock;
|
||||||
let expectedBody;
|
let patchMock;
|
||||||
const mockData= {name: 'Tony', lastName: 'Stark', text: 'Test Note', observationTypeFk: 1};
|
let expectedInsertBody;
|
||||||
|
let expectedUpdateBody;
|
||||||
function generateExpectedBody() {
|
const defaultOptions = {
|
||||||
expectedBody = {...vm.$props.body, ...{ text: vm.newNote.text, observationTypeFk: vm.newNote.observationTypeFk }};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function setTestParams(text, observationType, type){
|
|
||||||
vm.newNote.text = text;
|
|
||||||
vm.newNote.observationTypeFk = observationType;
|
|
||||||
wrapper.setProps({ selectType: type });
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
|
||||||
vi.spyOn(axios, 'get').mockReturnValue({ data: [] });
|
|
||||||
|
|
||||||
wrapper = createWrapper(VnNotes, {
|
|
||||||
propsData: {
|
|
||||||
url: '/test',
|
url: '/test',
|
||||||
body: { name: 'Tony', lastName: 'Stark' },
|
body: { name: 'Tony', lastName: 'Stark' },
|
||||||
}
|
selectType: false,
|
||||||
|
saveUrl: null,
|
||||||
|
justInput: false,
|
||||||
|
};
|
||||||
|
function generateWrapper(
|
||||||
|
options = defaultOptions,
|
||||||
|
text = null,
|
||||||
|
observationType = null,
|
||||||
|
) {
|
||||||
|
vi.spyOn(axios, 'get').mockResolvedValue({ data: [] });
|
||||||
|
wrapper = createWrapper(VnNotes, {
|
||||||
|
propsData: options,
|
||||||
});
|
});
|
||||||
wrapper = wrapper.wrapper;
|
wrapper = wrapper.wrapper;
|
||||||
vm = wrapper.vm;
|
vm = wrapper.vm;
|
||||||
});
|
vm.newNote.text = text;
|
||||||
|
vm.newNote.observationTypeFk = observationType;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createSpyFetch() {
|
||||||
|
spyFetch = vi.spyOn(vm.$refs.vnPaginateRef, 'fetch');
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateExpectedBody() {
|
||||||
|
expectedInsertBody = {
|
||||||
|
...vm.$props.body,
|
||||||
|
...{ text: vm.newNote.text, observationTypeFk: vm.newNote.observationTypeFk },
|
||||||
|
};
|
||||||
|
expectedUpdateBody = { ...vm.$props.body, ...{ notes: vm.newNote.text } };
|
||||||
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
postMock = vi.spyOn(axios, 'post').mockResolvedValue(mockData);
|
postMock = vi.spyOn(axios, 'post');
|
||||||
spyFetch = vi.spyOn(vm.vnPaginateRef, 'fetch').mockImplementation(() => vi.fn());
|
patchMock = vi.spyOn(axios, 'patch');
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
expectedBody = {};
|
expectedInsertBody = {};
|
||||||
|
expectedUpdateBody = {};
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
vi.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('insert', () => {
|
describe('insert', () => {
|
||||||
it('should not call axios.post and vnPaginateRef.fetch if newNote.text is null', async () => {
|
it('should not call axios.post and vnPaginateRef.fetch when newNote.text is null', async () => {
|
||||||
await setTestParams( null, null, true );
|
generateWrapper({ selectType: true });
|
||||||
|
createSpyFetch();
|
||||||
|
|
||||||
await vm.insert();
|
await vm.insert();
|
||||||
|
|
||||||
|
@ -53,8 +80,9 @@ describe('VnNotes', () => {
|
||||||
expect(spyFetch).not.toHaveBeenCalled();
|
expect(spyFetch).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not call axios.post and vnPaginateRef.fetch if newNote.text is empty', async () => {
|
it('should not call axios.post and vnPaginateRef.fetch when newNote.text is empty', async () => {
|
||||||
await setTestParams( "", null, false );
|
generateWrapper(null, '');
|
||||||
|
createSpyFetch();
|
||||||
|
|
||||||
await vm.insert();
|
await vm.insert();
|
||||||
|
|
||||||
|
@ -62,8 +90,9 @@ describe('VnNotes', () => {
|
||||||
expect(spyFetch).not.toHaveBeenCalled();
|
expect(spyFetch).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not call axios.post and vnPaginateRef.fetch if observationTypeFk is missing and selectType is true', async () => {
|
it('should not call axios.post and vnPaginateRef.fetch when observationTypeFk is null and selectType is true', async () => {
|
||||||
await setTestParams( "Test Note", null, true );
|
generateWrapper({ selectType: true }, 'Test Note');
|
||||||
|
createSpyFetch();
|
||||||
|
|
||||||
await vm.insert();
|
await vm.insert();
|
||||||
|
|
||||||
|
@ -71,37 +100,57 @@ describe('VnNotes', () => {
|
||||||
expect(spyFetch).not.toHaveBeenCalled();
|
expect(spyFetch).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call axios.post and vnPaginateRef.fetch if observationTypeFk is missing and selectType is false', async () => {
|
it('should call axios.post and vnPaginateRef.fetch when observationTypeFk is missing and selectType is false', async () => {
|
||||||
await setTestParams( "Test Note", null, false );
|
generateWrapper(null, 'Test Note');
|
||||||
|
createSpyFetch();
|
||||||
generateExpectedBody();
|
generateExpectedBody();
|
||||||
|
|
||||||
await vm.insert();
|
await vm.insert();
|
||||||
|
|
||||||
expect(postMock).toHaveBeenCalledWith(vm.$props.url, expectedBody);
|
expect(postMock).toHaveBeenCalledWith(vm.$props.url, expectedInsertBody);
|
||||||
expect(spyFetch).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call axios.post and vnPaginateRef.fetch if observationTypeFk is setted and selectType is false', async () => {
|
|
||||||
await setTestParams( "Test Note", 1, false );
|
|
||||||
|
|
||||||
generateExpectedBody();
|
|
||||||
|
|
||||||
await vm.insert();
|
|
||||||
|
|
||||||
expect(postMock).toHaveBeenCalledWith(vm.$props.url, expectedBody);
|
|
||||||
expect(spyFetch).toHaveBeenCalled();
|
expect(spyFetch).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call axios.post and vnPaginateRef.fetch when newNote is valid', async () => {
|
it('should call axios.post and vnPaginateRef.fetch when newNote is valid', async () => {
|
||||||
await setTestParams( "Test Note", 1, true );
|
generateWrapper({ selectType: true }, 'Test Note', 1);
|
||||||
|
createSpyFetch();
|
||||||
generateExpectedBody();
|
generateExpectedBody();
|
||||||
|
|
||||||
await vm.insert();
|
await vm.insert();
|
||||||
|
|
||||||
expect(postMock).toHaveBeenCalledWith(vm.$props.url, expectedBody);
|
expect(postMock).toHaveBeenCalledWith(vm.$props.url, expectedInsertBody);
|
||||||
expect(spyFetch).toHaveBeenCalled();
|
expect(spyFetch).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('update', () => {
|
||||||
|
it('should call axios.patch with saveUrl when saveUrl is set and justInput is true', async () => {
|
||||||
|
generateWrapper({
|
||||||
|
url: '/business',
|
||||||
|
justInput: true,
|
||||||
|
saveUrl: '/saveUrlTest',
|
||||||
|
});
|
||||||
|
generateExpectedBody();
|
||||||
|
|
||||||
|
await vm.update();
|
||||||
|
|
||||||
|
expect(patchMock).toHaveBeenCalledWith(vm.$props.saveUrl, expectedUpdateBody);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call axios.patch with url when saveUrl is not set and justInput is true', async () => {
|
||||||
|
generateWrapper({
|
||||||
|
url: '/business',
|
||||||
|
body: { workerFk: 1110 },
|
||||||
|
justInput: true,
|
||||||
|
});
|
||||||
|
generateExpectedBody();
|
||||||
|
|
||||||
|
await vm.update();
|
||||||
|
|
||||||
|
expect(patchMock).toHaveBeenCalledWith(
|
||||||
|
`${vm.$props.url}/${vm.$props.body.workerFk}`,
|
||||||
|
expectedUpdateBody,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
|
@ -59,10 +59,11 @@ onBeforeMount(async () => {
|
||||||
url: $props.url,
|
url: $props.url,
|
||||||
filter: $props.filter,
|
filter: $props.filter,
|
||||||
skip: 0,
|
skip: 0,
|
||||||
|
oneRecord: true,
|
||||||
});
|
});
|
||||||
store = arrayData.store;
|
store = arrayData.store;
|
||||||
entity = computed(() => {
|
entity = computed(() => {
|
||||||
const data = (Array.isArray(store.data) ? store.data[0] : store.data) ?? {};
|
const data = store.data ?? {};
|
||||||
if (data) emit('onFetch', data);
|
if (data) emit('onFetch', data);
|
||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
|
@ -73,7 +74,7 @@ onBeforeMount(async () => {
|
||||||
() => [$props.url, $props.filter],
|
() => [$props.url, $props.filter],
|
||||||
async () => {
|
async () => {
|
||||||
if (!isSameDataKey.value) await getData();
|
if (!isSameDataKey.value) await getData();
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ async function getData() {
|
||||||
try {
|
try {
|
||||||
const { data } = await arrayData.fetch({ append: false, updateRouter: false });
|
const { data } = await arrayData.fetch({ append: false, updateRouter: false });
|
||||||
state.set($props.dataKey, data);
|
state.set($props.dataKey, data);
|
||||||
emit('onFetch', Array.isArray(data) ? data[0] : data);
|
emit('onFetch', data);
|
||||||
} finally {
|
} finally {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +109,7 @@ const iconModule = computed(() => route.matched[1].meta.icon);
|
||||||
const toModule = computed(() =>
|
const toModule = computed(() =>
|
||||||
route.matched[1].path.split('/').length > 2
|
route.matched[1].path.split('/').length > 2
|
||||||
? route.matched[1].redirect
|
? route.matched[1].redirect
|
||||||
: route.matched[1].children[0].redirect
|
: route.matched[1].children[0].redirect,
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,10 @@ const props = defineProps({
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
|
userFilter: {
|
||||||
|
type: Object,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
entityId: {
|
entityId: {
|
||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
default: null,
|
default: null,
|
||||||
|
@ -34,10 +38,12 @@ const isSummary = ref();
|
||||||
const arrayData = useArrayData(props.dataKey, {
|
const arrayData = useArrayData(props.dataKey, {
|
||||||
url: props.url,
|
url: props.url,
|
||||||
filter: props.filter,
|
filter: props.filter,
|
||||||
|
userFilter: props.userFilter,
|
||||||
skip: 0,
|
skip: 0,
|
||||||
|
oneRecord: true,
|
||||||
});
|
});
|
||||||
const { store } = arrayData;
|
const { store } = arrayData;
|
||||||
const entity = computed(() => (Array.isArray(store.data) ? store.data[0] : store.data));
|
const entity = computed(() => store.data);
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
@ -56,7 +62,7 @@ async function fetch() {
|
||||||
store.filter = props.filter ?? {};
|
store.filter = props.filter ?? {};
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
const { data } = await arrayData.fetch({ append: false, updateRouter: false });
|
const { data } = await arrayData.fetch({ append: false, updateRouter: false });
|
||||||
emit('onFetch', Array.isArray(data) ? data[0] : data);
|
emit('onFetch', data);
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -203,4 +209,13 @@ async function fetch() {
|
||||||
.summaryHeader {
|
.summaryHeader {
|
||||||
color: $white;
|
color: $white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cardSummary :deep(.q-card__section[content]) {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
padding: 0;
|
||||||
|
> * {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -114,7 +114,7 @@ async function clearFilters() {
|
||||||
arrayData.resetPagination();
|
arrayData.resetPagination();
|
||||||
// Filtrar los params no removibles
|
// Filtrar los params no removibles
|
||||||
const removableFilters = Object.keys(userParams.value).filter((param) =>
|
const removableFilters = Object.keys(userParams.value).filter((param) =>
|
||||||
$props.unremovableParams.includes(param)
|
$props.unremovableParams.includes(param),
|
||||||
);
|
);
|
||||||
const newParams = {};
|
const newParams = {};
|
||||||
// Conservar solo los params que no son removibles
|
// Conservar solo los params que no son removibles
|
||||||
|
@ -162,13 +162,13 @@ const formatTags = (tags) => {
|
||||||
|
|
||||||
const tags = computed(() => {
|
const tags = computed(() => {
|
||||||
const filteredTags = tagsList.value.filter(
|
const filteredTags = tagsList.value.filter(
|
||||||
(tag) => !($props.customTags || []).includes(tag.label)
|
(tag) => !($props.customTags || []).includes(tag.label),
|
||||||
);
|
);
|
||||||
return formatTags(filteredTags);
|
return formatTags(filteredTags);
|
||||||
});
|
});
|
||||||
|
|
||||||
const customTags = computed(() =>
|
const customTags = computed(() =>
|
||||||
tagsList.value.filter((tag) => ($props.customTags || []).includes(tag.label))
|
tagsList.value.filter((tag) => ($props.customTags || []).includes(tag.label)),
|
||||||
);
|
);
|
||||||
|
|
||||||
async function remove(key) {
|
async function remove(key) {
|
||||||
|
@ -188,10 +188,13 @@ function formatValue(value) {
|
||||||
const getLocale = (label) => {
|
const getLocale = (label) => {
|
||||||
const param = label.split('.').at(-1);
|
const param = label.split('.').at(-1);
|
||||||
const globalLocale = `globals.params.${param}`;
|
const globalLocale = `globals.params.${param}`;
|
||||||
|
const moduleName = route.meta.moduleName;
|
||||||
|
const moduleLocale = `${moduleName.toLowerCase()}.${param}`;
|
||||||
if (te(globalLocale)) return t(globalLocale);
|
if (te(globalLocale)) return t(globalLocale);
|
||||||
else if (te(t(`params.${param}`)));
|
else if (te(moduleLocale)) return t(moduleLocale);
|
||||||
else {
|
else {
|
||||||
const camelCaseModuleName = route.meta.moduleName.charAt(0).toLowerCase() + route.meta.moduleName.slice(1);
|
const camelCaseModuleName =
|
||||||
|
moduleName.charAt(0).toLowerCase() + moduleName.slice(1);
|
||||||
return t(`${camelCaseModuleName}.params.${param}`);
|
return t(`${camelCaseModuleName}.params.${param}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { ref, reactive } from 'vue';
|
import { ref, reactive, useAttrs, computed } from 'vue';
|
||||||
import { onBeforeRouteLeave } from 'vue-router';
|
import { onBeforeRouteLeave } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
|
@ -16,12 +16,22 @@ import VnSelect from 'components/common/VnSelect.vue';
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
import VnInput from 'components/common/VnInput.vue';
|
import VnInput from 'components/common/VnInput.vue';
|
||||||
|
|
||||||
|
const emit = defineEmits(['onFetch']);
|
||||||
|
|
||||||
|
const $attrs = useAttrs();
|
||||||
|
|
||||||
|
const isRequired = computed(() => {
|
||||||
|
return Object.keys($attrs).includes('required')
|
||||||
|
});
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
url: { type: String, default: null },
|
url: { type: String, default: null },
|
||||||
|
saveUrl: {type: String, default: null},
|
||||||
filter: { type: Object, default: () => {} },
|
filter: { type: Object, default: () => {} },
|
||||||
body: { type: Object, default: () => {} },
|
body: { type: Object, default: () => {} },
|
||||||
addNote: { type: Boolean, default: false },
|
addNote: { type: Boolean, default: false },
|
||||||
selectType: { type: Boolean, default: false },
|
selectType: { type: Boolean, default: false },
|
||||||
|
justInput: { type: Boolean, default: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -29,6 +39,13 @@ const quasar = useQuasar();
|
||||||
const newNote = reactive({ text: null, observationTypeFk: null });
|
const newNote = reactive({ text: null, observationTypeFk: null });
|
||||||
const observationTypes = ref([]);
|
const observationTypes = ref([]);
|
||||||
const vnPaginateRef = ref();
|
const vnPaginateRef = ref();
|
||||||
|
let originalText;
|
||||||
|
|
||||||
|
function handleClick(e) {
|
||||||
|
if (e.shiftKey && e.key === 'Enter') return;
|
||||||
|
if ($props.justInput) confirmAndUpdate();
|
||||||
|
else insert();
|
||||||
|
}
|
||||||
|
|
||||||
async function insert() {
|
async function insert() {
|
||||||
if (!newNote.text || ($props.selectType && !newNote.observationTypeFk)) return;
|
if (!newNote.text || ($props.selectType && !newNote.observationTypeFk)) return;
|
||||||
|
@ -41,8 +58,36 @@ async function insert() {
|
||||||
await axios.post($props.url, newBody);
|
await axios.post($props.url, newBody);
|
||||||
await vnPaginateRef.value.fetch();
|
await vnPaginateRef.value.fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function confirmAndUpdate() {
|
||||||
|
if(!newNote.text && originalText)
|
||||||
|
quasar
|
||||||
|
.dialog({
|
||||||
|
component: VnConfirm,
|
||||||
|
componentProps: {
|
||||||
|
title: t('New note is empty'),
|
||||||
|
message: t('Are you sure remove this note?'),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.onOk(update)
|
||||||
|
.onCancel(() => {
|
||||||
|
newNote.text = originalText;
|
||||||
|
});
|
||||||
|
else update();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function update() {
|
||||||
|
originalText = newNote.text;
|
||||||
|
const body = $props.body;
|
||||||
|
const newBody = {
|
||||||
|
...body,
|
||||||
|
...{ notes: newNote.text },
|
||||||
|
};
|
||||||
|
await axios.patch(`${$props.saveUrl ?? `${$props.url}/${$props.body.workerFk}`}`, newBody);
|
||||||
|
}
|
||||||
|
|
||||||
onBeforeRouteLeave((to, from, next) => {
|
onBeforeRouteLeave((to, from, next) => {
|
||||||
if (newNote.text)
|
if ((newNote.text && !$props.justInput) || (newNote.text !== originalText) && $props.justInput)
|
||||||
quasar.dialog({
|
quasar.dialog({
|
||||||
component: VnConfirm,
|
component: VnConfirm,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
@ -53,6 +98,13 @@ onBeforeRouteLeave((to, from, next) => {
|
||||||
});
|
});
|
||||||
else next();
|
else next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function fetchData([ data ]) {
|
||||||
|
newNote.text = data?.notes;
|
||||||
|
originalText = data?.notes;
|
||||||
|
emit('onFetch', data);
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
@ -62,8 +114,19 @@ onBeforeRouteLeave((to, from, next) => {
|
||||||
auto-load
|
auto-load
|
||||||
@on-fetch="(data) => (observationTypes = data)"
|
@on-fetch="(data) => (observationTypes = data)"
|
||||||
/>
|
/>
|
||||||
<QCard class="q-pa-xs q-mb-lg full-width" v-if="$props.addNote">
|
<FetchData
|
||||||
<QCardSection horizontal>
|
v-if="justInput"
|
||||||
|
:url="url"
|
||||||
|
:filter="filter"
|
||||||
|
@on-fetch="fetchData"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
|
<QCard
|
||||||
|
class="q-pa-xs q-mb-lg full-width"
|
||||||
|
:class="{ 'just-input': $props.justInput }"
|
||||||
|
v-if="$props.addNote || $props.justInput"
|
||||||
|
>
|
||||||
|
<QCardSection horizontal v-if="!$props.justInput">
|
||||||
{{ t('New note') }}
|
{{ t('New note') }}
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<QCardSection class="q-px-xs q-my-none q-py-none">
|
<QCardSection class="q-px-xs q-my-none q-py-none">
|
||||||
|
@ -75,19 +138,19 @@ onBeforeRouteLeave((to, from, next) => {
|
||||||
v-model="newNote.observationTypeFk"
|
v-model="newNote.observationTypeFk"
|
||||||
option-label="description"
|
option-label="description"
|
||||||
style="flex: 0.15"
|
style="flex: 0.15"
|
||||||
:required="true"
|
:required="isRequired"
|
||||||
@keyup.enter.stop="insert"
|
@keyup.enter.stop="insert"
|
||||||
/>
|
/>
|
||||||
<VnInput
|
<VnInput
|
||||||
v-model.trim="newNote.text"
|
v-model.trim="newNote.text"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
:label="t('Add note here...')"
|
:label="$props.justInput && newNote.text ? '' : t('Add note here...')"
|
||||||
filled
|
filled
|
||||||
size="lg"
|
size="lg"
|
||||||
autogrow
|
autogrow
|
||||||
@keyup.enter.stop="insert"
|
@keyup.enter.stop="handleClick"
|
||||||
|
:required="isRequired"
|
||||||
clearable
|
clearable
|
||||||
:required="true"
|
|
||||||
>
|
>
|
||||||
<template #append>
|
<template #append>
|
||||||
<QBtn
|
<QBtn
|
||||||
|
@ -95,7 +158,7 @@ onBeforeRouteLeave((to, from, next) => {
|
||||||
icon="save"
|
icon="save"
|
||||||
color="primary"
|
color="primary"
|
||||||
flat
|
flat
|
||||||
@click="insert"
|
@click="handleClick"
|
||||||
class="q-mb-xs"
|
class="q-mb-xs"
|
||||||
dense
|
dense
|
||||||
data-cy="saveNote"
|
data-cy="saveNote"
|
||||||
|
@ -106,6 +169,7 @@ onBeforeRouteLeave((to, from, next) => {
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
</QCard>
|
</QCard>
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
|
v-if="!$props.justInput"
|
||||||
:data-key="$props.url"
|
:data-key="$props.url"
|
||||||
:url="$props.url"
|
:url="$props.url"
|
||||||
order="created DESC"
|
order="created DESC"
|
||||||
|
@ -198,6 +262,11 @@ onBeforeRouteLeave((to, from, next) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.just-input {
|
||||||
|
padding-right: 18px;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<i18n>
|
<i18n>
|
||||||
es:
|
es:
|
||||||
|
@ -205,4 +274,6 @@ onBeforeRouteLeave((to, from, next) => {
|
||||||
New note: Nueva nota
|
New note: Nueva nota
|
||||||
Save (Enter): Guardar (Intro)
|
Save (Enter): Guardar (Intro)
|
||||||
Observation type: Tipo de observación
|
Observation type: Tipo de observación
|
||||||
|
New note is empty: La nueva nota esta vacia
|
||||||
|
Are you sure remove this note?: Estas seguro de quitar esta nota?
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -49,7 +49,7 @@ function formatNumber(number) {
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
:data-key="$props.url"
|
:data-key="$props.url"
|
||||||
:url="$props.url"
|
:url="$props.url"
|
||||||
:filter="filter"
|
:user-filter="filter"
|
||||||
order="smsFk DESC"
|
order="smsFk DESC"
|
||||||
:offset="100"
|
:offset="100"
|
||||||
:limit="5"
|
:limit="5"
|
||||||
|
|
|
@ -19,23 +19,26 @@ onMounted(() => {
|
||||||
const observer = new MutationObserver(
|
const observer = new MutationObserver(
|
||||||
() =>
|
() =>
|
||||||
(hasContent.value =
|
(hasContent.value =
|
||||||
actions.value?.childNodes?.length + data.value?.childNodes?.length)
|
actions.value?.childNodes?.length + data.value?.childNodes?.length),
|
||||||
);
|
);
|
||||||
if (actions.value) observer.observe(actions.value, opts);
|
if (actions.value) observer.observe(actions.value, opts);
|
||||||
if (data.value) observer.observe(data.value, opts);
|
if (data.value) observer.observe(data.value, opts);
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => stateStore.toggleSubToolbar());
|
const actionsChildCount = () => !!actions.value?.childNodes?.length;
|
||||||
|
|
||||||
|
onBeforeUnmount(() => stateStore.toggleSubToolbar() && hasSubToolbar);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<QToolbar
|
<QToolbar
|
||||||
id="subToolbar"
|
id="subToolbar"
|
||||||
class="justify-end sticky"
|
|
||||||
v-show="hasContent || $slots['st-actions'] || $slots['st-data']"
|
v-show="hasContent || $slots['st-actions'] || $slots['st-data']"
|
||||||
|
class="justify-end sticky"
|
||||||
>
|
>
|
||||||
<slot name="st-data">
|
<slot name="st-data">
|
||||||
<div id="st-data"></div>
|
<div id="st-data" :class="{ 'full-width': !actionsChildCount() }">
|
||||||
|
</div>
|
||||||
</slot>
|
</slot>
|
||||||
<QSpace />
|
<QSpace />
|
||||||
<slot name="st-actions">
|
<slot name="st-actions">
|
||||||
|
|
|
@ -51,16 +51,6 @@ describe('CardSummary', () => {
|
||||||
expect(vm.store.filter).toEqual('cardFilter');
|
expect(vm.store.filter).toEqual('cardFilter');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should compute entity correctly from store data', () => {
|
|
||||||
vm.store.data = [{ id: 1, name: 'Entity 1' }];
|
|
||||||
expect(vm.entity).toEqual({ id: 1, name: 'Entity 1' });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle empty data gracefully', () => {
|
|
||||||
vm.store.data = [];
|
|
||||||
expect(vm.entity).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should respond to prop changes and refetch data', async () => {
|
it('should respond to prop changes and refetch data', async () => {
|
||||||
const newUrl = 'CardSummary/35';
|
const newUrl = 'CardSummary/35';
|
||||||
const newKey = 'cardSummaryKey/35';
|
const newKey = 'cardSummaryKey/35';
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe('useArrayData', () => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch and repalce url with new params', async () => {
|
it('should fetch and replace url with new params', async () => {
|
||||||
vi.spyOn(axios, 'get').mockReturnValueOnce({ data: [] });
|
vi.spyOn(axios, 'get').mockReturnValueOnce({ data: [] });
|
||||||
|
|
||||||
const arrayData = useArrayData('ArrayData', { url: 'mockUrl' });
|
const arrayData = useArrayData('ArrayData', { url: 'mockUrl' });
|
||||||
|
@ -33,11 +33,11 @@ describe('useArrayData', () => {
|
||||||
});
|
});
|
||||||
expect(routerReplace.path).toEqual('mockSection/list');
|
expect(routerReplace.path).toEqual('mockSection/list');
|
||||||
expect(JSON.parse(routerReplace.query.params)).toEqual(
|
expect(JSON.parse(routerReplace.query.params)).toEqual(
|
||||||
expect.objectContaining(params)
|
expect.objectContaining(params),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should get data and send new URL without keeping parameters, if there is only one record', async () => {
|
it('should get data and send new URL without keeping parameters, if there is only one record', async () => {
|
||||||
vi.spyOn(axios, 'get').mockReturnValueOnce({ data: [{ id: 1 }] });
|
vi.spyOn(axios, 'get').mockReturnValueOnce({ data: [{ id: 1 }] });
|
||||||
|
|
||||||
const arrayData = useArrayData('ArrayData', { url: 'mockUrl', navigate: {} });
|
const arrayData = useArrayData('ArrayData', { url: 'mockUrl', navigate: {} });
|
||||||
|
@ -56,7 +56,7 @@ describe('useArrayData', () => {
|
||||||
expect(routerPush.query).toBeUndefined();
|
expect(routerPush.query).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should get data and send new URL keeping parameters, if you have more than one record', async () => {
|
it('should get data and send new URL keeping parameters, if you have more than one record', async () => {
|
||||||
vi.spyOn(axios, 'get').mockReturnValueOnce({ data: [{ id: 1 }, { id: 2 }] });
|
vi.spyOn(axios, 'get').mockReturnValueOnce({ data: [{ id: 1 }, { id: 2 }] });
|
||||||
|
|
||||||
vi.spyOn(vueRouter, 'useRoute').mockReturnValue({
|
vi.spyOn(vueRouter, 'useRoute').mockReturnValue({
|
||||||
|
@ -95,4 +95,25 @@ describe('useArrayData', () => {
|
||||||
expect(routerPush.path).toEqual('mockName/');
|
expect(routerPush.path).toEqual('mockName/');
|
||||||
expect(routerPush.query.params).toBeDefined();
|
expect(routerPush.query.params).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return one record', async () => {
|
||||||
|
vi.spyOn(axios, 'get').mockReturnValueOnce({
|
||||||
|
data: [
|
||||||
|
{ id: 1, name: 'Entity 1' },
|
||||||
|
{ id: 2, name: 'Entity 2' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
const arrayData = useArrayData('ArrayData', { url: 'mockUrl', oneRecord: true });
|
||||||
|
await arrayData.fetch({});
|
||||||
|
|
||||||
|
expect(arrayData.store.data).toEqual({ id: 1, name: 'Entity 1' });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle empty data gracefully if has to return one record', async () => {
|
||||||
|
vi.spyOn(axios, 'get').mockReturnValueOnce({ data: [] });
|
||||||
|
const arrayData = useArrayData('ArrayData', { url: 'mockUrl', oneRecord: true });
|
||||||
|
await arrayData.fetch({});
|
||||||
|
|
||||||
|
expect(arrayData.store.data).toBeUndefined();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -57,6 +57,7 @@ export function useArrayData(key, userOptions) {
|
||||||
'navigate',
|
'navigate',
|
||||||
'mapKey',
|
'mapKey',
|
||||||
'keepData',
|
'keepData',
|
||||||
|
'oneRecord',
|
||||||
];
|
];
|
||||||
if (typeof userOptions === 'object') {
|
if (typeof userOptions === 'object') {
|
||||||
for (const option in userOptions) {
|
for (const option in userOptions) {
|
||||||
|
@ -93,6 +94,9 @@ export function useArrayData(key, userOptions) {
|
||||||
|
|
||||||
if (params.filter.where || exprFilter)
|
if (params.filter.where || exprFilter)
|
||||||
params.filter.where = { ...params.filter.where, ...exprFilter };
|
params.filter.where = { ...params.filter.where, ...exprFilter };
|
||||||
|
|
||||||
|
if (!params?.filter?.order?.length) delete params?.filter?.order;
|
||||||
|
|
||||||
params.filter = JSON.stringify(params.filter);
|
params.filter = JSON.stringify(params.filter);
|
||||||
|
|
||||||
store.isLoading = true;
|
store.isLoading = true;
|
||||||
|
@ -109,7 +113,11 @@ export function useArrayData(key, userOptions) {
|
||||||
store.isLoading = false;
|
store.isLoading = false;
|
||||||
canceller = null;
|
canceller = null;
|
||||||
|
|
||||||
processData(response.data, { map: !!store.mapKey, append });
|
processData(response.data, {
|
||||||
|
map: !!store.mapKey,
|
||||||
|
append,
|
||||||
|
oneRecord: store.oneRecord,
|
||||||
|
});
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
@ -311,7 +319,11 @@ export function useArrayData(key, userOptions) {
|
||||||
return { params, limit };
|
return { params, limit };
|
||||||
}
|
}
|
||||||
|
|
||||||
function processData(data, { map = true, append = true }) {
|
function processData(data, { map = true, append = true, oneRecord = false }) {
|
||||||
|
if (oneRecord) {
|
||||||
|
store.data = Array.isArray(data) ? data[0] : data;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!append) {
|
if (!append) {
|
||||||
store.data = [];
|
store.data = [];
|
||||||
store.map = new Map();
|
store.map = new Map();
|
||||||
|
|
|
@ -212,6 +212,10 @@ select:-webkit-autofill {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.q-card__section[dense] {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
input[type='number'] {
|
input[type='number'] {
|
||||||
-moz-appearance: textfield;
|
-moz-appearance: textfield;
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,10 +332,13 @@ globals:
|
||||||
wasteRecalc: Waste recaclulate
|
wasteRecalc: Waste recaclulate
|
||||||
operator: Operator
|
operator: Operator
|
||||||
parking: Parking
|
parking: Parking
|
||||||
|
vehicleList: Vehicles
|
||||||
|
vehicle: Vehicle
|
||||||
unsavedPopup:
|
unsavedPopup:
|
||||||
title: Unsaved changes will be lost
|
title: Unsaved changes will be lost
|
||||||
subtitle: Are you sure exit without saving?
|
subtitle: Are you sure exit without saving?
|
||||||
params:
|
params:
|
||||||
|
description: Description
|
||||||
clientFk: Client id
|
clientFk: Client id
|
||||||
salesPersonFk: Sales person
|
salesPersonFk: Sales person
|
||||||
warehouseFk: Warehouse
|
warehouseFk: Warehouse
|
||||||
|
@ -358,7 +361,13 @@ globals:
|
||||||
correctingFk: Rectificative
|
correctingFk: Rectificative
|
||||||
daysOnward: Days onward
|
daysOnward: Days onward
|
||||||
countryFk: Country
|
countryFk: Country
|
||||||
|
countryCodeFk: Country
|
||||||
companyFk: Company
|
companyFk: Company
|
||||||
|
model: Model
|
||||||
|
fuel: Fuel
|
||||||
|
active: Active
|
||||||
|
inactive: Inactive
|
||||||
|
deliveryPoint: Delivery point
|
||||||
errors:
|
errors:
|
||||||
statusUnauthorized: Access denied
|
statusUnauthorized: Access denied
|
||||||
statusInternalServerError: An internal server error has ocurred
|
statusInternalServerError: An internal server error has ocurred
|
||||||
|
@ -626,6 +635,8 @@ wagon:
|
||||||
name: Name
|
name: Name
|
||||||
|
|
||||||
supplier:
|
supplier:
|
||||||
|
search: Search supplier
|
||||||
|
searchInfo: Search supplier by id or name
|
||||||
list:
|
list:
|
||||||
payMethod: Pay method
|
payMethod: Pay method
|
||||||
account: Account
|
account: Account
|
||||||
|
|
|
@ -332,10 +332,13 @@ globals:
|
||||||
wasteRecalc: Recalcular mermas
|
wasteRecalc: Recalcular mermas
|
||||||
operator: Operario
|
operator: Operario
|
||||||
parking: Parking
|
parking: Parking
|
||||||
|
vehicleList: Vehículos
|
||||||
|
vehicle: Vehículo
|
||||||
unsavedPopup:
|
unsavedPopup:
|
||||||
title: Los cambios que no haya guardado se perderán
|
title: Los cambios que no haya guardado se perderán
|
||||||
subtitle: ¿Seguro que quiere salir sin guardar?
|
subtitle: ¿Seguro que quiere salir sin guardar?
|
||||||
params:
|
params:
|
||||||
|
description: Descripción
|
||||||
clientFk: Id cliente
|
clientFk: Id cliente
|
||||||
salesPersonFk: Comercial
|
salesPersonFk: Comercial
|
||||||
warehouseFk: Almacén
|
warehouseFk: Almacén
|
||||||
|
@ -356,6 +359,7 @@ globals:
|
||||||
daysOnward: Días adelante
|
daysOnward: Días adelante
|
||||||
packing: ITP
|
packing: ITP
|
||||||
countryFk: País
|
countryFk: País
|
||||||
|
countryCodeFk: País
|
||||||
companyFk: Empresa
|
companyFk: Empresa
|
||||||
errors:
|
errors:
|
||||||
statusUnauthorized: Acceso denegado
|
statusUnauthorized: Acceso denegado
|
||||||
|
@ -640,6 +644,8 @@ wagon:
|
||||||
volume: Volumen
|
volume: Volumen
|
||||||
name: Nombre
|
name: Nombre
|
||||||
supplier:
|
supplier:
|
||||||
|
search: Buscar proveedor
|
||||||
|
searchInfo: Buscar proveedor por id o nombre
|
||||||
list:
|
list:
|
||||||
payMethod: Método de pago
|
payMethod: Método de pago
|
||||||
account: Cuenta
|
account: Cuenta
|
||||||
|
@ -647,6 +653,7 @@ supplier:
|
||||||
tableVisibleColumns:
|
tableVisibleColumns:
|
||||||
nif: NIF/CIF
|
nif: NIF/CIF
|
||||||
account: Cuenta
|
account: Cuenta
|
||||||
|
|
||||||
summary:
|
summary:
|
||||||
responsible: Responsable
|
responsible: Responsable
|
||||||
verified: Verificado
|
verified: Verificado
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import Navbar from 'src/components/NavBar.vue';
|
import Navbar from 'src/components/NavBar.vue';
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<QLayout view="hHh LpR fFf" v-shortcut>
|
<QLayout view="hHh LpR fFf">
|
||||||
<Navbar />
|
<Navbar />
|
||||||
<RouterView></RouterView>
|
<RouterView></RouterView>
|
||||||
<QFooter v-if="$q.platform.is.mobile"></QFooter>
|
<QFooter v-if="$q.platform.is.mobile"></QFooter>
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { Dark, Quasar } from 'quasar';
|
import { Dark, Quasar } from 'quasar';
|
||||||
import { computed } from 'vue';
|
import { computed, onMounted } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { localeEquivalence } from 'src/i18n/index';
|
import { localeEquivalence } from 'src/i18n/index';
|
||||||
import quasarLang from 'src/utils/quasarLang';
|
import quasarLang from 'src/utils/quasarLang';
|
||||||
|
import { langs } from 'src/boot/defaults/constants.js';
|
||||||
|
|
||||||
const { t, locale } = useI18n();
|
const { t, locale } = useI18n();
|
||||||
|
|
||||||
const userLocale = computed({
|
const userLocale = computed({
|
||||||
get() {
|
get() {
|
||||||
return locale.value;
|
return locale.value;
|
||||||
|
@ -28,7 +28,6 @@ const darkMode = computed({
|
||||||
Dark.set(value);
|
Dark.set(value);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const langs = ['en', 'es'];
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { useI18n } from 'vue-i18n';
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import VnTable from 'components/VnTable/VnTable.vue';
|
import VnTable from 'components/VnTable/VnTable.vue';
|
||||||
import VnSection from 'src/components/common/VnSection.vue';
|
import VnSection from 'src/components/common/VnSection.vue';
|
||||||
|
import exprBuilder from './Alias/AliasExprBuilder';
|
||||||
|
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -31,15 +32,6 @@ const columns = computed(() => [
|
||||||
create: true,
|
create: true,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const exprBuilder = (param, value) => {
|
|
||||||
switch (param) {
|
|
||||||
case 'search':
|
|
||||||
return /^\d+$/.test(value)
|
|
||||||
? { id: value }
|
|
||||||
: { alias: { like: `%${value}%` } };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -46,7 +46,7 @@ const killSession = async ({ userId, created }) => {
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
:data-key="urlPath"
|
:data-key="urlPath"
|
||||||
ref="paginateRef"
|
ref="paginateRef"
|
||||||
:filter="filter"
|
:user-filter="filter"
|
||||||
:url="urlPath"
|
:url="urlPath"
|
||||||
order="created DESC"
|
order="created DESC"
|
||||||
auto-load
|
auto-load
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
export default (param, value) => {
|
||||||
|
switch (param) {
|
||||||
|
case 'search':
|
||||||
|
return /^\d+$/.test(value)
|
||||||
|
? { id: value }
|
||||||
|
: {
|
||||||
|
or: [
|
||||||
|
{ name: { like: `%${value}%` } },
|
||||||
|
{ nickname: { like: `%${value}%` } },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
case 'name':
|
||||||
|
case 'nickname':
|
||||||
|
return { [param]: { like: `%${value}%` } };
|
||||||
|
case 'roleFk':
|
||||||
|
return { [param]: value };
|
||||||
|
}
|
||||||
|
};
|
|
@ -4,15 +4,16 @@ import { computed, ref } from 'vue';
|
||||||
import VnTable from 'components/VnTable/VnTable.vue';
|
import VnTable from 'components/VnTable/VnTable.vue';
|
||||||
import AccountSummary from './Card/AccountSummary.vue';
|
import AccountSummary from './Card/AccountSummary.vue';
|
||||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||||
|
import exprBuilder from './AccountExprBuilder.js';
|
||||||
|
import filter from './Card/AccountFilter.js';
|
||||||
import VnSection from 'src/components/common/VnSection.vue';
|
import VnSection from 'src/components/common/VnSection.vue';
|
||||||
import FetchData from 'src/components/FetchData.vue';
|
import FetchData from 'src/components/FetchData.vue';
|
||||||
import VnInputPassword from 'src/components/common/VnInputPassword.vue';
|
import VnInputPassword from 'src/components/common/VnInputPassword.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { viewSummary } = useSummaryDialog();
|
const { viewSummary } = useSummaryDialog();
|
||||||
const filter = {
|
const tableRef = ref();
|
||||||
include: { relation: 'role', scope: { fields: ['id', 'name'] } },
|
|
||||||
};
|
|
||||||
const dataKey = 'AccountList';
|
const dataKey = 'AccountList';
|
||||||
const roles = ref([]);
|
const roles = ref([]);
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
|
@ -117,25 +118,6 @@ const columns = computed(() => [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function exprBuilder(param, value) {
|
|
||||||
switch (param) {
|
|
||||||
case 'search':
|
|
||||||
return /^\d+$/.test(value)
|
|
||||||
? { id: value }
|
|
||||||
: {
|
|
||||||
or: [
|
|
||||||
{ name: { like: `%${value}%` } },
|
|
||||||
{ nickname: { like: `%${value}%` } },
|
|
||||||
],
|
|
||||||
};
|
|
||||||
case 'name':
|
|
||||||
case 'nickname':
|
|
||||||
return { [param]: { like: `%${value}%` } };
|
|
||||||
case 'roleFk':
|
|
||||||
return { [param]: value };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData url="VnRoles" @on-fetch="(data) => (roles = data)" auto-load />
|
<FetchData url="VnRoles" @on-fetch="(data) => (roles = data)" auto-load />
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default (param, value) => {
|
||||||
|
switch (param) {
|
||||||
|
case 'search':
|
||||||
|
return /^\d+$/.test(value)
|
||||||
|
? { id: value }
|
||||||
|
: { alias: { like: `%${value}%` } };
|
||||||
|
}
|
||||||
|
};
|
|
@ -1,21 +1,13 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
||||||
import AliasDescriptor from './AliasDescriptor.vue';
|
import AliasDescriptor from './AliasDescriptor.vue';
|
||||||
const { t } = useI18n();
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnCardBeta
|
<VnCardBeta
|
||||||
data-key="Alias"
|
data-key="Alias"
|
||||||
base-url="MailAliases"
|
url="MailAliases"
|
||||||
:descriptor="AliasDescriptor"
|
:descriptor="AliasDescriptor"
|
||||||
search-data-key="AccountAliasList"
|
search-data-key="AccountAliasList"
|
||||||
:searchbar-props="{
|
|
||||||
url: 'MailAliases',
|
|
||||||
info: t('mailAlias.searchInfo'),
|
|
||||||
label: t('mailAlias.search'),
|
|
||||||
searchUrl: 'table',
|
|
||||||
}"
|
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { useQuasar } from 'quasar';
|
||||||
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
||||||
import VnLv from 'src/components/ui/VnLv.vue';
|
import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
|
|
||||||
import useCardDescription from 'src/composables/useCardDescription';
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
|
|
||||||
|
@ -29,9 +28,6 @@ const entityId = computed(() => {
|
||||||
return $props.id || route.params.id;
|
return $props.id || route.params.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = ref(useCardDescription());
|
|
||||||
const setData = (entity) => (data.value = useCardDescription(entity.alias, entity.id));
|
|
||||||
|
|
||||||
const removeAlias = () => {
|
const removeAlias = () => {
|
||||||
quasar
|
quasar
|
||||||
.dialog({
|
.dialog({
|
||||||
|
@ -56,10 +52,8 @@ const removeAlias = () => {
|
||||||
ref="descriptor"
|
ref="descriptor"
|
||||||
:url="`MailAliases/${entityId}`"
|
:url="`MailAliases/${entityId}`"
|
||||||
module="Alias"
|
module="Alias"
|
||||||
@on-fetch="setData"
|
data-key="Alias"
|
||||||
data-key="aliasData"
|
title="alias"
|
||||||
:title="data.title"
|
|
||||||
:subtitle="data.subtitle"
|
|
||||||
>
|
>
|
||||||
<template #menu>
|
<template #menu>
|
||||||
<QItem v-ripple clickable @click="removeAlias()">
|
<QItem v-ripple clickable @click="removeAlias()">
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
import CardSummary from 'components/ui/CardSummary.vue';
|
import CardSummary from 'components/ui/CardSummary.vue';
|
||||||
import VnLv from 'src/components/ui/VnLv.vue';
|
import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
|
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
@ -18,20 +16,15 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { store } = useArrayData('Alias');
|
|
||||||
const alias = ref(store.data);
|
|
||||||
const entityId = computed(() => $props.id || route.params.id);
|
const entityId = computed(() => $props.id || route.params.id);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<CardSummary
|
<CardSummary ref="summary" :url="`MailAliases/${entityId}`" data-key="Alias">
|
||||||
ref="summary"
|
<template #header="{ entity: alias }">
|
||||||
:url="`MailAliases/${entityId}`"
|
{{ alias.id }} - {{ alias.alias }}
|
||||||
@on-fetch="(data) => (alias = data)"
|
</template>
|
||||||
data-key="MailAliasesSummary"
|
<template #body="{ entity: alias }">
|
||||||
>
|
|
||||||
<template #header> {{ alias.id }} - {{ alias.alias }} </template>
|
|
||||||
<template #body>
|
|
||||||
<QCard class="vn-one">
|
<QCard class="vn-one">
|
||||||
<QCardSection class="q-pa-none">
|
<QCardSection class="q-pa-none">
|
||||||
<router-link
|
<router-link
|
||||||
|
|
|
@ -69,7 +69,7 @@ const fetchAliases = () => paginateRef.value.fetch();
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
ref="paginateRef"
|
ref="paginateRef"
|
||||||
data-key="AliasUsers"
|
data-key="AliasUsers"
|
||||||
:filter="filter"
|
:user-filter="filter"
|
||||||
:url="urlPath"
|
:url="urlPath"
|
||||||
:limit="0"
|
:limit="0"
|
||||||
auto-load
|
auto-load
|
||||||
|
|
|
@ -1,46 +1,20 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
import VnSelectEnum from 'src/components/common/VnSelectEnum.vue';
|
import VnSelectEnum from 'src/components/common/VnSelectEnum.vue';
|
||||||
import FormModel from 'components/FormModel.vue';
|
import FormModel from 'components/FormModel.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
import { ref, watch } from 'vue';
|
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
const { t } = useI18n();
|
|
||||||
const formModelRef = ref(null);
|
|
||||||
|
|
||||||
const accountFilter = {
|
|
||||||
where: { id: route.params.id },
|
|
||||||
fields: ['id', 'email', 'nickname', 'name', 'accountStateFk', 'packages', 'pickup'],
|
|
||||||
include: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => route.params.id,
|
|
||||||
() => formModelRef.value.reset()
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FormModel
|
<FormModel :url-update="`VnUsers/${$route.params.id}/update-user`" model="Account">
|
||||||
ref="formModelRef"
|
|
||||||
url="VnUsers/preview"
|
|
||||||
:url-update="`VnUsers/${route.params.id}/update-user`"
|
|
||||||
:filter="accountFilter"
|
|
||||||
model="Accounts"
|
|
||||||
auto-load
|
|
||||||
@on-data-saved="formModelRef.fetch()"
|
|
||||||
>
|
|
||||||
<template #form="{ data }">
|
<template #form="{ data }">
|
||||||
<div class="q-gutter-y-sm">
|
<div class="q-gutter-y-sm">
|
||||||
<VnInput v-model="data.name" :label="t('account.card.nickname')" />
|
<VnInput v-model="data.name" :label="$t('account.card.nickname')" />
|
||||||
<VnInput v-model="data.nickname" :label="t('account.card.alias')" />
|
<VnInput v-model="data.nickname" :label="$t('account.card.alias')" />
|
||||||
<VnInput v-model="data.email" :label="t('globals.params.email')" />
|
<VnInput v-model="data.email" :label="$t('globals.params.email')" />
|
||||||
<VnSelect
|
<VnSelect
|
||||||
url="Languages"
|
url="Languages"
|
||||||
v-model="data.lang"
|
v-model="data.lang"
|
||||||
:label="t('account.card.lang')"
|
:label="$t('account.card.lang')"
|
||||||
option-value="code"
|
option-value="code"
|
||||||
option-label="code"
|
option-label="code"
|
||||||
/>
|
/>
|
||||||
|
@ -49,7 +23,7 @@ watch(
|
||||||
table="user"
|
table="user"
|
||||||
column="twoFactor"
|
column="twoFactor"
|
||||||
v-model="data.twoFactor"
|
v-model="data.twoFactor"
|
||||||
:label="t('account.card.twoFactor')"
|
:label="$t('account.card.twoFactor')"
|
||||||
option-value="code"
|
option-value="code"
|
||||||
option-label="code"
|
option-label="code"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
||||||
import AccountDescriptor from './AccountDescriptor.vue';
|
import AccountDescriptor from './AccountDescriptor.vue';
|
||||||
|
import filter from './AccountFilter.js';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnCardBeta data-key="AccountId" :descriptor="AccountDescriptor" />
|
<VnCardBeta
|
||||||
|
url="VnUsers/preview"
|
||||||
|
:id-in-where="true"
|
||||||
|
data-key="Account"
|
||||||
|
:descriptor="AccountDescriptor"
|
||||||
|
:filter="filter"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,36 +1,18 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted } from 'vue';
|
import { ref, computed, onMounted } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
||||||
import VnLv from 'src/components/ui/VnLv.vue';
|
import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
import useCardDescription from 'src/composables/useCardDescription';
|
|
||||||
import AccountDescriptorMenu from './AccountDescriptorMenu.vue';
|
import AccountDescriptorMenu from './AccountDescriptorMenu.vue';
|
||||||
import VnImg from 'src/components/ui/VnImg.vue';
|
import VnImg from 'src/components/ui/VnImg.vue';
|
||||||
|
import filter from './AccountFilter.js';
|
||||||
import useHasAccount from 'src/composables/useHasAccount.js';
|
import useHasAccount from 'src/composables/useHasAccount.js';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({ id: { type: Number, default: null } });
|
||||||
id: {
|
|
||||||
type: Number,
|
|
||||||
required: false,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const { t } = useI18n();
|
const entityId = computed(() => $props.id || route.params.id);
|
||||||
const entityId = computed(() => {
|
|
||||||
return $props.id || route.params.id;
|
|
||||||
});
|
|
||||||
const data = ref(useCardDescription());
|
|
||||||
const hasAccount = ref();
|
const hasAccount = ref();
|
||||||
const setData = (entity) => (data.value = useCardDescription(entity.nickname, entity.id));
|
|
||||||
|
|
||||||
const filter = {
|
|
||||||
where: { id: entityId },
|
|
||||||
fields: ['id', 'nickname', 'name', 'role'],
|
|
||||||
include: { relation: 'role', scope: { fields: ['id', 'name'] } },
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
hasAccount.value = await useHasAccount(entityId.value);
|
hasAccount.value = await useHasAccount(entityId.value);
|
||||||
|
@ -43,10 +25,8 @@ onMounted(async () => {
|
||||||
:url="`VnUsers/preview`"
|
:url="`VnUsers/preview`"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
module="Account"
|
module="Account"
|
||||||
@on-fetch="setData"
|
data-key="Account"
|
||||||
data-key="AccountId"
|
title="nickname"
|
||||||
:title="data.title"
|
|
||||||
:subtitle="data.subtitle"
|
|
||||||
>
|
>
|
||||||
<template #menu>
|
<template #menu>
|
||||||
<AccountDescriptorMenu :entity-id="entityId" />
|
<AccountDescriptorMenu :entity-id="entityId" />
|
||||||
|
@ -62,7 +42,7 @@ onMounted(async () => {
|
||||||
<QIcon name="vn:claims" />
|
<QIcon name="vn:claims" />
|
||||||
</div>
|
</div>
|
||||||
<div class="text-grey-5" style="opacity: 0.4">
|
<div class="text-grey-5" style="opacity: 0.4">
|
||||||
{{ t('account.imageNotFound') }}
|
{{ $t('account.imageNotFound') }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -70,8 +50,8 @@ onMounted(async () => {
|
||||||
</VnImg>
|
</VnImg>
|
||||||
</template>
|
</template>
|
||||||
<template #body="{ entity }">
|
<template #body="{ entity }">
|
||||||
<VnLv :label="t('account.card.nickname')" :value="entity.name" />
|
<VnLv :label="$t('account.card.nickname')" :value="entity.name" />
|
||||||
<VnLv :label="t('account.card.role')" :value="entity.role.name" />
|
<VnLv :label="$t('account.card.role')" :value="entity.role?.name" />
|
||||||
</template>
|
</template>
|
||||||
<template #actions="{ entity }">
|
<template #actions="{ entity }">
|
||||||
<QCardActions class="q-gutter-x-md">
|
<QCardActions class="q-gutter-x-md">
|
||||||
|
@ -84,7 +64,7 @@ onMounted(async () => {
|
||||||
size="sm"
|
size="sm"
|
||||||
class="fill-icon"
|
class="fill-icon"
|
||||||
>
|
>
|
||||||
<QTooltip>{{ t('account.card.deactivated') }}</QTooltip>
|
<QTooltip>{{ $t('account.card.deactivated') }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon
|
<QIcon
|
||||||
color="primary"
|
color="primary"
|
||||||
|
@ -95,7 +75,7 @@ onMounted(async () => {
|
||||||
size="sm"
|
size="sm"
|
||||||
class="fill-icon"
|
class="fill-icon"
|
||||||
>
|
>
|
||||||
<QTooltip>{{ t('account.card.enabled') }}</QTooltip>
|
<QTooltip>{{ $t('account.card.enabled') }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
</QCardActions>
|
</QCardActions>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -29,7 +29,7 @@ const router = useRouter();
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const user = state.getUser();
|
const user = state.getUser();
|
||||||
const { notify } = useQuasar();
|
const { notify } = useQuasar();
|
||||||
const account = computed(() => useArrayData('AccountId').store.data[0]);
|
const account = computed(() => useArrayData('Account').store.data[0]);
|
||||||
account.value.hasAccount = hasAccount.value;
|
account.value.hasAccount = hasAccount.value;
|
||||||
const entityId = computed(() => +route.params.id);
|
const entityId = computed(() => +route.params.id);
|
||||||
const hasitManagementAccess = ref();
|
const hasitManagementAccess = ref();
|
||||||
|
@ -152,7 +152,7 @@ onMounted(() => {
|
||||||
openConfirmationModal(
|
openConfirmationModal(
|
||||||
t('account.card.actions.disableAccount.title'),
|
t('account.card.actions.disableAccount.title'),
|
||||||
t('account.card.actions.disableAccount.subtitle'),
|
t('account.card.actions.disableAccount.subtitle'),
|
||||||
() => deleteAccount()
|
() => deleteAccount(),
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
@ -177,7 +177,7 @@ onMounted(() => {
|
||||||
openConfirmationModal(
|
openConfirmationModal(
|
||||||
t('account.card.actions.enableAccount.title'),
|
t('account.card.actions.enableAccount.title'),
|
||||||
t('account.card.actions.enableAccount.subtitle'),
|
t('account.card.actions.enableAccount.subtitle'),
|
||||||
() => updateStatusAccount(true)
|
() => updateStatusAccount(true),
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
@ -191,7 +191,7 @@ onMounted(() => {
|
||||||
openConfirmationModal(
|
openConfirmationModal(
|
||||||
t('account.card.actions.disableAccount.title'),
|
t('account.card.actions.disableAccount.title'),
|
||||||
t('account.card.actions.disableAccount.subtitle'),
|
t('account.card.actions.disableAccount.subtitle'),
|
||||||
() => updateStatusAccount(false)
|
() => updateStatusAccount(false),
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
@ -206,7 +206,7 @@ onMounted(() => {
|
||||||
openConfirmationModal(
|
openConfirmationModal(
|
||||||
t('account.card.actions.activateUser.title'),
|
t('account.card.actions.activateUser.title'),
|
||||||
t('account.card.actions.activateUser.title'),
|
t('account.card.actions.activateUser.title'),
|
||||||
() => updateStatusUser(true)
|
() => updateStatusUser(true),
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
@ -220,7 +220,7 @@ onMounted(() => {
|
||||||
openConfirmationModal(
|
openConfirmationModal(
|
||||||
t('account.card.actions.deactivateUser.title'),
|
t('account.card.actions.deactivateUser.title'),
|
||||||
t('account.card.actions.deactivateUser.title'),
|
t('account.card.actions.deactivateUser.title'),
|
||||||
() => updateStatusUser(false)
|
() => updateStatusUser(false),
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
export default {
|
||||||
|
include: { relation: 'role', scope: { fields: ['id', 'name'] } },
|
||||||
|
};
|
|
@ -86,7 +86,7 @@ watch(
|
||||||
() => route.params.id,
|
() => route.params.id,
|
||||||
() => {
|
() => {
|
||||||
getAccountData();
|
getAccountData();
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
onMounted(async () => await getAccountData(false));
|
onMounted(async () => await getAccountData(false));
|
||||||
|
@ -99,7 +99,7 @@ onMounted(async () => await getAccountData(false));
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
ref="paginateRef"
|
ref="paginateRef"
|
||||||
data-key="AccountMailAliases"
|
data-key="AccountMailAliases"
|
||||||
:filter="filter"
|
:user-filter="filter"
|
||||||
:url="urlPath"
|
:url="urlPath"
|
||||||
auto-load
|
auto-load
|
||||||
>
|
>
|
||||||
|
@ -130,7 +130,8 @@ onMounted(async () => await getAccountData(false));
|
||||||
openConfirmationModal(
|
openConfirmationModal(
|
||||||
t('User will be removed from alias'),
|
t('User will be removed from alias'),
|
||||||
t('¿Seguro que quieres continuar?'),
|
t('¿Seguro que quieres continuar?'),
|
||||||
() => deleteMailAlias(row, rows, rowIndex)
|
() =>
|
||||||
|
deleteMailAlias(row, rows, rowIndex),
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
@ -157,7 +158,7 @@ onMounted(async () => await getAccountData(false));
|
||||||
icon="add"
|
icon="add"
|
||||||
color="primary"
|
color="primary"
|
||||||
@click="openCreateMailAliasForm()"
|
@click="openCreateMailAliasForm()"
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
>
|
>
|
||||||
<QTooltip>{{ t('warehouses.add') }}</QTooltip>
|
<QTooltip>{{ t('warehouses.add') }}</QTooltip>
|
||||||
</QBtn>
|
</QBtn>
|
||||||
|
|
|
@ -1,58 +1,41 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
import CardSummary from 'components/ui/CardSummary.vue';
|
import CardSummary from 'components/ui/CardSummary.vue';
|
||||||
import VnLv from 'src/components/ui/VnLv.vue';
|
import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
|
import filter from './AccountFilter.js';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
|
||||||
import AccountDescriptorMenu from './AccountDescriptorMenu.vue';
|
import AccountDescriptorMenu from './AccountDescriptorMenu.vue';
|
||||||
|
|
||||||
|
const $props = defineProps({ id: { type: Number, default: 0 } });
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
const $props = defineProps({
|
|
||||||
id: {
|
|
||||||
type: Number,
|
|
||||||
default: 0,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const { store } = useArrayData('Account');
|
|
||||||
const account = ref(store.data);
|
|
||||||
|
|
||||||
const entityId = computed(() => $props.id || route.params.id);
|
const entityId = computed(() => $props.id || route.params.id);
|
||||||
const filter = {
|
|
||||||
where: { id: entityId },
|
|
||||||
fields: ['id', 'nickname', 'name', 'role'],
|
|
||||||
include: { relation: 'role', scope: { fields: ['id', 'name'] } },
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<CardSummary
|
<CardSummary
|
||||||
data-key="AccountId"
|
data-key="Account"
|
||||||
|
ref="AccountSummary"
|
||||||
url="VnUsers/preview"
|
url="VnUsers/preview"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
@on-fetch="(data) => (account = data)"
|
|
||||||
>
|
>
|
||||||
<template #header>{{ account.id }} - {{ account.nickname }}</template>
|
<template #header="{ entity }">{{ entity.id }} - {{ entity.nickname }}</template>
|
||||||
<template #menu="">
|
<template #menu>
|
||||||
<AccountDescriptorMenu :entity-id="entityId" />
|
<AccountDescriptorMenu :entity-id="entityId" />
|
||||||
</template>
|
</template>
|
||||||
<template #body>
|
<template #body="{ entity }">
|
||||||
<QCard class="vn-one">
|
<QCard class="vn-one">
|
||||||
<QCardSection class="q-pa-none">
|
<QCardSection class="q-pa-none">
|
||||||
<router-link
|
<router-link
|
||||||
:to="{ name: 'AccountBasicData', params: { id: entityId } }"
|
:to="{ name: 'AccountBasicData', params: { id: entityId } }"
|
||||||
class="header header-link"
|
class="header header-link"
|
||||||
>
|
>
|
||||||
{{ t('globals.pageTitles.basicData') }}
|
{{ $t('globals.pageTitles.basicData') }}
|
||||||
<QIcon name="open_in_new" />
|
<QIcon name="open_in_new" />
|
||||||
</router-link>
|
</router-link>
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<VnLv :label="t('account.card.nickname')" :value="account.name" />
|
<VnLv :label="$t('account.card.nickname')" :value="entity.name" />
|
||||||
<VnLv :label="t('account.card.role')" :value="account.role.name" />
|
<VnLv :label="$t('account.card.role')" :value="entity.role?.name" />
|
||||||
</QCard>
|
</QCard>
|
||||||
</template>
|
</template>
|
||||||
</CardSummary>
|
</CardSummary>
|
||||||
|
|
|
@ -59,7 +59,7 @@ const redirectToRoleSummary = (id) =>
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
ref="paginateRef"
|
ref="paginateRef"
|
||||||
:data-key="dataKey"
|
:data-key="dataKey"
|
||||||
:filter="filter"
|
:user-filter="filter"
|
||||||
:url="urlPath"
|
:url="urlPath"
|
||||||
:limit="0"
|
:limit="0"
|
||||||
auto-load
|
auto-load
|
||||||
|
|
|
@ -5,6 +5,7 @@ import VnTable from 'components/VnTable/VnTable.vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||||
import RoleSummary from './Card/RoleSummary.vue';
|
import RoleSummary from './Card/RoleSummary.vue';
|
||||||
|
import exprBuilder from './RoleExprBuilder.js';
|
||||||
import VnSection from 'src/components/common/VnSection.vue';
|
import VnSection from 'src/components/common/VnSection.vue';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
@ -66,24 +67,7 @@ const columns = computed(() => [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
const exprBuilder = (param, value) => {
|
|
||||||
switch (param) {
|
|
||||||
case 'search':
|
|
||||||
return /^\d+$/.test(value)
|
|
||||||
? { id: value }
|
|
||||||
: {
|
|
||||||
or: [
|
|
||||||
{ name: { like: `%${value}%` } },
|
|
||||||
{ nickname: { like: `%${value}%` } },
|
|
||||||
],
|
|
||||||
};
|
|
||||||
case 'name':
|
|
||||||
case 'description':
|
|
||||||
return { [param]: { like: `%${value}%` } };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnSection
|
<VnSection
|
||||||
:data-key="dataKey"
|
:data-key="dataKey"
|
||||||
|
|
|
@ -58,7 +58,7 @@ const redirectToRoleSummary = (id) =>
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
ref="paginateRef"
|
ref="paginateRef"
|
||||||
data-key="InheritedRoles"
|
data-key="InheritedRoles"
|
||||||
:filter="filter"
|
:user-filter="filter"
|
||||||
:url="urlPath"
|
:url="urlPath"
|
||||||
:limit="0"
|
:limit="0"
|
||||||
auto-load
|
auto-load
|
||||||
|
|
|
@ -1,24 +1,16 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import FormModel from 'components/FormModel.vue';
|
import FormModel from 'components/FormModel.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
const route = useRoute();
|
|
||||||
const { t } = useI18n();
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FormModel :url="`VnRoles/${route.params.id}`" model="VnRole" auto-load>
|
<FormModel model="Role" auto-load>
|
||||||
<template #form="{ data }">
|
<template #form="{ data }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<div class="col">
|
<VnInput v-model="data.name" :label="$t('globals.name')" />
|
||||||
<VnInput v-model="data.name" :label="t('globals.name')" />
|
|
||||||
</div>
|
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<div class="col">
|
<VnInput v-model="data.description" :label="$t('role.description')" />
|
||||||
<VnInput v-model="data.description" :label="t('role.description')" />
|
|
||||||
</div>
|
|
||||||
</VnRow>
|
</VnRow>
|
||||||
</template>
|
</template>
|
||||||
</FormModel>
|
</FormModel>
|
||||||
|
|
|
@ -3,5 +3,10 @@ import VnCardBeta from 'components/common/VnCardBeta.vue';
|
||||||
import RoleDescriptor from './RoleDescriptor.vue';
|
import RoleDescriptor from './RoleDescriptor.vue';
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VnCardBeta data-key="Role" :descriptor="RoleDescriptor" />
|
<VnCardBeta
|
||||||
|
url="VnRoles"
|
||||||
|
data-key="Role"
|
||||||
|
:id-in-where="true"
|
||||||
|
:descriptor="RoleDescriptor"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
||||||
import VnLv from 'src/components/ui/VnLv.vue';
|
import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
import useCardDescription from 'src/composables/useCardDescription';
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
|
@ -26,11 +25,6 @@ const { t } = useI18n();
|
||||||
const entityId = computed(() => {
|
const entityId = computed(() => {
|
||||||
return $props.id || route.params.id;
|
return $props.id || route.params.id;
|
||||||
});
|
});
|
||||||
const data = ref(useCardDescription());
|
|
||||||
const setData = (entity) => (data.value = useCardDescription(entity.name, entity.id));
|
|
||||||
const filter = {
|
|
||||||
where: { id: entityId },
|
|
||||||
};
|
|
||||||
const removeRole = async () => {
|
const removeRole = async () => {
|
||||||
await axios.delete(`VnRoles/${entityId.value}`);
|
await axios.delete(`VnRoles/${entityId.value}`);
|
||||||
notify(t('Role removed'), 'positive');
|
notify(t('Role removed'), 'positive');
|
||||||
|
@ -39,13 +33,10 @@ const removeRole = async () => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<CardDescriptor
|
<CardDescriptor
|
||||||
:url="`VnRoles/${entityId}`"
|
url="VnRoles"
|
||||||
:filter="filter"
|
:filter="{ where: { id: entityId } }"
|
||||||
module="Role"
|
module="Role"
|
||||||
@on-fetch="setData"
|
|
||||||
data-key="Role"
|
data-key="Role"
|
||||||
:title="data.title"
|
|
||||||
:subtitle="data.subtitle"
|
|
||||||
:summary="$props.summary"
|
:summary="$props.summary"
|
||||||
>
|
>
|
||||||
<template #menu>
|
<template #menu>
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import CardSummary from 'components/ui/CardSummary.vue';
|
import CardSummary from 'components/ui/CardSummary.vue';
|
||||||
import VnLv from 'src/components/ui/VnLv.vue';
|
import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -16,24 +15,18 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { store } = useArrayData('Role');
|
|
||||||
const role = ref(store.data);
|
|
||||||
const entityId = computed(() => $props.id || route.params.id);
|
const entityId = computed(() => $props.id || route.params.id);
|
||||||
const filter = {
|
|
||||||
where: { id: entityId },
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<CardSummary
|
<CardSummary
|
||||||
ref="summary"
|
ref="summary"
|
||||||
:url="`VnRoles/${entityId}`"
|
url="VnRoles"
|
||||||
:filter="filter"
|
:filter="{ where: { id: entityId } }"
|
||||||
@on-fetch="(data) => (role = data)"
|
|
||||||
data-key="Role"
|
data-key="Role"
|
||||||
>
|
>
|
||||||
<template #header> {{ role.id }} - {{ role.name }} </template>
|
<template #header="{ entity }"> {{ entity.id }} - {{ entity.name }} </template>
|
||||||
<template #body>
|
<template #body="{ entity }">
|
||||||
<QCard class="vn-one">
|
<QCard class="vn-one">
|
||||||
<QCardSection class="q-pa-none">
|
<QCardSection class="q-pa-none">
|
||||||
<a
|
<a
|
||||||
|
@ -44,9 +37,9 @@ const filter = {
|
||||||
<QIcon name="open_in_new" />
|
<QIcon name="open_in_new" />
|
||||||
</a>
|
</a>
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<VnLv :label="t('role.id')" :value="role.id" />
|
<VnLv :label="t('role.id')" :value="entity.id" />
|
||||||
<VnLv :label="t('globals.name')" :value="role.name" />
|
<VnLv :label="t('globals.name')" :value="entity.name" />
|
||||||
<VnLv :label="t('role.description')" :value="role.description" />
|
<VnLv :label="t('role.description')" :value="entity.description" />
|
||||||
</QCard>
|
</QCard>
|
||||||
</template>
|
</template>
|
||||||
</CardSummary>
|
</CardSummary>
|
||||||
|
|
|
@ -63,7 +63,7 @@ watch(
|
||||||
store.url = urlPath.value;
|
store.url = urlPath.value;
|
||||||
store.filter = filter.value;
|
store.filter = filter.value;
|
||||||
fetchSubRoles();
|
fetchSubRoles();
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const fetchSubRoles = () => paginateRef.value.fetch();
|
const fetchSubRoles = () => paginateRef.value.fetch();
|
||||||
|
@ -80,7 +80,7 @@ const redirectToRoleSummary = (id) =>
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
ref="paginateRef"
|
ref="paginateRef"
|
||||||
data-key="SubRoles"
|
data-key="SubRoles"
|
||||||
:filter="filter"
|
:user-filter="filter"
|
||||||
:url="urlPath"
|
:url="urlPath"
|
||||||
auto-load
|
auto-load
|
||||||
>
|
>
|
||||||
|
@ -109,7 +109,7 @@ const redirectToRoleSummary = (id) =>
|
||||||
openConfirmationModal(
|
openConfirmationModal(
|
||||||
t('El rol va a ser eliminado'),
|
t('El rol va a ser eliminado'),
|
||||||
t('¿Seguro que quieres continuar?'),
|
t('¿Seguro que quieres continuar?'),
|
||||||
() => deleteSubRole(row, rows, rowIndex)
|
() => deleteSubRole(row, rows, rowIndex),
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
@ -131,7 +131,7 @@ const redirectToRoleSummary = (id) =>
|
||||||
<QBtn
|
<QBtn
|
||||||
fab
|
fab
|
||||||
icon="add"
|
icon="add"
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
color="primary"
|
color="primary"
|
||||||
@click="openCreateSubRoleForm()"
|
@click="openCreateSubRoleForm()"
|
||||||
>
|
>
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
export default (param, value) => {
|
||||||
|
switch (param) {
|
||||||
|
case 'search':
|
||||||
|
return /^\d+$/.test(value)
|
||||||
|
? { id: value }
|
||||||
|
: {
|
||||||
|
or: [
|
||||||
|
{ name: { like: `%${value}%` } },
|
||||||
|
{ nickname: { like: `%${value}%` } },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
case 'name':
|
||||||
|
case 'description':
|
||||||
|
return { [param]: { like: `%${value}%` } };
|
||||||
|
}
|
||||||
|
};
|
|
@ -28,7 +28,6 @@ const workersOptions = ref([]);
|
||||||
model="Claim"
|
model="Claim"
|
||||||
:url-update="`Claims/updateClaim/${route.params.id}`"
|
:url-update="`Claims/updateClaim/${route.params.id}`"
|
||||||
auto-load
|
auto-load
|
||||||
:reload="true"
|
|
||||||
>
|
>
|
||||||
<template #form="{ data, validate }">
|
<template #form="{ data, validate }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
|
|
|
@ -6,8 +6,9 @@ import filter from './ClaimFilter.js';
|
||||||
<template>
|
<template>
|
||||||
<VnCardBeta
|
<VnCardBeta
|
||||||
data-key="Claim"
|
data-key="Claim"
|
||||||
base-url="Claims"
|
url="Claims"
|
||||||
:descriptor="ClaimDescriptor"
|
:descriptor="ClaimDescriptor"
|
||||||
|
search-data-key="ClaimList"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -3,12 +3,10 @@ import { ref, computed, onMounted } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { toDateHourMinSec, toPercentage } from 'src/filters';
|
import { toDateHourMinSec, toPercentage } from 'src/filters';
|
||||||
import { useState } from 'src/composables/useState';
|
|
||||||
import TicketDescriptorProxy from 'pages/Ticket/Card/TicketDescriptorProxy.vue';
|
import TicketDescriptorProxy from 'pages/Ticket/Card/TicketDescriptorProxy.vue';
|
||||||
import ClaimDescriptorMenu from 'pages/Claim/Card/ClaimDescriptorMenu.vue';
|
import ClaimDescriptorMenu from 'pages/Claim/Card/ClaimDescriptorMenu.vue';
|
||||||
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
||||||
import VnLv from 'src/components/ui/VnLv.vue';
|
import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
import useCardDescription from 'src/composables/useCardDescription';
|
|
||||||
import VnUserLink from 'src/components/ui/VnUserLink.vue';
|
import VnUserLink from 'src/components/ui/VnUserLink.vue';
|
||||||
import { getUrl } from 'src/composables/getUrl';
|
import { getUrl } from 'src/composables/getUrl';
|
||||||
import ZoneDescriptorProxy from 'src/pages/Zone/Card/ZoneDescriptorProxy.vue';
|
import ZoneDescriptorProxy from 'src/pages/Zone/Card/ZoneDescriptorProxy.vue';
|
||||||
|
@ -23,7 +21,6 @@ const $props = defineProps({
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const state = useState();
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const salixUrl = ref();
|
const salixUrl = ref();
|
||||||
const entityId = computed(() => {
|
const entityId = computed(() => {
|
||||||
|
@ -39,12 +36,7 @@ const STATE_COLOR = {
|
||||||
function stateColor(code) {
|
function stateColor(code) {
|
||||||
return STATE_COLOR[code];
|
return STATE_COLOR[code];
|
||||||
}
|
}
|
||||||
const data = ref(useCardDescription());
|
|
||||||
const setData = (entity) => {
|
|
||||||
if (!entity) return;
|
|
||||||
data.value = useCardDescription(entity?.client?.name, entity.id);
|
|
||||||
state.set('ClaimDescriptor', entity);
|
|
||||||
};
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
salixUrl.value = await getUrl('');
|
salixUrl.value = await getUrl('');
|
||||||
});
|
});
|
||||||
|
@ -56,7 +48,6 @@ onMounted(async () => {
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
module="Claim"
|
module="Claim"
|
||||||
title="client.name"
|
title="client.name"
|
||||||
@on-fetch="setData"
|
|
||||||
data-key="Claim"
|
data-key="Claim"
|
||||||
>
|
>
|
||||||
<template #menu="{ entity }">
|
<template #menu="{ entity }">
|
||||||
|
|
|
@ -57,7 +57,6 @@ function onFetch(rows, newRows) {
|
||||||
const price = row.quantity * sale.price;
|
const price = row.quantity * sale.price;
|
||||||
const discount = (sale.discount * price) / 100;
|
const discount = (sale.discount * price) / 100;
|
||||||
amountClaimed.value = amountClaimed.value + (price - discount);
|
amountClaimed.value = amountClaimed.value + (price - discount);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +207,6 @@ async function saveWhenHasChanges() {
|
||||||
selection="multiple"
|
selection="multiple"
|
||||||
v-model:selected="selected"
|
v-model:selected="selected"
|
||||||
:grid="$q.screen.lt.md"
|
:grid="$q.screen.lt.md"
|
||||||
|
|
||||||
>
|
>
|
||||||
<template #body-cell-claimed="{ row }">
|
<template #body-cell-claimed="{ row }">
|
||||||
<QTd auto-width align="right" class="text-primary shrink">
|
<QTd auto-width align="right" class="text-primary shrink">
|
||||||
|
@ -319,7 +317,13 @@ async function saveWhenHasChanges() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<QPageSticky position="bottom-right" :offset="[25, 25]">
|
<QPageSticky position="bottom-right" :offset="[25, 25]">
|
||||||
<QBtn fab color="primary" shortcut="+" icon="add" @click="showImportDialog()" />
|
<QBtn
|
||||||
|
fab
|
||||||
|
color="primary"
|
||||||
|
v-shortcut="'+'"
|
||||||
|
icon="add"
|
||||||
|
@click="showImportDialog()"
|
||||||
|
/>
|
||||||
</QPageSticky>
|
</QPageSticky>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -330,9 +334,10 @@ async function saveWhenHasChanges() {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
.grid-style-transition {
|
.grid-style-transition {
|
||||||
transition: transform 0.28s, background-color 0.28s;
|
transition:
|
||||||
|
transform 0.28s,
|
||||||
|
background-color 0.28s;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
|
|
|
@ -61,7 +61,7 @@ watch(
|
||||||
() => {
|
() => {
|
||||||
claimDmsFilter.value.where.id = router.currentRoute.value.params.id;
|
claimDmsFilter.value.where.id = router.currentRoute.value.params.id;
|
||||||
claimDmsRef.value.fetch();
|
claimDmsRef.value.fetch();
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
function openDialog(dmsId) {
|
function openDialog(dmsId) {
|
||||||
|
@ -249,7 +249,7 @@ function onDrag() {
|
||||||
<QBtn
|
<QBtn
|
||||||
fab
|
fab
|
||||||
@click="inputFile.nativeEl.click()"
|
@click="inputFile.nativeEl.click()"
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
icon="add"
|
icon="add"
|
||||||
color="primary"
|
color="primary"
|
||||||
>
|
>
|
||||||
|
|
|
@ -61,7 +61,7 @@ watch(
|
||||||
(newValue) => {
|
(newValue) => {
|
||||||
if (!newValue) return;
|
if (!newValue) return;
|
||||||
getClientData(newValue);
|
getClientData(newValue);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const getClientData = async (id) => {
|
const getClientData = async (id) => {
|
||||||
|
@ -117,7 +117,7 @@ const toCustomerAddressEdit = (addressId) => {
|
||||||
data-key="CustomerAddresses"
|
data-key="CustomerAddresses"
|
||||||
order="id DESC"
|
order="id DESC"
|
||||||
ref="vnPaginateRef"
|
ref="vnPaginateRef"
|
||||||
:filter="addressFilter"
|
:user-filter="addressFilter"
|
||||||
:url="`Clients/${route.params.id}/addresses`"
|
:url="`Clients/${route.params.id}/addresses`"
|
||||||
/>
|
/>
|
||||||
<div class="full-width flex justify-center">
|
<div class="full-width flex justify-center">
|
||||||
|
@ -137,7 +137,7 @@ const toCustomerAddressEdit = (addressId) => {
|
||||||
<QIcon
|
<QIcon
|
||||||
:style="{
|
:style="{
|
||||||
'font-variation-settings': `'FILL' ${isDefaultAddress(
|
'font-variation-settings': `'FILL' ${isDefaultAddress(
|
||||||
item
|
item,
|
||||||
)}`,
|
)}`,
|
||||||
}"
|
}"
|
||||||
color="primary"
|
color="primary"
|
||||||
|
@ -150,7 +150,7 @@ const toCustomerAddressEdit = (addressId) => {
|
||||||
t(
|
t(
|
||||||
isDefaultAddress(item)
|
isDefaultAddress(item)
|
||||||
? 'Default address'
|
? 'Default address'
|
||||||
: 'Set as default'
|
: 'Set as default',
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
|
@ -216,7 +216,7 @@ const toCustomerAddressEdit = (addressId) => {
|
||||||
color="primary"
|
color="primary"
|
||||||
fab
|
fab
|
||||||
icon="add"
|
icon="add"
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
/>
|
/>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ t('New consignee') }}
|
{{ t('New consignee') }}
|
||||||
|
|
|
@ -158,7 +158,7 @@ const columns = computed(() => [
|
||||||
openConfirmationModal(
|
openConfirmationModal(
|
||||||
t('Send compensation'),
|
t('Send compensation'),
|
||||||
t('Do you want to report compensation to the client by mail?'),
|
t('Do you want to report compensation to the client by mail?'),
|
||||||
() => sendEmail(`Receipts/${id}/balance-compensation-email`)
|
() => sendEmail(`Receipts/${id}/balance-compensation-email`),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -291,7 +291,7 @@ const showBalancePdf = ({ id }) => {
|
||||||
color="primary"
|
color="primary"
|
||||||
fab
|
fab
|
||||||
icon="add"
|
icon="add"
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
/>
|
/>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ t('New payment') }}
|
{{ t('New payment') }}
|
||||||
|
|
|
@ -54,10 +54,10 @@ function onBeforeSave(formData, originalData) {
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<FormModel
|
<FormModel
|
||||||
:url="`Clients/${route.params.id}`"
|
:url-update="`Clients/${route.params.id}`"
|
||||||
auto-load
|
auto-load
|
||||||
model="customer"
|
|
||||||
:mapper="onBeforeSave"
|
:mapper="onBeforeSave"
|
||||||
|
model="Customer"
|
||||||
>
|
>
|
||||||
<template #form="{ data, validate }">
|
<template #form="{ data, validate }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
|
|
|
@ -28,7 +28,7 @@ const getBankEntities = (data, formData) => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FormModel :url-update="`Clients/${route.params.id}`" auto-load model="customer">
|
<FormModel :url-update="`Clients/${route.params.id}`" auto-load model="Customer">
|
||||||
<template #form="{ data, validate }">
|
<template #form="{ data, validate }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
|
|
|
@ -5,8 +5,8 @@ import CustomerDescriptor from './CustomerDescriptor.vue';
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnCardBeta
|
<VnCardBeta
|
||||||
data-key="Client"
|
data-key="Customer"
|
||||||
base-url="Clients"
|
:url="`Clients/${$route.params.id}/getCard`"
|
||||||
:descriptor="CustomerDescriptor"
|
:descriptor="CustomerDescriptor"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -119,7 +119,7 @@ const openSendEmailDialog = async () => {
|
||||||
openConfirmationModal(
|
openConfirmationModal(
|
||||||
t('The consumption report will be sent'),
|
t('The consumption report will be sent'),
|
||||||
t('Please, confirm'),
|
t('Please, confirm'),
|
||||||
() => sendCampaignMetricsEmail({ address: arrayData.store.data.email })
|
() => sendCampaignMetricsEmail({ address: arrayData.store.data.email }),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
const sendCampaignMetricsEmail = ({ address }) => {
|
const sendCampaignMetricsEmail = ({ address }) => {
|
||||||
|
|
|
@ -62,7 +62,7 @@ const customerContactsRef = ref(null);
|
||||||
color="primary"
|
color="primary"
|
||||||
flat
|
flat
|
||||||
icon="add"
|
icon="add"
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ t('Add contact') }}
|
{{ t('Add contact') }}
|
||||||
|
|
|
@ -75,7 +75,7 @@ const updateData = () => {
|
||||||
<div class="full-width flex justify-center">
|
<div class="full-width flex justify-center">
|
||||||
<QCard class="card-width q-pa-lg">
|
<QCard class="card-width q-pa-lg">
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
:filter="filter"
|
:user-filter="filter"
|
||||||
@on-fetch="fetch"
|
@on-fetch="fetch"
|
||||||
auto-load
|
auto-load
|
||||||
data-key="CustomerCreditContracts"
|
data-key="CustomerCreditContracts"
|
||||||
|
@ -195,7 +195,7 @@ const updateData = () => {
|
||||||
color="primary"
|
color="primary"
|
||||||
fab
|
fab
|
||||||
icon="add"
|
icon="add"
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
/>
|
/>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ t('New contract') }}
|
{{ t('New contract') }}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { onMounted, ref, computed } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
@ -11,6 +11,15 @@ import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
||||||
import VnLv from 'src/components/ui/VnLv.vue';
|
import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
import VnUserLink from 'src/components/ui/VnUserLink.vue';
|
import VnUserLink from 'src/components/ui/VnUserLink.vue';
|
||||||
import CustomerDescriptorMenu from './CustomerDescriptorMenu.vue';
|
import CustomerDescriptorMenu from './CustomerDescriptorMenu.vue';
|
||||||
|
import { useState } from 'src/composables/useState';
|
||||||
|
const state = useState();
|
||||||
|
|
||||||
|
const customer = ref();
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
customer.value = state.get('Customer');
|
||||||
|
if (customer.value) customer.value.webAccess = data.value?.account?.isActive;
|
||||||
|
});
|
||||||
|
|
||||||
const customerDebt = ref();
|
const customerDebt = ref();
|
||||||
const customerCredit = ref();
|
const customerCredit = ref();
|
||||||
|
@ -48,11 +57,9 @@ const debtWarning = computed(() => {
|
||||||
<CardDescriptor
|
<CardDescriptor
|
||||||
module="Customer"
|
module="Customer"
|
||||||
:url="`Clients/${entityId}/getCard`"
|
:url="`Clients/${entityId}/getCard`"
|
||||||
:title="data.title"
|
|
||||||
:subtitle="data.subtitle"
|
|
||||||
@on-fetch="setData"
|
|
||||||
:summary="$props.summary"
|
:summary="$props.summary"
|
||||||
data-key="customer"
|
data-key="Customer"
|
||||||
|
@on-fetch="setData"
|
||||||
width="lg-width"
|
width="lg-width"
|
||||||
>
|
>
|
||||||
<template #menu="{ entity }">
|
<template #menu="{ entity }">
|
||||||
|
@ -61,7 +68,7 @@ const debtWarning = computed(() => {
|
||||||
<template #body="{ entity }">
|
<template #body="{ entity }">
|
||||||
<VnLv
|
<VnLv
|
||||||
:label="t('customer.summary.payMethod')"
|
:label="t('customer.summary.payMethod')"
|
||||||
:value="entity.payMethod.name"
|
:value="entity.payMethod?.name"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<VnLv
|
<VnLv
|
||||||
|
@ -90,7 +97,7 @@ const debtWarning = computed(() => {
|
||||||
</VnLv>
|
</VnLv>
|
||||||
<VnLv
|
<VnLv
|
||||||
:label="t('customer.extendedList.tableVisibleColumns.businessTypeFk')"
|
:label="t('customer.extendedList.tableVisibleColumns.businessTypeFk')"
|
||||||
:value="entity.businessType.description"
|
:value="entity.businessType?.description"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #icons="{ entity }">
|
<template #icons="{ entity }">
|
||||||
|
@ -143,13 +150,13 @@ const debtWarning = computed(() => {
|
||||||
<br />
|
<br />
|
||||||
{{
|
{{
|
||||||
t('unpaidDated', {
|
t('unpaidDated', {
|
||||||
dated: toDate(customer.unpaid.dated),
|
dated: toDate(customer.unpaid?.dated),
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
<br />
|
<br />
|
||||||
{{
|
{{
|
||||||
t('unpaidAmount', {
|
t('unpaidAmount', {
|
||||||
amount: toCurrency(customer.unpaid.amount),
|
amount: toCurrency(customer.unpaid?.amount),
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
|
@ -192,6 +199,7 @@ const debtWarning = computed(() => {
|
||||||
query: {
|
query: {
|
||||||
createForm: JSON.stringify({
|
createForm: JSON.stringify({
|
||||||
clientFk: entity.id,
|
clientFk: entity.id,
|
||||||
|
addressId: entity.defaultAddressFk,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
}"
|
}"
|
||||||
|
|
|
@ -236,7 +236,7 @@ const toCustomerFileManagementCreate = () => {
|
||||||
@click.stop="toCustomerFileManagementCreate()"
|
@click.stop="toCustomerFileManagementCreate()"
|
||||||
color="primary"
|
color="primary"
|
||||||
fab
|
fab
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
icon="add"
|
icon="add"
|
||||||
/>
|
/>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
|
|
|
@ -35,7 +35,7 @@ function handleLocation(data, location) {
|
||||||
<FormModel
|
<FormModel
|
||||||
:url-update="`Clients/${route.params.id}/updateFiscalData`"
|
:url-update="`Clients/${route.params.id}/updateFiscalData`"
|
||||||
auto-load
|
auto-load
|
||||||
model="customer"
|
model="Customer"
|
||||||
>
|
>
|
||||||
<template #form="{ data, validate }">
|
<template #form="{ data, validate }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
|
|
|
@ -23,5 +23,6 @@ const noteFilter = computed(() => {
|
||||||
:body="{ clientFk: route.params.id }"
|
:body="{ clientFk: route.params.id }"
|
||||||
style="overflow-y: auto"
|
style="overflow-y: auto"
|
||||||
:select-type="true"
|
:select-type="true"
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -104,7 +104,7 @@ const tableRef = ref();
|
||||||
color="primary"
|
color="primary"
|
||||||
fab
|
fab
|
||||||
icon="add"
|
icon="add"
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
/>
|
/>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ t('Send sample') }}
|
{{ t('Send sample') }}
|
||||||
|
|
|
@ -27,7 +27,7 @@ async function hasCustomerRole() {
|
||||||
<FormModel
|
<FormModel
|
||||||
:url-update="`Clients/${route.params.id}/updateUser`"
|
:url-update="`Clients/${route.params.id}/updateUser`"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
model="customer"
|
model="Customer"
|
||||||
:mapper="
|
:mapper="
|
||||||
({ account }) => {
|
({ account }) => {
|
||||||
const { name, email, active } = account;
|
const { name, email, active } = account;
|
||||||
|
|
|
@ -49,7 +49,7 @@ const getData = async (observations) => {
|
||||||
notes.value = originalNotes
|
notes.value = originalNotes
|
||||||
.map((observation) => {
|
.map((observation) => {
|
||||||
const type = observationTypes.value.find(
|
const type = observationTypes.value.find(
|
||||||
(type) => type.id === observation.observationTypeFk
|
(type) => type.id === observation.observationTypeFk,
|
||||||
);
|
);
|
||||||
return type
|
return type
|
||||||
? {
|
? {
|
||||||
|
@ -112,8 +112,8 @@ function getPayload() {
|
||||||
(oNote) =>
|
(oNote) =>
|
||||||
oNote.id === note.id &&
|
oNote.id === note.id &&
|
||||||
(note.description !== oNote.description ||
|
(note.description !== oNote.description ||
|
||||||
note.observationTypeFk !== oNote.observationTypeFk)
|
note.observationTypeFk !== oNote.observationTypeFk),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.map((note) => ({
|
.map((note) => ({
|
||||||
data: note,
|
data: note,
|
||||||
|
@ -130,9 +130,7 @@ async function handleDialog(data) {
|
||||||
.dialog({
|
.dialog({
|
||||||
component: VnConfirm,
|
component: VnConfirm,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
title: t(
|
title: t('confirmTicket'),
|
||||||
'confirmTicket'
|
|
||||||
),
|
|
||||||
message: t('confirmDeletionMessage'),
|
message: t('confirmDeletionMessage'),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -341,7 +339,7 @@ function handleLocation(data, location) {
|
||||||
class="cursor-pointer add-icon q-mt-md"
|
class="cursor-pointer add-icon q-mt-md"
|
||||||
flat
|
flat
|
||||||
icon="add"
|
icon="add"
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ t('Add note') }}
|
{{ t('Add note') }}
|
||||||
|
|
|
@ -39,7 +39,7 @@ const optionsSamplesVisible = ref([]);
|
||||||
const sampleType = ref({ hasPreview: false });
|
const sampleType = ref({ hasPreview: false });
|
||||||
const initialData = reactive({});
|
const initialData = reactive({});
|
||||||
const entityId = computed(() => route.params.id);
|
const entityId = computed(() => route.params.id);
|
||||||
const customer = computed(() => state.get('customer'));
|
const customer = computed(() => state.get('Customer'));
|
||||||
const filterEmailUsers = { where: { userFk: user.value.id } };
|
const filterEmailUsers = { where: { userFk: user.value.id } };
|
||||||
const filterClientsAddresses = {
|
const filterClientsAddresses = {
|
||||||
include: [
|
include: [
|
||||||
|
|
|
@ -1,27 +1,16 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
import FormModel from 'components/FormModel.vue';
|
import FormModel from 'components/FormModel.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
import VnSelectWorker from 'src/components/common/VnSelectWorker.vue';
|
import VnSelectWorker from 'src/components/common/VnSelectWorker.vue';
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
const { t } = useI18n();
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FormModel
|
<FormModel model="Department" auto-load class="full-width">
|
||||||
:url="`Departments/${route.params.id}`"
|
|
||||||
model="department"
|
|
||||||
auto-load
|
|
||||||
class="full-width"
|
|
||||||
>
|
|
||||||
<template #form="{ data, validate }">
|
<template #form="{ data, validate }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnInput
|
<VnInput
|
||||||
:label="t('globals.name')"
|
:label="$t('globals.name')"
|
||||||
v-model="data.name"
|
v-model="data.name"
|
||||||
:rules="validate('globals.name')"
|
:rules="validate('globals.name')"
|
||||||
clearable
|
clearable
|
||||||
|
@ -29,33 +18,33 @@ const { t } = useI18n();
|
||||||
/>
|
/>
|
||||||
<VnInput
|
<VnInput
|
||||||
v-model="data.code"
|
v-model="data.code"
|
||||||
:label="t('globals.code')"
|
:label="$t('globals.code')"
|
||||||
:rules="validate('globals.code')"
|
:rules="validate('globals.code')"
|
||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnInput
|
<VnInput
|
||||||
:label="t('department.chat')"
|
:label="$t('department.chat')"
|
||||||
v-model="data.chatName"
|
v-model="data.chatName"
|
||||||
:rules="validate('department.chat')"
|
:rules="validate('department.chat')"
|
||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
<VnInput
|
<VnInput
|
||||||
v-model="data.notificationEmail"
|
v-model="data.notificationEmail"
|
||||||
:label="t('globals.params.email')"
|
:label="$t('globals.params.email')"
|
||||||
:rules="validate('globals.params.email')"
|
:rules="validate('globals.params.email')"
|
||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnSelectWorker
|
<VnSelectWorker
|
||||||
:label="t('department.bossDepartment')"
|
:label="$t('department.bossDepartment')"
|
||||||
v-model="data.workerFk"
|
v-model="data.workerFk"
|
||||||
:rules="validate('department.bossDepartment')"
|
:rules="validate('department.bossDepartment')"
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('department.selfConsumptionCustomer')"
|
:label="$t('department.selfConsumptionCustomer')"
|
||||||
v-model="data.clientFk"
|
v-model="data.clientFk"
|
||||||
url="Clients"
|
url="Clients"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
|
@ -67,11 +56,11 @@ const { t } = useI18n();
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<QCheckbox
|
<QCheckbox
|
||||||
:label="t('department.telework')"
|
:label="$t('department.telework')"
|
||||||
v-model="data.isTeleworking"
|
v-model="data.isTeleworking"
|
||||||
/>
|
/>
|
||||||
<QCheckbox
|
<QCheckbox
|
||||||
:label="t('department.notifyOnErrors')"
|
:label="$t('department.notifyOnErrors')"
|
||||||
v-model="data.hasToMistake"
|
v-model="data.hasToMistake"
|
||||||
:false-value="0"
|
:false-value="0"
|
||||||
:true-value="1"
|
:true-value="1"
|
||||||
|
@ -79,17 +68,17 @@ const { t } = useI18n();
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<QCheckbox
|
<QCheckbox
|
||||||
:label="t('department.worksInProduction')"
|
:label="$t('department.worksInProduction')"
|
||||||
v-model="data.isProduction"
|
v-model="data.isProduction"
|
||||||
/>
|
/>
|
||||||
<QCheckbox
|
<QCheckbox
|
||||||
:label="t('department.hasToRefill')"
|
:label="$t('department.hasToRefill')"
|
||||||
v-model="data.hasToRefill"
|
v-model="data.hasToRefill"
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<QCheckbox
|
<QCheckbox
|
||||||
:label="t('department.hasToSendMail')"
|
:label="$t('department.hasToSendMail')"
|
||||||
v-model="data.hasToSendMail"
|
v-model="data.hasToSendMail"
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
|
|
@ -7,7 +7,7 @@ import DepartmentDescriptor from 'pages/Department/Card/DepartmentDescriptor.vue
|
||||||
class="q-pa-md column items-center"
|
class="q-pa-md column items-center"
|
||||||
v-bind="{ ...$attrs }"
|
v-bind="{ ...$attrs }"
|
||||||
data-key="Department"
|
data-key="Department"
|
||||||
base-url="Departments"
|
url="Departments"
|
||||||
:descriptor="DepartmentDescriptor"
|
:descriptor="DepartmentDescriptor"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { useI18n } from 'vue-i18n';
|
||||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||||
import VnLv from 'src/components/ui/VnLv.vue';
|
import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
import CardDescriptor from 'src/components/ui/CardDescriptor.vue';
|
import CardDescriptor from 'src/components/ui/CardDescriptor.vue';
|
||||||
import useCardDescription from 'src/composables/useCardDescription';
|
|
||||||
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
|
@ -32,15 +31,6 @@ const entityId = computed(() => {
|
||||||
return $props.id || route.params.id;
|
return $props.id || route.params.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
const department = ref();
|
|
||||||
|
|
||||||
const data = ref(useCardDescription());
|
|
||||||
|
|
||||||
const setData = (entity) => {
|
|
||||||
if (!entity) return;
|
|
||||||
data.value = useCardDescription(entity.name, entity.id);
|
|
||||||
};
|
|
||||||
|
|
||||||
const removeDepartment = async () => {
|
const removeDepartment = async () => {
|
||||||
await axios.post(`/Departments/${entityId.value}/removeChild`, entityId.value);
|
await axios.post(`/Departments/${entityId.value}/removeChild`, entityId.value);
|
||||||
router.push({ name: 'WorkerDepartment' });
|
router.push({ name: 'WorkerDepartment' });
|
||||||
|
@ -54,17 +44,9 @@ const { openConfirmationModal } = useVnConfirm();
|
||||||
ref="DepartmentDescriptorRef"
|
ref="DepartmentDescriptorRef"
|
||||||
module="Department"
|
module="Department"
|
||||||
:url="`Departments/${entityId}`"
|
:url="`Departments/${entityId}`"
|
||||||
:title="data.title"
|
|
||||||
:subtitle="data.subtitle"
|
|
||||||
:summary="$props.summary"
|
:summary="$props.summary"
|
||||||
:to-module="{ name: 'WorkerDepartment' }"
|
:to-module="{ name: 'WorkerDepartment' }"
|
||||||
@on-fetch="
|
data-key="Department"
|
||||||
(data) => {
|
|
||||||
department = data;
|
|
||||||
setData(data);
|
|
||||||
}
|
|
||||||
"
|
|
||||||
data-key="department"
|
|
||||||
>
|
>
|
||||||
<template #menu="{}">
|
<template #menu="{}">
|
||||||
<QItem
|
<QItem
|
||||||
|
@ -74,7 +56,7 @@ const { openConfirmationModal } = useVnConfirm();
|
||||||
openConfirmationModal(
|
openConfirmationModal(
|
||||||
t('Are you sure you want to delete it?'),
|
t('Are you sure you want to delete it?'),
|
||||||
t('Delete department'),
|
t('Delete department'),
|
||||||
removeDepartment
|
removeDepartment,
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
|
|
@ -27,7 +27,7 @@ onMounted(async () => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<CardSummary
|
<CardSummary
|
||||||
data-key="DepartmentSummary"
|
data-key="Department"
|
||||||
ref="summary"
|
ref="summary"
|
||||||
:url="`Departments/${entityId}`"
|
:url="`Departments/${entityId}`"
|
||||||
class="full-width"
|
class="full-width"
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
||||||
import EntryDescriptor from './EntryDescriptor.vue';
|
import EntryDescriptor from './EntryDescriptor.vue';
|
||||||
import filter from './EntryFilter.js'
|
import filter from './EntryFilter.js';
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VnCardBeta
|
<VnCardBeta
|
||||||
data-key="Entry"
|
data-key="Entry"
|
||||||
base-url="Entries"
|
url="Entries"
|
||||||
:descriptor="EntryDescriptor"
|
:descriptor="EntryDescriptor"
|
||||||
:user-filter="filter"
|
:filter="filter"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -17,7 +17,7 @@ const selected = ref([]);
|
||||||
|
|
||||||
const sortEntryObservationOptions = (data) => {
|
const sortEntryObservationOptions = (data) => {
|
||||||
entryObservationsOptions.value = [...data].sort((a, b) =>
|
entryObservationsOptions.value = [...data].sort((a, b) =>
|
||||||
a.description.localeCompare(b.description)
|
a.description.localeCompare(b.description),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ const columns = computed(() => [
|
||||||
fab
|
fab
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="add"
|
icon="add"
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
@click="entryObservationsRef.insert()"
|
@click="entryObservationsRef.insert()"
|
||||||
/>
|
/>
|
||||||
</QPageSticky>
|
</QPageSticky>
|
||||||
|
|
|
@ -215,7 +215,7 @@ function deleteFile(dmsFk) {
|
||||||
v-else
|
v-else
|
||||||
icon="add_circle"
|
icon="add_circle"
|
||||||
round
|
round
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
padding="xs"
|
padding="xs"
|
||||||
@click="
|
@click="
|
||||||
() => {
|
() => {
|
||||||
|
|
|
@ -1,47 +1,18 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
||||||
import InvoiceInDescriptor from './InvoiceInDescriptor.vue';
|
import InvoiceInDescriptor from './InvoiceInDescriptor.vue';
|
||||||
|
import { onBeforeRouteUpdate } from 'vue-router';
|
||||||
|
import { setRectificative } from '../composables/setRectificative';
|
||||||
|
import filter from './InvoiceInFilter.js';
|
||||||
|
|
||||||
const filter = {
|
onBeforeRouteUpdate(async (to) => await setRectificative(to));
|
||||||
include: [
|
|
||||||
{
|
|
||||||
relation: 'supplier',
|
|
||||||
scope: {
|
|
||||||
include: {
|
|
||||||
relation: 'contacts',
|
|
||||||
scope: { where: { email: { neq: null } } },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ relation: 'invoiceInDueDay' },
|
|
||||||
{ relation: 'company' },
|
|
||||||
{ relation: 'currency' },
|
|
||||||
{
|
|
||||||
relation: 'dms',
|
|
||||||
scope: {
|
|
||||||
fields: [
|
|
||||||
'dmsTypeFk',
|
|
||||||
'reference',
|
|
||||||
'hardCopyNumber',
|
|
||||||
'workerFk',
|
|
||||||
'description',
|
|
||||||
'hasFile',
|
|
||||||
'file',
|
|
||||||
'created',
|
|
||||||
'companyFk',
|
|
||||||
'warehouseFk',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnCardBeta
|
<VnCardBeta
|
||||||
data-key="InvoiceIn"
|
data-key="InvoiceIn"
|
||||||
base-url="InvoiceIns"
|
url="InvoiceIns"
|
||||||
:descriptor="InvoiceInDescriptor"
|
:descriptor="InvoiceInDescriptor"
|
||||||
:user-filter="filter"
|
:filter="filter"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { toCurrency, toDate } from 'src/filters';
|
||||||
import VnLv from 'src/components/ui/VnLv.vue';
|
import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
||||||
import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorProxy.vue';
|
import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorProxy.vue';
|
||||||
|
import filter from './InvoiceInFilter.js';
|
||||||
import InvoiceInDescriptorMenu from './InvoiceInDescriptorMenu.vue';
|
import InvoiceInDescriptorMenu from './InvoiceInDescriptorMenu.vue';
|
||||||
|
|
||||||
const $props = defineProps({ id: { type: Number, default: null } });
|
const $props = defineProps({ id: { type: Number, default: null } });
|
||||||
|
@ -16,33 +17,10 @@ const { t } = useI18n();
|
||||||
const cardDescriptorRef = ref();
|
const cardDescriptorRef = ref();
|
||||||
const entityId = computed(() => $props.id || +currentRoute.value.params.id);
|
const entityId = computed(() => $props.id || +currentRoute.value.params.id);
|
||||||
const totalAmount = ref();
|
const totalAmount = ref();
|
||||||
|
const config = ref();
|
||||||
const filter = {
|
const cplusRectificationTypes = ref([]);
|
||||||
include: [
|
const siiTypeInvoiceIns = ref([]);
|
||||||
{
|
const invoiceCorrectionTypes = ref([]);
|
||||||
relation: 'supplier',
|
|
||||||
scope: {
|
|
||||||
include: {
|
|
||||||
relation: 'contacts',
|
|
||||||
scope: {
|
|
||||||
where: {
|
|
||||||
email: { neq: null },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
relation: 'invoiceInDueDay',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
relation: 'company',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
relation: 'currency',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const invoiceInCorrection = reactive({ correcting: [], corrected: null });
|
const invoiceInCorrection = reactive({ correcting: [], corrected: null });
|
||||||
const routes = reactive({
|
const routes = reactive({
|
||||||
getSupplier: (id) => {
|
getSupplier: (id) => {
|
||||||
|
|
|
@ -232,7 +232,7 @@ async function insert() {
|
||||||
<QBtn
|
<QBtn
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="add"
|
icon="add"
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
size="lg"
|
size="lg"
|
||||||
round
|
round
|
||||||
@click="!areRows ? insert() : invoiceInFormRef.insert()"
|
@click="!areRows ? insert() : invoiceInFormRef.insert()"
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
export default {
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
relation: 'supplier',
|
||||||
|
scope: {
|
||||||
|
include: {
|
||||||
|
relation: 'contacts',
|
||||||
|
scope: { where: { email: { neq: null } } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ relation: 'invoiceInDueDay' },
|
||||||
|
{ relation: 'company' },
|
||||||
|
{ relation: 'currency' },
|
||||||
|
{
|
||||||
|
relation: 'dms',
|
||||||
|
scope: {
|
||||||
|
fields: [
|
||||||
|
'dmsTypeFk',
|
||||||
|
'reference',
|
||||||
|
'hardCopyNumber',
|
||||||
|
'workerFk',
|
||||||
|
'description',
|
||||||
|
'hasFile',
|
||||||
|
'file',
|
||||||
|
'created',
|
||||||
|
'companyFk',
|
||||||
|
'warehouseFk',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
|
@ -218,7 +218,7 @@ const columns = computed(() => [
|
||||||
<QBtn
|
<QBtn
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="add"
|
icon="add"
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
size="lg"
|
size="lg"
|
||||||
round
|
round
|
||||||
@click="invoiceInFormRef.insert()"
|
@click="invoiceInFormRef.insert()"
|
||||||
|
|
|
@ -117,7 +117,7 @@ const isNotEuro = (code) => code != 'EUR';
|
||||||
function taxRate(invoiceInTax) {
|
function taxRate(invoiceInTax) {
|
||||||
const sageTaxTypeId = invoiceInTax.taxTypeSageFk;
|
const sageTaxTypeId = invoiceInTax.taxTypeSageFk;
|
||||||
const taxRateSelection = sageTaxTypes.value.find(
|
const taxRateSelection = sageTaxTypes.value.find(
|
||||||
(transaction) => transaction.id == sageTaxTypeId
|
(transaction) => transaction.id == sageTaxTypeId,
|
||||||
);
|
);
|
||||||
const taxTypeSage = taxRateSelection?.rate ?? 0;
|
const taxTypeSage = taxRateSelection?.rate ?? 0;
|
||||||
const taxableBase = invoiceInTax?.taxableBase ?? 0;
|
const taxableBase = invoiceInTax?.taxableBase ?? 0;
|
||||||
|
@ -131,14 +131,14 @@ function autocompleteExpense(evt, row, col) {
|
||||||
|
|
||||||
const param = isNaN(val) ? row[col.model] : val;
|
const param = isNaN(val) ? row[col.model] : val;
|
||||||
const lookup = expenses.value.find(
|
const lookup = expenses.value.find(
|
||||||
({ id }) => id == useAccountShortToStandard(param)
|
({ id }) => id == useAccountShortToStandard(param),
|
||||||
);
|
);
|
||||||
|
|
||||||
expenseRef.value.vnSelectDialogRef.vnSelectRef.toggleOption(lookup);
|
expenseRef.value.vnSelectDialogRef.vnSelectRef.toggleOption(lookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
const taxableBaseTotal = computed(() => {
|
const taxableBaseTotal = computed(() => {
|
||||||
return getTotal(invoiceInFormRef.value.formData, 'taxableBase', );
|
return getTotal(invoiceInFormRef.value.formData, 'taxableBase');
|
||||||
});
|
});
|
||||||
|
|
||||||
const taxRateTotal = computed(() => {
|
const taxRateTotal = computed(() => {
|
||||||
|
@ -147,13 +147,9 @@ const taxRateTotal = computed(() => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const combinedTotal = computed(() => {
|
const combinedTotal = computed(() => {
|
||||||
return +taxableBaseTotal.value + +taxRateTotal.value;
|
return +taxableBaseTotal.value + +taxRateTotal.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
@ -283,7 +279,7 @@ const combinedTotal = computed(() => {
|
||||||
row.taxableBase = await getExchange(
|
row.taxableBase = await getExchange(
|
||||||
val,
|
val,
|
||||||
row.currencyFk,
|
row.currencyFk,
|
||||||
invoiceIn.issued
|
invoiceIn.issued,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
@ -426,7 +422,7 @@ const combinedTotal = computed(() => {
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="add"
|
icon="add"
|
||||||
size="lg"
|
size="lg"
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
round
|
round
|
||||||
@click="invoiceInFormRef.insert()"
|
@click="invoiceInFormRef.insert()"
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import InvoiceOutDescriptor from './InvoiceOutDescriptor.vue';
|
import InvoiceOutDescriptor from './InvoiceOutDescriptor.vue';
|
||||||
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
||||||
|
import filter from './InvoiceOutFilter.js';
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VnCardBeta
|
<VnCardBeta
|
||||||
data-key="InvoiceOut"
|
data-key="InvoiceOut"
|
||||||
base-url="InvoiceOuts"
|
url="InvoiceOuts"
|
||||||
|
:filter="filter"
|
||||||
:descriptor="InvoiceOutDescriptor"
|
:descriptor="InvoiceOutDescriptor"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -8,8 +8,8 @@ import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy
|
||||||
import VnLv from 'src/components/ui/VnLv.vue';
|
import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
import InvoiceOutDescriptorMenu from './InvoiceOutDescriptorMenu.vue';
|
import InvoiceOutDescriptorMenu from './InvoiceOutDescriptorMenu.vue';
|
||||||
|
|
||||||
import useCardDescription from 'src/composables/useCardDescription';
|
|
||||||
import { toCurrency, toDate } from 'src/filters';
|
import { toCurrency, toDate } from 'src/filters';
|
||||||
|
import filter from './InvoiceOutFilter.js';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
id: {
|
id: {
|
||||||
|
@ -26,30 +26,11 @@ const entityId = computed(() => {
|
||||||
return $props.id || route.params.id;
|
return $props.id || route.params.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
const filter = {
|
|
||||||
include: [
|
|
||||||
{
|
|
||||||
relation: 'company',
|
|
||||||
scope: {
|
|
||||||
fields: ['id', 'code'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
relation: 'client',
|
|
||||||
scope: {
|
|
||||||
fields: ['id', 'name', 'email'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const descriptor = ref();
|
const descriptor = ref();
|
||||||
|
|
||||||
function ticketFilter(invoice) {
|
function ticketFilter(invoice) {
|
||||||
return JSON.stringify({ refFk: invoice.ref });
|
return JSON.stringify({ refFk: invoice.ref });
|
||||||
}
|
}
|
||||||
const data = ref(useCardDescription());
|
|
||||||
const setData = (entity) => (data.value = useCardDescription(entity.ref, entity.id));
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -58,10 +39,8 @@ const setData = (entity) => (data.value = useCardDescription(entity.ref, entity.
|
||||||
module="InvoiceOut"
|
module="InvoiceOut"
|
||||||
:url="`InvoiceOuts/${entityId}`"
|
:url="`InvoiceOuts/${entityId}`"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
:title="data.title"
|
title="ref"
|
||||||
:subtitle="data.subtitle"
|
data-key="InvoiceOut"
|
||||||
@on-fetch="setData"
|
|
||||||
data-key="invoiceOutData"
|
|
||||||
width="lg-width"
|
width="lg-width"
|
||||||
>
|
>
|
||||||
<template #menu="{ entity, menuRef }">
|
<template #menu="{ entity, menuRef }">
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
export default {
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
relation: 'company',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'code'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
relation: 'client',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'name', 'email'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
|
@ -92,7 +92,7 @@ const submit = async (rows) => {
|
||||||
class="cursor-pointer fill-icon-on-hover"
|
class="cursor-pointer fill-icon-on-hover"
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="add_circle"
|
icon="add_circle"
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
flat
|
flat
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
|
|
|
@ -54,9 +54,8 @@ const onIntrastatCreated = (response, formData) => {
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<FormModel
|
<FormModel
|
||||||
:url="`Items/${route.params.id}`"
|
|
||||||
:url-update="`Items/${route.params.id}`"
|
:url-update="`Items/${route.params.id}`"
|
||||||
model="item"
|
model="Item"
|
||||||
auto-load
|
auto-load
|
||||||
:clear-store-on-unmount="false"
|
:clear-store-on-unmount="false"
|
||||||
>
|
>
|
||||||
|
|
|
@ -5,7 +5,7 @@ import ItemDescriptor from './ItemDescriptor.vue';
|
||||||
<template>
|
<template>
|
||||||
<VnCardBeta
|
<VnCardBeta
|
||||||
data-key="Item"
|
data-key="Item"
|
||||||
base-url="Items"
|
:url="`Items/${$route.params.id}/getCard`"
|
||||||
:descriptor="ItemDescriptor"
|
:descriptor="ItemDescriptor"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -7,7 +7,6 @@ import CardDescriptor from 'src/components/ui/CardDescriptor.vue';
|
||||||
import VnLv from 'src/components/ui/VnLv.vue';
|
import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
|
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
|
||||||
import ItemDescriptorImage from 'src/pages/Item/Card/ItemDescriptorImage.vue';
|
import ItemDescriptorImage from 'src/pages/Item/Card/ItemDescriptorImage.vue';
|
||||||
import useCardDescription from 'src/composables/useCardDescription';
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { dashIfEmpty } from 'src/filters';
|
import { dashIfEmpty } from 'src/filters';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
|
@ -55,10 +54,8 @@ onMounted(async () => {
|
||||||
mounted.value = true;
|
mounted.value = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = ref(useCardDescription());
|
|
||||||
const setData = async (entity) => {
|
const setData = async (entity) => {
|
||||||
if (!entity) return;
|
if (!entity) return;
|
||||||
data.value = useCardDescription(entity.name, entity.id);
|
|
||||||
await updateStock();
|
await updateStock();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -90,10 +87,8 @@ const updateStock = async () => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<CardDescriptor
|
<CardDescriptor
|
||||||
data-key="ItemData"
|
data-key="Item"
|
||||||
module="Item"
|
module="Item"
|
||||||
:title="data.title"
|
|
||||||
:subtitle="data.subtitle"
|
|
||||||
:summary="$props.summary"
|
:summary="$props.summary"
|
||||||
:url="`Items/${entityId}/getCard`"
|
:url="`Items/${entityId}/getCard`"
|
||||||
@on-fetch="setData"
|
@on-fetch="setData"
|
||||||
|
|
|
@ -125,7 +125,7 @@ onMounted(async () => {
|
||||||
inventoriedDate.value =
|
inventoriedDate.value =
|
||||||
(await axios.get('Configs/findOne')).data?.inventoried || today;
|
(await axios.get('Configs/findOne')).data?.inventoried || today;
|
||||||
|
|
||||||
if (query.warehouseFk) ref.warehouseFk = query.warehouseFk;
|
if (query.warehouseFk) ref.warehouseFk = +query.warehouseFk;
|
||||||
else if (!ref.warehouseFk && user.value) ref.warehouseFk = user.value.warehouseFk;
|
else if (!ref.warehouseFk && user.value) ref.warehouseFk = user.value.warehouseFk;
|
||||||
if (ref.date) showWhatsBeforeInventory.value = true;
|
if (ref.date) showWhatsBeforeInventory.value = true;
|
||||||
ref.itemFk = route.params.id;
|
ref.itemFk = route.params.id;
|
||||||
|
@ -143,7 +143,7 @@ onMounted(async () => {
|
||||||
const fetchItemBalances = async () => await arrayDataItemBalances.fetch({});
|
const fetchItemBalances = async () => await arrayDataItemBalances.fetch({});
|
||||||
|
|
||||||
const getBadgeAttrs = (_date) => {
|
const getBadgeAttrs = (_date) => {
|
||||||
const isSameDate = date.isSameDate(today.value, _date);
|
const isSameDate = date.isSameDate(today, _date);
|
||||||
const attrs = {
|
const attrs = {
|
||||||
'text-color': isSameDate ? 'black' : 'white',
|
'text-color': isSameDate ? 'black' : 'white',
|
||||||
color: isSameDate ? 'warning' : 'transparent',
|
color: isSameDate ? 'warning' : 'transparent',
|
||||||
|
@ -153,8 +153,6 @@ const getBadgeAttrs = (_date) => {
|
||||||
|
|
||||||
const scrollToToday = async () => {
|
const scrollToToday = async () => {
|
||||||
await nextTick();
|
await nextTick();
|
||||||
const today = Date.vnNew();
|
|
||||||
today.setHours(0, 0, 0, 0);
|
|
||||||
const todayCell = document.querySelector(`td[data-date="${today.toISOString()}"]`);
|
const todayCell = document.querySelector(`td[data-date="${today.toISOString()}"]`);
|
||||||
if (todayCell) {
|
if (todayCell) {
|
||||||
todayCell.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
todayCell.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||||
|
|
|
@ -175,7 +175,7 @@ const insertTag = (rows) => {
|
||||||
@click="insertTag(rows)"
|
@click="insertTag(rows)"
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="add"
|
icon="add"
|
||||||
shortcut="+"
|
v-shortcut="'+'"
|
||||||
fab
|
fab
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue