salix-front/src/pages/Route/Cmr/CmrList.vue

213 lines
7.2 KiB
Vue
Raw Normal View History

<script setup>
2023-08-10 12:33:25 +00:00
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
2023-09-01 10:11:56 +00:00
import { Notify } from 'quasar';
import { useStateStore } from 'stores/useStateStore';
import VnPaginate from 'components/ui/VnPaginate.vue';
import { useSession } from 'src/composables/useSession';
import { toDate } from 'filters/index';
import CmrFilter from './CmrFilter.vue';
2023-08-30 10:53:18 +00:00
import TicketDescriptorProxy from 'pages/Ticket/Card/TicketDescriptorProxy.vue';
import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue';
const stateStore = useStateStore();
const { t } = useI18n();
const { getTokenMultimedia } = useSession();
const token = getTokenMultimedia();
2023-09-01 10:11:56 +00:00
const selected = ref([]);
const columns = computed(() => [
{
name: 'cmrFk',
label: t('route.cmr.list.cmrFk'),
field: (row) => row.cmrFk,
sortable: true,
},
{
name: 'hasCmrDms',
label: t('route.cmr.list.hasCmrDms'),
field: (row) => row.hasCmrDms,
2023-08-09 12:26:13 +00:00
align: 'center',
sortable: true,
2023-08-10 05:49:57 +00:00
headerStyle: 'padding-left: 35px',
},
{
name: 'ticketFk',
label: t('route.cmr.list.ticketFk'),
field: (row) => row.ticketFk,
sortable: true,
},
2023-09-01 10:11:56 +00:00
{
name: 'routeFkFk',
label: t('route.cmr.list.routeFk'),
field: (row) => row.routeFk,
sortable: true,
},
{
name: 'clientFk',
label: t('route.cmr.list.clientFk'),
field: (row) => row.clientFk,
sortable: true,
},
{
name: 'country',
label: t('route.cmr.list.country'),
field: (row) => row.country,
2023-08-09 12:26:13 +00:00
align: 'left',
sortable: true,
},
{
name: 'shipped',
label: t('route.cmr.list.shipped'),
field: (row) => toDate(row.shipped),
2023-08-09 12:26:13 +00:00
align: 'center',
sortable: true,
2023-08-10 05:49:57 +00:00
headerStyle: 'padding-left: 33px',
},
2023-08-30 10:53:18 +00:00
{
name: 'icons',
align: 'center',
field: (row) => row.cmrFk,
},
]);
2023-09-01 10:11:56 +00:00
function getApiUrl() {
2023-08-10 12:10:57 +00:00
return new URL(window.location).origin;
}
2023-09-01 10:11:56 +00:00
function getCmrUrl(value) {
return `${getApiUrl()}/api/Routes/${value}/cmr?access_token=${token}`;
}
function downloadPdfs() {
if (!selected.value.length) {
Notify.create({
message: t('globals.noSelectedRows'),
type: 'warning',
});
return;
}
let cmrs = [];
for (let value of selected.value) cmrs.push(value.cmrFk);
// prettier-ignore
return window.open(`${getApiUrl()}/api/Routes/downloadCmrsZip?ids=${cmrs.join(',')}&access_token=${token}`);
2023-08-30 10:53:18 +00:00
}
</script>
<template>
2024-05-03 15:38:16 +00:00
<template v-if="stateStore.isHeaderMounted()">
2024-02-28 05:38:59 +00:00
<Teleport to="#actions-append">
<div class="row q-gutter-x-sm">
<QBtn
flat
@click="stateStore.toggleRightDrawer()"
round
dense
icon="menu"
>
<QTooltip bottom anchor="bottom right">
{{ t('globals.collapseMenu') }}
</QTooltip>
</QBtn>
</div>
</Teleport>
</template>
<div class="column items-center">
<div class="list">
<VnPaginate
data-key="CmrList"
2024-05-03 15:38:16 +00:00
:url="`Routes/cmrs`"
order="cmrFk DESC"
limit="null"
auto-load
>
<template #body="{ rows }">
<QTable
2023-08-10 05:49:57 +00:00
:columns="columns"
:rows="rows"
:dense="$q.screen.lt.md"
2023-09-01 10:11:56 +00:00
row-key="cmrFk"
selection="multiple"
v-model:selected="selected"
2023-08-10 05:49:57 +00:00
:grid="$q.screen.lt.md"
auto-load
>
2023-08-10 12:10:57 +00:00
<template #top>
2023-09-01 10:11:56 +00:00
<div style="width: 100%; display: table">
<div style="float: right; color: lightgray">
{{ `${rows.length} ${t('route.cmr.list.results')}` }}
</div>
</div>
2023-08-10 12:10:57 +00:00
</template>
<template #body-cell-hasCmrDms="{ value }">
<QTd align="center">
<QBadge
text-color="black"
2023-08-10 12:10:57 +00:00
:id="value ? 'true' : 'false'"
:label="
value
? t('route.cmr.list.true')
: t('route.cmr.list.false')
"
/>
</QTd>
</template>
2023-08-30 10:53:18 +00:00
<template #body-cell-ticketFk="{ value }">
<QTd align="right" class="text-primary">
<span class="text-primary link">{{ value }}</span>
<TicketDescriptorProxy :id="value" />
</QTd>
</template>
<template #body-cell-clientFk="{ value }">
<QTd align="right" class="text-primary">
<span class="text-primary link">{{ value }}</span>
<CustomerDescriptorProxy :id="value" />
</QTd>
</template>
<template #body-cell-icons="{ value }">
<QTd align="center">
2023-09-01 10:11:56 +00:00
<a :href="getCmrUrl(value)" target="_blank">
2023-08-30 10:53:18 +00:00
<QIcon
name="visibility"
color="primary"
2024-01-03 14:02:14 +00:00
size="md"
2023-08-30 10:53:18 +00:00
class="q-mr-sm q-ml-sm"
/>
<QTooltip>
{{ t('route.cmr.list.viewCmr') }}
</QTooltip>
</a>
</QTd>
</template>
</QTable>
</template>
</VnPaginate>
</div>
2023-09-01 10:11:56 +00:00
<QPageSticky :offset="[20, 20]">
<QBtn @click="downloadPdfs" fab icon="cloud_download" color="primary" />
</QPageSticky>
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
2023-08-10 12:10:57 +00:00
<QScrollArea class="fit text-grey-8">
<CmrFilter data-key="CmrList" />
2023-09-01 10:11:56 +00:00
<QTooltip>
{{ t('route.cmr.list.downloadCmrs') }}
</QTooltip>
2023-08-10 12:10:57 +00:00
</QScrollArea>
</QDrawer>
</div>
</template>
<style lang="scss" scoped>
.list {
padding-top: 15px;
padding-bottom: 15px;
2023-09-01 10:11:56 +00:00
max-width: 1000px;
width: 100%;
}
.grid-style-transition {
transition: transform 0.28s, background-color 0.28s;
}
#true {
2023-08-09 10:02:15 +00:00
background-color: $positive;
}
#false {
2023-08-09 10:02:15 +00:00
background-color: $negative;
}
2023-08-10 12:10:57 +00:00
</style>