feat: refs #6564 implement getValueFromPath utility
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
bbf4234351
commit
530dc62e00
|
@ -1,12 +1,22 @@
|
|||
<script setup>
|
||||
import { toCurrency } from 'src/filters';
|
||||
import { getValueFromPath } from 'src/composables/getValueFromPath';
|
||||
|
||||
defineProps({ row: { type: Object, required: true } });
|
||||
const { row, visibleProblems = null } = defineProps({
|
||||
row: { type: Object, required: true },
|
||||
visibleProblems: { type: Array },
|
||||
});
|
||||
|
||||
function showProblem(problem) {
|
||||
const val = getValueFromPath(row, problem);
|
||||
if (!visibleProblems) return val;
|
||||
return !!(visibleProblems?.includes(problem) && val);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<span class="q-gutter-x-xs">
|
||||
<router-link
|
||||
v-if="row.claim?.claimFk"
|
||||
v-if="showProblem('claim.claimFk')"
|
||||
:to="{ name: 'ClaimBasicData', params: { id: row.claim?.claimFk } }"
|
||||
class="link"
|
||||
>
|
||||
|
@ -18,7 +28,7 @@ defineProps({ row: { type: Object, required: true } });
|
|||
</QIcon>
|
||||
</router-link>
|
||||
<QIcon
|
||||
v-if="row?.reserved"
|
||||
v-if="showProblem('reserved')"
|
||||
color="primary"
|
||||
name="vn:reserva"
|
||||
size="xs"
|
||||
|
@ -29,7 +39,7 @@ defineProps({ row: { type: Object, required: true } });
|
|||
</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon
|
||||
v-if="row?.isDeleted"
|
||||
v-if="showProblem('isDeleted')"
|
||||
color="primary"
|
||||
name="vn:deletedTicket"
|
||||
size="xs"
|
||||
|
@ -40,7 +50,7 @@ defineProps({ row: { type: Object, required: true } });
|
|||
</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon
|
||||
v-if="row?.hasRisk"
|
||||
v-if="showProblem('hasRisk')"
|
||||
name="vn:risk"
|
||||
:color="row.hasHighRisk ? 'negative' : 'primary'"
|
||||
size="xs"
|
||||
|
@ -51,51 +61,76 @@ defineProps({ row: { type: Object, required: true } });
|
|||
</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon
|
||||
v-if="row?.hasComponentLack"
|
||||
v-if="showProblem('hasComponentLack')"
|
||||
name="vn:components"
|
||||
color="primary"
|
||||
size="xs"
|
||||
>
|
||||
<QTooltip>{{ $t('salesTicketsTable.componentLack') }}</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon v-if="row?.hasItemDelay" color="primary" size="xs" name="vn:hasItemDelay">
|
||||
<QIcon
|
||||
v-if="showProblem('hasItemDelay')"
|
||||
color="primary"
|
||||
size="xs"
|
||||
name="vn:hasItemDelay"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ $t('ticket.summary.hasItemDelay') }}
|
||||
</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon v-if="row?.hasItemLost" color="primary" size="xs" name="vn:hasItemLost">
|
||||
<QIcon
|
||||
v-if="showProblem('hasItemLost')"
|
||||
color="primary"
|
||||
size="xs"
|
||||
name="vn:hasItemLost"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ $t('salesTicketsTable.hasItemLost') }}
|
||||
</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon
|
||||
v-if="row?.hasItemShortage"
|
||||
v-if="showProblem('hasItemShortage')"
|
||||
name="vn:unavailable"
|
||||
color="primary"
|
||||
size="xs"
|
||||
>
|
||||
<QTooltip>{{ $t('salesTicketsTable.notVisible') }}</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon v-if="row?.hasRounding" color="primary" name="sync_problem" size="xs">
|
||||
<QIcon
|
||||
v-if="showProblem('hasRounding')"
|
||||
color="primary"
|
||||
name="sync_problem"
|
||||
size="xs"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ $t('ticketList.rounding') }}
|
||||
</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon
|
||||
v-if="row?.hasTicketRequest"
|
||||
v-if="showProblem('hasTicketRequest')"
|
||||
name="vn:buyrequest"
|
||||
color="primary"
|
||||
size="xs"
|
||||
>
|
||||
<QTooltip>{{ $t('salesTicketsTable.purchaseRequest') }}</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon v-if="row?.isTaxDataChecked" name="vn:no036" color="primary" size="xs">
|
||||
<QIcon
|
||||
v-if="showProblem('isTaxDataChecked')"
|
||||
name="vn:no036"
|
||||
color="primary"
|
||||
size="xs"
|
||||
>
|
||||
<QTooltip>{{ $t('salesTicketsTable.noVerifiedData') }}</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon v-if="row?.isFreezed" name="vn:frozen" color="primary" size="xs">
|
||||
<QIcon v-if="showProblem('isFreezed')" name="vn:frozen" color="primary" size="xs">
|
||||
<QTooltip>{{ $t('salesTicketsTable.clientFrozen') }}</QTooltip>
|
||||
</QIcon>
|
||||
<QIcon v-if="row?.isTooLittle" name="vn:isTooLittle" color="primary" size="xs">
|
||||
<QIcon
|
||||
v-if="showProblem('isTooLittle')"
|
||||
name="vn:isTooLittle"
|
||||
color="primary"
|
||||
size="xs"
|
||||
>
|
||||
<QTooltip>{{ $t('salesTicketsTable.tooLittle') }}</QTooltip>
|
||||
</QIcon>
|
||||
</span>
|
||||
|
|
|
@ -6,6 +6,7 @@ import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
|||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useClipboard } from 'src/composables/useClipboard';
|
||||
import VnMoreOptions from './VnMoreOptions.vue';
|
||||
import { getValueFromPath } from 'src/composables/getValueFromPath';
|
||||
|
||||
const entity = defineModel({ type: Object, default: null });
|
||||
const $props = defineProps({
|
||||
|
@ -56,18 +57,6 @@ const routeName = computed(() => {
|
|||
return `${routeName}Summary`;
|
||||
});
|
||||
|
||||
function getValueFromPath(path) {
|
||||
if (!path) return;
|
||||
const keys = path.toString().split('.');
|
||||
let current = entity.value;
|
||||
|
||||
for (const key of keys) {
|
||||
if (current[key] === undefined) return undefined;
|
||||
else current = current[key];
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
function copyIdText(id) {
|
||||
copyText(id, {
|
||||
component: {
|
||||
|
@ -170,10 +159,10 @@ const toModule = computed(() => {
|
|||
<div class="title">
|
||||
<span
|
||||
v-if="title"
|
||||
:title="getValueFromPath(title)"
|
||||
:title="getValueFromPath(entity, title)"
|
||||
:data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_title`"
|
||||
>
|
||||
{{ getValueFromPath(title) ?? title }}
|
||||
{{ getValueFromPath(entity, title) ?? title }}
|
||||
</span>
|
||||
<slot v-else name="description" :entity="entity">
|
||||
<span
|
||||
|
@ -189,7 +178,7 @@ const toModule = computed(() => {
|
|||
class="subtitle"
|
||||
:data-cy="`${$attrs['data-cy'] ?? 'vnDescriptor'}_subtitle`"
|
||||
>
|
||||
#{{ getValueFromPath(subtitle) ?? entity.id }}
|
||||
#{{ getValueFromPath(entity, subtitle) ?? entity.id }}
|
||||
</QItemLabel>
|
||||
<QBtn
|
||||
round
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
export function getValueFromPath(root, path) {
|
||||
if (!root || !path) return;
|
||||
const keys = path.toString().split('.');
|
||||
let current = root;
|
||||
|
||||
for (const key of keys) {
|
||||
if (current[key] === undefined) return undefined;
|
||||
else current = current[key];
|
||||
}
|
||||
return current;
|
||||
}
|
|
@ -559,7 +559,7 @@ watch(
|
|||
</QBadge>
|
||||
</template>
|
||||
<template #column-problems="{ row }">
|
||||
<TicketProblems :row="row.problems" />
|
||||
<TicketProblems :row="row?.problems" :visible-problems="['hasRisk']" />
|
||||
</template>
|
||||
<template #column-futureId="{ row }">
|
||||
<QBtn flat class="link" dense>
|
||||
|
|
|
@ -10,7 +10,7 @@ import VnInputDate from 'src/components/common/VnInputDate.vue';
|
|||
import axios from 'axios';
|
||||
import { onMounted } from 'vue';
|
||||
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
||||
|
||||
import VnCheckbox from 'src/components/common/VnCheckbox.vue';
|
||||
const { t, te } = useI18n();
|
||||
const props = defineProps({
|
||||
dataKey: {
|
||||
|
@ -130,11 +130,12 @@ onMounted(async () => await getItemPackingTypes());
|
|||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<QCheckbox
|
||||
<VnCheckbox
|
||||
:label="t('params.isFullMovable')"
|
||||
v-model="params.isFullMovable"
|
||||
toggle-indeterminate
|
||||
@update:model-value="searchFn()"
|
||||
dense
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
|
@ -167,11 +168,12 @@ onMounted(async () => await getItemPackingTypes());
|
|||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<QCheckbox
|
||||
<VnCheckbox
|
||||
toggle-indeterminate
|
||||
label="only with destination"
|
||||
v-model="params.onlyWithDestination"
|
||||
@update:model-value="searchFn()"
|
||||
dense
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
|
|
Loading…
Reference in New Issue