166 lines
4.2 KiB
Vue
166 lines
4.2 KiB
Vue
<script setup>
|
|
import { ref, computed, onBeforeMount } from 'vue';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
|
|
import { date, QBtn } from 'quasar';
|
|
|
|
import { useArrayData } from 'composables/useArrayData';
|
|
import { useStateStore } from 'stores/useStateStore';
|
|
|
|
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
|
|
|
|
const { t } = useI18n();
|
|
const route = useRoute();
|
|
const router = useRouter();
|
|
const stateStore = useStateStore();
|
|
|
|
const arrayData = ref(null);
|
|
const workerId = ref(0);
|
|
const rows = computed(() => arrayData.value.store.data);
|
|
|
|
onBeforeMount(async () => {
|
|
const filter = {
|
|
include: [
|
|
{ relation: 'type', scope: { fields: ['code', 'description'] } },
|
|
{ relation: 'user', scope: { fields: ['id', 'name'] } },
|
|
{ relation: 'company', scope: { fields: ['code'] } },
|
|
],
|
|
where: { clientFk: route.params.id },
|
|
order: ['created DESC'],
|
|
limit: 20,
|
|
};
|
|
|
|
arrayData.value = useArrayData('CustomerSamplesCard', {
|
|
url: 'ClientSamples',
|
|
filter,
|
|
});
|
|
await arrayData.value.fetch({ append: false });
|
|
stateStore.rightDrawer = true;
|
|
});
|
|
|
|
const tableColumnComponents = {
|
|
sent: {
|
|
component: 'span',
|
|
props: () => {},
|
|
event: () => {},
|
|
},
|
|
description: {
|
|
component: 'span',
|
|
props: () => {},
|
|
event: () => {},
|
|
},
|
|
worker: {
|
|
component: QBtn,
|
|
props: () => ({ flat: true, color: 'blue' }),
|
|
event: (prop) => {
|
|
selectWorkerId(prop.row.clientFk);
|
|
},
|
|
},
|
|
company: {
|
|
component: 'span',
|
|
props: () => {},
|
|
event: () => {},
|
|
},
|
|
};
|
|
|
|
const columns = computed(() => [
|
|
{
|
|
align: 'left',
|
|
field: 'created',
|
|
label: t('Sent'),
|
|
name: 'sent',
|
|
format: (value) => date.formatDate(value, 'DD/MM/YYYY hh:mm'),
|
|
},
|
|
{
|
|
align: 'left',
|
|
field: (value) => value.type.description,
|
|
label: t('Description'),
|
|
name: 'description',
|
|
},
|
|
{
|
|
align: 'left',
|
|
field: (value) => value.user.name,
|
|
label: t('Worker'),
|
|
name: 'worker',
|
|
},
|
|
{
|
|
align: 'left',
|
|
field: (value) => value.company.code,
|
|
label: t('Company'),
|
|
name: 'company',
|
|
},
|
|
]);
|
|
|
|
const selectWorkerId = (id) => {
|
|
workerId.value = id;
|
|
};
|
|
|
|
const toCustomerSamplesCreate = () => {
|
|
router.push({ name: 'CustomerSamplesCreate' });
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<QPage class="column items-center q-pa-md">
|
|
<QTable
|
|
:columns="columns"
|
|
:pagination="{ rowsPerPage: 12 }"
|
|
:rows="rows"
|
|
class="full-width q-mt-md"
|
|
row-key="id"
|
|
v-if="rows?.length"
|
|
>
|
|
<template #body-cell="props">
|
|
<QTd :props="props">
|
|
<QTr :props="props" class="cursor-pointer">
|
|
<component
|
|
:is="tableColumnComponents[props.col.name].component"
|
|
class="col-content"
|
|
v-bind="tableColumnComponents[props.col.name].props(props)"
|
|
@click="tableColumnComponents[props.col.name].event(props)"
|
|
>
|
|
{{ props.value }}
|
|
<WorkerDescriptorProxy :id="workerId" />
|
|
</component>
|
|
</QTr>
|
|
</QTd>
|
|
</template>
|
|
</QTable>
|
|
|
|
<QCard class="full-width" v-else>
|
|
<h5 class="flex justify-center label-color">
|
|
{{ t('globals.noResults') }}
|
|
</h5>
|
|
</QCard>
|
|
</QPage>
|
|
|
|
<QPageSticky :offset="[18, 18]">
|
|
<QBtn @click.stop="toCustomerSamplesCreate()" color="primary" fab icon="add" />
|
|
<QTooltip>
|
|
{{ t('Send sample') }}
|
|
</QTooltip>
|
|
</QPageSticky>
|
|
</template>
|
|
|
|
<style lang="scss">
|
|
.consignees-card {
|
|
border: 2px solid var(--vn-light-gray);
|
|
border-radius: 10px;
|
|
padding: 10px;
|
|
}
|
|
|
|
.label-color {
|
|
color: var(--vn-label);
|
|
}
|
|
</style>
|
|
|
|
<i18n>
|
|
es:
|
|
Sent: Enviado
|
|
Description: Descripción
|
|
Worker: Trabajador
|
|
Company: Empresa
|
|
Send sample: Enviar plantilla
|
|
</i18n>
|