Merge branch 'test' into warmFix-nextTick
gitea/salix-front/pipeline/pr-test This commit looks good
Details
gitea/salix-front/pipeline/pr-test This commit looks good
Details
This commit is contained in:
commit
a71a039bfa
|
@ -184,8 +184,11 @@ async function saveChanges(data) {
|
|||
if ($props.beforeSaveFn) {
|
||||
changes = await $props.beforeSaveFn(changes, getChanges);
|
||||
}
|
||||
|
||||
try {
|
||||
if (changes?.creates?.length === 0 && changes?.updates?.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
await axios.post($props.saveUrl || $props.url + '/crud', changes);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
|
|
|
@ -168,16 +168,18 @@ describe('CrudModel', () => {
|
|||
result = vm.isEmpty(dummyArray);
|
||||
|
||||
expect(result).toBe(false);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('resetData()', () => {
|
||||
it('should add $index to elements in data[] and sets originalData and formData with data', async () => {
|
||||
data = [{
|
||||
data = [
|
||||
{
|
||||
name: 'Tony',
|
||||
lastName: 'Stark',
|
||||
age: 42,
|
||||
}];
|
||||
},
|
||||
];
|
||||
|
||||
vm.resetData(data);
|
||||
|
||||
|
@ -210,11 +212,13 @@ describe('CrudModel', () => {
|
|||
});
|
||||
|
||||
describe('saveChanges()', () => {
|
||||
data = [{
|
||||
data = [
|
||||
{
|
||||
name: 'Tony',
|
||||
lastName: 'Stark',
|
||||
age: 42,
|
||||
}];
|
||||
},
|
||||
];
|
||||
|
||||
it('should call saveFn if exists', async () => {
|
||||
await wrapper.setProps({ saveFn: vi.fn() });
|
||||
|
@ -231,11 +235,13 @@ describe('CrudModel', () => {
|
|||
it("should use default url if there's not saveFn", async () => {
|
||||
const postMock = vi.spyOn(axios, 'post');
|
||||
|
||||
vm.formData = [{
|
||||
vm.formData = [
|
||||
{
|
||||
name: 'Bruce',
|
||||
lastName: 'Wayne',
|
||||
age: 45,
|
||||
}]
|
||||
},
|
||||
];
|
||||
|
||||
await vm.saveChanges(data);
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
<script setup>
|
||||
import { onBeforeMount } from 'vue';
|
||||
import { useRouter, onBeforeRouteUpdate } from 'vue-router';
|
||||
import { useRouter, onBeforeRouteUpdate, onBeforeRouteLeave } from 'vue-router';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import useCardSize from 'src/composables/useCardSize';
|
||||
import LeftMenu from 'components/LeftMenu.vue';
|
||||
import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
||||
|
||||
const props = defineProps({
|
||||
|
@ -27,7 +26,13 @@ const arrayData = useArrayData(props.dataKey, {
|
|||
oneRecord: true,
|
||||
});
|
||||
|
||||
onBeforeRouteLeave(() => {
|
||||
stateStore.cardDescriptorChangeValue(null);
|
||||
});
|
||||
|
||||
onBeforeMount(async () => {
|
||||
stateStore.cardDescriptorChangeValue(props.descriptor);
|
||||
|
||||
const route = router.currentRoute.value;
|
||||
try {
|
||||
await fetch(route.params.id);
|
||||
|
@ -62,11 +67,6 @@ function hasRouteParam(params, valueToCheck = ':addressId') {
|
|||
}
|
||||
</script>
|
||||
<template>
|
||||
<Teleport to="#left-panel" v-if="stateStore.isHeaderMounted()">
|
||||
<component :is="descriptor" />
|
||||
<QSeparator />
|
||||
<LeftMenu source="card" />
|
||||
</Teleport>
|
||||
<VnSubToolbar />
|
||||
<div :class="[useCardSize(), $attrs.class]">
|
||||
<RouterView :key="$route.path" />
|
||||
|
|
|
@ -12,7 +12,7 @@ const $props = defineProps({
|
|||
},
|
||||
});
|
||||
onMounted(
|
||||
() => (stateStore.leftDrawer = useQuasar().screen.gt.xs ? $props.leftDrawer : false)
|
||||
() => (stateStore.leftDrawer = useQuasar().screen.gt.xs ? $props.leftDrawer : false),
|
||||
);
|
||||
|
||||
const teleportRef = ref({});
|
||||
|
@ -35,8 +35,14 @@ onMounted(() => {
|
|||
<template>
|
||||
<QDrawer v-model="stateStore.leftDrawer" show-if-above :width="256">
|
||||
<QScrollArea class="fit text-grey-8">
|
||||
<div id="left-panel" ref="teleportRef"></div>
|
||||
<LeftMenu v-if="!hasContent" />
|
||||
<div id="left-panel" ref="teleportRef">
|
||||
<template v-if="stateStore.cardDescriptor">
|
||||
<component :is="stateStore.cardDescriptor" />
|
||||
<QSeparator />
|
||||
<LeftMenu source="card" />
|
||||
</template>
|
||||
<template v-else> <LeftMenu /></template>
|
||||
</div>
|
||||
</QScrollArea>
|
||||
</QDrawer>
|
||||
<QPageContainer>
|
||||
|
|
|
@ -325,7 +325,7 @@ const sumRisk = ({ clientRisks }) => {
|
|||
</QCard>
|
||||
<QCard class="vn-max">
|
||||
<VnTitle :text="t('Latest tickets')" />
|
||||
<CustomerSummaryTable />
|
||||
<CustomerSummaryTable :id="entityId" />
|
||||
</QCard>
|
||||
</template>
|
||||
</CardSummary>
|
||||
|
|
|
@ -20,7 +20,12 @@ const { t } = useI18n();
|
|||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { viewSummary } = useSummaryDialog();
|
||||
|
||||
const $props = defineProps({
|
||||
id: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
const filter = {
|
||||
include: [
|
||||
{
|
||||
|
@ -43,7 +48,7 @@ const filter = {
|
|||
},
|
||||
},
|
||||
],
|
||||
where: { clientFk: route.params.id },
|
||||
where: { clientFk: $props.id ?? route.params.id },
|
||||
order: ['shipped DESC', 'id'],
|
||||
limit: 30,
|
||||
};
|
||||
|
|
|
@ -62,9 +62,10 @@ const columns = [
|
|||
name: 'workerFk',
|
||||
component: 'select',
|
||||
attrs: {
|
||||
url: 'Workers/search',
|
||||
url: 'TicketRequests/getItemTypeWorker',
|
||||
fields: ['id', 'nickname'],
|
||||
optionLabel: 'nickname',
|
||||
sortBy: 'nickname ASC',
|
||||
optionValue: 'id',
|
||||
},
|
||||
visible: false,
|
||||
|
|
|
@ -248,7 +248,7 @@ const entryFilterPanel = ref();
|
|||
<i18n>
|
||||
en:
|
||||
params:
|
||||
isExcludedFromAvailable: Inventory
|
||||
isExcludedFromAvailable: Is excluded
|
||||
isOrdered: Ordered
|
||||
isReceived: Received
|
||||
isConfirmed: Confirmed
|
||||
|
|
|
@ -19,6 +19,7 @@ const { t } = useI18n();
|
|||
const quasar = useQuasar();
|
||||
const state = useState();
|
||||
const user = state.getUser();
|
||||
const footer = ref({ bought: 0, reserve: 0 });
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -38,16 +39,14 @@ const columns = computed(() => [
|
|||
cardVisible: true,
|
||||
create: true,
|
||||
attrs: {
|
||||
url: 'Workers/activeWithInheritedRole',
|
||||
fields: ['id', 'name', 'nickname'],
|
||||
where: { role: 'buyer' },
|
||||
optionFilter: 'firstName',
|
||||
url: 'TicketRequests/getItemTypeWorker',
|
||||
fields: ['id', 'nickname'],
|
||||
optionLabel: 'nickname',
|
||||
sortBy: 'nickname ASC',
|
||||
optionValue: 'id',
|
||||
useLike: false,
|
||||
},
|
||||
columnFilter: false,
|
||||
width: '70px',
|
||||
width: '50px',
|
||||
},
|
||||
{
|
||||
align: 'center',
|
||||
|
@ -58,6 +57,7 @@ const columns = computed(() => [
|
|||
component: 'number',
|
||||
summation: true,
|
||||
width: '50px',
|
||||
format: ({ reserve }, dashIfEmpty) => dashIfEmpty(round(reserve)),
|
||||
},
|
||||
{
|
||||
align: 'center',
|
||||
|
@ -65,6 +65,7 @@ const columns = computed(() => [
|
|||
name: 'bought',
|
||||
summation: true,
|
||||
cardVisible: true,
|
||||
style: ({ reserve, bought }) => boughtStyle(bought, reserve),
|
||||
columnFilter: false,
|
||||
},
|
||||
{
|
||||
|
@ -95,7 +96,6 @@ const columns = computed(() => [
|
|||
},
|
||||
},
|
||||
],
|
||||
dataCy: 'table-actions',
|
||||
},
|
||||
]);
|
||||
|
||||
|
@ -137,20 +137,20 @@ function openDialog() {
|
|||
}
|
||||
|
||||
function setFooter(data) {
|
||||
const footer = {
|
||||
bought: 0,
|
||||
reserve: 0,
|
||||
};
|
||||
footer.value = { bought: 0, reserve: 0 };
|
||||
data.forEach((row) => {
|
||||
footer.bought += row?.bought;
|
||||
footer.reserve += row?.reserve;
|
||||
footer.value.bought += row?.bought;
|
||||
footer.value.reserve += row?.reserve;
|
||||
});
|
||||
tableRef.value.footer = footer;
|
||||
}
|
||||
|
||||
function round(value) {
|
||||
return Math.round(value * 100) / 100;
|
||||
}
|
||||
|
||||
function boughtStyle(bought, reserve) {
|
||||
return reserve < bought ? { color: 'var(--q-negative)' } : '';
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<VnSubToolbar>
|
||||
|
@ -253,24 +253,14 @@ function round(value) {
|
|||
<WorkerDescriptorProxy :id="row?.workerFk" />
|
||||
</span>
|
||||
</template>
|
||||
<template #column-bought="{ row }">
|
||||
<span :class="{ 'text-negative': row.reserve < row.bought }">
|
||||
{{ row?.bought }}
|
||||
</span>
|
||||
</template>
|
||||
<template #column-footer-reserve>
|
||||
<span>
|
||||
{{ round(tableRef.footer.reserve) }}
|
||||
{{ round(footer.reserve) }}
|
||||
</span>
|
||||
</template>
|
||||
<template #column-footer-bought>
|
||||
<span
|
||||
:class="{
|
||||
'text-negative':
|
||||
tableRef.footer.reserve < tableRef.footer.bought,
|
||||
}"
|
||||
>
|
||||
{{ round(tableRef.footer.bought) }}
|
||||
<span :style="boughtStyle(footer?.bought, footer?.reserve)">
|
||||
{{ round(footer.bought) }}
|
||||
</span>
|
||||
</template>
|
||||
</VnTable>
|
||||
|
@ -286,7 +276,7 @@ function round(value) {
|
|||
justify-content: center;
|
||||
}
|
||||
.column {
|
||||
min-width: 40%;
|
||||
min-width: 35%;
|
||||
margin-top: 5%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
|
@ -14,7 +14,7 @@ const $props = defineProps({
|
|||
required: true,
|
||||
},
|
||||
dated: {
|
||||
type: Date,
|
||||
type: [Date, String],
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ import FetchData from 'components/FetchData.vue';
|
|||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||
|
||||
import { toDateFormat } from 'src/filters/date.js';
|
||||
import { toDateTimeFormat } from 'src/filters/date.js';
|
||||
import { dashIfEmpty } from 'src/filters';
|
||||
import { date } from 'quasar';
|
||||
import { useState } from 'src/composables/useState';
|
||||
|
@ -143,7 +143,12 @@ onMounted(async () => {
|
|||
const fetchItemBalances = async () => await arrayDataItemBalances.fetch({});
|
||||
|
||||
const getBadgeAttrs = (_date) => {
|
||||
const isSameDate = date.isSameDate(today, _date);
|
||||
let today = Date.vnNew();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
let timeTicket = new Date(_date);
|
||||
timeTicket.setHours(0, 0, 0, 0);
|
||||
|
||||
const isSameDate = date.isSameDate(today, timeTicket);
|
||||
const attrs = {
|
||||
'text-color': isSameDate ? 'black' : 'white',
|
||||
color: isSameDate ? 'warning' : 'transparent',
|
||||
|
@ -153,15 +158,10 @@ const getBadgeAttrs = (_date) => {
|
|||
|
||||
const scrollToToday = async () => {
|
||||
await nextTick();
|
||||
const todayCell = document.querySelector(`td[data-date="${today.toISOString()}"]`);
|
||||
if (todayCell) {
|
||||
todayCell.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
};
|
||||
|
||||
const formatDateForAttribute = (dateValue) => {
|
||||
if (dateValue instanceof Date) return date.formatDate(dateValue, 'YYYY-MM-DD');
|
||||
return dateValue;
|
||||
const todayCell = document.querySelector(
|
||||
`td[data-date="${date.formatDate(today, 'YYYY-MM-DD')}"]`,
|
||||
);
|
||||
if (todayCell) todayCell.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
};
|
||||
|
||||
async function updateWarehouse(warehouseFk) {
|
||||
|
@ -237,14 +237,14 @@ async function updateWarehouse(warehouseFk) {
|
|||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-date="{ row }">
|
||||
<QTd @click.stop :data-date="formatDateForAttribute(row.shipped)">
|
||||
<QTd @click.stop :data-date="row?.shipped.substring(0, 10)">
|
||||
<QBadge
|
||||
v-bind="getBadgeAttrs(row.shipped)"
|
||||
class="q-ma-none"
|
||||
dense
|
||||
style="font-size: 14px"
|
||||
>
|
||||
{{ toDateFormat(row.shipped) }}
|
||||
{{ toDateTimeFormat(row.shipped) }}
|
||||
</QBadge>
|
||||
</QTd>
|
||||
</template>
|
||||
|
|
|
@ -11,7 +11,6 @@ import { toCurrency } from 'filters/index';
|
|||
import { useArrayData } from 'composables/useArrayData';
|
||||
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||
import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorProxy.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const from = ref();
|
||||
|
@ -41,7 +40,7 @@ const itemLastEntries = ref([]);
|
|||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
label: 'Nv',
|
||||
label: 'NV',
|
||||
name: 'ig',
|
||||
align: 'center',
|
||||
},
|
||||
|
@ -70,6 +69,7 @@ const columns = computed(() => [
|
|||
field: 'reference',
|
||||
align: 'center',
|
||||
format: (_, row) => toCurrency(row.price2) + ' / ' + toCurrency(row.price3),
|
||||
style: (row) => highlightedRow(row),
|
||||
},
|
||||
{
|
||||
label: t('lastEntries.printedStickers'),
|
||||
|
@ -84,6 +84,7 @@ const columns = computed(() => [
|
|||
field: 'stickers',
|
||||
align: 'center',
|
||||
format: (val) => dashIfEmpty(val),
|
||||
style: (row) => highlightedRow(row),
|
||||
},
|
||||
{
|
||||
label: 'Packing',
|
||||
|
@ -102,12 +103,14 @@ const columns = computed(() => [
|
|||
name: 'stems',
|
||||
field: 'stems',
|
||||
align: 'center',
|
||||
style: (row) => highlightedRow(row),
|
||||
},
|
||||
{
|
||||
label: t('lastEntries.quantity'),
|
||||
name: 'quantity',
|
||||
field: 'quantity',
|
||||
align: 'center',
|
||||
style: (row) => highlightedRow(row),
|
||||
},
|
||||
{
|
||||
label: t('lastEntries.cost'),
|
||||
|
@ -120,12 +123,14 @@ const columns = computed(() => [
|
|||
name: 'weight',
|
||||
field: 'weight',
|
||||
align: 'center',
|
||||
style: (row) => highlightedRow(row),
|
||||
},
|
||||
{
|
||||
label: t('lastEntries.cube'),
|
||||
name: 'cube',
|
||||
field: 'packagingFk',
|
||||
align: 'center',
|
||||
style: (row) => highlightedRow(row),
|
||||
},
|
||||
{
|
||||
label: t('lastEntries.supplier'),
|
||||
|
@ -208,6 +213,14 @@ onMounted(async () => {
|
|||
function getBadgeClass(groupingMode, expectedGrouping) {
|
||||
return groupingMode === expectedGrouping ? 'accent-badge' : 'simple-badge';
|
||||
}
|
||||
|
||||
function highlightedRow(row) {
|
||||
return row?.isInventorySupplier
|
||||
? {
|
||||
'background-color': 'var(--vn-section-hover-color)',
|
||||
}
|
||||
: '';
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<VnSubToolbar>
|
||||
|
@ -236,7 +249,7 @@ function getBadgeClass(groupingMode, expectedGrouping) {
|
|||
:no-data-label="t('globals.noResults')"
|
||||
>
|
||||
<template #body-cell-ig="{ row }">
|
||||
<QTd class="text-center">
|
||||
<QTd class="text-center" :style="highlightedRow(row)">
|
||||
<QIcon
|
||||
:name="row.isIgnored ? 'check_box' : 'check_box_outline_blank'"
|
||||
style="color: var(--vn-label-color)"
|
||||
|
@ -245,38 +258,38 @@ function getBadgeClass(groupingMode, expectedGrouping) {
|
|||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-warehouse="{ row }">
|
||||
<QTd>
|
||||
<QTd :style="highlightedRow(row)">
|
||||
<span>{{ row.warehouse }}</span>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-date="{ row }">
|
||||
<QTd class="text-center">
|
||||
<QTd class="text-center" :style="highlightedRow(row)">
|
||||
<VnDateBadge :date="row.landed" />
|
||||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-entry="{ row }">
|
||||
<QTd @click.stop>
|
||||
<QTd @click.stop :style="highlightedRow(row)">
|
||||
<div class="full-width flex justify-center">
|
||||
<EntryDescriptorProxy :id="row.entryFk" class="q-ma-none" dense />
|
||||
<span class="link">{{ row.entryFk }}</span>
|
||||
</div>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-pvp="{ value }">
|
||||
<QTd @click.stop class="text-center">
|
||||
<template #body-cell-pvp="{ row, value }">
|
||||
<QTd @click.stop class="text-center" :style="highlightedRow(row)">
|
||||
<span> {{ value }}</span>
|
||||
<QTooltip> {{ t('lastEntries.grouping') }}/Packing </QTooltip></QTd
|
||||
>
|
||||
<QTooltip> {{ t('lastEntries.grouping') }}/Packing </QTooltip>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-printedStickers="{ row }">
|
||||
<QTd @click.stop class="text-center">
|
||||
<QTd @click.stop class="text-center" :style="highlightedRow(row)">
|
||||
<span style="color: var(--vn-label-color)">
|
||||
{{ row.printedStickers }}</span
|
||||
>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-packing="{ row }">
|
||||
<QTd @click.stop>
|
||||
<QTd @click.stop :style="highlightedRow(row)">
|
||||
<QBadge
|
||||
class="center-content"
|
||||
:class="getBadgeClass(row.groupingMode, 'packing')"
|
||||
|
@ -288,7 +301,7 @@ function getBadgeClass(groupingMode, expectedGrouping) {
|
|||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-grouping="{ row }">
|
||||
<QTd @click.stop>
|
||||
<QTd @click.stop :style="highlightedRow(row)">
|
||||
<QBadge
|
||||
class="center-content"
|
||||
:class="getBadgeClass(row.groupingMode, 'grouping')"
|
||||
|
@ -300,7 +313,7 @@ function getBadgeClass(groupingMode, expectedGrouping) {
|
|||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-cost="{ row }">
|
||||
<QTd @click.stop class="text-center">
|
||||
<QTd @click.stop class="text-center" :style="highlightedRow(row)">
|
||||
<span>
|
||||
{{ toCurrency(row.cost, 'EUR', 3) }}
|
||||
<QTooltip>
|
||||
|
@ -319,7 +332,7 @@ function getBadgeClass(groupingMode, expectedGrouping) {
|
|||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-supplier="{ row }">
|
||||
<QTd @click.stop>
|
||||
<QTd @click.stop :style="highlightedRow(row)">
|
||||
<div class="full-width flex justify-left">
|
||||
<QBadge
|
||||
:class="
|
||||
|
@ -354,7 +367,6 @@ function getBadgeClass(groupingMode, expectedGrouping) {
|
|||
.th :first-child {
|
||||
.td {
|
||||
text-align: center;
|
||||
background-color: red;
|
||||
}
|
||||
}
|
||||
.accent-badge {
|
||||
|
|
|
@ -10,6 +10,7 @@ import OrderCatalogFilter from 'src/pages/Order/Card/OrderCatalogFilter.vue';
|
|||
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||
import { onUnmounted } from 'vue';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
@ -23,16 +24,40 @@ const catalogParams = {
|
|||
const arrayData = useArrayData(dataKey, {
|
||||
url: 'Orders/CatalogFilter',
|
||||
userParams: catalogParams,
|
||||
exprBuilder,
|
||||
searchUrl: 'table',
|
||||
});
|
||||
const store = arrayData.store;
|
||||
const tags = ref([]);
|
||||
const itemRefs = ref({});
|
||||
|
||||
onMounted(() => {
|
||||
onMounted(async () => {
|
||||
stateStore.rightDrawer = true;
|
||||
checkOrderConfirmation();
|
||||
|
||||
if (
|
||||
arrayData.store.userParams &&
|
||||
Object.keys(arrayData.store.userParams).some((key) => !key.startsWith('order'))
|
||||
) {
|
||||
await arrayData.fetch({});
|
||||
}
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
arrayData.destroy();
|
||||
});
|
||||
|
||||
function exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'categoryFk':
|
||||
case 'typeFk':
|
||||
return { [param]: value };
|
||||
case 'search':
|
||||
if (/^\d+$/.test(value)) return { 'i.id': value };
|
||||
else return { 'i.name': { like: `%${value}%` } };
|
||||
}
|
||||
}
|
||||
|
||||
async function checkOrderConfirmation() {
|
||||
const response = await axios.get(`Orders/${route.params.id}`);
|
||||
if (response.data.isConfirmed === 1) {
|
||||
|
@ -96,6 +121,7 @@ watch(
|
|||
:tag-value="tagValue"
|
||||
:tags="tags"
|
||||
:initial-catalog-params="catalogParams"
|
||||
:arrayData
|
||||
/>
|
||||
</template>
|
||||
</RightMenu>
|
||||
|
|
|
@ -24,6 +24,10 @@ const props = defineProps({
|
|||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
arrayData: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
|
@ -74,17 +78,6 @@ const loadTypes = async (id) => {
|
|||
typeList.value = data;
|
||||
};
|
||||
|
||||
function exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'categoryFk':
|
||||
case 'typeFk':
|
||||
return { [param]: value };
|
||||
case 'search':
|
||||
if (/^\d+$/.test(value)) return { 'i.id': value };
|
||||
else return { 'i.name': { like: `%${value}%` } };
|
||||
}
|
||||
}
|
||||
|
||||
const applyTags = (tagInfo, params, search) => {
|
||||
if (!tagInfo || !tagInfo.values.length) {
|
||||
params.tagGroups = null;
|
||||
|
@ -152,9 +145,8 @@ function addOrder(value, field, params) {
|
|||
:data-key="props.dataKey"
|
||||
:hidden-tags="['filter', 'orderFk', 'orderBy']"
|
||||
:unremovable-params="['orderFk', 'orderBy']"
|
||||
:expr-builder="exprBuilder"
|
||||
:custom-tags="['tagGroups', 'categoryFk']"
|
||||
:redirect="false"
|
||||
:arrayData
|
||||
>
|
||||
<template #tags="{ tag, formatFn }">
|
||||
<strong v-if="tag.label === 'typeFk' && typeList">
|
||||
|
|
|
@ -121,6 +121,50 @@ async function handleSave() {
|
|||
isSaving.value = false;
|
||||
}
|
||||
}
|
||||
function validateFields(item) {
|
||||
// Only validate fields that are being updated
|
||||
const shouldExist = (field) => !isUpdate || field in item;
|
||||
|
||||
if (!shouldExist('ticketServiceTypeFk') && !item.ticketServiceTypeFk) {
|
||||
notify('Description is required', 'negative');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!shouldExist('quantity') && (!item.quantity || item.quantity <= 0)) {
|
||||
notify('Quantity must be greater than 0', 'negative');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!shouldExist('price') && (!item.price || item.price < 0)) {
|
||||
notify('Price must be valid', 'negative');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function beforeSave(data) {
|
||||
const { creates = [], updates = [] } = data;
|
||||
const validData = { creates: [], updates: [] };
|
||||
|
||||
// Validate creates
|
||||
if (creates.length) {
|
||||
for (const create of creates) {
|
||||
create.ticketFk = route.params.id;
|
||||
if (validateFields(create)) {
|
||||
validData.creates.push(create);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validate updates
|
||||
if (updates.length) {
|
||||
for (const update of updates) {
|
||||
validData.updates.push(update);
|
||||
}
|
||||
}
|
||||
return validData;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -141,6 +185,7 @@ async function handleSave() {
|
|||
v-model:selected="selected"
|
||||
:order="['description ASC']"
|
||||
:default-remove="false"
|
||||
:beforeSaveFn="beforeSave"
|
||||
>
|
||||
<template #moreBeforeActions>
|
||||
<QBtn
|
||||
|
@ -170,6 +215,7 @@ async function handleSave() {
|
|||
option-value="id"
|
||||
hide-selected
|
||||
sort-by="name ASC"
|
||||
:required="true"
|
||||
>
|
||||
<template #form>
|
||||
<TicketCreateServiceType
|
||||
|
@ -185,6 +231,7 @@ async function handleSave() {
|
|||
:label="col.label"
|
||||
v-model.number="row.quantity"
|
||||
type="number"
|
||||
:required="true"
|
||||
min="0"
|
||||
:info="t('service.quantityInfo')"
|
||||
/>
|
||||
|
@ -196,6 +243,7 @@ async function handleSave() {
|
|||
:label="col.label"
|
||||
v-model.number="row.price"
|
||||
type="number"
|
||||
:required="true"
|
||||
min="0"
|
||||
@keyup.enter="handleSave"
|
||||
/>
|
||||
|
|
|
@ -456,6 +456,7 @@ watch(
|
|||
:pagination="{ rowsPerPage: 0 }"
|
||||
:no-data-label="t('globals.noResults')"
|
||||
:right-search="false"
|
||||
:order="['futureTotalWithVat ASC']"
|
||||
auto-load
|
||||
:disable-option="{ card: true }"
|
||||
>
|
||||
|
|
|
@ -79,7 +79,7 @@ const editEvent = async (event) => {
|
|||
};
|
||||
const { data } = await axios.patch(
|
||||
`Workers/${route.params.id}/updateAbsence`,
|
||||
params
|
||||
params,
|
||||
);
|
||||
|
||||
if (data) emit('refresh');
|
||||
|
@ -108,14 +108,14 @@ const handleDateSelected = (date) => {
|
|||
if (!event) createEvent(_date);
|
||||
};
|
||||
|
||||
const handleEventSelected = (event, { year, month, day }) => {
|
||||
const handleEventSelected = async (event, { year, month, day }) => {
|
||||
if (!props.absenceType) {
|
||||
notify(t('Choose an absence type from the right menu'), 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
const date = new Date(year, month - 1, day);
|
||||
if (!event?.absenceId) createEvent(date);
|
||||
if (!event?.absenceId) await createEvent(date);
|
||||
else if (event.type == props.absenceType.code) deleteEvent(event, date);
|
||||
else editEvent(event);
|
||||
};
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
<script setup>
|
||||
import VnSection from 'src/components/common/VnSection.vue';
|
||||
import WorkerDepartmentTree from './WorkerDepartmentTree.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnSection data-key="WorkerDepartment" :search-bar="false">
|
||||
<template #body>
|
||||
<div class="flex flex-center q-pa-md">
|
||||
<WorkerDepartmentTree />
|
||||
</div>
|
||||
</template>
|
||||
</VnSection>
|
||||
<QPage class="q-pa-md flex justify-center"> <WorkerDepartmentTree /> </QPage>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
|
|
|
@ -7,7 +7,11 @@ export const useStateStore = defineStore('stateStore', () => {
|
|||
const rightDrawer = ref(false);
|
||||
const rightAdvancedDrawer = ref(false);
|
||||
const subToolbar = ref(false);
|
||||
const cardDescriptor = ref(null);
|
||||
|
||||
function cardDescriptorChangeValue(descriptor) {
|
||||
cardDescriptor.value = descriptor;
|
||||
}
|
||||
function toggleLeftDrawer() {
|
||||
leftDrawer.value = !leftDrawer.value;
|
||||
}
|
||||
|
@ -49,6 +53,8 @@ export const useStateStore = defineStore('stateStore', () => {
|
|||
}
|
||||
|
||||
return {
|
||||
cardDescriptor,
|
||||
cardDescriptorChangeValue,
|
||||
leftDrawer,
|
||||
rightDrawer,
|
||||
rightAdvancedDrawer,
|
||||
|
|
Loading…
Reference in New Issue