hotFix(orderCatalog): load when reload section #1524
|
@ -10,6 +10,7 @@ import OrderCatalogFilter from 'src/pages/Order/Card/OrderCatalogFilter.vue';
|
||||||
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||||
|
import { onUnmounted } from 'vue';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
@ -23,16 +24,40 @@ const catalogParams = {
|
||||||
const arrayData = useArrayData(dataKey, {
|
const arrayData = useArrayData(dataKey, {
|
||||||
url: 'Orders/CatalogFilter',
|
url: 'Orders/CatalogFilter',
|
||||||
userParams: catalogParams,
|
userParams: catalogParams,
|
||||||
|
exprBuilder,
|
||||||
|
searchUrl: 'table',
|
||||||
});
|
});
|
||||||
const store = arrayData.store;
|
const store = arrayData.store;
|
||||||
const tags = ref([]);
|
const tags = ref([]);
|
||||||
const itemRefs = ref({});
|
const itemRefs = ref({});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
stateStore.rightDrawer = true;
|
stateStore.rightDrawer = true;
|
||||||
checkOrderConfirmation();
|
checkOrderConfirmation();
|
||||||
|
|
||||||
|
if (
|
||||||
|
arrayData.store.userParams &&
|
||||||
|
Object.keys(arrayData.store.userParams).some((key) => !key.startsWith('order'))
|
||||||
|
|||||||
|
) {
|
||||||
|
await arrayData.fetch({});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
arrayData.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
function exprBuilder(param, value) {
|
||||||
alexm
commented
Lo he movido aqui, asi el filter usa el mismo arrayData Lo he movido aqui, asi el filter usa el mismo arrayData
|
|||||||
|
switch (param) {
|
||||||
|
case 'categoryFk':
|
||||||
|
case 'typeFk':
|
||||||
|
return { [param]: value };
|
||||||
|
case 'search':
|
||||||
|
if (/^\d+$/.test(value)) return { 'i.id': value };
|
||||||
|
else return { 'i.name': { like: `%${value}%` } };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function checkOrderConfirmation() {
|
async function checkOrderConfirmation() {
|
||||||
const response = await axios.get(`Orders/${route.params.id}`);
|
const response = await axios.get(`Orders/${route.params.id}`);
|
||||||
if (response.data.isConfirmed === 1) {
|
if (response.data.isConfirmed === 1) {
|
||||||
|
@ -96,6 +121,7 @@ watch(
|
||||||
:tag-value="tagValue"
|
:tag-value="tagValue"
|
||||||
:tags="tags"
|
:tags="tags"
|
||||||
:initial-catalog-params="catalogParams"
|
:initial-catalog-params="catalogParams"
|
||||||
|
:arrayData
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</RightMenu>
|
</RightMenu>
|
||||||
|
|
|
@ -24,6 +24,10 @@ const props = defineProps({
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
arrayData: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -74,17 +78,6 @@ const loadTypes = async (id) => {
|
||||||
typeList.value = data;
|
typeList.value = data;
|
||||||
};
|
};
|
||||||
|
|
||||||
function exprBuilder(param, value) {
|
|
||||||
switch (param) {
|
|
||||||
case 'categoryFk':
|
|
||||||
case 'typeFk':
|
|
||||||
return { [param]: value };
|
|
||||||
case 'search':
|
|
||||||
if (/^\d+$/.test(value)) return { 'i.id': value };
|
|
||||||
else return { 'i.name': { like: `%${value}%` } };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const applyTags = (tagInfo, params, search) => {
|
const applyTags = (tagInfo, params, search) => {
|
||||||
if (!tagInfo || !tagInfo.values.length) {
|
if (!tagInfo || !tagInfo.values.length) {
|
||||||
params.tagGroups = null;
|
params.tagGroups = null;
|
||||||
|
@ -152,9 +145,8 @@ function addOrder(value, field, params) {
|
||||||
:data-key="props.dataKey"
|
:data-key="props.dataKey"
|
||||||
:hidden-tags="['filter', 'orderFk', 'orderBy']"
|
:hidden-tags="['filter', 'orderFk', 'orderBy']"
|
||||||
:unremovable-params="['orderFk', 'orderBy']"
|
:unremovable-params="['orderFk', 'orderBy']"
|
||||||
:expr-builder="exprBuilder"
|
|
||||||
:custom-tags="['tagGroups', 'categoryFk']"
|
:custom-tags="['tagGroups', 'categoryFk']"
|
||||||
:redirect="false"
|
:arrayData
|
||||||
>
|
>
|
||||||
<template #tags="{ tag, formatFn }">
|
<template #tags="{ tag, formatFn }">
|
||||||
<strong v-if="tag.label === 'typeFk' && typeList">
|
<strong v-if="tag.label === 'typeFk' && typeList">
|
||||||
|
@ -184,7 +176,7 @@ function addOrder(value, field, params) {
|
||||||
{{
|
{{
|
||||||
t(
|
t(
|
||||||
categoryList.find((c) => c.id == customTag.value)?.name ||
|
categoryList.find((c) => c.id == customTag.value)?.name ||
|
||||||
''
|
'',
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
</strong>
|
</strong>
|
||||||
|
|
Loading…
Reference in New Issue
Solo en el caso de que haya userParams al montar que no sean de orden (esos estan siempre)