0
0
Fork 0

feat: refs #7404 add some style to the form and reorganize fields

This commit is contained in:
Pablo Natek 2024-09-06 07:26:04 +02:00
parent 717bf1c3e3
commit cd12343302
7 changed files with 120 additions and 75 deletions

View File

@ -171,6 +171,8 @@ const components = computed(() => $props.components ?? defaultComponents);
:value="{ row, model }" :value="{ row, model }"
v-model="model" v-model="model"
/> />
{{ console.log('model: ', col) }}
<VnComponent <VnComponent
v-if="col.component" v-if="col.component"
:prop="col" :prop="col"
@ -178,6 +180,7 @@ const components = computed(() => $props.components ?? defaultComponents);
:value="{ row, model }" :value="{ row, model }"
v-model="model" v-model="model"
/> />
<span :title="value" v-else>{{ value }}</span> <span :title="value" v-else>{{ value }}</span>
<VnComponent <VnComponent
v-if="col.after" v-if="col.after"

View File

@ -15,7 +15,6 @@ import VnTableChip from 'components/VnTable/VnChip.vue';
import VnVisibleColumn from 'src/components/VnTable/VnVisibleColumn.vue'; import VnVisibleColumn from 'src/components/VnTable/VnVisibleColumn.vue';
import VnLv from 'components/ui/VnLv.vue'; import VnLv from 'components/ui/VnLv.vue';
import VnTableOrder from 'src/components/VnTable/VnOrder.vue'; import VnTableOrder from 'src/components/VnTable/VnOrder.vue';
import item from 'src/router/modules/item';
const $props = defineProps({ const $props = defineProps({
columns: { columns: {
@ -410,7 +409,7 @@ defineExpose({
/> />
</template> </template>
<template #header-cell="{ col }"> <template #header-cell="{ col }">
<QTh v-if="col.visible ?? true"> <QTh table-header-style="max-width:50%" v-if="col.visible ?? true">
<div <div
class="column self-start q-ml-xs ellipsis" class="column self-start q-ml-xs ellipsis"
:class="`text-${col?.align ?? 'left'}`" :class="`text-${col?.align ?? 'left'}`"
@ -665,6 +664,7 @@ defineExpose({
:column-name="column.name" :column-name="column.name"
:label="column.label" :label="column.label"
> >
{{ console.log('data: ', data) }}
<VnTableColumn <VnTableColumn
:column="column" :column="column"
:row="{}" :row="{}"
@ -708,9 +708,7 @@ es:
.q-table--dark .q-table__bottom, .q-table--dark .q-table__bottom,
.q-table--dark thead, .q-table--dark thead,
.q-table--dark tr, .q-table--dark tr {
.q-table--dark th,
.q-table--dark td {
border-color: var(--vn-section-color); border-color: var(--vn-section-color);
} }

View File

@ -17,17 +17,16 @@ const $props = defineProps({
}, },
}); });
let mixed;
const componentArray = computed(() => { const componentArray = computed(() => {
if (typeof $props.prop === 'object') return [$props.prop]; if (typeof $props.prop === 'object') return [$props.prop];
return $props.prop; return $props.prop;
}); });
function mix(toComponent) { function mix(toComponent) {
if (mixed) return mixed;
const { component, attrs, event } = toComponent; const { component, attrs, event } = toComponent;
console.log('attrs: ', attrs);
const customComponent = $props.components[component]; const customComponent = $props.components[component];
mixed = { return {
component: customComponent?.component ?? component, component: customComponent?.component ?? component,
attrs: { attrs: {
...toValueAttrs(attrs), ...toValueAttrs(attrs),
@ -37,7 +36,6 @@ function mix(toComponent) {
}, },
event: { ...customComponent?.event, ...event }, event: { ...customComponent?.event, ...event },
}; };
return mixed;
} }
function toValueAttrs(attrs) { function toValueAttrs(attrs) {

View File

@ -4,20 +4,18 @@ import { useI18n } from 'vue-i18n';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import VnTable from 'components/VnTable/VnTable.vue';
import VnRow from 'src/components/ui/VnRow.vue';
import FetchData from 'src/components/FetchData.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import EntryStockBoughtFilter from './EntryStockBoughtFilter.vue';
import VnTable from 'components/VnTable/VnTable.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue'; import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import EntryStockBoughtDetail from 'src/pages/Entry/EntryStockBoughtDetail.vue'; import EntryStockBoughtDetail from 'src/pages/Entry/EntryStockBoughtDetail.vue';
import { useRouter } from 'vue-router';
const { t } = useI18n(); const { t } = useI18n();
const quasar = useQuasar(); const quasar = useQuasar();
const tableRef = ref(); const tableRef = ref();
const state = useState(); const state = useState();
const user = state.getUser(); const user = state.getUser();
const router = useRouter();
const columns = [ const columns = [
{ {
align: 'left', align: 'left',
@ -31,8 +29,17 @@ const columns = [
align: 'left', align: 'left',
name: 'workerFk', name: 'workerFk',
label: t('Buyer'), label: t('Buyer'),
isTitle: true, component: 'select',
columnFilter: false, create: true,
attrs: {
url: 'Workers/activeWithInheritedRole',
fields: ['id', 'name'],
where: { role: 'buyer' },
optionFilter: 'firstName',
optionLabel: 'name',
optionValue: 'id',
useLike: false,
},
}, },
{ {
align: 'left', align: 'left',
@ -44,31 +51,13 @@ const columns = [
summation: true, summation: true,
cardVisible: true, cardVisible: true,
}, },
{
align: 'left',
name: 'workerFk',
label: t('Buyer'),
component: 'select',
create: true,
visible: false,
columnFilter: false,
attrs: {
url: 'Workers/activeWithInheritedRole',
fields: ['id', 'name'],
where: { role: 'buyer' },
optionFilter: 'firstName',
optionLabel: 'name',
optionValue: 'id',
useLike: false,
},
},
{ {
align: 'left', align: 'left',
label: t('Bought'), label: t('Bought'),
name: 'bought', name: 'bought',
columnFilter: false,
summation: true, summation: true,
cardVisible: true, cardVisible: true,
columnFilter: false,
}, },
{ {
align: 'left', align: 'left',
@ -92,7 +81,6 @@ const columns = [
componentProps: { componentProps: {
workerFk: row.workerFk, workerFk: row.workerFk,
}, },
maximized: true,
}); });
}, },
}, },
@ -100,10 +88,6 @@ const columns = [
}, },
]; ];
function navigate(id) {
router.push({ path: `/travel/${id}/basic-data` });
}
function getFilter(dated) { function getFilter(dated) {
const shipped = dated ? new Date(dated) : Date.vnNew(); const shipped = dated ? new Date(dated) : Date.vnNew();
shipped.setHours(0, 0, 0, 0); shipped.setHours(0, 0, 0, 0);
@ -119,35 +103,13 @@ function getFilter(dated) {
], ],
}; };
} }
const travel = ref(); const userParams = ref({
const fetchDataRef = ref(); dated: Date.vnNew(),
});
</script> </script>
<template> <template>
<VnSubToolbar /> <VnSubToolbar>
<QPage class="column items-center q-pa-md"> <template #st-data="{ params }">
<VnTable
ref="tableRef"
data-key="StockBoughts"
url="StockBoughts/getStockBought"
save-url="StockBoughts/crud"
order="reserve DESC"
:is-editable="true"
:create="{
urlCreate: 'StockBoughts',
title: t('Reserve some space'),
onDataSaved: () => tableRef.reload(),
formInitialData: {
workerFk: user.id,
dated: Date.vnNow(),
},
}"
:columns="columns"
auto-load
@on-fetch="() => console.log('fetching...', fetchDataRef.fetch())"
style="max-width: 40%"
:footer="true"
>
<template #moreFilterPanel="{ params }">
<FetchData <FetchData
ref="fetchDataRef" ref="fetchDataRef"
url="Travels" url="Travels"
@ -156,7 +118,7 @@ const fetchDataRef = ref();
:filter="getFilter(params?.dated)" :filter="getFilter(params?.dated)"
@on-fetch="(data) => (travel = data)" @on-fetch="(data) => (travel = data)"
/> />
<div class="trucks"> <div>
<div> <div>
<span style="color: var(--vn-label-color)"> <span style="color: var(--vn-label-color)">
{{ t('Booked trucks') + ': ' }} {{ t('Booked trucks') + ': ' }}
@ -175,6 +137,35 @@ const fetchDataRef = ref();
</div> </div>
</div> </div>
</template> </template>
</VnSubToolbar>
<RightMenu>
<template #right-panel>
<EntryStockBoughtFilter data-key="StockBoughts" />
</template>
</RightMenu>
<QPage class="column items-center q-pa-md">
<VnTable
ref="tableRef"
data-key="StockBoughts"
url="StockBoughts/getStockBought"
save-url="StockBoughts/crud"
order="reserve DESC"
:right-search="false"
:is-editable="true"
:create="{
urlCreate: 'StockBoughts',
title: t('Reserve some space'),
onDataSaved: () => tableRef.reload(),
formInitialData: {
workerFk: user.id,
dated: Date.vnNow(),
},
}"
:columns="columns"
:user-params="userParams"
auto-load
:footer="true"
>
<template #column-workerFk="{ row }"> <template #column-workerFk="{ row }">
<span class="link" @click.stop> <span class="link" @click.stop>
{{ row?.worker?.user?.name }} {{ row?.worker?.user?.name }}

