Compare commits
3 Commits
7e6c5cc189
...
4db753d34a
| Author | SHA1 | Date | |
|---|---|---|---|
| 4db753d34a | |||
| e0e99ba6f5 | |||
| ace2213cc4 |
@@ -174,6 +174,49 @@ const setupQuery = () => {
|
|||||||
setupQuery()
|
setupQuery()
|
||||||
|
|
||||||
const loadedOptions = ref({})
|
const loadedOptions = ref({})
|
||||||
|
|
||||||
|
const normalizeSelectFieldValue = (value, isMultiple = false) => {
|
||||||
|
if (isMultiple) {
|
||||||
|
if (!Array.isArray(value)) return []
|
||||||
|
|
||||||
|
return value.map((entry) => {
|
||||||
|
if (entry && typeof entry === "object" && "id" in entry) {
|
||||||
|
return entry.id
|
||||||
|
}
|
||||||
|
|
||||||
|
return entry
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value && typeof value === "object" && "id" in value) {
|
||||||
|
return value.id
|
||||||
|
}
|
||||||
|
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalizeLoadedSelectValues = () => {
|
||||||
|
dataType.templateColumns.forEach((datapoint) => {
|
||||||
|
if (datapoint.inputType !== "select") return
|
||||||
|
|
||||||
|
if (datapoint.key.includes(".")) {
|
||||||
|
const [parentKey, childKey] = datapoint.key.split(".")
|
||||||
|
if (!item.value[parentKey]) return
|
||||||
|
|
||||||
|
item.value[parentKey][childKey] = normalizeSelectFieldValue(
|
||||||
|
item.value[parentKey][childKey],
|
||||||
|
datapoint.selectMultiple
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
item.value[datapoint.key] = normalizeSelectFieldValue(
|
||||||
|
item.value[datapoint.key],
|
||||||
|
datapoint.selectMultiple
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const loadOptions = async () => {
|
const loadOptions = async () => {
|
||||||
let optionsToLoad = dataType.templateColumns.filter(i => i.selectDataType).map(i => {
|
let optionsToLoad = dataType.templateColumns.filter(i => i.selectDataType).map(i => {
|
||||||
return {
|
return {
|
||||||
@@ -198,6 +241,7 @@ const loadOptions = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadOptions()
|
loadOptions()
|
||||||
|
normalizeLoadedSelectValues()
|
||||||
|
|
||||||
const contentChanged = (content, datapoint) => {
|
const contentChanged = (content, datapoint) => {
|
||||||
if (datapoint.key.includes(".")) {
|
if (datapoint.key.includes(".")) {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ setupPage()
|
|||||||
:type="props.type"
|
:type="props.type"
|
||||||
:item="item"
|
:item="item"
|
||||||
:inModal="true"
|
:inModal="true"
|
||||||
@return-data="(data) => emit('return-data',data)"
|
@return-data="(data) => emit('returnData', data)"
|
||||||
:createQuery="props.createQuery"
|
:createQuery="props.createQuery"
|
||||||
:mode="props.mode"
|
:mode="props.mode"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -582,20 +582,20 @@ setup()
|
|||||||
<div class="flex gap-1">
|
<div class="flex gap-1">
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
class="w-full"
|
class="w-full"
|
||||||
:options="accounts"
|
:items="accounts"
|
||||||
value-attribute="id"
|
value-key="id"
|
||||||
option-attribute="label"
|
label-key="label"
|
||||||
v-model="accountToSave"
|
v-model="accountToSave"
|
||||||
searchable
|
:search-input="{ placeholder: 'Konto suchen...' }"
|
||||||
:search-attributes="['number','label']"
|
:filter-fields="['number','label']"
|
||||||
placeholder="Konto suchen..."
|
placeholder="Konto suchen..."
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #default>
|
||||||
<span v-if="accountToSave"
|
<span v-if="accountToSave"
|
||||||
class="truncate">{{ accounts.find(i => i.id === accountToSave).number }} - {{ accounts.find(i => i.id === accountToSave).label }}</span>
|
class="truncate">{{ accounts.find(i => i.id === accountToSave).number }} - {{ accounts.find(i => i.id === accountToSave).label }}</span>
|
||||||
<span v-else>Direkt verbuchen...</span>
|
<span v-else>Direkt verbuchen...</span>
|
||||||
</template>
|
</template>
|
||||||
<template #option="{option}">
|
<template #item-label="{ item: option }">
|
||||||
<span class="font-mono text-xs text-gray-500 mr-2">{{ option.number }}</span> {{ option.label }}
|
<span class="font-mono text-xs text-gray-500 mr-2">{{ option.number }}</span> {{ option.label }}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
@@ -620,21 +620,21 @@ setup()
|
|||||||
|
|
||||||
<div v-if="showMoreWithoutRecipe"
|
<div v-if="showMoreWithoutRecipe"
|
||||||
class="mt-4 p-3 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 grid grid-cols-1 md:grid-cols-3 gap-3">
|
class="mt-4 p-3 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 grid grid-cols-1 md:grid-cols-3 gap-3">
|
||||||
<USelectMenu :options="ownaccounts" value-attribute="id" option-attribute="name" v-model="ownAccountToSave"
|
<USelectMenu :items="ownaccounts" value-key="id" label-key="name" v-model="ownAccountToSave"
|
||||||
searchable placeholder="Eigenes Konto">
|
:search-input="{ placeholder: 'Eigenes Konto' }" :filter-fields="['number','name']" placeholder="Eigenes Konto">
|
||||||
<template #label>
|
<template #default>
|
||||||
{{ ownAccountToSave ? ownaccounts.find(i => i.id === ownAccountToSave).name : 'Eigenes Konto' }}
|
{{ ownAccountToSave ? ownaccounts.find(i => i.id === ownAccountToSave).name : 'Eigenes Konto' }}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
<USelectMenu :options="customers" value-attribute="id" option-attribute="name"
|
<USelectMenu :items="customers" value-key="id" label-key="name"
|
||||||
v-model="customerAccountToSave" searchable placeholder="Kunde (Guthaben)">
|
v-model="customerAccountToSave" :search-input="{ placeholder: 'Kunde (Guthaben)' }" :filter-fields="['name','customerNumber']" placeholder="Kunde (Guthaben)">
|
||||||
<template #label>
|
<template #default>
|
||||||
{{ customerAccountToSave ? customers.find(i => i.id === customerAccountToSave).name : 'Kunde' }}
|
{{ customerAccountToSave ? customers.find(i => i.id === customerAccountToSave).name : 'Kunde' }}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
<USelectMenu :options="vendors" value-attribute="id" option-attribute="name" v-model="vendorAccountToSave"
|
<USelectMenu :items="vendors" value-key="id" label-key="name" v-model="vendorAccountToSave"
|
||||||
searchable placeholder="Lieferant (Guthaben)">
|
:search-input="{ placeholder: 'Lieferant (Guthaben)' }" :filter-fields="['name','vendorNumber']" placeholder="Lieferant (Guthaben)">
|
||||||
<template #label>
|
<template #default>
|
||||||
{{ vendorAccountToSave ? vendors.find(i => i.id === vendorAccountToSave).name : 'Lieferant' }}
|
{{ vendorAccountToSave ? vendors.find(i => i.id === vendorAccountToSave).name : 'Lieferant' }}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
|
|||||||
@@ -2707,7 +2707,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
:disabled="itemInfo.type === 'cancellationInvoices'"
|
:disabled="itemInfo.type === 'cancellationInvoices'"
|
||||||
type="number"
|
type="number"
|
||||||
:step="units.find(i => i.id === row.unit) ? units.find(i => i.id === row.unit).step : '1' "
|
:step="units.find(i => i.id === row.unit) ? units.find(i => i.id === row.unit).step : '1' "
|
||||||
class="w-full"
|
class="w-20"
|
||||||
|
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
@@ -2738,7 +2738,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
|||||||
type="number"
|
type="number"
|
||||||
step="0.001"
|
step="0.001"
|
||||||
@change="updateCustomSurcharge"
|
@change="updateCustomSurcharge"
|
||||||
class="w-full"
|
class="w-30"
|
||||||
>
|
>
|
||||||
<template #leading>
|
<template #leading>
|
||||||
<span class="text-gray-500 dark:text-gray-400 text-xs">EUR</span>
|
<span class="text-gray-500 dark:text-gray-400 text-xs">EUR</span>
|
||||||
|
|||||||
@@ -1,11 +1,39 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const toast = useToast()
|
||||||
|
|
||||||
const items = ref([])
|
const items = ref([])
|
||||||
|
const pending = ref(true)
|
||||||
|
|
||||||
|
const mapProfileRow = (user) => {
|
||||||
|
const profile = user?.profile || {}
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: profile?.id || null,
|
||||||
|
employee_number: profile?.employee_number || '',
|
||||||
|
full_name: profile?.full_name || user?.full_name || user?.email || 'Ohne Profil',
|
||||||
|
email: user?.email || profile?.email || ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
items.value = (await useNuxtApp().$api("/api/tenant/users")).users
|
pending.value = true
|
||||||
items.value = items.value.map(i => i.profile)
|
|
||||||
|
try {
|
||||||
|
const response = await useNuxtApp().$api("/api/tenant/users")
|
||||||
|
items.value = (response?.users || [])
|
||||||
|
.map(mapProfileRow)
|
||||||
|
.filter((item) => !!item.id)
|
||||||
|
} catch (err) {
|
||||||
|
console.error('[staff/profiles/index]', err)
|
||||||
|
items.value = []
|
||||||
|
toast.add({
|
||||||
|
title: 'Profile konnten nicht geladen werden',
|
||||||
|
color: 'error'
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
pending.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setupPage()
|
setupPage()
|
||||||
@@ -31,7 +59,7 @@
|
|||||||
<UDashboardNavbar title="Benutzer Einstellungen">
|
<UDashboardNavbar title="Benutzer Einstellungen">
|
||||||
<template #right>
|
<template #right>
|
||||||
<UButton
|
<UButton
|
||||||
@click="router.push(`/profiles/create`)"
|
@click="router.push(`/staff/profiles/create`)"
|
||||||
disabled
|
disabled
|
||||||
>
|
>
|
||||||
+ Mitarbeiter
|
+ Mitarbeiter
|
||||||
@@ -41,9 +69,14 @@
|
|||||||
<UTable
|
<UTable
|
||||||
:data="items"
|
:data="items"
|
||||||
:columns="normalizeTableColumns(columns)"
|
:columns="normalizeTableColumns(columns)"
|
||||||
:on-select="(i) => navigateTo(`/staff/profiles/${i.id}`)"
|
:loading="pending"
|
||||||
|
:on-select="(row) => navigateTo(`/staff/profiles/${row.original?.id || row.id}`)"
|
||||||
>
|
>
|
||||||
|
<template #empty>
|
||||||
|
<div class="py-10 text-center text-sm text-gray-500">
|
||||||
|
Keine Mitarbeiterprofile gefunden.
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</UTable>
|
</UTable>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user