mirror of
https://github.com/frappe/books.git
synced 2024-11-08 14:50:56 +00:00
incr: get printview to display
- printing still not working
This commit is contained in:
parent
8cc46c584c
commit
8c19f51814
2
main.ts
2
main.ts
@ -18,7 +18,7 @@ import registerProcessListeners from './main/registerProcessListeners';
|
||||
import { IPC_CHANNELS } from './utils/messages';
|
||||
|
||||
const WIDTH = 1200;
|
||||
const HEIGHT = 907;
|
||||
const HEIGHT = 900;
|
||||
|
||||
export class Main {
|
||||
title: string = 'Frappe Books';
|
||||
|
@ -110,7 +110,7 @@ export class Party extends Doc {
|
||||
|
||||
static getListViewSettings(): ListViewSettings {
|
||||
return {
|
||||
columns: ['name', 'phone', 'outstandingAmount'],
|
||||
columns: ['name', 'email', 'phone', 'outstandingAmount'],
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -2,13 +2,13 @@
|
||||
import { fyo } from 'src/initFyo';
|
||||
export default {
|
||||
name: 'Base',
|
||||
props: ['doc', 'printSettings'],
|
||||
props: { doc: Object, printSettings: Object },
|
||||
data: () => ({ party: null, companyAddress: null }),
|
||||
methods: {
|
||||
format(row, fieldname) {
|
||||
let value = row.get(fieldname);
|
||||
return fyo.format(value, row.meta.getField(fieldname));
|
||||
}
|
||||
const value = row.get(fieldname);
|
||||
return fyo.format(value, fyo.getField(row.schemaName, fieldname));
|
||||
},
|
||||
},
|
||||
async mounted() {
|
||||
await this.doc.loadLink('party');
|
||||
@ -19,7 +19,7 @@ export default {
|
||||
computed: {
|
||||
isSalesInvoice() {
|
||||
return this.doc.schemaName === 'SalesInvoice';
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
@ -23,7 +23,12 @@
|
||||
</div>
|
||||
<div class="w-1/3">
|
||||
<div v-if="companyAddress">{{ companyAddress.addressDisplay }}</div>
|
||||
<div v-if="fyo.singles.AccountingSettings && fyo.singles.AccountingSettings.gstin">
|
||||
<div
|
||||
v-if="
|
||||
fyo.singles.AccountingSettings &&
|
||||
fyo.singles.AccountingSettings.gstin
|
||||
"
|
||||
>
|
||||
GSTIN: {{ fyo.singles.AccountingSettings.gstin }}
|
||||
</div>
|
||||
</div>
|
||||
@ -85,11 +90,7 @@
|
||||
</div>
|
||||
<div class="px-6 mt-2 flex justify-end text-base">
|
||||
<div class="w-1/2 bg-pink">
|
||||
<div
|
||||
class="text-sm tracking-widest text-gray-600 mt-2"
|
||||
>
|
||||
Notes
|
||||
</div>
|
||||
<div class="text-sm tracking-widest text-gray-600 mt-2">Notes</div>
|
||||
<div class="my-4 text-lg whitespace-pre-line">
|
||||
{{ doc.terms }}
|
||||
</div>
|
||||
@ -108,7 +109,16 @@
|
||||
<div>{{ fyo.format(tax.amount, 'Currency') }}</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex pl-2 justify-between py-3 border-t text-green-600 font-semibold text-base"
|
||||
class="
|
||||
flex
|
||||
pl-2
|
||||
justify-between
|
||||
py-3
|
||||
border-t
|
||||
text-green-600
|
||||
font-semibold
|
||||
text-base
|
||||
"
|
||||
>
|
||||
<div>{{ t`Grand Total` }}</div>
|
||||
<div>{{ fyo.format(doc.grandTotal, 'Currency') }}</div>
|
||||
@ -119,11 +129,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Base from './Base';
|
||||
import Base from './BaseTemplate.vue';
|
||||
|
||||
export default {
|
||||
name: 'Default',
|
||||
extends: Base,
|
||||
props: ['doc', 'printSettings']
|
||||
props: ['doc', 'printSettings'],
|
||||
};
|
||||
</script>
|
||||
|
@ -128,7 +128,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Base from './Base';
|
||||
import Base from './BaseTemplate.vue';
|
||||
|
||||
export default {
|
||||
name: 'Business',
|
||||
|
@ -140,7 +140,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Base from './Base';
|
||||
import Base from './BaseTemplate.vue';
|
||||
|
||||
export default {
|
||||
name: 'Minimal',
|
||||
|
@ -101,7 +101,13 @@ export default {
|
||||
}
|
||||
|
||||
return columns
|
||||
.map((fieldname) => fyo.getField(this.schemaName, fieldname))
|
||||
.map((fieldname) => {
|
||||
if (typeof fieldname === 'object') {
|
||||
return fieldname;
|
||||
}
|
||||
|
||||
return fyo.getField(this.schemaName, fieldname);
|
||||
})
|
||||
.filter(Boolean);
|
||||
},
|
||||
hasImage() {
|
||||
|
@ -12,6 +12,8 @@
|
||||
{{ t`Save as PDF` }}
|
||||
</Button>
|
||||
</PageHeader>
|
||||
|
||||
<!-- Printview Preview -->
|
||||
<div
|
||||
v-if="doc && printSettings"
|
||||
class="flex justify-center flex-1 -mt-36 overflow-auto relative"
|
||||
@ -34,6 +36,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Printview Customizer -->
|
||||
<div class="border-l w-80" v-if="showCustomiser">
|
||||
<div class="mt-4 px-4 flex items-center justify-between">
|
||||
<h2 class="font-semibold">{{ t`Customise` }}</h2>
|
||||
@ -52,7 +56,7 @@ import Button from 'src/components/Button.vue';
|
||||
import PageHeader from 'src/components/PageHeader.vue';
|
||||
import InvoiceTemplate from 'src/components/SalesInvoice/InvoiceTemplate.vue';
|
||||
import TwoColumnForm from 'src/components/TwoColumnForm.vue';
|
||||
import { makePDF } from 'src/utils';
|
||||
import { makePDF } from 'src/utils/ipcCalls';
|
||||
import { IPC_ACTIONS } from 'utils/messages';
|
||||
|
||||
export default {
|
||||
@ -76,7 +80,7 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
printTemplate() {
|
||||
return InvoiceTemplate
|
||||
return InvoiceTemplate;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
@ -86,7 +90,7 @@ export default {
|
||||
|
||||
const html = this.$refs.printContainer.innerHTML;
|
||||
fyo.telemetry.log(Verb.Exported, 'SalesInvoice', { extension: 'pdf' });
|
||||
makePDF(html, savePath);
|
||||
await makePDF(html, savePath);
|
||||
},
|
||||
async getSavePath() {
|
||||
const options = {
|
||||
|
@ -10,7 +10,10 @@ const PRINT_OPTIONS = {
|
||||
printSelectionOnly: false,
|
||||
};
|
||||
|
||||
export default async function makePDF(html, savePath) {
|
||||
export default async function saveHtmlAsPdf(
|
||||
html: string,
|
||||
savePath: string
|
||||
): Promise<void> {
|
||||
const printWindow = getInitializedPrintWindow();
|
||||
|
||||
printWindow.webContents.executeJavaScript(`
|
||||
@ -22,9 +25,7 @@ export default async function makePDF(html, savePath) {
|
||||
await sleep(1); // Required else pdf'll be blank.
|
||||
|
||||
const data = await printWindow.webContents.printToPDF(PRINT_OPTIONS);
|
||||
await fs.writeFile(savePath, data, (error) => {
|
||||
if (error) throw error;
|
||||
});
|
||||
await fs.writeFile(savePath, data);
|
||||
|
||||
resolve();
|
||||
});
|
||||
@ -38,15 +39,17 @@ function getInitializedPrintWindow() {
|
||||
show: false,
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION,
|
||||
nodeIntegration: false,
|
||||
},
|
||||
});
|
||||
printWindow.loadURL(getPrintWindowUrl());
|
||||
const printWindowUrl = getPrintWindowUrl();
|
||||
printWindow.loadURL(printWindowUrl);
|
||||
return printWindow;
|
||||
}
|
||||
|
||||
function getPrintWindowUrl() {
|
||||
let url = global.WEBPACK_DEV_SERVER_URL;
|
||||
// @ts-ignore
|
||||
let url = global.WEBPACK_DEV_SERVER_URL as string | undefined;
|
||||
if (url) {
|
||||
url = url + 'print';
|
||||
} else {
|
Loading…
Reference in New Issue
Block a user