some changes in register 1401-03-02
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import store from '@/store/store.js'
|
||||
|
||||
export const printWindow = (innerHTML = document.getElementById('printContent') ? document.getElementById('printContent').innerHTML : '') => {
|
||||
|
||||
// Get all stylesheets HTML
|
||||
let stylesHtml = ''
|
||||
for (const node of [...document.querySelectorAll('link[rel="stylesheet"], style')]) {
|
||||
stylesHtml += node.outerHTML
|
||||
}
|
||||
|
||||
// Open the print window
|
||||
const WinPrint = window.open('', '', 'left=0,top=0,width=800,height=900,toolbar=0,scrollbars=0,status=0')
|
||||
WinPrint.document.write('<!DOCTYPE html><html><head>' +
|
||||
stylesHtml +
|
||||
'<title>چاپ اطلاعات</title>' +
|
||||
'</head><body>' +
|
||||
innerHTML +
|
||||
'</body></html>')
|
||||
|
||||
WinPrint.document.close()
|
||||
WinPrint.focus()
|
||||
setTimeout(() => {
|
||||
// WinPrint.print()
|
||||
// WinPrint.close()
|
||||
}, 600)
|
||||
}
|
||||
|
||||
const keyEvent = ($event) => {
|
||||
if ($event.ctrlKey && $event.code == 'KeyP' && store.state.isViewData) {
|
||||
$event.preventDefault()
|
||||
printWindow()
|
||||
}
|
||||
}
|
||||
|
||||
export const setKeyEvent = () => {
|
||||
document.addEventListener('keydown', keyEvent)
|
||||
}
|
||||
export const removeKeyEvent = () => {
|
||||
|
||||
document.removeEventListener('keydown', keyEvent)
|
||||
}
|
||||
Reference in New Issue
Block a user