-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue
index fd508cea3..3c1a4c8a5 100644
--- a/src/components/ui/VnFilterPanel.vue
+++ b/src/components/ui/VnFilterPanel.vue
@@ -4,11 +4,11 @@ import { useI18n } from 'vue-i18n';
import { useArrayData } from 'composables/useArrayData';
import { useRoute } from 'vue-router';
import toDate from 'filters/toDate';
-import useRedirect from 'src/composables/useRedirect';
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
const { t } = useI18n();
-const props = defineProps({
+const params = defineModel({ default: {}, required: true, type: Object });
+const $props = defineProps({
dataKey: {
type: String,
required: true,
@@ -18,11 +18,6 @@ const props = defineProps({
required: false,
default: false,
},
- params: {
- type: Object,
- required: false,
- default: null,
- },
showAll: {
type: Boolean,
default: true,
@@ -40,12 +35,20 @@ const props = defineProps({
},
hiddenTags: {
type: Array,
- default: () => [],
+ default: () => ['filter'],
},
customTags: {
type: Array,
default: () => [],
},
+ disableSubmitEvent: {
+ type: Boolean,
+ default: false,
+ },
+ searchUrl: {
+ type: String,
+ default: 'params',
+ },
redirect: {
type: Boolean,
default: true,
@@ -54,61 +57,64 @@ const props = defineProps({
const emit = defineEmits(['refresh', 'clear', 'search', 'init', 'remove']);
-const arrayData = useArrayData(props.dataKey, {
- exprBuilder: props.exprBuilder,
+const arrayData = useArrayData($props.dataKey, {
+ exprBuilder: $props.exprBuilder,
+ searchUrl: $props.searchUrl,
+ navigate: $props.redirect ? {} : null,
});
const route = useRoute();
const store = arrayData.store;
-const userParams = ref({});
-const { navigate } = useRedirect();
onMounted(() => {
- if (props.params) userParams.value = JSON.parse(JSON.stringify(props.params));
- if (Object.keys(store.userParams).length > 0) {
- userParams.value = JSON.parse(JSON.stringify(store.userParams));
- }
- emit('init', { params: userParams.value });
+ emit('init', { params: params.value });
});
+function setUserParams(watchedParams) {
+ if (!watchedParams) return;
+
+ if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams);
+ watchedParams = { ...watchedParams, ...watchedParams.filter?.where };
+ delete watchedParams.filter;
+ params.value = { ...params.value, ...watchedParams };
+}
+
watch(
- () => route.query.params,
- (val) => {
- if (!val) {
- userParams.value = {};
- } else {
- const parsedParams = JSON.parse(val);
- userParams.value = { ...parsedParams };
- }
- }
+ () => route.query[$props.searchUrl],
+ (val) => setUserParams(val)
+);
+
+watch(
+ () => arrayData.store.userParams,
+ (val) => setUserParams(val)
);
const isLoading = ref(false);
-async function search() {
+async function search(evt) {
+ if (evt && $props.disableSubmitEvent) return;
+
store.filter.where = {};
isLoading.value = true;
- const params = { ...userParams.value };
+ const filter = { ...params.value };
store.userParamsChanged = true;
store.filter.skip = 0;
store.skip = 0;
- const { params: newParams } = await arrayData.addFilter({ params });
- userParams.value = newParams;
+ const { params: newParams } = await arrayData.addFilter({ params: params.value });
+ params.value = newParams;
- if (!props.showAll && !Object.values(params).length) store.data = [];
+ if (!$props.showAll && !Object.values(filter).length) store.data = [];
isLoading.value = false;
emit('search');
- if (props.redirect) navigate(store.data, {});
}
async function reload() {
isLoading.value = true;
- const params = Object.values(userParams.value).filter((param) => param);
+ const params = Object.values(params.value).filter((param) => param);
await arrayData.fetch({ append: false });
- if (!props.showAll && !params.length) store.data = [];
+ if (!$props.showAll && !params.length) store.data = [];
isLoading.value = false;
emit('refresh');
- if (props.redirect) navigate(store.data, {});
}
async function clearFilters() {
@@ -117,18 +123,19 @@ async function clearFilters() {
store.filter.skip = 0;
store.skip = 0;
// Filtrar los params no removibles
- const removableFilters = Object.keys(userParams.value).filter((param) =>
- props.unremovableParams.includes(param)
+ const removableFilters = Object.keys(params.value).filter((param) =>
+ $props.unremovableParams.includes(param)
);
const newParams = {};
// Conservar solo los params que no son removibles
for (const key of removableFilters) {
- newParams[key] = userParams.value[key];
+ newParams[key] = params.value[key];
}
- userParams.value = { ...newParams }; // Actualizar los params con los removibles
- await arrayData.applyFilter({ params: userParams.value });
+ params.value = {};
+ params.value = { ...newParams }; // Actualizar los params con los removibles
+ await arrayData.applyFilter({ params: params.value });
- if (!props.showAll) {
+ if (!$props.showAll) {
store.data = [];
}
@@ -136,36 +143,32 @@ async function clearFilters() {
emit('clear');
}
-const tagsList = computed(() =>
- Object.entries(userParams.value)
- .filter(([key, value]) => value && !(props.hiddenTags || []).includes(key))
- .map(([key, value]) => ({
- label: key,
- value: value,
- }))
-);
+const tagsList = computed(() => {
+ const tagList = [];
+ for (const key of Object.keys(params.value)) {
+ const value = params.value[key];
+ if (value == null || ($props.hiddenTags || []).includes(key)) continue;
+ tagList.push({ label: key, value });
+ }
+ return tagList;
+});
-const tags = computed(() =>
- tagsList.value.filter((tag) => !(props.customTags || []).includes(tag.label))
-);
+const tags = computed(() => {
+ return tagsList.value.filter((tag) => !($props.customTags || []).includes(tag.key));
+});
const customTags = computed(() =>
- tagsList.value.filter((tag) => (props.customTags || []).includes(tag.label))
+ tagsList.value.filter((tag) => ($props.customTags || []).includes(tag.key))
);
async function remove(key) {
- userParams.value[key] = null;
- await arrayData.applyFilter({ params: userParams.value });
+ params.value[key] = undefined;
+ search();
emit('remove', key);
}
function formatValue(value) {
- if (typeof value === 'boolean') {
- return value ? t('Yes') : t('No');
- }
-
- if (isNaN(value) && !isNaN(Date.parse(value))) {
- return toDate(value);
- }
+ if (typeof value === 'boolean') return value ? t('Yes') : t('No');
+ if (isNaN(value) && !isNaN(Date.parse(value))) return toDate(value);
return `"${value}"`;
}
@@ -226,14 +229,14 @@ function formatValue(value) {
{{ chip.label }}:
- "{{ chip.value }}"
+ "{{ formatValue(chip.value) }}"
-
+
-
+
@@ -269,7 +272,6 @@ function formatValue(value) {
color="primary"
/>
-
diff --git a/src/components/ui/VnNotes.vue b/src/components/ui/VnNotes.vue
index 937ec4b6c..f4cdde310 100644
--- a/src/components/ui/VnNotes.vue
+++ b/src/components/ui/VnNotes.vue
@@ -21,7 +21,7 @@ const currentUser = ref(state.getUser());
const newNote = ref('');
const vnPaginateRef = ref();
function handleKeyUp(event) {
- if (event.key === 'Enter') {
+ if (event.key === 'Enter') {
event.preventDefault();
if (!event.shiftKey) insert();
}
@@ -78,6 +78,7 @@ async function insert() {
ref="vnPaginateRef"
class="show"
v-bind="$attrs"
+ search-url="notes"
>
diff --git a/src/components/ui/VnPaginate.vue b/src/components/ui/VnPaginate.vue
index 190393d2f..9a2c06b0c 100644
--- a/src/components/ui/VnPaginate.vue
+++ b/src/components/ui/VnPaginate.vue
@@ -58,14 +58,19 @@ const props = defineProps({
type: Function,
default: null,
},
+ searchUrl: {
+ type: String,
+ default: null,
+ },
disableInfiniteScroll: {
type: Boolean,
default: false,
},
});
-const emit = defineEmits(['onFetch', 'onPaginate']);
+const emit = defineEmits(['onFetch', 'onPaginate', 'onChange']);
const isLoading = ref(false);
+const mounted = ref(false);
const pagination = ref({
sortBy: props.order,
rowsPerPage: props.limit,
@@ -81,11 +86,13 @@ const arrayData = useArrayData(props.dataKey, {
userParams: props.userParams,
exprBuilder: props.exprBuilder,
keepOpts: props.keepOpts,
+ searchUrl: props.searchUrl,
});
const store = arrayData.store;
-onMounted(() => {
- if (props.autoLoad) fetch();
+onMounted(async () => {
+ if (props.autoLoad) await fetch();
+ mounted.value = true;
});
watch(
@@ -95,11 +102,22 @@ watch(
}
);
+watch(
+ () => store.data,
+ (data) => emit('onChange', data)
+);
+
+watch(
+ () => props.url,
+ (url) => fetch({ url })
+);
+
const addFilter = async (filter, params) => {
await arrayData.addFilter({ filter, params });
};
-async function fetch() {
+async function fetch(params) {
+ useArrayData(props.dataKey, params);
store.filter.skip = 0;
store.skip = 0;
await arrayData.fetch({ append: false });
@@ -107,6 +125,7 @@ async function fetch() {
isLoading.value = false;
}
emit('onFetch', store.data);
+ return store.data;
}
async function paginate() {
@@ -138,7 +157,7 @@ function endPagination() {
emit('onPaginate');
}
async function onLoad(index, done) {
- if (!store.data) return done();
+ if (!store.data || !mounted.value) return done();
if (store.data.length === 0 || !props.url) return done(false);
@@ -150,7 +169,7 @@ async function onLoad(index, done) {
done(isDone);
}
-defineExpose({ fetch, addFilter });
+defineExpose({ fetch, addFilter, paginate });
@@ -199,12 +218,6 @@ defineExpose({ fetch, addFilter });
-
-
-
diff --git a/src/pages/Customer/Defaulter/CustomerDefaulter.vue b/src/pages/Customer/Defaulter/CustomerDefaulter.vue
index af7ce0a26..06732b944 100644
--- a/src/pages/Customer/Defaulter/CustomerDefaulter.vue
+++ b/src/pages/Customer/Defaulter/CustomerDefaulter.vue
@@ -22,7 +22,7 @@ const balanceDueTotal = ref(0);
const selected = ref([]);
const tableColumnComponents = {
- client: {
+ clientFk: {
component: QBtn,
props: () => ({ flat: true, class: 'link', noCaps: true }),
event: () => {},
@@ -40,7 +40,7 @@ const tableColumnComponents = {
props: () => ({ flat: true, class: 'link', noCaps: true }),
event: () => {},
},
- department: {
+ departmentName: {
component: 'span',
props: () => {},
event: () => {},
@@ -102,12 +102,12 @@ const columns = computed(() => [
align: 'left',
field: 'clientName',
label: t('Client'),
- name: 'client',
+ name: 'clientFk',
sortable: true,
},
{
align: 'left',
- field: 'isWorker',
+ field: ({ isWorker }) => Boolean(isWorker),
label: t('Is worker'),
name: 'isWorker',
},
@@ -122,7 +122,7 @@ const columns = computed(() => [
align: 'left',
field: 'departmentName',
label: t('Department'),
- name: 'department',
+ name: 'departmentName',
sortable: true,
},
{
@@ -204,48 +204,24 @@ const viewAddObservation = (rowsSelected) => {
});
};
-const departments = ref(new Map());
-
const onFetch = async (data) => {
- const salesPersonFks = data.map((item) => item.salesPersonFk);
- const departmentNames = salesPersonFks.map(async (salesPersonFk) => {
- try {
- const { data: workerDepartment } = await axios.get(
- `WorkerDepartments/${salesPersonFk}`
- );
- const { data: department } = await axios.get(
- `Departments/${workerDepartment.departmentFk}`
- );
- departments.value.set(salesPersonFk, department.name);
- } catch (error) {
- console.error('Err: ', error);
- }
- });
const recoveryData = await axios.get('Recoveries');
-
const recoveries = recoveryData.data.map(({ clientFk, finished }) => ({
clientFk,
finished,
}));
- await Promise.all(departmentNames);
-
data.forEach((item) => {
- item.departmentName = departments.value.get(item.salesPersonFk);
- item.isWorker = item.businessTypeFk === 'worker';
const recovery = recoveries.find(({ clientFk }) => clientFk === item.clientFk);
item.finished = recovery?.finished === null;
});
-
- for (const element of data) element.isWorker = element.businessTypeFk === 'worker';
-
balanceDueTotal.value = data.reduce((acc, { amount = 0 }) => acc + amount, 0);
};
function exprBuilder(param, value) {
switch (param) {
case 'clientFk':
- return { [`d.${param}`]: value?.id };
+ return { [`d.${param}`]: value };
case 'creditInsurance':
case 'amount':
case 'workerFk':
diff --git a/src/pages/Customer/Defaulter/CustomerDefaulterFilter.vue b/src/pages/Customer/Defaulter/CustomerDefaulterFilter.vue
index 9220bd7c0..1d7f63f36 100644
--- a/src/pages/Customer/Defaulter/CustomerDefaulterFilter.vue
+++ b/src/pages/Customer/Defaulter/CustomerDefaulterFilter.vue
@@ -1,7 +1,6 @@
- (clients = data)" auto-load url="Clients" />
(salespersons = data)"
@@ -36,6 +34,7 @@ const authors = ref();
auto-load
url="Workers/activeWithInheritedRole"
/>
+ (departments = data)" auto-load url="Departments" />
@@ -47,29 +46,22 @@ const authors = ref();
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
@@ -104,7 +119,7 @@ const authors = ref();
emit-value
hide-selected
map-options
- option-label="country"
+ option-label="name"
option-value="id"
outlined
rounded
diff --git a/src/pages/Customer/ExtendedList/CustomerExtendedList.vue b/src/pages/Customer/ExtendedList/CustomerExtendedList.vue
deleted file mode 100644
index 79459d1a1..000000000
--- a/src/pages/Customer/ExtendedList/CustomerExtendedList.vue
+++ /dev/null
@@ -1,619 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- navigateToTravelId(row.id)"
- >
-
-
- {{ value }}
-
-
-
-
-
-
-
-
-
-
-
-
- {{ props.row.id }}
-
-
-
-
-
-
-
- {{ props.row.salesPerson }}
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/pages/Customer/ExtendedList/CustomerExtendedListActions.vue b/src/pages/Customer/ExtendedList/CustomerExtendedListActions.vue
deleted file mode 100644
index 8355c7560..000000000
--- a/src/pages/Customer/ExtendedList/CustomerExtendedListActions.vue
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
- {{ t('Client ticket list') }}
-
-
-
-
- {{ t('Preview') }}
-
-
-
-
-
-
-es:
- Client ticket list: Listado de tickets del cliente
- Preview: Vista previa
-
diff --git a/src/pages/Customer/ExtendedList/CustomerExtendedListFilter.vue b/src/pages/Customer/ExtendedList/CustomerExtendedListFilter.vue
deleted file mode 100644
index 1be20f26c..000000000
--- a/src/pages/Customer/ExtendedList/CustomerExtendedListFilter.vue
+++ /dev/null
@@ -1,571 +0,0 @@
-
-
-
- (clients = data)"
- auto-load
- />
- (workers = data)"
- auto-load
- />
- (workers = data)"
- auto-load
- />
- (countriesOptions = data)"
- auto-load
- />
- (provincesOptions = data)"
- auto-load
- url="Provinces"
- />
- (paymethodsOptions = data)"
- auto-load
- />
- (businessTypesOptions = data)"
- auto-load
- />
- (sageTaxTypesOptions = data)"
- />
- (sageTransactionTypesOptions = data)"
- />
-
-
-
- {{ t(`customer.extendedList.tableVisibleColumns.${tag.label}`) }}:
-
- {{ formatFn(tag.value) }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-es:
- Social name: Razón social
-
diff --git a/src/pages/Department/Card/DepartmentDescriptorProxy.vue b/src/pages/Department/Card/DepartmentDescriptorProxy.vue
index 07a6b6af1..5b556f655 100644
--- a/src/pages/Department/Card/DepartmentDescriptorProxy.vue
+++ b/src/pages/Department/Card/DepartmentDescriptorProxy.vue
@@ -1,6 +1,6 @@
diff --git a/src/pages/InvoiceOut/Card/InvoiceOutSummary.vue b/src/pages/InvoiceOut/Card/InvoiceOutSummary.vue
index e98de6b30..c773c43cf 100644
--- a/src/pages/InvoiceOut/Card/InvoiceOutSummary.vue
+++ b/src/pages/InvoiceOut/Card/InvoiceOutSummary.vue
@@ -106,6 +106,7 @@ const ticketsColumns = ref([
ref="summary"
:url="`InvoiceOuts/${entityId}/summary`"
:entity-id="entityId"
+ data-key="InvoiceOutSummary"
>
{{ invoiceOut.ref }} - {{ invoiceOut.client?.socialName }}
diff --git a/src/pages/Item/Card/ItemDescriptor.vue b/src/pages/Item/Card/ItemDescriptor.vue
index 155c9eb4c..f3eba8c82 100644
--- a/src/pages/Item/Card/ItemDescriptor.vue
+++ b/src/pages/Item/Card/ItemDescriptor.vue
@@ -13,7 +13,6 @@ import ItemDescriptorImage from 'src/pages/Item/Card/ItemDescriptorImage.vue';
import { useState } from 'src/composables/useState';
import useCardDescription from 'src/composables/useCardDescription';
-import { useSession } from 'src/composables/useSession';
import { getUrl } from 'src/composables/getUrl';
import axios from 'axios';
import { dashIfEmpty } from 'src/filters';
@@ -42,14 +41,12 @@ const quasar = useQuasar();
const route = useRoute();
const router = useRouter();
const { t } = useI18n();
-const { getTokenMultimedia } = useSession();
const state = useState();
const user = state.getUser();
const entityId = computed(() => {
return $props.id || route.params.id;
});
-const image = ref(null);
const regularizeStockFormDialog = ref(null);
const item = ref(null);
const available = ref(null);
@@ -67,17 +64,10 @@ const warehouseFk = computed({
});
onMounted(async () => {
- await getItemAvatar();
warehouseFk.value = user.value.warehouseFk;
salixUrl.value = await getUrl('');
});
-const getItemAvatar = async () => {
- const token = getTokenMultimedia();
- const timeStamp = `timestamp=${Date.now()}`;
- image.value = `/api/Images/catalog/200x200/${entityId.value}/download?access_token=${token}&${timeStamp}`;
-};
-
const data = ref(useCardDescription());
const setData = (entity) => {
if (!entity) return;
diff --git a/src/pages/Item/Card/ItemDescriptorImage.vue b/src/pages/Item/Card/ItemDescriptorImage.vue
index f16a57548..aceede880 100644
--- a/src/pages/Item/Card/ItemDescriptorImage.vue
+++ b/src/pages/Item/Card/ItemDescriptorImage.vue
@@ -3,8 +3,7 @@ import { ref, onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
import EditPictureForm from 'components/EditPictureForm.vue';
-
-import { useSession } from 'src/composables/useSession';
+import VnImg from 'src/components/ui/VnImg.vue';
import axios from 'axios';
const $props = defineProps({
@@ -27,19 +26,12 @@ const $props = defineProps({
});
const { t } = useI18n();
-const { getTokenMultimedia } = useSession();
const image = ref(null);
const editPhotoFormDialog = ref(null);
const showEditPhotoForm = ref(false);
const warehouseName = ref(null);
-const getItemAvatar = async () => {
- const token = getTokenMultimedia();
- const timeStamp = `timestamp=${Date.now()}`;
- image.value = `/api/Images/catalog/200x200/${$props.entityId}/download?access_token=${token}&${timeStamp}`;
-};
-
const toggleEditPictureForm = () => {
showEditPhotoForm.value = !showEditPhotoForm.value;
};
@@ -62,14 +54,17 @@ const getWarehouseName = async (warehouseFk) => {
};
onMounted(async () => {
- getItemAvatar();
getItemConfigs();
});
+
+const handlePhotoUpdated = (evt = false) => {
+ image.value.reload(evt);
+};
-
+
@@ -82,7 +77,7 @@ onMounted(async () => {
-
+
{
collection="catalog"
:id="entityId"
@close-form="toggleEditPictureForm()"
- @on-photo-uploaded="getItemAvatar()"
+ @on-photo-uploaded="handlePhotoUpdated"
/>
diff --git a/src/pages/Item/ItemFixedPrice.vue b/src/pages/Item/ItemFixedPrice.vue
index 97f40b84d..2ecd1f21b 100644
--- a/src/pages/Item/ItemFixedPrice.vue
+++ b/src/pages/Item/ItemFixedPrice.vue
@@ -33,7 +33,6 @@ const user = state.getUser();
const fixedPrices = ref([]);
const fixedPricesOriginalData = ref([]);
const warehousesOptions = ref([]);
-const itemsWithNameOptions = ref([]);
const rowsSelected = ref([]);
const exprBuilder = (param, value) => {
@@ -371,12 +370,6 @@ onUnmounted(() => (stateStore.rightDrawer = false));
auto-load
@on-fetch="(data) => onWarehousesFetched(data)"
/>
-
(itemsWithNameOptions = data)"
- />
(stateStore.rightDrawer = false));
(stateStore.rightDrawer = false));
-
+
{{ t('Edit fixed price(s)') }}
diff --git a/src/pages/Item/ItemList.vue b/src/pages/Item/ItemList.vue
index 0e40740b9..f1e3629cd 100644
--- a/src/pages/Item/ItemList.vue
+++ b/src/pages/Item/ItemList.vue
@@ -16,17 +16,15 @@ import ItemListFilter from './ItemListFilter.vue';
import { useStateStore } from 'stores/useStateStore';
import { toDateFormat } from 'src/filters/date.js';
-import { useSession } from 'composables/useSession';
import { dashIfEmpty } from 'src/filters';
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import { useVnConfirm } from 'composables/useVnConfirm';
import axios from 'axios';
import RightMenu from 'src/components/common/RightMenu.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
+import VnImg from 'src/components/ui/VnImg.vue';
const router = useRouter();
-const { getTokenMultimedia } = useSession();
-const token = getTokenMultimedia();
const stateStore = useStateStore();
const { t } = useI18n();
const { viewSummary } = useSummaryDialog();
@@ -491,10 +489,9 @@ onUnmounted(() => (stateStore.rightDrawer = false));
- {
+ if (val.length > 2) {
+ if (!tagOptions.value.includes(val)) {
+ done(tagOptions.value, 'add-unique');
+ }
+ tagValues.value.push({ value: val });
+ }
+};
const resetCategory = () => {
selectedCategoryFk.value = null;
typeList.value = null;
};
-const selectedOrder = ref(null);
-const orderList = [
- { way: 'ASC', name: 'Ascendant' },
- { way: 'DESC', name: 'Descendant' },
-];
-
-const selectedOrderField = ref(null);
-const OrderFields = [
- { field: 'relevancy DESC, name', name: 'Relevancy', priority: 999 },
- { field: 'showOrder, price', name: 'Color and price', priority: 999 },
- { field: 'name', name: 'Name', priority: 999 },
- { field: 'price', name: 'Price', priority: 999 },
-];
-
const clearFilter = (key) => {
if (key === 'categoryFk') {
resetCategory();
@@ -72,21 +75,6 @@ const loadTypes = async (categoryFk) => {
typeList.value = data;
};
-const onFilterInit = async ({ params }) => {
- if (params.typeFk) {
- selectedTypeFk.value = params.typeFk;
- }
- if (params.categoryFk) {
- await loadTypes(params.categoryFk);
- selectedCategoryFk.value = params.categoryFk;
- }
- if (params.orderBy) {
- orderByParam.value = JSON.parse(params.orderBy);
- selectedOrder.value = orderByParam.value?.way;
- selectedOrderField.value = orderByParam.value?.field;
- }
-};
-
const selectedCategory = computed(() =>
(categoryList.value || []).find(
(category) => category?.id === selectedCategoryFk.value
@@ -109,10 +97,7 @@ function exprBuilder(param, value) {
const selectedTag = ref(null);
const tagValues = ref([{}]);
-const tagOptions = ref(null);
-const isButtonDisabled = computed(
- () => !selectedTag.value || tagValues.value.some((item) => !item.value)
-);
+const tagOptions = ref([]);
const applyTagFilter = (params, search) => {
if (!tagValues.value?.length) {
@@ -125,12 +110,12 @@ const applyTagFilter = (params, search) => {
}
params.tagGroups.push(
JSON.stringify({
- values: tagValues.value,
+ values: tagValues.value.filter((obj) => Object.keys(obj).length > 0),
tagSelection: {
...selectedTag.value,
- orgShowField: selectedTag.value.name,
+ orgShowField: selectedTag?.value?.name,
},
- tagFk: selectedTag.value.tagFk,
+ tagFk: selectedTag?.value?.tagFk,
})
);
search();
@@ -147,20 +132,52 @@ const removeTagChip = (selection, params, search) => {
search();
};
-const orderByParam = ref(null);
-
-const onOrderFieldChange = (value, params, search) => {
- const orderBy = Object.assign({}, orderByParam.value, { field: value.field });
- params.orderBy = JSON.stringify(orderBy);
- search();
+const onOrderChange = (value, params) => {
+ const tagObj = JSON.parse(params.orderBy);
+ tagObj.way = value.name;
+ params.orderBy = JSON.stringify(tagObj);
};
-const onOrderChange = (value, params, search) => {
- const orderBy = Object.assign({}, orderByParam.value, { way: value.way });
- params.orderBy = JSON.stringify(orderBy);
- search();
+const onOrderFieldChange = (value, params) => {
+ const tagObj = JSON.parse(params.orderBy); // esto donde va
+ const fields = {
+ Relevancy: (value) => value + ' DESC, name',
+ ColorAndPrice: 'showOrder, price',
+ Name: 'name',
+ Price: 'price',
+ };
+ let tagField = fields[value];
+ if (!tagField) return;
+
+ if (typeof tagField === 'function') tagField = tagField(value);
+ tagObj.field = tagField;
+ params.orderBy = JSON.stringify(tagObj);
+ switch (value) {
+ case 'Relevancy':
+ tagObj.field = value + ' DESC, name';
+ params.orderBy = JSON.stringify(tagObj);
+ console.log('params: ', params);
+ break;
+ case 'ColorAndPrice':
+ tagObj.field = 'showOrder, price';
+ params.orderBy = JSON.stringify(tagObj);
+ console.log('params: ', params);
+ break;
+ case 'Name':
+ tagObj.field = 'name';
+ params.orderBy = JSON.stringify(tagObj);
+ console.log('params: ', params);
+ break;
+ case 'Price':
+ tagObj.field = 'price';
+ params.orderBy = JSON.stringify(tagObj);
+ console.log('params: ', params);
+ break;
+ }
};
+const _moreFields = ['ASC', 'DESC'];
+const _moreFieldsTypes = ['Relevancy', 'ColorAndPrice', 'Name', 'Price'];
const setCategoryList = (data) => {
categoryList.value = (data || [])
.filter((category) => category.display)
@@ -168,6 +185,8 @@ const setCategoryList = (data) => {
...category,
icon: `vn:${(category.icon || '').split('-')[1]}`,
}));
+ moreFields.value = useLang(_moreFields);
+ moreFieldsOrder.value = useLang(_moreFieldsTypes);
};
const getCategoryClass = (category, params) => {
@@ -175,6 +194,20 @@ const getCategoryClass = (category, params) => {
return 'active';
}
};
+
+const useLang = (values) => {
+ const { models } = validationsStore;
+ const properties = models.Item?.properties || {};
+ return values.map((name) => {
+ let prop = properties[name];
+ const label = t(`params.${name}`);
+ return {
+ name,
+ label,
+ type: prop ? prop.type : null,
+ };
+ });
+};
@@ -182,10 +215,11 @@ const getCategoryClass = (category, params) => {
@@ -274,40 +308,29 @@ const getCategoryClass = (category, params) => {
onOrderChange(value, params, searchFn)
- "
+ @update:model-value="(value) => onOrderChange(value, params)"
/>
onOrderFieldChange(value, params, searchFn)
- "
+ @update:model-value="(value) => onOrderFieldChange(value, params)"
/>
@@ -333,15 +356,30 @@ const getCategoryClass = (category, params) => {
:key="value"
class="q-mt-md filter-value"
>
- (tagOptions = data)"
/>
+ {
rounded
emit-value
use-input
- :disable="!selectedTag"
+ class="filter-input"
+ @new-value="createValue"
+ />
+
-
- (tagOptions = data)"
- />
-
{
rounded
type="button"
unelevated
- :disable="isButtonDisabled"
@click.stop="applyTagFilter(params, searchFn)"
/>
@@ -453,6 +490,12 @@ en:
tag: Tag
value: Value
order: Order
+ ASC: Ascendant
+ DESC: Descendant
+ Relevancy: Relevancy
+ ColorAndPrice: Color and price
+ Name: Name
+ Price: Price
es:
params:
type: Tipo
@@ -460,6 +503,14 @@ es:
tag: Etiqueta
value: Valor
order: Orden
+ ASC: Ascendiente
+ DESC: Descendiente
+ Relevancy: Relevancia
+ ColorAndPrice: Color y precio
+ Name: Nombre
+ Price: Precio
+ Order: Orden
+ Order by: Ordenar por
Plant: Planta
Flower: Flor
Handmade: Confección
diff --git a/src/pages/Order/Card/OrderCatalogItem.vue b/src/pages/Order/Card/OrderCatalogItem.vue
index 0e1005493..34e22915d 100644
--- a/src/pages/Order/Card/OrderCatalogItem.vue
+++ b/src/pages/Order/Card/OrderCatalogItem.vue
@@ -3,16 +3,14 @@ import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import VnLv from 'components/ui/VnLv.vue';
+import VnImg from 'src/components/ui/VnImg.vue';
import OrderCatalogItemDialog from 'pages/Order/Card/OrderCatalogItemDialog.vue';
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
-import { useSession } from 'composables/useSession';
import toCurrency from '../../../filters/toCurrency';
const DEFAULT_PRICE_KG = 0;
-const { getTokenMultimedia } = useSession();
-const token = getTokenMultimedia();
const { t } = useI18n();
defineProps({
@@ -29,14 +27,7 @@ const dialog = ref(null);