mirror of
https://github.com/frappe/books.git
synced 2025-02-02 20:18:26 +00:00
[add] PrintView component
This commit is contained in:
parent
dc08d8bbbc
commit
41d3cb79e6
@ -7,6 +7,7 @@
|
|||||||
@save="save"
|
@save="save"
|
||||||
@submit="submit"
|
@submit="submit"
|
||||||
@revert="revert"
|
@revert="revert"
|
||||||
|
@print="print"
|
||||||
/>
|
/>
|
||||||
<div class="p-3">
|
<div class="p-3">
|
||||||
<form-layout
|
<form-layout
|
||||||
@ -120,6 +121,10 @@ export default {
|
|||||||
await this.save();
|
await this.save();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
print() {
|
||||||
|
this.$router.push(`/print/${this.doctype}/${this.name}`);
|
||||||
|
},
|
||||||
|
|
||||||
onValidate(fieldname, isValid) {
|
onValidate(fieldname, isValid) {
|
||||||
if (!isValid && !this.invalidFields.includes(fieldname)) {
|
if (!isValid && !this.invalidFields.includes(fieldname)) {
|
||||||
this.invalidFields.push(fieldname);
|
this.invalidFields.push(fieldname);
|
||||||
|
@ -5,10 +5,12 @@
|
|||||||
<f-button primary v-if="showSave" :disabled="disableSave" @click="$emit('save')">{{ _('Save') }}</f-button>
|
<f-button primary v-if="showSave" :disabled="disableSave" @click="$emit('save')">{{ _('Save') }}</f-button>
|
||||||
<f-button primary v-if="showSubmit" @click="$emit('submit')">{{ _('Submit') }}</f-button>
|
<f-button primary v-if="showSubmit" @click="$emit('submit')">{{ _('Submit') }}</f-button>
|
||||||
<f-button secondary v-if="showRevert" @click="$emit('revert')">{{ _('Revert') }}</f-button>
|
<f-button secondary v-if="showRevert" @click="$emit('revert')">{{ _('Revert') }}</f-button>
|
||||||
|
<f-button secondary @click="$emit('print')">{{ _('Print') }}</f-button>
|
||||||
<dropdown class="ml-2" v-if="showNextAction" :label="_('Actions')" :options="links"></dropdown>
|
<dropdown class="ml-2" v-if="showNextAction" :label="_('Actions')" :options="links"></dropdown>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import frappe from 'frappejs';
|
import frappe from 'frappejs';
|
||||||
import Dropdown from '../Dropdown';
|
import Dropdown from '../Dropdown';
|
||||||
|
20
ui/components/PrintView.vue
Normal file
20
ui/components/PrintView.vue
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<template>
|
||||||
|
<div v-html="printTemplate"></div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getHTML } from '../../common/print.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'PrintView',
|
||||||
|
props: ['doctype', 'name'],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
printTemplate: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async created(vm) {
|
||||||
|
this.printTemplate = await getHTML(this.doctype, this.name);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
27
ui/pages/ListAndPrintView.vue
Normal file
27
ui/pages/ListAndPrintView.vue
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<template>
|
||||||
|
<div class="frappe-list-form row no-gutters">
|
||||||
|
<div class="col-4 border-right">
|
||||||
|
<frappe-list :doctype="doctype" :filters="filters" :key="doctype" />
|
||||||
|
</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<print-view v-if="name" :key="doctype + name" :doctype="doctype" :name="name" @save="onSave" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import List from '../components/List/List';
|
||||||
|
import PrintView from '../components/PrintView';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: ['doctype', 'name', 'filters'],
|
||||||
|
components: {
|
||||||
|
FrappeList: List,
|
||||||
|
PrintView: PrintView,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
.frappe-list-form {
|
||||||
|
min-height: calc(100vh - 4rem);
|
||||||
|
}
|
||||||
|
</style>
|
@ -1,4 +1,5 @@
|
|||||||
import ListAndForm from '../pages/ListAndForm';
|
import ListAndForm from '../pages/ListAndForm';
|
||||||
|
import ListAndPrintView from '../pages/ListAndPrintView';
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
@ -12,5 +13,11 @@ export default [
|
|||||||
name: 'Form',
|
name: 'Form',
|
||||||
component: ListAndForm,
|
component: ListAndForm,
|
||||||
props: true
|
props: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/print/:doctype/:name',
|
||||||
|
name: 'PrintView',
|
||||||
|
component: ListAndPrintView,
|
||||||
|
props: true
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user