feat: #6943 use openURL quasar
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Javier Segarra 2024-11-14 12:48:33 +01:00
parent ecf131ba78
commit 291e97e540
2 changed files with 22 additions and 26 deletions

View File

@ -0,0 +1,8 @@
import { openURL } from 'quasar';
const defaultWindowFeatures = {
noopener: true,
noreferrer: true,
};
export default function (url, windowFeatures = defaultWindowFeatures, fn = undefined) {
openURL(url, fn, windowFeatures);
}

View File

@ -6,8 +6,8 @@ import axios from 'axios';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import useNotify from 'src/composables/useNotify'; import useNotify from 'src/composables/useNotify';
import VnSmsDialog from 'src/components/common/VnSmsDialog.vue'; import VnSmsDialog from 'src/components/common/VnSmsDialog.vue';
import useOpenURL from 'src/composables/useOpenURL';
const $props = defineProps({ const $props = defineProps({
customer: { customer: {
@ -15,7 +15,6 @@ const $props = defineProps({
required: true, required: true,
}, },
}); });
const { notify } = useNotify(); const { notify } = useNotify();
const { t } = useI18n(); const { t } = useI18n();
const quasar = useQuasar(); const quasar = useQuasar();
@ -41,48 +40,37 @@ const sendSms = async (payload) => {
} }
}; };
const openTicketCreateForm = () => { const openCreateForm = (type) => {
const query = { const query = {
table: { table: {
clientFk: $props.customer.id, clientFk: $props.customer.id,
}, },
createForm: { createForm: {
clientId: $props.customer.id,
addressId: $props.customer.defaultAddressFk, addressId: $props.customer.defaultAddressFk,
}, },
}; };
openWindow('ticket', query); const clientFk = {
}; ticket: 'clientId',
const openOrderCreateForm = () => { order: 'clientFk',
const query = {
table: {
clientFk: $props.customer.id,
},
createForm: {
clientFk: $props.customer.id,
addressId: $props.customer.defaultAddressFk,
},
}; };
openWindow('order', query); const key = clientFk[type];
}; if (!key) return;
query.createForm[key] = $props.customer.id;
const openWindow = (type, { createForm, table }) => { const params = Object.entries(query)
window.open( .map(([key, value]) => `${key}=${JSON.stringify(value)}`)
`/#/${type}/list?createForm=${JSON.stringify(createForm)}&table=${JSON.stringify( .join('&');
table useOpenURL(`/#/${type}/list?${params}`);
)}`,
'_blank'
);
}; };
</script> </script>
<template> <template>
<QItem v-ripple clickable @click="openTicketCreateForm()"> <QItem v-ripple clickable @click="openCreateForm('ticket')">
<QItemSection> <QItemSection>
{{ t('globals.pageTitles.createTicket') }} {{ t('globals.pageTitles.createTicket') }}
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem v-ripple clickable @click="openOrderCreateForm()"> <QItem v-ripple clickable @click="openCreateForm('order')">
<QItemSection> <QItemSection>
{{ t('globals.pageTitles.createOrder') }} {{ t('globals.pageTitles.createOrder') }}
</QItemSection> </QItemSection>