diff --git a/src/pages/Entry/EntryLatestBuys.vue b/src/pages/Entry/EntryLatestBuys.vue index 32f975ca7..7c5e03285 100644 --- a/src/pages/Entry/EntryLatestBuys.vue +++ b/src/pages/Entry/EntryLatestBuys.vue @@ -1,5 +1,5 @@ @@ -649,6 +652,11 @@ onMounted(async () => { + + + + + +import { computed, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute } from 'vue-router'; + +// import VnInput from 'components/common/VnInput.vue'; +import FetchData from 'components/FetchData.vue'; +import VnInputDate from 'src/components/common/VnInputDate.vue'; +import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue'; +import VnSelectFilter from 'components/common/VnSelectFilter.vue'; +// import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue'; + +import axios from 'axios'; + +const { t } = useI18n(); +const route = useRoute(); +const props = defineProps({ + dataKey: { + type: String, + required: true, + }, + tags: { + type: Array, + required: true, + }, +}); + +const itemCategories = ref(null); +const selectedCategoryFk = ref(null); +const selectedTypeFk = ref(null); +const itemTypesOptions = ref([]); +const itemTypeWorkersOptions = ref([]); +const suppliersOptions = ref([]); + +const categoryList = computed(() => { + return (itemCategories.value || []) + .filter((category) => category.display) + .map((category) => ({ + ...category, + icon: `vn:${(category.icon || '').split('-')[1]}`, + })); +}); + +const selectCategory = async (params, categoryId, search) => { + if (params.categoryFk === categoryId) { + resetCategory(); + params.categoryFk = null; + return; + } + + selectedCategoryFk.value = categoryId; + params.categoryFk = categoryId; + console.log('params:: ', params); + await fetchItemTypes(categoryId); + search(); +}; + +const resetCategory = () => { + selectedCategoryFk.value = null; + itemTypesOptions.value = null; +}; + +const fetchItemTypes = async (id) => { + try { + const filter = { + fields: ['id', 'name', 'categoryFk'], + where: { categoryFk: id }, + include: 'category', + order: 'name ASC', + }; + const { data } = await axios.get('ItemTypes', { + params: { filter: JSON.stringify(filter) }, + }); + itemTypesOptions.value = data; + } catch (err) { + console.error('Error fetching item types', err); + } +}; + +// 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(); +// } +// }; + +// 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(() => +// (itemCategories.value || []).find( +// (category) => category?.id === selectedCategoryFk.value +// ) +// ); + +// const selectedType = computed(() => { +// return (typeList.value || []).find((type) => type?.id === selectedTypeFk.value); +// }); + +// function exprBuilder(param, value) { +// switch (param) { +// case 'categoryFk': +// case 'typeFk': +// return { [param]: value }; +// case 'search': +// return { 'i.name': { like: `%${value}%` } }; +// } +// } + +// const selectedTag = ref(null); +// const tagValues = ref([{}]); +// const tagOptions = ref(null); +// const isButtonDisabled = computed( +// () => !selectedTag.value || tagValues.value.some((item) => !item.value) +// ); + +// const applyTagFilter = (params, search) => { +// if (!tagValues.value?.length) { +// params.tagGroups = null; +// search(); +// return; +// } +// if (!params.tagGroups) { +// params.tagGroups = []; +// } +// params.tagGroups.push( +// JSON.stringify({ +// values: tagValues.value, +// tagSelection: { +// ...selectedTag.value, +// orgShowField: selectedTag.value.name, +// }, +// tagFk: selectedTag.value.tagFk, +// }) +// ); +// search(); +// selectedTag.value = null; +// tagValues.value = [{}]; +// }; + +// const removeTagChip = (selection, params, search) => { +// if (params.tagGroups) { +// params.tagGroups = (params.tagGroups || []).filter( +// (value) => value !== selection +// ); +// } +// 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, search) => { +// const orderBy = Object.assign({}, orderByParam.value, { way: value.way }); +// params.orderBy = JSON.stringify(orderBy); +// search(); +// }; + +const getCategoryClass = (category, params) => { + if (category.id === params?.categoryFk) { + return 'active'; + } +}; + + + + (itemCategories = data)" + /> + (itemTypeWorkersOptions = data)" + /> + (suppliersOptions = data)" + /> + + + + {{ t(`params.${tag.label}`) }}: + {{ formatFn(tag.value) }} + + + + + + + + + {{ t(category.name) }} + + + + + + + { + selectedTypeFk = value; + searchFn(); + } + " + > + + + + {{ opt.name }} + + {{ opt.categoryName }} + + + + + + + + + + + + + + + + + + + + {{ opt.name }} + + {{ opt.nickname }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +en: + params: + orderBy: Order By + tag: Tag + value: Value + order: Order + + supplier: Supplier + from: From + to: To + active: Is active + visible: Is visible + floramondo: Is floramondo + salesPersonFk: Buyer + categoryFk: Category + typeFk: Type +es: + params: + orderBy: Ordenar por + tag: Etiqueta + value: Valor + order: Orden + + supplier: Proveedor + from: Desde + to: Hasta + active: Activo + visible: Visible + floramondo: Floramondo + salesPersonFk: Comprador + categoryFk: CategorÃa + typeFk: Tipo + + Plant: Planta + Flower: Flor + Handmade: Confección + Green: Verde + Accessories: Complemento + Fruit: Fruta + + +