0
0
Fork 0
This commit is contained in:
Alex Moreno 2024-07-23 14:46:27 +02:00
commit 38437aa2f9
2 changed files with 24 additions and 2 deletions

View File

@ -37,6 +37,10 @@ const $props = defineProps({
type: [Function, Boolean],
default: null,
},
rowCtrlClick: {
type: [Function, Boolean],
default: null,
},
redirect: {
type: String,
default: null,
@ -206,6 +210,16 @@ const rowClickFunction = computed(() => {
return () => {};
});
const rowCtrlClickFunction = computed(() => {
if ($props.rowCtrlClick != undefined) return $props.rowCtrlClick;
if ($props.redirect)
return (evt, { id }) => {
stopEventPropagation(evt);
window.open(`/#/${$props.redirect}/${id}`, '_blank');
};
return () => {};
});
function redirectFn(id) {
router.push({ path: `/${$props.redirect}/${id}` });
}
@ -420,6 +434,11 @@ defineExpose({
class="no-margin q-px-xs"
:class="[getColAlign(col), col.class, col.columnField?.class]"
v-if="col.visible ?? true"
@click.ctrl="
($event) =>
rowCtrlClickFunction &&
rowCtrlClickFunction($event, row)
"
>
<slot :name="`column-${col.name}`" :col="col" :row="row">
<VnTableColumn

View File

@ -1,5 +1,5 @@
<script setup>
import { onMounted, onUnmounted } from 'vue';
import { onMounted, onUnmounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import RightMenu from 'src/components/common/RightMenu.vue';
import VnTable from 'components/VnTable/VnTable.vue';
@ -15,12 +15,13 @@ const columns = [
{
align: 'center',
label: t('entry.latestBuys.tableVisibleColumns.image'),
name: 'image',
name: 'itemFk',
columnField: {
component: VnImg,
attrs: (id) => {
return {
id,
size: '50x50',
width: '50px',
};
},
@ -169,6 +170,7 @@ const columns = [
format: (row, dashIfEmpty) => dashIfEmpty(toDate(row.landing)),
},
];
const tableRef = ref();
onMounted(async () => {
stateStore.rightDrawer = true;
@ -191,6 +193,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
order="id DESC"
:columns="columns"
redirect="entry"
:row-click="({ entryFk }) => tableRef.redirect(entryFk)"
auto-load
:right-search="false"
/>