Desarrollo de los submodulos basic data, notes y pbx #245
File diff suppressed because it is too large
Load Diff
|
@ -1,129 +1,56 @@
|
|||
<script setup>
|
||||
import { computed, onBeforeMount, ref, watch } from 'vue';
|
||||
import { reactive, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import axios from 'axios';
|
||||
|
||||
import { useState } from 'src/composables/useState';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import useNotify from 'src/composables/useNotify';
|
||||
|
||||
import FormModel from 'src/components/FormModel.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
|
||||
const { notify } = useNotify();
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const state = useState();
|
||||
const stateStore = useStateStore();
|
||||
const route = useRoute();
|
||||
|
||||
const isLoading = ref(false);
|
||||
const extension = ref('');
|
||||
const worker = ref({});
|
||||
const workersRef = ref(null);
|
||||
const formInitialData = reactive({});
|
||||
|
||||
const hasChanged = computed(() => {
|
||||
return extension.value !== worker.value?.sip?.extension;
|
||||
});
|
||||
|
||||
onBeforeMount(() => getData(route.params.id));
|
||||
const filter = {
|
||||
include: [
|
||||
{
|
||||
relation: 'sip',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
jsegarra marked this conversation as resolved
Outdated
|
||||
watch(
|
||||
() => route.params.id,
|
||||
(newValue) => {
|
||||
getData(newValue);
|
||||
}
|
||||
() => state.set('extension', null)
|
||||
);
|
||||
|
||||
const getData = async (id) => {
|
||||
const filter = {
|
||||
include: [
|
||||
{
|
||||
relation: 'sip',
|
||||
},
|
||||
],
|
||||
};
|
||||
const onFetch = (data) => state.set('extension', data?.sip?.extension);
|
||||
|
||||
try {
|
||||
const url = `Workers/${id}`;
|
||||
const { data } = await axios.get(url, {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
});
|
||||
extension.value = data.sip.extension;
|
||||
state.set('extension', data.sip.extension);
|
||||
worker.value = data;
|
||||
} catch (error) {
|
||||
state.set('extension', null);
|
||||
extension.value = '';
|
||||
}
|
||||
};
|
||||
|
||||
const setInitialData = () => {
|
||||
extension.value = worker.value?.sip?.extension;
|
||||
state.set('extension', worker.value?.sip?.extension);
|
||||
};
|
||||
|
||||
const onSubmit = async () => {
|
||||
isLoading.value = true;
|
||||
|
||||
const payload = {
|
||||
extension: extension.value,
|
||||
userFk: Number(route.params.id),
|
||||
};
|
||||
try {
|
||||
await axios.patch('Sips', payload);
|
||||
notify('worker.card.dataSavedCard', 'positive');
|
||||
|
||||
if (workersRef.value) workersRef.value.fetch();
|
||||
} catch (error) {
|
||||
notify(error.error, 'negative');
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const updateModelValue = () => {
|
||||
state.set('extension', extension.value);
|
||||
};
|
||||
const updateModelValue = (data) => state.set('extension', data);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="#st-actions" v-if="stateStore?.isSubToolbarShown()">
|
||||
<QBtnGroup push class="q-gutter-x-sm">
|
||||
<QBtn
|
||||
:disabled="!hasChanged"
|
||||
:label="t('globals.reset')"
|
||||
:loading="isLoading"
|
||||
@click="setInitialData"
|
||||
color="primary"
|
||||
flat
|
||||
icon="restart_alt"
|
||||
type="reset"
|
||||
/>
|
||||
<QBtn
|
||||
:disabled="!hasChanged"
|
||||
:label="t('globals.save')"
|
||||
:loading="isLoading"
|
||||
@click="onSubmit"
|
||||
color="primary"
|
||||
icon="save"
|
||||
/>
|
||||
</QBtnGroup>
|
||||
</Teleport>
|
||||
|
||||
<div class="full-width flex justify-center">
|
||||
<QCard class="card-width q-pa-lg">
|
||||
<QCardSection>
|
||||
<VnRow class="row q-gutter-md q-mb-md">
|
||||
<div class="col">
|
||||
<QInput
|
||||
:label="t('worker.summary.sipExtension')"
|
||||
v-model="extension"
|
||||
@update:model-value="updateModelValue()"
|
||||
/>
|
||||
</div>
|
||||
</VnRow>
|
||||
</QCardSection>
|
||||
</QCard>
|
||||
</div>
|
||||
<FormModel
|
||||
jsegarra marked this conversation as resolved
Outdated
jsegarra
commented
Los botones no se habilitan cuando se modifica el campo Los botones no se habilitan cuando se modifica el campo
wbuezas
commented
Corregido Commit: Corregido
Commit: https://gitea.verdnatura.es/verdnatura/salix-front/commit/239daceca60bd3158ea8faa79c851a137a7e3a4a
|
||||
:filter="filter"
|
||||
:form-initial-data="formInitialData"
|
||||
:url="`Workers/${route.params.id}`"
|
||||
jsegarra marked this conversation as resolved
Outdated
jsegarra
commented
En el caso de que este funcionando bien. Al pulsar guardar, que URL se usaría En el caso de que este funcionando bien. Al pulsar guardar, que URL se usaría
wbuezas
commented
Corregido Commit: Corregido
Commit: https://gitea.verdnatura.es/verdnatura/salix-front/commit/239daceca60bd3158ea8faa79c851a137a7e3a4a
|
||||
auto-load
|
||||
model="DeviceProductionUser"
|
||||
@on-fetch="onFetch"
|
||||
>
|
||||
<template #form="{ data }">
|
||||
<VnRow class="row q-gutter-md q-mb-md">
|
||||
<div class="col">
|
||||
<QInput
|
||||
jsegarra marked this conversation as resolved
Outdated
jsegarra
commented
QInput? Usar VnInput QInput? Usar VnInput
wbuezas
commented
Corregido Commit: Corregido
Commit: https://gitea.verdnatura.es/verdnatura/salix-front/commit/239daceca60bd3158ea8faa79c851a137a7e3a4a
|
||||
:label="t('worker.summary.sipExtension')"
|
||||
jsegarra marked this conversation as resolved
jsegarra
commented
Cuando se pierde el foco del campo el valor del input desaparece Cuando se pierde el foco del campo el valor del input desaparece
wbuezas
commented
Corregido Commit: Corregido
Commit: https://gitea.verdnatura.es/verdnatura/salix-front/commit/239daceca60bd3158ea8faa79c851a137a7e3a4a
|
||||
:model-value="data?.sip?.extension"
|
||||
@update:model-value="updateModelValue"
|
||||
/>
|
||||
</div>
|
||||
</VnRow>
|
||||
</template>
|
||||
</FormModel>
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue
Cuando se modifica no actualiza el valor del Descriptor
Corregido:
c06d810fe9