设为首页
收藏本站
首页
BBS
vue
JavaScript
Discuz!
热点排行
1
安装Discuz! Q 环境要求与配置
代码人
»
首页
›
技术广场
›
Vue
›
查看内容
返回列表
发新帖
vue 标签打印,打印二维码弹框前端代码
dmr
dmr
当前离线
积分
1151
294
主题
2
回帖
1151
积分
管理员
积分
1151
发消息
显示全部楼层
<script lang="ts" setup>
import { ref } from 'vue'
import { printElement } from '@/utils/printUtils'
interface IDialogProps {
type?: string
title?: string
row?: networkDeviceApi.NetworkDeviceVO[]
}
const dialogVisible = ref(false) // 弹窗的是否展示
const dialogProps = ref<IDialogProps>({})
/** 打开弹窗 */
const open = async (value) => {
dialogVisible.value = true
dialogProps.value = value
}
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
</script>
<template>
<div>
<Dialog
v-model="dialogVisible"
width="60%"
top="4vh"
custom-class="custom-dialog"
title="标签打印"
>
<div class="px-[0px]">
<div class="flex justify-center mb-8">
<el-button type="primary" class="font-bold text-lg" @click="printElement('printMe')"
>标签打印</el-button
>
</div>
<div id="printMe">
<!-- 需要打印的内容 -->
<div
v-for="(item, index) in dialogProps.row"
:key="index"
style="border-top: 1px solid #f2f2f2;"
>
<table class="printTable" style="width: 100%">
<tr>
<td>
<div style="width: 76mm;float: left;display: inline-block;padding-top: 3px;">
<div class="printTable_left" style="width: 44mm;float: left;">
<table class="table_text" style="width: 44mm!important;">
<tbody>
<tr>
<th style="width: 10mm!important;">类型:</th>
<td>{{ item.ciidDesc == null ? '--' : item.ciidDesc }}</td>
</tr>
<tr>
<th style="width: 10mm!important;">位置:</th>
<td>{{ item.location == null ? '--' : item.location }}</td>
</tr>
<tr>
<th style="width: 10mm!important;">名称:</th>
<td>{{ item.name == null ? '--' : item.name }}</td>
</tr>
<tr>
<th style="width: 10mm!important;">型号:</th>
<td>{{ item.modelName == null ? '--' : item.modelName }}</td
>
</tr>
<tr>
<th style="width: 10mm!important;">SN:</th>
<td>{{ item.serialNumber == null ? '--' : item.serialNumber }}</td>
</tr>
</tbody>
</table>
</div>
<div class="printTable_right" style="width: 32mm;float: left;">
<div style="width: 100%;text-align: center;font-weight: bold;">
{{
item.floorCode.slice(
item.floorCode.lastIndexOf('-') + 1,
item.floorCode.length
)
}}
</div>
<div style="width: 100%;text-align: center;">
<img :src="item.base64Img" alt="" width="100%" height="100%" />
</div>
</div>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
</Dialog>
</div>
</template>
<style lang="scss" scoped>
.label {
width: 50px;
font-weight: bold;
text-align: right;
padding-right: 10px;
white-space: nowrap;
}
:deep(.custom-dialog .el-dialog__body) {
height: 650px;
overflow-y: auto;
}
#printMe {
display: block;
}
.printTable {
display: table;
height: 33mm;
font-size: 13px;
margin: 0;
}
.printTable_left {
float: left;
padding: 0;
vertical-align: bottom;
}
.printTable_right {
float: left;
padding: 0;
vertical-align: bottom;
font-size: 12px;
font-weight: bold;
width: 32mm;
text-align: center;
}
.table_text {
border: none;
line-height: 3.6mm;
table-layout: fixed;
}
.table_text th {
font-weight: normal;
font-size: 12px;
text-align: right;
vertical-align: top;
padding: 0;
white-space:nowrap!important;
}
.table_text td {
word-break: break-all;
font-size: 12px;
padding: 0;
width: 34mm;
}
.codeNuber {
width: 100%;
text-align: center;
}
.codeImg {
text-align: left;
width: 33mm;
height: 28mm;
vertical-align: middle !important;
}
</style>
复制代码
微信扫一扫,分享更方便
代码人
相关帖子
2025-4-16
vue3页面标签<template>,<script>,<style>顺序
2025-4-16
vue3的tags页面标签跳转的同时关闭标签
2025-5-8
餐后2小时血糖超过10,这4类食物就要注意了!
2025-5-14
秦艽泡水喝对男性功效有哪些
2025-5-14
喝绿茶的好处和坏处
2025-5-14
主食吃太少,可能引发这些健康问题
2025-5-14
有这7个坏习惯,血糖越升越高,看看你有吗?
2025-5-14
不想孩子养成“讨好型人格”,父母要常说这5句话
2025-6-3
中国寻亲网(www.china-seek.net)将于7月15日关闭服务器
2025-6-5
车充安致歉信
上一篇:
vue3跳转页面参数router.query找不到显示undefined
下一篇:
vue3 介绍
发表于 2025-1-6 19:05:49
举报
回复
分享
返回列表
发新帖
本版积分规则
高级模式
B
Color
Image
Link
Quote
Code
Smilies
您需要登录后才可以回帖
登录
|
立即注册
黑夜模式
快速发帖
返回列表
返回顶部