2
0
mirror of https://github.com/frappe/books.git synced 2025-02-04 21:18:32 +00:00
books/src/pages/Settings/TabBase.vue
2022-11-18 23:01:50 +05:30

60 lines
1.1 KiB
Vue

<template>
<div>
<TwoColumnForm
v-if="doc"
:doc="doc"
:fields="fields"
:autosave="true"
:emit-change="true"
@change="(...args:unknown[])=>$emit('change', ...args)"
/>
</div>
</template>
<script lang="ts">
import { Doc } from 'fyo/model/doc';
import TwoColumnForm from 'src/components/TwoColumnForm.vue';
import { defineComponent } from 'vue';
export default defineComponent({
name: 'TabGeneral',
emits: ['change'],
props: { schemaName: String },
components: {
TwoColumnForm,
},
async mounted() {
await this.setDoc();
},
watch: {
async schemaName() {
await this.setDoc();
},
},
methods: {
async setDoc() {
if (this.doc && this.schemaName === this.doc.schemaName) {
return;
}
if (!this.schemaName) {
return;
}
this.doc = await this.fyo.doc.getDoc(this.schemaName, this.schemaName, {
skipDocumentCache: true,
});
},
},
data() {
return {
doc: undefined,
} as { doc?: Doc };
},
computed: {
fields() {
return this.doc?.schema.fields;
},
},
});
</script>