soybean-admin/src/views/plugin/print/index.vue

40 lines
1.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script lang="ts" setup>
import printJS from 'print-js';
function printTable() {
printJS({
printable: [
{ name: 'soybean', wechat: 'honghuangdc', remark: '欢迎来技术交流' },
{ name: 'soybean', wechat: 'honghuangdc', remark: '欢迎来技术交流' }
],
properties: ['name', 'wechat', 'remark'],
type: 'json'
});
}
function printImage() {
printJS({
printable: [
'https://i.loli.net/2021/11/24/1J6REWXiHomU2kM.jpg',
'https://i.loli.net/2021/11/24/1J6REWXiHomU2kM.jpg'
],
type: 'image',
header: 'Multiple Images',
imageStyle: 'width:100%;'
});
}
</script>
<template>
<div class="h-full">
<NCard title="打印" :bordered="false" class="card-wrapper">
<NButton type="primary" class="mr-10px" @click="printTable">打印表格</NButton>
<NButton type="primary" @click="printImage">打印图片</NButton>
<template #footer>
<GithubLink label="printJS" link="https://github.com/crabbly/Print.js" class="mt-10px" />
</template>
</NCard>
</div>
</template>
<style scoped></style>