Merge branch 'dev' into CambiosSolicitadosSuppliers
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
4bc57d0287
|
@ -10,6 +10,7 @@ import { useValidator } from 'src/composables/useValidator';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
import SkeletonForm from 'components/ui/SkeletonForm.vue';
|
import SkeletonForm from 'components/ui/SkeletonForm.vue';
|
||||||
import VnConfirm from './ui/VnConfirm.vue';
|
import VnConfirm from './ui/VnConfirm.vue';
|
||||||
|
import { tMobile } from 'src/composables/tMobile';
|
||||||
|
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const state = useState();
|
const state = useState();
|
||||||
|
@ -43,6 +44,10 @@ const $props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
defaultButtons: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {},
|
||||||
|
},
|
||||||
autoLoad: {
|
autoLoad: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
|
@ -128,7 +133,19 @@ const hasChanges = ref(!$props.observeFormChanges);
|
||||||
const originalData = ref({ ...$props.formInitialData });
|
const originalData = ref({ ...$props.formInitialData });
|
||||||
const formData = computed(() => state.get($props.model));
|
const formData = computed(() => state.get($props.model));
|
||||||
const formUrl = computed(() => $props.url);
|
const formUrl = computed(() => $props.url);
|
||||||
|
const defaultButtons = computed(() => ({
|
||||||
|
save: {
|
||||||
|
color: 'primary',
|
||||||
|
icon: 'restart_alt',
|
||||||
|
label: 'globals.save',
|
||||||
|
},
|
||||||
|
reset: {
|
||||||
|
color: 'primary',
|
||||||
|
icon: 'save',
|
||||||
|
label: 'globals.reset',
|
||||||
|
},
|
||||||
|
...$props.defaultButtons,
|
||||||
|
}));
|
||||||
const startFormWatcher = () => {
|
const startFormWatcher = () => {
|
||||||
watch(
|
watch(
|
||||||
() => formData.value,
|
() => formData.value,
|
||||||
|
@ -140,10 +157,6 @@ const startFormWatcher = () => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
function tMobile(...args) {
|
|
||||||
if (!quasar.platform.is.mobile) return t(...args);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetch() {
|
async function fetch() {
|
||||||
const { data } = await axios.get($props.url, {
|
const { data } = await axios.get($props.url, {
|
||||||
params: { filter: JSON.stringify($props.filter) },
|
params: { filter: JSON.stringify($props.filter) },
|
||||||
|
@ -242,21 +255,21 @@ watch(formUrl, async () => {
|
||||||
<QBtnGroup push class="q-gutter-x-sm">
|
<QBtnGroup push class="q-gutter-x-sm">
|
||||||
<slot name="moreActions" />
|
<slot name="moreActions" />
|
||||||
<QBtn
|
<QBtn
|
||||||
:label="tMobile('globals.reset')"
|
:label="tMobile(defaultButtons.reset.label)"
|
||||||
color="primary"
|
:color="defaultButtons.reset.color"
|
||||||
icon="restart_alt"
|
:icon="defaultButtons.reset.icon"
|
||||||
flat
|
flat
|
||||||
@click="reset"
|
@click="reset"
|
||||||
:disable="!hasChanges"
|
:disable="!hasChanges"
|
||||||
:title="t('globals.reset')"
|
:title="t(defaultButtons.reset.label)"
|
||||||
/>
|
/>
|
||||||
<QBtn
|
<QBtn
|
||||||
:label="tMobile('globals.save')"
|
:label="tMobile(defaultButtons.save.label)"
|
||||||
color="primary"
|
:color="defaultButtons.save.color"
|
||||||
icon="save"
|
:icon="defaultButtons.save.icon"
|
||||||
@click="save"
|
@click="save"
|
||||||
:disable="!hasChanges"
|
:disable="!hasChanges"
|
||||||
:title="t('globals.save')"
|
:title="t(defaultButtons.save.label)"
|
||||||
/>
|
/>
|
||||||
</QBtnGroup>
|
</QBtnGroup>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -31,6 +31,7 @@ export default {
|
||||||
close: 'Close',
|
close: 'Close',
|
||||||
cancel: 'Cancel',
|
cancel: 'Cancel',
|
||||||
confirm: 'Confirm',
|
confirm: 'Confirm',
|
||||||
|
assign: 'Assign',
|
||||||
back: 'Back',
|
back: 'Back',
|
||||||
yes: 'Yes',
|
yes: 'Yes',
|
||||||
no: 'No',
|
no: 'No',
|
||||||
|
@ -833,6 +834,7 @@ export default {
|
||||||
notifications: 'Notifications',
|
notifications: 'Notifications',
|
||||||
workerCreate: 'New worker',
|
workerCreate: 'New worker',
|
||||||
department: 'Department',
|
department: 'Department',
|
||||||
|
pda: 'PDA',
|
||||||
},
|
},
|
||||||
list: {
|
list: {
|
||||||
name: 'Name',
|
name: 'Name',
|
||||||
|
@ -874,6 +876,13 @@ export default {
|
||||||
subscribed: 'Subscribed to the notification',
|
subscribed: 'Subscribed to the notification',
|
||||||
unsubscribed: 'Unsubscribed from the notification',
|
unsubscribed: 'Unsubscribed from the notification',
|
||||||
},
|
},
|
||||||
|
pda: {
|
||||||
|
newPDA: 'New PDA',
|
||||||
|
currentPDA: 'Current PDA',
|
||||||
|
model: 'Model',
|
||||||
|
serialNumber: 'Serial number',
|
||||||
|
removePDA: 'Deallocate PDA',
|
||||||
|
},
|
||||||
create: {
|
create: {
|
||||||
name: 'Name',
|
name: 'Name',
|
||||||
lastName: 'Last name',
|
lastName: 'Last name',
|
||||||
|
|
|
@ -31,6 +31,7 @@ export default {
|
||||||
close: 'Cerrar',
|
close: 'Cerrar',
|
||||||
cancel: 'Cancelar',
|
cancel: 'Cancelar',
|
||||||
confirm: 'Confirmar',
|
confirm: 'Confirmar',
|
||||||
|
assign: 'Asignar',
|
||||||
back: 'Volver',
|
back: 'Volver',
|
||||||
yes: 'Si',
|
yes: 'Si',
|
||||||
no: 'No',
|
no: 'No',
|
||||||
|
@ -833,6 +834,7 @@ export default {
|
||||||
notifications: 'Notificaciones',
|
notifications: 'Notificaciones',
|
||||||
workerCreate: 'Nuevo trabajador',
|
workerCreate: 'Nuevo trabajador',
|
||||||
department: 'Departamentos',
|
department: 'Departamentos',
|
||||||
|
pda: 'PDA',
|
||||||
},
|
},
|
||||||
list: {
|
list: {
|
||||||
name: 'Nombre',
|
name: 'Nombre',
|
||||||
|
@ -874,6 +876,13 @@ export default {
|
||||||
subscribed: 'Se ha suscrito a la notificación',
|
subscribed: 'Se ha suscrito a la notificación',
|
||||||
unsubscribed: 'Se ha dado de baja de la notificación',
|
unsubscribed: 'Se ha dado de baja de la notificación',
|
||||||
},
|
},
|
||||||
|
pda: {
|
||||||
|
newPDA: 'Nueva PDA',
|
||||||
|
currentPDA: 'PDA Actual',
|
||||||
|
model: 'Modelo',
|
||||||
|
serialNumber: 'Número de serie',
|
||||||
|
removePDA: 'Desasignar PDA',
|
||||||
|
},
|
||||||
create: {
|
create: {
|
||||||
name: 'Nombre',
|
name: 'Nombre',
|
||||||
lastName: 'Apellido',
|
lastName: 'Apellido',
|
||||||
|
|
|
@ -0,0 +1,140 @@
|
||||||
|
<script setup>
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
import { onMounted, ref, computed } from 'vue';
|
||||||
|
import FetchData from 'components/FetchData.vue';
|
||||||
|
import FormModel from 'components/FormModel.vue';
|
||||||
|
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
|
||||||
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
|
import axios from 'axios';
|
||||||
|
import { useRole } from 'src/composables/useRole';
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
const { t } = useI18n();
|
||||||
|
const { notify } = useNotify();
|
||||||
|
const { hasAny } = useRole();
|
||||||
|
|
||||||
|
const fetchCurrentDeviceRef = ref(null);
|
||||||
|
const deviceProductionsFilter = {
|
||||||
|
fields: ['id', 'serialNumber', 'modelFk'],
|
||||||
|
where: { stateFk: 'idle' },
|
||||||
|
order: 'id',
|
||||||
|
};
|
||||||
|
const deviceProductionsOptions = ref([]);
|
||||||
|
const newPDA = ref({});
|
||||||
|
const currentPDA = ref(null);
|
||||||
|
|
||||||
|
const isAllowedToEdit = computed(() => hasAny(['hr', 'productionAssi']));
|
||||||
|
|
||||||
|
const setCurrentPDA = (data) => {
|
||||||
|
currentPDA.value = data;
|
||||||
|
currentPDA.value.description = `ID: ${currentPDA.value.deviceProductionFk} ${t(
|
||||||
|
'worker.pda.model'
|
||||||
|
)}: ${currentPDA.value.deviceProduction.modelFk} ${t('worker.pda.serialNumber')}: ${
|
||||||
|
currentPDA.value.deviceProduction.serialNumber
|
||||||
|
}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const deallocatePDA = async (data) => {
|
||||||
|
try {
|
||||||
|
await axios.post(`Workers/${route.params.id}/deallocatePDA`, {
|
||||||
|
pda: currentPDA.value.deviceProductionFk,
|
||||||
|
});
|
||||||
|
data.pda = null;
|
||||||
|
currentPDA.value = null;
|
||||||
|
await fetchCurrentDeviceRef.value.fetch();
|
||||||
|
notify(t('PDA deallocated'), 'positive');
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error deallocating PDA');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(async () => await fetchCurrentDeviceRef.value.fetch());
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<FetchData
|
||||||
|
url="DeviceProductions"
|
||||||
|
:filter="deviceProductionsFilter"
|
||||||
|
auto-load
|
||||||
|
@on-fetch="(data) => (deviceProductionsOptions = data)"
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
ref="fetchCurrentDeviceRef"
|
||||||
|
url="DeviceProductionUsers"
|
||||||
|
:filter="{
|
||||||
|
where: { userFk: route.params.id },
|
||||||
|
include: { relation: 'deviceProduction' },
|
||||||
|
}"
|
||||||
|
auto-load
|
||||||
|
@on-fetch="(data) => setCurrentPDA(data[0])"
|
||||||
|
/>
|
||||||
|
<QPage class="column items-center q-pa-md">
|
||||||
|
<FormModel
|
||||||
|
url="DeviceProductionUsers"
|
||||||
|
:url-create="`Workers/${route.params.id}/allocatePDA`"
|
||||||
|
model="DeviceProductionUser"
|
||||||
|
:form-initial-data="newPDA"
|
||||||
|
auto-load
|
||||||
|
:default-buttons="{ save: { label: 'globals.assign', color: 'primary' } }"
|
||||||
|
@on-data-saved="(_, data) => setCurrentPDA(data)"
|
||||||
|
>
|
||||||
|
<template #form="{ data }">
|
||||||
|
<QField
|
||||||
|
v-if="currentPDA && currentPDA.description"
|
||||||
|
:label="t('worker.pda.currentPDA')"
|
||||||
|
:model-value="currentPDA.description"
|
||||||
|
:editable="false"
|
||||||
|
class="full-width"
|
||||||
|
>
|
||||||
|
<template #control>
|
||||||
|
<div tabindex="0">
|
||||||
|
{{ currentPDA.description }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-if="isAllowedToEdit" #append>
|
||||||
|
<QIcon
|
||||||
|
name="delete"
|
||||||
|
size="sm"
|
||||||
|
class="cursor-pointer"
|
||||||
|
color="primary"
|
||||||
|
@click="deallocatePDA(data)"
|
||||||
|
>
|
||||||
|
<QTooltip>
|
||||||
|
{{ t('worker.pda.removePDA') }}
|
||||||
|
</QTooltip>
|
||||||
|
</QIcon>
|
||||||
|
</template>
|
||||||
|
</QField>
|
||||||
|
|
||||||
|
<VnSelectFilter
|
||||||
|
v-else
|
||||||
|
:label="t('worker.pda.newPDA')"
|
||||||
|
v-model="data.pda"
|
||||||
|
:options="deviceProductionsOptions"
|
||||||
|
option-label="serialNumber"
|
||||||
|
option-value="id"
|
||||||
|
hide-selected
|
||||||
|
:disable="!isAllowedToEdit"
|
||||||
|
>
|
||||||
|
<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>
|
||||||
|
</VnSelectFilter>
|
||||||
|
</template>
|
||||||
|
</FormModel>
|
||||||
|
</QPage>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<i18n>
|
||||||
|
es:
|
||||||
|
PDA deallocated: PDA desasignada
|
||||||
|
</i18n>
|
|
@ -12,7 +12,7 @@ export default {
|
||||||
redirect: { name: 'WorkerMain' },
|
redirect: { name: 'WorkerMain' },
|
||||||
menus: {
|
menus: {
|
||||||
main: ['WorkerList', 'WorkerDepartment'],
|
main: ['WorkerList', 'WorkerDepartment'],
|
||||||
card: ['WorkerNotificationsManager'],
|
card: ['WorkerNotificationsManager', 'WorkerPda'],
|
||||||
departmentCard: ['BasicData'],
|
departmentCard: ['BasicData'],
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
|
@ -76,6 +76,15 @@ export default {
|
||||||
component: () =>
|
component: () =>
|
||||||
import('src/pages/Worker/Card/WorkerNotificationsManager.vue'),
|
import('src/pages/Worker/Card/WorkerNotificationsManager.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'WorkerPda',
|
||||||
|
path: 'pda',
|
||||||
|
meta: {
|
||||||
|
title: 'pda',
|
||||||
|
icon: 'phone_android',
|
||||||
|
},
|
||||||
|
component: () => import('src/pages/Worker/Card/WorkerPda.vue'),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue