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,106 +58,105 @@ 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 }">
<QCard <div v-if="rows.length">
flat <QCard
bordered flat
:key="row.id" bordered
v-for="row of rows" :key="row"
class="card q-px-md q-mb-sm container" v-for="row of rows"
> class="card q-px-md q-mb-sm container"
<VnRow> >
<VnInput <VnRow>
:label="t('worker.operator.numberOfWagons')" <VnInput
:model-value="row?.numberOfWagons" :label="t('worker.operator.numberOfWagons')"
/> v-model="row.numberOfWagons"
<VnSelect />
:label="t('worker.operator.train')" <VnSelect
:options="trainsData" :label="t('worker.operator.train')"
hide-selected :options="trainsData"
option-label="name" hide-selected
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" v-model="row.itemPackingTypeFk"
v-model="row.itemPackingTypeFk" />
/> <VnSelect
<VnSelect :label="t('worker.operator.warehouse')"
:label="t('worker.operator.warehouse')" :options="warehousesData"
:options="warehousesData" hide-selected
hide-selected v-model="row.warehouseFk"
option-label="name" />
option-value="id" </VnRow>
v-model="row.warehouseFk" <VnRow>
/> <VnSelect
</VnRow> :label="t('worker.operator.sector')"
<VnRow> :options="sectorsData"
<VnSelect hide-selected
:label="t('worker.operator.sector')" option-label="description"
:options="shelvingsData" v-model="row.sectorFk"
hide-selected />
option-label="description" <VnInput
option-value="id" :label="t('worker.operator.labeler')"
v-model="row.sectorFk" v-model="row.labelerFk"
/> lazy-rules
<VnInput />
:label="t('worker.operator.labeler')" </VnRow>
:model-value="row.labelerFk" <VnRow>
lazy-rules <VnInput
/> :label="t('worker.operator.linesLimit')"
</VnRow> v-model="row.linesLimit"
<VnRow> lazy-rules
<VnInput />
:label="t('worker.operator.linesLimit')" <VnInput
:model-value="row.linesLimit" :label="t('worker.operator.volumeLimit')"
lazy-rules v-model="row.volumeLimit"
/> lazy-rules
<VnInput />
:label="t('worker.operator.volumeLimit')" </VnRow>
:model-value="row.volumeLimit" <VnRow>
lazy-rules <VnInput
/> :label="t('worker.operator.sizeLimit')"
</VnRow> v-model="row.sizeLimit"
<VnRow> lazy-rules
<VnInput />
:label="t('worker.operator.sizeLimit')" <VnInput
:model-value="row.sizeLimit" :label="t('worker.operator.isOnReservationMode')"
lazy-rules v-model="row.isOnReservationMode"
/> lazy-rules
<VnInput />
:label="t('worker.operator.isOnReservationMode')" </VnRow>
:model-value="row.isOnReservationMode" <VnRow>
lazy-rules <VnSelect
/> :label="t('worker.operator.machine')"
</VnRow> :options="machinesData"
<VnRow> hide-selected
<VnSelect option-label="plate"
:label="t('worker.operator.machine')" v-model="row.machineFk"
:options="machinesData" />
hide-selected </VnRow>
option-label="plate" </QCard>
option-value="id" </div>
v-model="row.machineFk" <!-- <QBtn
/>
</VnRow>
<!-- <QBtn
flat flat
icon="delete" icon="delete"
color="primary" color="primary"
@ -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" <QBtn fab color="primary" icon="add" @click="test.insert()" />
model="operator"
:form-initial-data="initialData"
@on-data-saved="reloadData()"
>
<template #form-inputs="{ data }">
<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>