refactor: refs #8193 modified default observation type to adapt it to user
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
d1eab07b76
commit
db021194c2
|
@ -5,7 +5,7 @@ import { onBeforeRouteLeave } from 'vue-router';
|
|||
import { useI18n } from 'vue-i18n';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
|
||||
import { useState } from 'src/composables/useState';
|
||||
import { toDateHourMin } from 'src/filters';
|
||||
|
||||
import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||
|
@ -42,7 +42,9 @@ const quasar = useQuasar();
|
|||
const newNote = reactive({ text: null, observationTypeFk: null });
|
||||
const observationTypes = ref([]);
|
||||
const vnPaginateRef = ref();
|
||||
|
||||
const state = useState();
|
||||
const user = state.getUser();
|
||||
const userRole = ref();
|
||||
const defaultObservationType = computed(
|
||||
() => observationTypes.value.find((ot) => ot.code === 'salesPerson')?.id,
|
||||
);
|
||||
|
@ -124,11 +126,13 @@ function fetchData([data]) {
|
|||
emit('onFetch', data);
|
||||
}
|
||||
|
||||
const handleObservationTypes = (data) => {
|
||||
const handleObservationTypes = async (data) => {
|
||||
observationTypes.value = data;
|
||||
if (defaultObservationType.value) {
|
||||
newNote.observationTypeFk = defaultObservationType.value;
|
||||
}
|
||||
const { data: res } = await axios.get(`VnRoles/${userRole?.value[0]?.roleFk}`);
|
||||
const hasObservationType = observationTypes.value.find((ot) => ot.code === res.name);
|
||||
newNote.observationTypeFk = hasObservationType
|
||||
? hasObservationType.code
|
||||
: defaultObservationType.value;
|
||||
};
|
||||
|
||||
function exprBuilder(param, value) {
|
||||
|
@ -147,6 +151,14 @@ onUnmounted(() => {
|
|||
});
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
v-if="selectType"
|
||||
url="VnUsers/preview"
|
||||
:filter="{ fields: ['id', 'roleFk', 'username'] }"
|
||||
:where="{ id: user.id }"
|
||||
auto-load
|
||||
@on-fetch="(data) => (userRole = data)"
|
||||
/>
|
||||
<FetchData
|
||||
v-if="selectType"
|
||||
url="ObservationTypes"
|
||||
|
|
Loading…
Reference in New Issue