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);
|
||||
}
|
||||
|
||||
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) {
|
||||
switch (param) {
|
||||
case 'observationTypeFk':
|
||||
|
@ -131,19 +150,6 @@ function exprBuilder(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>
|
||||
<template>
|
||||
<FetchData
|
||||
|
@ -154,6 +160,13 @@ onMounted(async () => {
|
|||
auto-load
|
||||
@on-fetch="(data) => (userRole = data)"
|
||||
/>
|
||||
<FetchData
|
||||
v-if="selectType"
|
||||
url="ObservationTypes"
|
||||
:filter="{ fields: ['id', 'description', 'code', 'departmentFk'] }"
|
||||
auto-load
|
||||
@on-fetch="handleObservationTypes"
|
||||
/>
|
||||
<FetchData
|
||||
v-if="justInput"
|
||||
:url="url"
|
||||
|
@ -172,6 +185,7 @@ onMounted(async () => {
|
|||
<QCardSection class="q-px-xs q-my-none q-py-none">
|
||||
<VnRow class="full-width">
|
||||
<VnSelect
|
||||
class="q-mr-xs"
|
||||
:label="t('Observation type')"
|
||||
v-if="selectType"
|
||||
url="ObservationTypes"
|
||||
|
@ -181,6 +195,7 @@ onMounted(async () => {
|
|||
:required="'required' in originalAttrs"
|
||||
@keyup.enter.stop="insert"
|
||||
data-cy="VnNotes-observation-type"
|
||||
filled
|
||||
/>
|
||||
<VnInput
|
||||
v-model.trim="newNote.text"
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
<script setup>
|
||||
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 VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import FetchData from 'src/components/FetchData.vue';
|
||||
import VnNotes from 'src/components/ui/VnNotes.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';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
@ -126,3 +128,7 @@ onUnmounted(() => {
|
|||
order="created DESC"
|
||||
/>
|
||||
</template>
|
||||
<i18n>
|
||||
es:
|
||||
Observation type: Tipo de observación
|
||||
</i18n>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
describe('Vehicle Notes', () => {
|
||||
const selectors = {
|
||||
addNoteInput: 'Add note here..._input',
|
||||
addNoteInput: 'VnNotes-text-input',
|
||||
saveNoteBtn: 'saveNote',
|
||||
deleteNoteBtn: 'notesRemoveNoteBtn',
|
||||
noteCard: '.column.full-width > :nth-child(1) > .q-card__section--vert',
|
||||
|
|
Loading…
Reference in New Issue