diff --git a/src/components/common/VnSelectCache.vue b/src/components/common/VnSelectCache.vue index 51873ef6e..b56f11220 100644 --- a/src/components/common/VnSelectCache.vue +++ b/src/components/common/VnSelectCache.vue @@ -8,15 +8,29 @@ const $props = defineProps({ default: null, }, find: { - type: String, + type: [String, Array], default: null, + description: 'search in row to add default options', }, }); const options = ref([]); onBeforeMount(async () => { - const { url } = useAttrs(); + const { url, optionValue, optionLabel } = useAttrs(); const findBy = $props.find ?? url?.charAt(0)?.toLocaleLowerCase() + url?.slice(1, -1); - if (findBy) options.value = [$props.row[findBy]]; + if (!findBy || !$props.row) return; + // is array + if (Array.isArray(findBy)) { + const [id, name] = findBy; + if (!$props.row[id] || !$props.row[name]) return; + return (options.value = [ + { + [optionValue ?? 'id']: $props.row[id], + [optionLabel ?? 'name']: $props.row[name], + }, + ]); + } + // is string + if ($props.row[findBy]) options.value = [$props.row[findBy]]; }); diff --git a/src/pages/Ticket/Card/TicketCard.vue b/src/pages/Ticket/Card/TicketCard.vue index 689a717e6..8c9745c02 100644 --- a/src/pages/Ticket/Card/TicketCard.vue +++ b/src/pages/Ticket/Card/TicketCard.vue @@ -11,18 +11,14 @@ const { t } = useI18n(); const route = useRoute(); const routeName = computed(() => route.name); -const searchBarDataKeys = { - TicketSummary: 'TicketSummary', - TicketSale: 'TicketSale', - TicketPurchaseRequest: 'TicketPurchaseRequest', -};