This commit is contained in:
2024-07-02 18:38:11 +02:00
parent d2da96eaa3
commit d327277bac
14 changed files with 288 additions and 20 deletions

View File

@@ -42,7 +42,9 @@ useSeoMeta({
<NuxtPage/> <NuxtPage/>
</NuxtLayout> </NuxtLayout>
<!--
<UNotifications/> <UNotifications/>
-->
<VitePwaManifest/> <VitePwaManifest/>

View File

@@ -22,6 +22,49 @@ export const useSupabaseSelect = async (relation,select = '*', sortColumn = null
return data return data
} }
export const useSupabaseSelectDocuments = async (select = '*', sortColumn = null) => {
const supabase = useSupabaseClient()
const dataStore = useDataStore()
let data = null
if(sortColumn !== null ) {
data = (await supabase
.from("documents")
.select(select)
.eq("tenant", dataStore.currentTenant)
.order(sortColumn, {ascending: true})).data
} else {
data = (await supabase
.from("documents")
.select(select)
.eq("tenant", dataStore.currentTenant)).data
}
if(data.length > 0){
let paths = []
data.forEach(doc => {
paths.push(doc.path)
})
const {data: supabaseData,error} = await supabase.storage.from('files').createSignedUrls(paths,3600)
data = data.map((doc,index) => {
return {
...doc,
url: supabaseData[index].signedUrl
}
})
}
console.log(data)
return data
}
export const useSupabaseSelectSingle = async (relation,idToEq,select = '*' ) => { export const useSupabaseSelectSingle = async (relation,idToEq,select = '*' ) => {
const supabase = useSupabaseClient() const supabase = useSupabaseClient()
const dataStore = useDataStore() const dataStore = useDataStore()

View File

@@ -296,6 +296,10 @@ let links = computed(() => {
label: "Vorgänge", label: "Vorgänge",
to: "/inventory", to: "/inventory",
icon: "i-heroicons-square-3-stack-3d" icon: "i-heroicons-square-3-stack-3d"
},{
label: "Bestände",
to: "/inventory/stocks",
icon: "i-heroicons-square-3-stack-3d"
}, },
{ {
label: "Lagerplätze", label: "Lagerplätze",

8
package-lock.json generated
View File

@@ -48,7 +48,8 @@
"uuidv4": "^6.2.13", "uuidv4": "^6.2.13",
"v-calendar": "^3.1.2", "v-calendar": "^3.1.2",
"vuedraggable": "^4.1.0", "vuedraggable": "^4.1.0",
"vuetify": "^3.4.0-beta.1" "vuetify": "^3.4.0-beta.1",
"zebra-browser-print-wrapper": "^0.1.4"
}, },
"devDependencies": { "devDependencies": {
"@nuxt/devtools": "latest", "@nuxt/devtools": "latest",
@@ -19292,6 +19293,11 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/zebra-browser-print-wrapper": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/zebra-browser-print-wrapper/-/zebra-browser-print-wrapper-0.1.4.tgz",
"integrity": "sha512-w0mqnq83flxnNTgSgzkvSZWgnP/ffD0v+a5smOHUhB3UiaWqkDqIXzS6n6QnD6BBjE0qdrmlCmzoasSogEBJlw=="
},
"node_modules/zhead": { "node_modules/zhead": {
"version": "2.2.4", "version": "2.2.4",
"resolved": "https://registry.npmjs.org/zhead/-/zhead-2.2.4.tgz", "resolved": "https://registry.npmjs.org/zhead/-/zhead-2.2.4.tgz",

View File

@@ -61,6 +61,7 @@
"uuidv4": "^6.2.13", "uuidv4": "^6.2.13",
"v-calendar": "^3.1.2", "v-calendar": "^3.1.2",
"vuedraggable": "^4.1.0", "vuedraggable": "^4.1.0",
"vuetify": "^3.4.0-beta.1" "vuetify": "^3.4.0-beta.1",
"zebra-browser-print-wrapper": "^0.1.4"
} }
} }

View File

@@ -232,6 +232,7 @@ const saveRowDescription = () => {
} }
const removePosition = (id) => { const removePosition = (id) => {
let rows = itemInfo.value.rows.filter(row => row.id !== id) let rows = itemInfo.value.rows.filter(row => row.id !== id)
/*rows = rows.sort((a,b) => a.pos - b.pos) /*rows = rows.sort((a,b) => a.pos - b.pos)
@@ -397,6 +398,8 @@ const saveDocument = async () => {
project: itemInfo.value.project, project: itemInfo.value.project,
documentNumber: itemInfo.value.documentNumber, documentNumber: itemInfo.value.documentNumber,
documentDate: itemInfo.value.documentDate, documentDate: itemInfo.value.documentDate,
deliveryDate: itemInfo.value.deliveryDate,
paymentDays: itemInfo.value.paymentDays,
deliveryDateType: itemInfo.value.deliveryDateType, deliveryDateType: itemInfo.value.deliveryDateType,
info: { info: {
@@ -929,9 +932,10 @@ setupPage()
row.description = dataStore.getProductById(row.product).description" row.description = dataStore.getProductById(row.product).description"
> >
<template #label> <template #label>
<span class="truncate">{{dataStore.getProductById(row.product) ?dataStore.getProductById(row.product).name : "Kein Produkt ausgewählt" }}</span> <span class="truncate">{{dataStore.getProductById(row.product) ? dataStore.getProductById(row.product).name : "Kein Produkt ausgewählt" }}</span>
</template> </template>
</USelectMenu> </USelectMenu>
{{dataStore.getProductById(66)}}
</td> </td>
<td <td
class="w-120" class="w-120"

View File

@@ -1,6 +1,7 @@
<script setup> <script setup>
import {BlobReader, BlobWriter, ZipWriter} from "@zip.js/zip.js"; import {BlobReader, BlobWriter, ZipWriter} from "@zip.js/zip.js";
import {useSupabaseSelectDocuments} from "~/composables/useSupabase.js";
definePageMeta({ definePageMeta({
middleware: "auth" middleware: "auth"
@@ -24,15 +25,24 @@ const fileUploadFormData = ref({
let tags = dataStore.getDocumentTags let tags = dataStore.getDocumentTags
const selectedTags = ref("Eingang") const selectedTags = ref("Eingang")
const documents = ref([])
const setupPage = async () => {
documents.value = await useSupabaseSelectDocuments("*, project(id,name), customer(id,name), contract(id,name), vendor(id,name), plant(id,name), vehicle(id,licensePlate), product(id,name), profile(id,fullName) ")
}
setupPage()
const filteredDocuments = computed(() => { const filteredDocuments = computed(() => {
let returnList = []
returnList = dataStore.documents.filter(i => i.tags.filter(t => selectedTags.value === t).length > 0) if(selectedTags.value !== "Archiviert") {
return documents.value.filter(i => i.tags.find(t => selectedTags.value === t) && !i.tags.includes("Archiviert"))
} else {
return documents.value.filter(i => i.tags.find(t => selectedTags.value === t))
}
//return dataStore.documents.filter(doc => doc.tags.filter(tag => selectedTags.value.find(t => t === tag)).length > 0)
return returnList
}) })

View File

@@ -21,7 +21,7 @@ const availableDocuments = computed(() => {
//console.log(dataStore.documents.filter(i => i.tags.includes('Eingangsrechnung') && !dataStore.incominginvoices.find(x => x.document === i.id))) //console.log(dataStore.documents.filter(i => i.tags.includes('Eingangsrechnung') && !dataStore.incominginvoices.find(x => x.document === i.id)))
//console.log(dataStore.documents.filter(i => i.tags.includes('Eingangsrechnung')).length) //console.log(dataStore.documents.filter(i => i.tags.includes('Eingangsrechnung')).length)
return dataStore.documents.filter(i => i.tags.includes('Eingangsrechnung') && !dataStore.incominginvoices.find(x => x.document === i.id)) return dataStore.documents.filter(i => i.tags.includes('Eingangsrechnung') && !i.tags.includes("Archiviert") && !dataStore.incominginvoices.find(x => x.document === i.id))
}) })
@@ -36,7 +36,7 @@ const itemInfo = ref({
reference: "", reference: "",
date: null, date: null,
dueDate: null, dueDate: null,
paymentType: "", paymentType: "Überweisung",
description: "", description: "",
state: "Entwurf", state: "Entwurf",
accounts: [ accounts: [
@@ -315,6 +315,13 @@ setupPage()
<UFormGroup label="Zahlart:" required>
<USelectMenu
:options="['Einzug','Kreditkarte','Überweisung','Sonstiges']"
v-model="itemInfo.paymentType"
/>
</UFormGroup>
<UFormGroup label="Beschreibung:" required> <UFormGroup label="Beschreibung:" required>
<UTextarea <UTextarea
v-model="itemInfo.description" v-model="itemInfo.description"

View File

@@ -73,6 +73,10 @@ const templateColumns = [
{ {
key: "paid", key: "paid",
label: "Bezahlt" label: "Bezahlt"
},
{
key: "paymentType",
label: "Zahlart"
} }
] ]
const selectedColumns = ref(templateColumns) const selectedColumns = ref(templateColumns)

View File

@@ -15,7 +15,8 @@ const inventoryChangeData = ref({
sourceProjectId: null, sourceProjectId: null,
destinationSpaceId: null, destinationSpaceId: null,
destinationProjectId: null, destinationProjectId: null,
quantity: 1 quantity: 1,
serials: []
}) })
const resetInput = () => { const resetInput = () => {
@@ -93,7 +94,14 @@ const createMovement = async () => {
.from("movements") .from("movements")
.insert(movements) .insert(movements)
.select() .select()
if(error) console.log(error) if(error) {
console.log(error)
} else {
resetInput()
}
} }
@@ -146,6 +154,7 @@ const findSpaceBySpaceNumber = (input) => {
const barcodeInput = ref("") const barcodeInput = ref("")
const showBarcodeTip = ref(true) const showBarcodeTip = ref(true)
const serialInput = ref("")
const processBarcodeInput = () => { const processBarcodeInput = () => {
if(findProductByBarcodeOrEAN(barcodeInput.value) && !findSpaceBySpaceNumber(barcodeInput.value)){ if(findProductByBarcodeOrEAN(barcodeInput.value) && !findSpaceBySpaceNumber(barcodeInput.value)){
@@ -380,6 +389,29 @@ const processBarcodeInput = () => {
id="quantityInput" id="quantityInput"
/> />
</UFormGroup> </UFormGroup>
<UFormGroup
label="Seriennummern:"
class="mt-3 w-80"
>
<InputGroup class="w-full">
<UInput
variant="outline"
color="primary"
placeholder="Seriennummern"
v-model="serialInput"
/>
<UButton
@click="inventoryChangeData.serials.push(serialInput)"
>
+
</UButton>
</InputGroup>
</UFormGroup>
<ul>
<li v-for="serial in inventoryChangeData.serials">{{serial}}</li>
</ul>
</div> </div>
</UDashboardPanelContent> </UDashboardPanelContent>

152
pages/inventory/stocks.vue Normal file
View File

@@ -0,0 +1,152 @@
<template>
<UDashboardNavbar title="Bestände" :badge="filteredRows.length">
<template #right>
<UInput
id="searchinput"
v-model="searchString"
icon="i-heroicons-funnel"
autocomplete="off"
placeholder="Suche..."
class="hidden lg:block"
@keydown.esc="$event.target.blur()"
>
<template #trailing>
<UKbd value="/" />
</template>
</UInput>
<UButton @click="router.push(`/products/create`)">+ Artikel</UButton>
</template>
</UDashboardNavbar>
<UDashboardToolbar>
<template #right>
<USelectMenu
v-model="selectedColumns"
icon="i-heroicons-adjustments-horizontal-solid"
:options="templateColumns"
multiple
class="hidden lg:block"
by="key"
>
<template #label>
Spalten
</template>
</USelectMenu>
</template>
</UDashboardToolbar>
<UTable
:rows="filteredRows"
:columns="columns"
class="w-full"
:ui="{ divide: 'divide-gray-200 dark:divide-gray-800' }"
@select="(i) => router.push(`/products/show/${i.id}`) "
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Artikel anzuzeigen' }"
>
<template #name-data="{row}">
<span
v-if="row === filteredRows[selectedItem]"
class="text-primary-500 font-bold">{{row.name}}</span>
<span v-else>
{{row.name}}
</span>
</template>
<template #stock-data="{row}">
{{`${dataStore.getStockByProductId(row.id)} ${(dataStore.units.find(unit => unit.id === row.unit) ? dataStore.units.find(unit => unit.id === row.unit).name : "")}`}}
</template>
</UTable>
</template>
<script setup>
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'/': () => {
document.getElementById("searchinput").focus()
},
'+': () => {
router.push("/products/create")
},
'Enter': {
usingInput: true,
handler: () => {
router.push(`/products/show/${filteredRows.value[selectedItem.value].id}`)
}
},
'arrowdown': () => {
if(selectedItem.value < filteredRows.value.length - 1) {
selectedItem.value += 1
} else {
selectedItem.value = 0
}
},
'arrowup': () => {
if(selectedItem.value === 0) {
selectedItem.value = filteredRows.value.length - 1
} else {
selectedItem.value -= 1
}
}
})
const dataStore = useDataStore()
const router = useRouter()
const items = ref([])
const selectedItem = ref(0)
const setupPage = async () => {
items.value = await useSupabaseSelect("products","*")
}
setupPage()
const templateColumns = [
{
key: "stock",
label: "Bestand"
},
{
key: "name",
label: "Name",
sortable: true
},
]
const selectedColumns = ref(templateColumns)
const columns = computed(() => templateColumns.filter((column) => selectedColumns.value.includes(column)))
const templateTags = computed(() => {
let temp = []
dataStore.products.forEach(row => {
row.tags.forEach(tag => {
if(!temp.includes(tag)) temp.push(tag)
})
})
return temp
})
const selectedTags = ref(templateTags.value)
const searchString = ref('')
const filteredRows = computed(() => {
let temp = items.value.filter(i => i.tags.some(x => selectedTags.value.includes(x)) || i.tags.length === 0)
return useSearch(searchString.value, temp)
})
</script>
<style scoped>
</style>

View File

@@ -128,8 +128,11 @@ setupPage()
<UDivider <UDivider
class="my-2" class="my-2"
/> />
<span v-if="itemInfo.purchasePrice">Einkaufspreis: {{Number(itemInfo.purchasePrice).toFixed(2)}} <br></span>
<span v-if="itemInfo.manufacturer">Hersteller: {{itemInfo.manufacturer}}<br></span>
<span v-if="itemInfo.manufacturerNumber">Herstellernummer: {{itemInfo.manufacturerNumber}}<br></span>
<span v-if="itemInfo.description">Beschreibung: {{itemInfo.description}}<br></span>
<span v-if="itemInfo.purchasePrice">Einkaufspreis: {{Number(itemInfo.purchasePrice).toFixed(2)}} <br></span>
</div> </div>
<div <div
v-if="item.label === 'Logbuch'" v-if="item.label === 'Logbuch'"
@@ -222,13 +225,13 @@ setupPage()
v-model="itemInfo.ean" v-model="itemInfo.ean"
/> />
</UFormGroup> </UFormGroup>
<UFormGroup <!-- <UFormGroup
label="Barcode:" label="Barcode:"
> >
<UInput <UInput
v-model="itemInfo.barcode" v-model="itemInfo.barcode"
/> />
</UFormGroup> </UFormGroup>-->
<UFormGroup <UFormGroup
label="Verkaufspreis:" label="Verkaufspreis:"
> >

View File

@@ -1,6 +1,6 @@
<script setup> <script setup>
import axios from "axios"; import axios from "axios";
import ZebraBrowserPrintWrapper from "zebra-browser-print-wrapper"
definePageMeta({ definePageMeta({
middleware: "auth" middleware: "auth"
}) })
@@ -11,6 +11,8 @@ const router = useRouter()
const toast = useToast() const toast = useToast()
const id = ref(route.params.id ? route.params.id : null ) const id = ref(route.params.id ? route.params.id : null )
const browserPrint = ZebraBrowserPrintWrapper();
let currentItem = ref(null) let currentItem = ref(null)
//Working //Working
@@ -36,6 +38,8 @@ const setupPage = async () => {
} }
if(mode.value === "edit") itemInfo.value = currentItem.value if(mode.value === "edit") itemInfo.value = currentItem.value
} }
const cancelEditorCreate = () => { const cancelEditorCreate = () => {

View File

@@ -1456,11 +1456,7 @@ export const useDataStore = defineStore('data', () => {
//Get Item By Id //Get Item By Id
const getProductById = computed(() => async (itemId) => { const getProductById = computed(() => async (itemId) => {
return products.value.find(item => item.id === itemId)
return await useSupabaseSelectSingle("products",itemId, "*")
//return products.value.find(item => item.id === itemId)
}) })
const getServiceById = computed(() => (itemId) => { const getServiceById = computed(() => (itemId) => {