0
0
Fork 0

refs #7986 fix front

This commit is contained in:
Carlos Satorres 2024-10-08 15:36:57 +02:00
parent 73e5039ec3
commit 855032e4a6
3 changed files with 334 additions and 187 deletions

View File

@ -1,187 +0,0 @@
<script setup>
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import { ref, computed } from 'vue';
import axios from 'axios';
import useNotify from 'src/composables/useNotify.js';
import FetchData from 'components/FetchData.vue';
import FormModelPopup from 'src/components/FormModelPopup.vue';
import { useVnConfirm } from 'composables/useVnConfirm';
import VnPaginate from 'src/components/ui/VnPaginate.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnInput from 'src/components/common/VnInput.vue';
const { t } = useI18n();
const { notify } = useNotify();
const paginate = ref();
const dialog = ref();
const route = useRoute();
const { openConfirmationModal } = useVnConfirm();
const routeId = computed(() => route.params.id);
const initialData = computed(() => {
return {
userFk: routeId.value,
deviceProductionFk: null,
simSerialNumber: null,
};
});
const deallocatePDA = async (deviceProductionFk) => {
try {
await axios.post(`Workers/${route.params.id}/deallocatePDA`, {
pda: deviceProductionFk,
});
notify(t('PDA deallocated'), 'positive');
} catch (err) {
console.error('Error deallocating PDA');
}
paginate.value.fetch();
};
function reloadData() {
initialData.value.deviceProductionFk = null;
initialData.value.simSerialNumber = null;
paginate.value.fetch();
}
</script>
<template>
<QPage class="column items-center q-pa-md centerCard">
<FetchData
url="workers/getAvailablePda"
@on-fetch="(data) => (deviceProductions = data)"
auto-load
/>
<VnPaginate
ref="paginate"
data-key="WorkerPda"
url="DeviceProductionUsers"
:filter="{ where: { userFk: routeId } }"
order="id"
auto-load
>
<template #body="{ rows }">
<QCard
flat
bordered
:key="row.id"
v-for="row of rows"
class="card q-px-md q-mb-sm container"
>
<VnRow>
<VnInput
:label="t('worker.pda.currentPDA')"
:model-value="row?.deviceProductionFk"
disable
/>
<VnInput
:label="t('Model')"
:model-value="row?.deviceProduction?.modelFk"
disable
/>
<VnInput
:label="t('Serial number')"
:model-value="row?.deviceProduction?.serialNumber"
disable
/>
<VnInput
:label="t('Current SIM')"
:model-value="row?.simSerialNumber"
disable
/>
<QBtn
flat
icon="delete"
color="primary"
class="btn-delete"
@click="
openConfirmationModal(
t(`Remove PDA`),
t('Do you want to remove this PDA?'),
() => deallocatePDA(row.deviceProductionFk)
)
"
>
<QTooltip>
{{ t('worker.pda.removePDA') }}
</QTooltip>
</QBtn>
</VnRow>
</QCard>
</template>
</VnPaginate>
<QPageSticky :offset="[18, 18]">
<QBtn @click.stop="dialog.show()" color="primary" fab icon="add" shortcut="+">
<QDialog ref="dialog">
<FormModelPopup
:title="t('Add new device')"
url-create="DeviceProductionUsers"
model="DeviceProductionUser"
:form-initial-data="initialData"
@on-data-saved="reloadData()"
>
<template #form-inputs="{ data }">
<VnRow>
<VnSelect
:label="t('worker.pda.newPDA')"
v-model="data.deviceProductionFk"
:options="deviceProductions"
option-label="id"
option-value="id"
id="deviceProductionFk"
hide-selected
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel
>ID: {{ scope.opt?.id }}</QItemLabel
>
<QItemLabel caption>
{{ scope.opt?.modelFk }},
{{ scope.opt?.serialNumber }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
<VnInput
v-model="data.simSerialNumber"
:label="t('SIM serial number')"
id="simSerialNumber"
use-input
/>
</VnRow>
</template>
</FormModelPopup>
</QDialog>
</QBtn>
<QTooltip>
{{ t('globals.new') }}
</QTooltip>
</QPageSticky>
</QPage>
</template>
<style lang="scss" scoped>
.btn-delete {
max-width: 4%;
margin-top: 30px;
}
</style>
<i18n>
es:
Model: Modelo
Serial number: Número de serie
Current SIM: SIM actual
Add new device: Añadir nuevo dispositivo
PDA deallocated: PDA desasignada
Remove PDA: Eliminar PDA
Do you want to remove this PDA?: ¿Desea eliminar este PDA?
You can only have one PDA: Solo puedes tener un PDA si no eres autonomo
This PDA is already assigned to another user: Este PDA ya está asignado a otro usuario
</i18n>

View File

@ -0,0 +1,322 @@
<script setup>
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import { ref, computed } from 'vue';
import axios from 'axios';
import useNotify from 'src/composables/useNotify.js';
import FetchData from 'components/FetchData.vue';
import FormModelPopup from 'src/components/FormModelPopup.vue';
import { useVnConfirm } from 'composables/useVnConfirm';
import VnPaginate from 'src/components/ui/VnPaginate.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnInput from 'src/components/common/VnInput.vue';
import { size } from 'cypress/types/lodash';
const { t } = useI18n();
const { notify } = useNotify();
const paginate = ref();
const dialog = ref();
const route = useRoute();
const { openConfirmationModal } = useVnConfirm();
const routeId = computed(() => route.params.id);
const initialData = computed(() => {
return {
workerFk: routeId.value,
numberOfWagons: 2,
trainFk: 1,
itemPackingTypeFk: 'H',
warehouseFk: 60,
sectorFk: null,
labelerFk: null,
linesLimit: 20,
volumenLimit: 0.5,
sizeLimit: null,
isOnReservationMode: 0,
machineFk: null,
};
});
// const deallocatePDA = async (deviceProductionFk) => {
// try {
// await axios.post(`Workers/${route.params.id}/deallocatePDA`, {
// pda: deviceProductionFk,
// });
// notify(t('PDA deallocated'), 'positive');
// } catch (err) {
// console.error('Error deallocating PDA');
// }
// paginate.value.fetch();
// };
function reloadData() {
// initialData.value.deviceProductionFk = null;
// initialData.value.simSerialNumber = null;
paginate.value.fetch();
}
</script>
<template>
<QPage class="column items-center q-pa-md centerCard">
<FetchData
url="shelvings/trains"
@on-fetch="(data) => (trainsData = data)"
auto-load
/>
<FetchData
url="items/ItemPackingTypes"
@on-fetch="(data) => (ItemPackingTypesData = data)"
auto-load
/>
<FetchData
url="warehouses"
@on-fetch="(data) => (warehousesData = data)"
auto-load
/>
<FetchData
url="shelvings/sectors"
@on-fetch="(data) => (shelvingsData = data)"
auto-load
/>
<FetchData url="machines" @on-fetch="(data) => (machinesData = data)" auto-load />
<VnPaginate
ref="paginate"
data-key="WorkerPda"
url="Operators"
:filter="{ where: { workerFk: routeId } }"
order="id"
auto-load
>
<template #body="{ rows }">
<QCard
flat
bordered
:key="row.id"
v-for="row of rows"
class="card q-px-md q-mb-sm container"
>
<VnRow>
<VnInput
:label="t('worker.operator.numberOfWagons')"
:model-value="row?.numberOfWagons"
disable
/>
<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="row?.labelerFk"
/>
</VnRow>
<VnRow>
<VnInput
:label="t('worker.operator.linesLimit')"
:model-value="row?.linesLimit"
/>
<VnInput
:label="t('worker.operator.volumeLimit')"
:model-value="row?.volumeLimit"
/>
</VnRow>
<VnRow>
<VnInput
:label="t('worker.operator.sizeLimit')"
:model-value="row?.sizeLimit"
/>
<VnInput
:label="t('worker.operator.sizeLimit')"
:model-value="row?.sizeLimit"
/>
</VnRow>
<VnRow>
<VnInput
:label="t('worker.operator.isOnReservationMode')"
:model-value="row?.isOnReservationMode"
/>
<VnSelect
:label="t('worker.operator.machine')"
:options="machinesData"
hide-selected
option-label="plate"
option-value="id"
v-model="data.machineFk"
/>
</VnRow>
<!-- <QBtn
flat
icon="delete"
color="primary"
class="btn-delete"
@click="
openConfirmationModal(
t(`Remove PDA`),
t('Do you want to remove this PDA?'),
() => deallocatePDA(row.deviceProductionFk)
)
"
>
<QTooltip>
{{ t('worker.pda.removePDA') }}
</QTooltip>
</QBtn>-->
</QCard>
</template>
</VnPaginate>
<QPageSticky :offset="[18, 18]">
<QBtn @click.stop="dialog.show()" color="primary" fab icon="add" shortcut="+">
<QDialog ref="dialog">
<FormModelPopup
:title="t('Add new device')"
url-create="operators"
model="operator"
:form-initial-data="initialData"
@on-data-saved="reloadData()"
>
<template #form-inputs="{ data }">
<VnRow>
<VnInput
:label="t('worker.operator.numberOfWagons')"
:model-value="row?.numberOfWagons"
disable
/>
<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="row?.labelerFk"
/>
</VnRow>
<VnRow>
<VnInput
:label="t('worker.operator.linesLimit')"
:model-value="row?.linesLimit"
/>
<VnInput
:label="t('worker.operator.volumeLimit')"
:model-value="row?.volumeLimit"
/>
</VnRow>
<VnRow>
<VnInput
:label="t('worker.operator.sizeLimit')"
:model-value="row?.sizeLimit"
/>
<VnInput
:label="t('worker.operator.sizeLimit')"
:model-value="row?.sizeLimit"
/>
</VnRow>
<VnRow>
<VnInput
:label="t('worker.operator.isOnReservationMode')"
:model-value="row?.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>
</QPage>
</template>
<style lang="scss" scoped>
.btn-delete {
max-width: 4%;
margin-top: 30px;
}
</style>
<i18n>
es:
Model: Modelo
Serial number: Número de serie
Current SIM: SIM actual
Add new device: Añadir nuevo dispositivo
PDA deallocated: PDA desasignada
Remove PDA: Eliminar PDA
Do you want to remove this PDA?: ¿Desea eliminar este PDA?
You can only have one PDA: Solo puedes tener un PDA si no eres autonomo
This PDA is already assigned to another user: Este PDA ya está asignado a otro usuario
</i18n>

View File

@ -1,3 +1,5 @@
import { path } from 'chromium';
import { name } from 'quasar/dist/icon-set/material-icons.umd.prod';
import { RouterView } from 'vue-router';
export default {
@ -27,6 +29,7 @@ export default {
'WorkerBalance',
'WorkerFormation',
'WorkerMedical',
'WorkerOperator',
],
},
children: [
@ -208,6 +211,15 @@ export default {
},
component: () => import('src/pages/Worker/Card/WorkerMedical.vue'),
},
{
name: 'WorkerOperator',
path: 'operator',
meta: {
title: 'operator',
icon: 'person',
},
component: () => import('src/pages/Worker/Card/WorkerOperator.vue'),
},
],
},
],