feat: refs #8372 workerPBX
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Robert Ferrús 2025-01-09 14:46:53 +01:00
parent c6a9c55ddc
commit 0057932bfa
2 changed files with 13 additions and 52 deletions

View File

@ -198,6 +198,7 @@ async function fetch() {
} catch (e) {
state.set(modelValue, {});
originalData.value = {};
throw e;
}
}

View File

@ -1,68 +1,28 @@
src/pages/Worker/Card/WorkerPBX.vue
<script setup>
import { watch, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import { useState } from 'src/composables/useState';
import FormModel from 'src/components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
const { t } = useI18n();
const state = useState();
const route = useRoute();
const workerPBXForm = ref();
const extension = ref(null);
const filter = {
include: [
{
relation: 'sip',
},
],
};
watch(
() => route.params.id,
() => state.set('extension', null)
);
const onFetch = (data) => {
state.set('extension', data?.sip?.extension);
extension.value = state.get('extension');
};
const updateModelValue = (data) => {
state.set('extension', data);
workerPBXForm.value.hasChanges = true;
};
</script>
<template>
<FormModel
ref="workerPBXForm"
:filter="filter"
:url="`Workers/${route.params.id}`"
model="WorkerPbx"
:url="`Workers/${$route.params.id}/sip`"
url-update="Sips"
auto-load
:mapper="
() => ({
userFk: +route.params.id,
({ userFk, extension }) => ({
userFk,
extension,
})
"
model="DeviceProductionUser"
@on-fetch="onFetch"
auto-load
>
<template #form="{}">
<VnRow>
<VnInput
:label="t('worker.summary.sipExtension')"
v-model="extension"
@update:model-value="updateModelValue"
/>
</VnRow>
<template #form="{ data }">
<VnInput
:label="$t('worker.summary.sipExtension')"
v-model="data.extension"
/>
</template>
</FormModel>
</template>