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 SkeletonForm from 'components/ui/SkeletonForm.vue';
|
||||
import VnConfirm from './ui/VnConfirm.vue';
|
||||
import { tMobile } from 'src/composables/tMobile';
|
||||
|
||||
const quasar = useQuasar();
|
||||
const state = useState();
|
||||
|
@ -43,6 +44,10 @@ const $props = defineProps({
|
|||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
defaultButtons: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
autoLoad: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
|
@ -128,7 +133,19 @@ const hasChanges = ref(!$props.observeFormChanges);
|
|||
const originalData = ref({ ...$props.formInitialData });
|
||||
const formData = computed(() => state.get($props.model));
|
||||
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 = () => {
|
||||
watch(
|
||||
() => formData.value,
|
||||
|
@ -140,10 +157,6 @@ const startFormWatcher = () => {
|
|||
);
|
||||
};
|
||||
|
||||
function tMobile(...args) {
|
||||
if (!quasar.platform.is.mobile) return t(...args);
|
||||
}
|
||||
|
||||
async function fetch() {
|
||||
const { data } = await axios.get($props.url, {
|
||||
params: { filter: JSON.stringify($props.filter) },
|
||||
|
@ -242,21 +255,21 @@ watch(formUrl, async () => {
|
|||
<QBtnGroup push class="q-gutter-x-sm">
|
||||
<slot name="moreActions" />
|
||||
<QBtn
|
||||
:label="tMobile('globals.reset')"
|
||||
color="primary"
|
||||
icon="restart_alt"
|
||||
:label="tMobile(defaultButtons.reset.label)"
|
||||
:color="defaultButtons.reset.color"
|
||||
:icon="defaultButtons.reset.icon"
|
||||
flat
|
||||
@click="reset"
|
||||
:disable="!hasChanges"
|
||||
:title="t('globals.reset')"
|
||||
:title="t(defaultButtons.reset.label)"
|
||||
/>
|
||||
<QBtn
|
||||
:label="tMobile('globals.save')"
|
||||
color="primary"
|
||||
icon="save"
|
||||
:label="tMobile(defaultButtons.save.label)"
|
||||
:color="defaultButtons.save.color"
|
||||
:icon="defaultButtons.save.icon"
|
||||
@click="save"
|
||||
:disable="!hasChanges"
|
||||
:title="t('globals.save')"
|
||||
:title="t(defaultButtons.save.label)"
|
||||
/>
|
||||
</QBtnGroup>
|
||||
</div>
|
||||
|
|
|
@ -31,6 +31,7 @@ export default {
|
|||
close: 'Close',
|
||||
cancel: 'Cancel',
|
||||
confirm: 'Confirm',
|
||||
assign: 'Assign',
|
||||
back: 'Back',
|
||||
yes: 'Yes',
|
||||
no: 'No',
|
||||
|
@ -833,6 +834,7 @@ export default {
|
|||
notifications: 'Notifications',
|
||||
workerCreate: 'New worker',
|
||||
department: 'Department',
|
||||
pda: 'PDA',
|
||||
},
|
||||
list: {
|
||||
name: 'Name',
|
||||
|
@ -874,6 +876,13 @@ export default {
|
|||
subscribed: 'Subscribed to the notification',
|
||||
unsubscribed: 'Unsubscribed from the notification',
|
||||
},
|
||||
pda: {
|
||||
newPDA: 'New PDA',
|
||||
currentPDA: 'Current PDA',
|
||||
model: 'Model',
|
||||
serialNumber: 'Serial number',
|
||||
removePDA: 'Deallocate PDA',
|
||||
},
|
||||
create: {
|
||||
name: 'Name',
|
||||
lastName: 'Last name',
|
||||
|
|
|
@ -31,6 +31,7 @@ export default {
|
|||
close: 'Cerrar',
|
||||
cancel: 'Cancelar',
|
||||
confirm: 'Confirmar',
|
||||
assign: 'Asignar',
|
||||
back: 'Volver',
|
||||
yes: 'Si',
|
||||
no: 'No',
|
||||
|
@ -833,6 +834,7 @@ export default {
|
|||
notifications: 'Notificaciones',
|
||||
workerCreate: 'Nuevo trabajador',
|
||||
department: 'Departamentos',
|
||||
pda: 'PDA',
|
||||
},
|
||||
list: {
|
||||
name: 'Nombre',
|
||||
|
@ -874,6 +876,13 @@ export default {
|
|||
subscribed: 'Se ha suscrito a 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: {
|
||||
name: 'Nombre',
|
||||
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' },
|
||||
menus: {
|
||||
main: ['WorkerList', 'WorkerDepartment'],
|
||||
card: ['WorkerNotificationsManager'],
|
||||
card: ['WorkerNotificationsManager', 'WorkerPda'],
|
||||
departmentCard: ['BasicData'],
|
||||
},
|
||||
children: [
|
||||
|
@ -76,6 +76,15 @@ export default {
|
|||
component: () =>
|
||||
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