<!-- 标签---三行信息,测试、校准、限用、停用、封存、合格、禁用 --> <script name="LabelThreeInfo" lang="ts" setup> import type { Ref } from 'vue' import { onMounted, ref } from 'vue' import dayjs from 'dayjs' import { ElLoading, ElMessage } from 'element-plus' import { printHtml } from '@/utils/printUtils' import { useCreateQr } from '@/commonMethods/useCreateQr' const props = defineProps({ title: { // 标题 type: String, default: '测试', }, backgroundColor: { // 背景颜色 type: String, default: '#12cccc', }, dateTitle: { // 日期标题 type: String, default: '测试日期', }, personTitle: { // 人员标题 type: String, default: '测试人', }, deviceNo: { // 设备编号 type: String, default: '', }, year: { type: String, default: '', }, month: { type: String, default: '', }, day: { type: String, default: '', }, personName: { type: String, default: '', }, }) const print = () => { printHtml('printData') } const qrCodeRef = ref() const qrUrl = ref('') // 二维码图片 watch(() => props.deviceNo, (newValue) => { if (newValue) { qrUrl.value = useCreateQr(newValue)! } }, { immediate: true }) defineExpose({ print }) </script> <template> <div id="printData" class="three-info"> <div class="left"> <div class="deviceNo-class"> {{ props.deviceNo }} </div> <div> <span class="year-class"> {{ props.year }} </span> <span class="month-class"> {{ props.month }} </span> <span class="day-class"> {{ props.day }} </span> </div> <div class="person-class"> {{ props.personName }} </div> </div> <div class="right"> <el-image class="qr" :src="qrUrl" /> </div> </div> </template> <style lang="scss" scoped> .three-info { display: flex; border-radius: 10px; width: 550px; height: 200px; background-color: #f2f3f5; .left { padding: 10px 20px; padding-left: 50px; flex: 1; background-color: #f2f3f5; border-radius: 10px; font-size: 24px; .deviceNo-class { position: relative; top: 30px; left: 60px; } .year-class { position: relative; top: 40px; left: 80px; } .month-class { position: relative; top: 40px; left: 120px; } .day-class { position: relative; top: 40px; left: 155px; } .person-class { position: relative; top: 50px; left: 60px; } } .right { width: 180px; width: 200px; display: flex; justify-content: center; align-items: center; .qr { width: 160px; height: 160px; position: relative; top: -20px; } } } </style>