CEES-manage/src/views/demo/jeecg/PrintDemo.vue

203 lines
7.0 KiB
Vue
Raw Normal View History

2022-03-10 09:47:29 +08:00
<template>
<PageWrapper>
<a-card :bordered="false" class="j-print-demo">
<div style="text-align: right">
<a-button type="primary" ghost @click="onPrint">打印</a-button>
</div>
<section ref="print" id="printContent">
<div style="text-align: center">
2022-06-10 10:44:44 +08:00
<p style="font-size: 24px; font-weight: 800">打印测试表单</p>
2022-03-10 09:47:29 +08:00
</div>
<!--签字-->
<a-col :md="24" :sm="24">
<div class="sign" style="text-align: center; height: inherit">
2022-03-10 09:47:29 +08:00
<a-col :span="24">
<span>打印人员:</span>
2022-06-10 10:44:44 +08:00
<a-input style="width: 30%" v-model:value="model.printer" />
2022-03-10 09:47:29 +08:00
<span style="margin-left: 12.5%">打印日期:</span>
2022-06-10 10:44:44 +08:00
<a-input style="width: 30%" v-model:value="model.printTime" />
2022-03-10 09:47:29 +08:00
</a-col>
2022-06-10 10:44:44 +08:00
<a-col :span="24"> </a-col>
2022-03-10 09:47:29 +08:00
<a-col :span="24" style="margin-top: 20px">
<span>打印内容:</span>
2022-06-10 10:44:44 +08:00
<a-input style="width: 80%" v-model:value="model.printContent" />
2022-03-10 09:47:29 +08:00
</a-col>
<a-col :span="24" style="margin-top: 20px">
2022-11-07 19:01:49 +08:00
<span>打印目的1:</span>
<a-input style="width: 80%" v-model:value="model.printReason" />
</a-col>
<a-col :span="24" style="margin-top: 20px">
<span>打印目的2:</span>
<a-input style="width: 80%" v-model:value="model.printReason" />
</a-col>
<a-col :span="24" style="margin-top: 20px">
<span>打印目的3:</span>
<a-input style="width: 80%" v-model:value="model.printReason" />
</a-col>
<a-col :span="24" style="margin-top: 20px">
<span>打印目的4:</span>
<a-input style="width: 80%" v-model:value="model.printReason" />
</a-col>
<a-col :span="24" style="margin-top: 20px">
<span>打印目的5:</span>
<a-input style="width: 80%" v-model:value="model.printReason" />
</a-col>
<a-col :span="24" style="margin-top: 20px">
<span>打印目的6:</span>
<a-input style="width: 80%" v-model:value="model.printReason" />
</a-col>
<a-col :span="24" style="margin-top: 20px">
<span>打印目的7:</span>
<a-input style="width: 80%" v-model:value="model.printReason" />
</a-col>
<a-col :span="24" style="margin-top: 20px">
<span>打印目的8:</span>
<a-input style="width: 80%" v-model:value="model.printReason" />
</a-col>
<a-col :span="24" style="margin-top: 20px">
<span>打印目的9:</span>
<a-input style="width: 80%" v-model:value="model.printReason" />
</a-col>
<a-col :span="24" style="margin-top: 20px">
<span>打印目的10:</span>
<a-input style="width: 80%" v-model:value="model.printReason" />
</a-col>
<a-col :span="24" style="margin-top: 20px">
<span>打印目的11:</span>
<a-input style="width: 80%" v-model:value="model.printReason" />
</a-col>
<a-col :span="24" style="margin-top: 20px">
<span>打印目的12:</span>
<a-input style="width: 80%" v-model:value="model.printReason" />
</a-col>
<a-col :span="24" style="margin-top: 20px">
<span>打印目的13:</span>
<a-input style="width: 80%" v-model:value="model.printReason" />
</a-col>
<a-col :span="24" style="margin-top: 20px">
<span>打印目的14:</span>
2022-06-10 10:44:44 +08:00
<a-input style="width: 80%" v-model:value="model.printReason" />
2022-03-10 09:47:29 +08:00
</a-col>
<a-col style="margin-top: 20px" :span="24">
<span>打印图片:</span>
2022-06-10 10:44:44 +08:00
<br />
<a-upload
action="/jsonplaceholder.typicode.com/posts/"
listType="picture-card"
:fileList="model.fileList"
@preview="handlePreview"
@change="handleChange"
>
2022-03-10 09:47:29 +08:00
<div v-if="model.fileList.length < 3">
2022-06-10 10:44:44 +08:00
<Icon icon="ant-design:plus-outlined" />
2022-03-10 09:47:29 +08:00
<div class="ant-upload-text">Upload</div>
</div>
</a-upload>
2023-12-29 21:41:35 +08:00
<a-modal :open="previewVisible" :footer="null" @cancel="previewVisible = false">
2022-06-10 10:44:44 +08:00
<img alt="example" style="width: 100%" :src="previewImage" />
2022-03-10 09:47:29 +08:00
</a-modal>
</a-col>
</div>
</a-col>
</section>
</a-card>
</PageWrapper>
</template>
<script lang="ts">
2022-06-10 10:44:44 +08:00
import { ref, reactive } from 'vue';
import { PageWrapper } from '/@/components/Page';
import Icon from '/@/components/Icon/src/Icon.vue';
import { printJS } from '/@/hooks/web/usePrintJS';
2022-03-10 09:47:29 +08:00
2022-06-10 10:44:44 +08:00
export default {
name: 'PrintDemo',
components: { PageWrapper, Icon },
props: {
reBizCode: {
type: String,
default: '',
},
2022-03-10 09:47:29 +08:00
},
2022-06-10 10:44:44 +08:00
setup() {
const model = reactive({
printer: '张三',
printTime: '2021-12-31 23:59:59',
printContent: '打印内容:这是一个打印测试!',
printReason: '做一个打印测试',
fileList: [
{
uid: '-1',
name: 'xxx.png',
status: 'done',
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
},
{
uid: '-2',
name: 'pic1.png',
status: 'done',
url: 'https://www.gizbot.com/img/2016/11/whatsapp-error-lead-image-08-1478607387.jpg',
},
],
});
const previewImage = ref('');
const previewVisible = ref(false);
2022-03-10 09:47:29 +08:00
2022-06-10 10:44:44 +08:00
function onPrint() {
printJS({
printable: '#printContent',
type: 'html',
});
}
2022-03-10 09:47:29 +08:00
2022-06-10 10:44:44 +08:00
function handlePreview(file) {
previewImage.value = file.url || file.thumbUrl;
previewVisible.value = true;
}
2022-03-10 09:47:29 +08:00
2022-06-10 10:44:44 +08:00
function handleChange({ fileList }) {
model.fileList = fileList;
}
2022-03-10 09:47:29 +08:00
2022-06-10 10:44:44 +08:00
return {
model,
previewImage,
previewVisible,
onPrint,
handlePreview,
handleChange,
};
},
};
2022-03-10 09:47:29 +08:00
</script>
<style lang="less" scoped>
2022-06-10 10:44:44 +08:00
.j-print-demo .ant-card-body {
margin-left: 0;
margin-right: 0;
margin-bottom: 1%;
border: 0 solid black;
min-width: 800px;
color: #000000 !important;
}
2022-03-10 09:47:29 +08:00
2022-06-10 10:44:44 +08:00
.sign .ant-input {
font-weight: bolder;
text-align: center;
border-left-width: 0 !important;
border-top-width: 0 !important;
border-right-width: 0 !important;
outline: none !important;
box-shadow: none !important;
}
2022-03-10 09:47:29 +08:00
2022-06-10 10:44:44 +08:00
/* you can make up upload button and sample style by using stylesheets */
.ant-upload-select-picture-card i {
font-size: 32px;
color: #999;
}
2022-03-10 09:47:29 +08:00
2022-06-10 10:44:44 +08:00
.ant-upload-select-picture-card .ant-upload-text {
margin-top: 8px;
color: #666;
}
</style>