View File

@ -0,0 +1,57 @@
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { onMounted } from 'vue';
import { useStateStore } from 'stores/useStateStore';
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
import FetchData from 'components/FetchData.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue';
const { t } = useI18n();
const props = defineProps({
dataKey: {
type: String,
required: true,
},
});
const companiesOptions = ref([]);
const stateStore = useStateStore();
onMounted(async () => {
stateStore.rightDrawer = true;
});
</script>
<template>
<FetchData
ref="buyer"
url="Workers/activeWithInheritedRole"
:filter="{
fields: ['id', 'name'],
where: { role: 'buyer' },
}"
order="name"
@on-fetch="(data) => (companiesOptions = data)"
auto-load
/>
<VnFilterPanel :data-key="props.dataKey" :search-button="true">
<template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong>
<span>{{ formatFn(tag.value) }}</span>
</div>
</template>
<template #body="{ params }">
<QItem class="q-my-sm">
<QItemSection>
<VnInputDate v-model="params.dated" :label="t('Date')" is-outlined />
</QItemSection>
</QItem>
</template>
</VnFilterPanel>
</template>
<i18n>
es:
Date: Fecha
</i18n>

View File

@ -3,7 +3,6 @@ import VnSearchbar from 'components/ui/VnSearchbar.vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
const { t } = useI18n(); const { t } = useI18n();
</script> </script>
<template> <template>
<VnSearchbar <VnSearchbar
data-key="RouteList" data-key="RouteList"

View File

@ -409,5 +409,4 @@ es:
Route is not served: La ruta no está servida Route is not served: La ruta no está servida
hourStarted: Hora de inicio hourStarted: Hora de inicio
hourFinished: Hora de fin hourFinished: Hora de fin
Volume: Volumen
</i18n> </i18n>