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

View File

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