17 changed files with 407 additions and 130 deletions
@ -0,0 +1,64 @@ |
|||||||
|
<template> |
||||||
|
<div> |
||||||
|
<el-dialog v-model="visible" :title="props.title" :width="props.width"> |
||||||
|
<div class="printCode"> |
||||||
|
<div v-html="props.html"></div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="flex-c-c mt10"> |
||||||
|
<el-button type="primary" @click="handleClose"> 关 闭 </el-button> |
||||||
|
<el-button type="primary" @click="printTemplate" icon="Printer"> 打 印 </el-button> |
||||||
|
</div> |
||||||
|
</el-dialog> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script setup lang="ts"> |
||||||
|
import { defineProps, computed } from 'vue'; |
||||||
|
import print from '@/utils/print'; |
||||||
|
|
||||||
|
const props = defineProps({ |
||||||
|
html: { |
||||||
|
type: String, |
||||||
|
default: '', |
||||||
|
}, |
||||||
|
modelValue: { |
||||||
|
type: Boolean, |
||||||
|
default: false, |
||||||
|
}, |
||||||
|
width: { |
||||||
|
type: String, |
||||||
|
default: '780px', |
||||||
|
}, |
||||||
|
title: { |
||||||
|
type: String, |
||||||
|
default: '二维码', |
||||||
|
}, |
||||||
|
}); |
||||||
|
|
||||||
|
const $emit = defineEmits(['update:modelValue']); |
||||||
|
|
||||||
|
const visible = computed({ |
||||||
|
get: () => props.modelValue, |
||||||
|
set: val => { |
||||||
|
$emit('update:modelValue', val); |
||||||
|
}, |
||||||
|
}); |
||||||
|
|
||||||
|
const handleClose = () => { |
||||||
|
visible.value = false; |
||||||
|
}; |
||||||
|
|
||||||
|
const printTemplate = () => { |
||||||
|
const printNode = document.querySelectorAll('.printCode > div > div'); |
||||||
|
console.log('printNode :>> ', printNode); |
||||||
|
print(printNode); |
||||||
|
}; |
||||||
|
</script> |
||||||
|
|
||||||
|
<style scoped lang="scss"> |
||||||
|
.printCode { |
||||||
|
max-height: 80vh; |
||||||
|
overflow-y: scroll; |
||||||
|
} |
||||||
|
</style> |
Loading…
Reference in new issue