fix: refs #7986 crudModel
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Carlos Satorres 2024-10-15 13:00:01 +02:00
parent af830591b3
commit b4245d05fb
3 changed files with 116 additions and 199 deletions

View File

@ -743,6 +743,7 @@ worker:
locker: Locker locker: Locker
balance: Balance balance: Balance
medical: Medical medical: Medical
operator: Operator
list: list:
name: Name name: Name
email: Email email: Email

View File

@ -750,6 +750,7 @@ worker:
balance: Balance balance: Balance
formation: Formación formation: Formación
medical: Mutua medical: Mutua
operator: Operario
list: list:
name: Nombre name: Nombre
email: Email email: Email

View File

@ -3,18 +3,23 @@ import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { ref, computed, watch } from 'vue'; import { ref, computed, watch } from 'vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import FormModelPopup from 'src/components/FormModelPopup.vue'; // import CrudModelPopup from 'src/components/CrudModelPopup.vue';
import VnPaginate from 'src/components/ui/VnPaginate.vue'; import VnPaginate from 'src/components/ui/VnPaginate.vue';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import FormModel from 'components/FormModel.vue'; import CrudModel from 'components/CrudModel.vue';
const { t } = useI18n(); const { t } = useI18n();
const formModelRef = ref(); const test = ref({});
const dialog = ref(); const dialog = ref();
const warehousesData = ref([]);
const itemPackingTypesData = ref([]);
const sectorsData = ref([]);
const trainsData = ref([]);
const machinesData = ref([]);
const route = useRoute(); const route = useRoute();
const routeId = computed(() => route.params.id); const routeId = computed(() => route.params.id);
@ -34,10 +39,10 @@ const initialData = computed(() => {
machineFk: null, machineFk: null,
}; };
}); });
watch( // watch(
() => route.params.id, // () => route.params.id,
() => formModelRef.value.reset() // () => CrudModelRef.value.reset()
); // );
</script> </script>
<template> <template>
@ -45,7 +50,7 @@ watch(
<FetchData url="Trains" @on-fetch="(data) => (trainsData = data)" auto-load /> <FetchData url="Trains" @on-fetch="(data) => (trainsData = data)" auto-load />
<FetchData <FetchData
url="ItemPackingTypes" url="ItemPackingTypes"
@on-fetch="(data) => (ItemPackingTypesData = data)" @on-fetch="(data) => (itemPackingTypesData = data)"
auto-load auto-load
/> />
<FetchData <FetchData
@ -53,42 +58,43 @@ watch(
@on-fetch="(data) => (warehousesData = data)" @on-fetch="(data) => (warehousesData = data)"
auto-load auto-load
/> />
<FetchData url="Sectors" @on-fetch="(data) => (shelvingsData = data)" auto-load /> <FetchData url="Sectors" @on-fetch="(data) => (sectorsData = data)" auto-load />
<FetchData url="Machines" @on-fetch="(data) => (machinesData = data)" auto-load /> <FetchData url="Machines" @on-fetch="(data) => (machinesData = data)" auto-load />
<CrudModel
<FormModel data-key="workerOperator"
ref="formModelRef"
:form-initial-data="initialData"
url="Operators" url="Operators"
:filter="{ where: { workerFk: routeId } }" model="workerOperator"
:filter="{ where: { workerFk: route.params.id } }"
ref="test"
:data-required="{ workerFk: route.params.id }"
:default-save="false"
auto-load auto-load
> >
<template #body="{ rows }"> <template #body="{ rows }">
<div v-if="rows.length">
<QCard <QCard
flat flat
bordered bordered
:key="row.id" :key="row"
v-for="row of rows" v-for="row of rows"
class="card q-px-md q-mb-sm container" class="card q-px-md q-mb-sm container"
> >
<VnRow> <VnRow>
<VnInput <VnInput
:label="t('worker.operator.numberOfWagons')" :label="t('worker.operator.numberOfWagons')"
:model-value="row?.numberOfWagons" v-model="row.numberOfWagons"
/> />
<VnSelect <VnSelect
:label="t('worker.operator.train')" :label="t('worker.operator.train')"
:options="trainsData" :options="trainsData"
hide-selected hide-selected
option-label="name"
option-value="id"
v-model="row.trainFk" v-model="row.trainFk"
/> />
</VnRow> </VnRow>
<VnRow> <VnRow>
<VnSelect <VnSelect
:label="t('worker.operator.itemPackingType')" :label="t('worker.operator.itemPackingType')"
:options="ItemPackingTypesData" :options="itemPackingTypesData"
hide-selected hide-selected
option-label="code" option-label="code"
option-value="code" option-value="code"
@ -98,47 +104,44 @@ watch(
:label="t('worker.operator.warehouse')" :label="t('worker.operator.warehouse')"
:options="warehousesData" :options="warehousesData"
hide-selected hide-selected
option-label="name"
option-value="id"
v-model="row.warehouseFk" v-model="row.warehouseFk"
/> />
</VnRow> </VnRow>
<VnRow> <VnRow>
<VnSelect <VnSelect
:label="t('worker.operator.sector')" :label="t('worker.operator.sector')"
:options="shelvingsData" :options="sectorsData"
hide-selected hide-selected
option-label="description" option-label="description"
option-value="id"
v-model="row.sectorFk" v-model="row.sectorFk"
/> />
<VnInput <VnInput
:label="t('worker.operator.labeler')" :label="t('worker.operator.labeler')"
:model-value="row.labelerFk" v-model="row.labelerFk"
lazy-rules lazy-rules
/> />
</VnRow> </VnRow>
<VnRow> <VnRow>
<VnInput <VnInput
:label="t('worker.operator.linesLimit')" :label="t('worker.operator.linesLimit')"
:model-value="row.linesLimit" v-model="row.linesLimit"
lazy-rules lazy-rules
/> />
<VnInput <VnInput
:label="t('worker.operator.volumeLimit')" :label="t('worker.operator.volumeLimit')"
:model-value="row.volumeLimit" v-model="row.volumeLimit"
lazy-rules lazy-rules
/> />
</VnRow> </VnRow>
<VnRow> <VnRow>
<VnInput <VnInput
:label="t('worker.operator.sizeLimit')" :label="t('worker.operator.sizeLimit')"
:model-value="row.sizeLimit" v-model="row.sizeLimit"
lazy-rules lazy-rules
/> />
<VnInput <VnInput
:label="t('worker.operator.isOnReservationMode')" :label="t('worker.operator.isOnReservationMode')"
:model-value="row.isOnReservationMode" v-model="row.isOnReservationMode"
lazy-rules lazy-rules
/> />
</VnRow> </VnRow>
@ -148,10 +151,11 @@ watch(
:options="machinesData" :options="machinesData"
hide-selected hide-selected
option-label="plate" option-label="plate"
option-value="id"
v-model="row.machineFk" v-model="row.machineFk"
/> />
</VnRow> </VnRow>
</QCard>
</div>
<!-- <QBtn <!-- <QBtn
flat flat
icon="delete" icon="delete"
@ -169,103 +173,14 @@ watch(
{{ t('worker.pda.removePDA') }} {{ t('worker.pda.removePDA') }}
</QTooltip> </QTooltip>
</QBtn>--> </QBtn>-->
</QCard>
</template> </template>
</FormModel> </CrudModel>
<QPageSticky :offset="[18, 18]"> <QPageSticky
<QBtn @click.stop="dialog.show()" color="primary" fab icon="add" shortcut="+"> position="bottom-right"
<QDialog ref="dialog"> :offset="[25, 25]"
<FormModelPopup v-if="!test.formData?.length"
:title="t('Add new device')"
url-create="operators"
model="operator"
:form-initial-data="initialData"
@on-data-saved="reloadData()"
> >
<template #form-inputs="{ data }"> <QBtn fab color="primary" icon="add" @click="test.insert()" />
<VnRow>
<VnInput
:label="t('worker.operator.numberOfWagons')"
:model-value="data.numberOfWagons"
/>
<VnSelect
:label="t('worker.operator.train')"
:options="trainsData"
hide-selected
option-label="name"
option-value="id"
v-model="data.trainFk"
/>
</VnRow>
<VnRow>
<VnSelect
:label="t('worker.operator.itemPackingType')"
:options="ItemPackingTypesData"
hide-selected
option-label="code"
option-value="code"
v-model="data.itemPackingTypeFk"
/>
<VnSelect
:label="t('worker.operator.warehouse')"
:options="warehousesData"
hide-selected
option-label="name"
option-value="id"
v-model="data.warehouseFk"
/>
</VnRow>
<VnRow>
<VnSelect
:label="t('worker.operator.sector')"
:options="shelvingsData"
hide-selected
option-label="description"
option-value="id"
v-model="data.sectorFk"
/>
<VnInput
:label="t('worker.operator.labeler')"
:model-value="data?.labelerFk"
/>
</VnRow>
<VnRow>
<VnInput
:label="t('worker.operator.linesLimit')"
:model-value="data?.linesLimit"
/>
<VnInput
:label="t('worker.operator.volumeLimit')"
:model-value="data?.volumeLimit"
/>
</VnRow>
<VnRow>
<VnInput
:label="t('worker.operator.sizeLimit')"
:model-value="data?.sizeLimit"
/>
</VnRow>
<VnRow>
<VnInput
:label="t('worker.operator.isOnReservationMode')"
:model-value="data?.isOnReservationMode"
/>
<VnSelect
:label="t('worker.operator.machine')"
:options="machinesData"
hide-selected
option-label="plate"
option-value="id"
v-model="data.machineFk"
/>
</VnRow>
</template>
</FormModelPopup>
</QDialog>
</QBtn>
<QTooltip>
{{ t('globals.new') }}
</QTooltip>
</QPageSticky> </QPageSticky>
</QPage> </QPage>
</template> </template>