feat: refs #8193 add default observationType rely on user department
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
This commit is contained in:
parent
bb8699f026
commit
200aed4ccc
|
@ -124,6 +124,25 @@ function fetchData([data]) {
|
||||||
emit('onFetch', data);
|
emit('onFetch', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleObservationTypes = async (data) => {
|
||||||
|
observationTypes.value = data;
|
||||||
|
|
||||||
|
const { data: departments } = await axios.get('Departments');
|
||||||
|
const userDepartment = departments.find((ot) => ot.id === user.value.departmentFk);
|
||||||
|
|
||||||
|
const hasObservationType =
|
||||||
|
observationTypes.value.find(
|
||||||
|
(ot) => parseInt(ot.departmentFk) === userDepartment.id,
|
||||||
|
) ||
|
||||||
|
observationTypes.value.find(
|
||||||
|
(ot) => parseInt(ot.departmentFk) === userDepartment.parentFk,
|
||||||
|
);
|
||||||
|
|
||||||
|
newNote.observationTypeFk = hasObservationType
|
||||||
|
? hasObservationType.code
|
||||||
|
: defaultObservationType.value;
|
||||||
|
};
|
||||||
|
|
||||||
function exprBuilder(param, value) {
|
function exprBuilder(param, value) {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case 'observationTypeFk':
|
case 'observationTypeFk':
|
||||||
|
@ -131,19 +150,6 @@ function exprBuilder(param, value) {
|
||||||
return { [param]: value };
|
return { [param]: value };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
const { data: obervations } = await axios.get('ObservationTypes');
|
|
||||||
observationTypes.value = obervations;
|
|
||||||
console.log('observationTypes.value: ', observationTypes.value);
|
|
||||||
const { data: res } = await axios.get(`VnRoles/${userRole?.value[0]?.roleFk}`);
|
|
||||||
console.log('res: ', res);
|
|
||||||
const hasObservationType = observationTypes.value.find((ot) => ot.code === res.name);
|
|
||||||
console.log('hasObservationType: ', hasObservationType);
|
|
||||||
newNote.observationTypeFk = hasObservationType
|
|
||||||
? hasObservationType.code
|
|
||||||
: defaultObservationType.value;
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
@ -154,6 +160,13 @@ onMounted(async () => {
|
||||||
auto-load
|
auto-load
|
||||||
@on-fetch="(data) => (userRole = data)"
|
@on-fetch="(data) => (userRole = data)"
|
||||||
/>
|
/>
|
||||||
|
<FetchData
|
||||||
|
v-if="selectType"
|
||||||
|
url="ObservationTypes"
|
||||||
|
:filter="{ fields: ['id', 'description', 'code', 'departmentFk'] }"
|
||||||
|
auto-load
|
||||||
|
@on-fetch="handleObservationTypes"
|
||||||
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
v-if="justInput"
|
v-if="justInput"
|
||||||
:url="url"
|
:url="url"
|
||||||
|
@ -172,6 +185,7 @@ onMounted(async () => {
|
||||||
<QCardSection class="q-px-xs q-my-none q-py-none">
|
<QCardSection class="q-px-xs q-my-none q-py-none">
|
||||||
<VnRow class="full-width">
|
<VnRow class="full-width">
|
||||||
<VnSelect
|
<VnSelect
|
||||||
|
class="q-mr-xs"
|
||||||
:label="t('Observation type')"
|
:label="t('Observation type')"
|
||||||
v-if="selectType"
|
v-if="selectType"
|
||||||
url="ObservationTypes"
|
url="ObservationTypes"
|
||||||
|
@ -181,6 +195,7 @@ onMounted(async () => {
|
||||||
:required="'required' in originalAttrs"
|
:required="'required' in originalAttrs"
|
||||||
@keyup.enter.stop="insert"
|
@keyup.enter.stop="insert"
|
||||||
data-cy="VnNotes-observation-type"
|
data-cy="VnNotes-observation-type"
|
||||||
|
filled
|
||||||
/>
|
/>
|
||||||
<VnInput
|
<VnInput
|
||||||
v-model.trim="newNote.text"
|
v-model.trim="newNote.text"
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted, onUnmounted } from 'vue';
|
import { ref, computed, onMounted, onUnmounted } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
|
|
||||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
import FetchData from 'src/components/FetchData.vue';
|
import FetchData from 'src/components/FetchData.vue';
|
||||||
import VnNotes from 'src/components/ui/VnNotes.vue';
|
import VnNotes from 'src/components/ui/VnNotes.vue';
|
||||||
import VnTableFilter from 'src/components/VnTable/VnTableFilter.vue';
|
import VnTableFilter from 'src/components/VnTable/VnTableFilter.vue';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import VnAvatar from 'src/components/ui/VnAvatar.vue';
|
import VnAvatar from 'src/components/ui/VnAvatar.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -126,3 +128,7 @@ onUnmounted(() => {
|
||||||
order="created DESC"
|
order="created DESC"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
<i18n>
|
||||||
|
es:
|
||||||
|
Observation type: Tipo de observación
|
||||||
|
</i18n>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
describe('Vehicle Notes', () => {
|
describe('Vehicle Notes', () => {
|
||||||
const selectors = {
|
const selectors = {
|
||||||
addNoteInput: 'Add note here..._input',
|
addNoteInput: 'VnNotes-text-input',
|
||||||
saveNoteBtn: 'saveNote',
|
saveNoteBtn: 'saveNote',
|
||||||
deleteNoteBtn: 'notesRemoveNoteBtn',
|
deleteNoteBtn: 'notesRemoveNoteBtn',
|
||||||
noteCard: '.column.full-width > :nth-child(1) > .q-card__section--vert',
|
noteCard: '.column.full-width > :nth-child(1) > .q-card__section--vert',
|
||||||
|
|
Loading…
Reference in New Issue