mirror of
https://github.com/duhanbalci/dreport.git
synced 2026-07-02 10:59:17 +00:00
to library
This commit is contained in:
@@ -3,68 +3,14 @@ import { ref, computed } from 'vue'
|
||||
import type { JsonSchema, SchemaNode } from '../core/schema-parser'
|
||||
import { parseSchema, findArrayFields, findScalarFields } from '../core/schema-parser'
|
||||
|
||||
/** Varsayılan fatura schema'sı */
|
||||
const defaultSchema: JsonSchema = {
|
||||
$id: 'fatura-schema',
|
||||
/** Minimal boş schema — gerçek schema dışarıdan (DreportEditor prop) gelir */
|
||||
const emptySchema: JsonSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
firma: {
|
||||
type: 'object',
|
||||
title: 'Firma',
|
||||
properties: {
|
||||
unvan: { type: 'string', title: 'Firma Unvani' },
|
||||
vergiNo: { type: 'string', title: 'Vergi No' },
|
||||
logo: { type: 'string', title: 'Logo', format: 'image' },
|
||||
adres: { type: 'string', title: 'Adres' },
|
||||
telefon: { type: 'string', title: 'Telefon' },
|
||||
},
|
||||
},
|
||||
fatura: {
|
||||
type: 'object',
|
||||
title: 'Fatura',
|
||||
properties: {
|
||||
no: { type: 'string', title: 'Fatura No' },
|
||||
tarih: { type: 'string', title: 'Tarih', format: 'date' },
|
||||
},
|
||||
},
|
||||
musteri: {
|
||||
type: 'object',
|
||||
title: 'Musteri',
|
||||
properties: {
|
||||
unvan: { type: 'string', title: 'Musteri Unvani' },
|
||||
vergiNo: { type: 'string', title: 'Vergi No' },
|
||||
adres: { type: 'string', title: 'Adres' },
|
||||
},
|
||||
},
|
||||
kalemler: {
|
||||
type: 'array',
|
||||
title: 'Fatura Kalemleri',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
siraNo: { type: 'integer', title: 'Sira No' },
|
||||
adi: { type: 'string', title: 'Urun / Hizmet Adi' },
|
||||
miktar: { type: 'number', title: 'Miktar' },
|
||||
birim: { type: 'string', title: 'Birim' },
|
||||
birimFiyat: { type: 'number', title: 'Birim Fiyat', format: 'currency' },
|
||||
tutar: { type: 'number', title: 'Tutar', format: 'currency' },
|
||||
},
|
||||
},
|
||||
},
|
||||
toplamlar: {
|
||||
type: 'object',
|
||||
title: 'Toplamlar',
|
||||
properties: {
|
||||
araToplam: { type: 'number', title: 'Ara Toplam', format: 'currency' },
|
||||
kdv: { type: 'number', title: 'KDV', format: 'currency' },
|
||||
genelToplam: { type: 'number', title: 'Genel Toplam', format: 'currency' },
|
||||
},
|
||||
},
|
||||
},
|
||||
properties: {},
|
||||
}
|
||||
|
||||
export const useSchemaStore = defineStore('schema', () => {
|
||||
const rawSchema = ref<JsonSchema>(defaultSchema)
|
||||
const rawSchema = ref<JsonSchema>(emptySchema)
|
||||
|
||||
const schemaTree = computed<SchemaNode>(() => parseSchema(rawSchema.value))
|
||||
|
||||
|
||||
@@ -47,7 +47,14 @@ function createDefaultTemplate(): Template {
|
||||
export const useTemplateStore = defineStore('template', () => {
|
||||
const template = ref<Template>(createDefaultTemplate())
|
||||
|
||||
const mockData = computed(() => generateMockData(template.value))
|
||||
/** Dışarıdan verilen önizleme verisi (null ise mock data üretilir) */
|
||||
const overrideData = ref<Record<string, unknown> | null>(null)
|
||||
|
||||
const mockData = computed(() => overrideData.value ?? generateMockData(template.value))
|
||||
|
||||
function setOverrideData(data: Record<string, unknown> | null) {
|
||||
overrideData.value = data
|
||||
}
|
||||
|
||||
// Undo / Redo
|
||||
const { undo, redo, canUndo, canRedo } = useUndoRedo(template)
|
||||
@@ -148,6 +155,7 @@ export const useTemplateStore = defineStore('template', () => {
|
||||
exportTemplate,
|
||||
importTemplate,
|
||||
resetTemplate,
|
||||
setOverrideData,
|
||||
undo,
|
||||
redo,
|
||||
canUndo,
|
||||
|
||||
Reference in New Issue
Block a user