skyouc
2024-12-21 c635d78b479510ebe2556a420948effcd30a0731
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<script setup>
import { ref } from 'vue';
import { formatMessage } from '@/utils/localeUtils';
import Template1 from './template/template1.vue';
import Template2 from './template/template2.vue';
 
const template = {
    Template1,
    Template2,
}
const selectTemplate = ref('Template1');
const printChild = ref(null);
 
let open = ref(false);
let printData = ref([]);
let repeatNum = ref(1);
 
const handleOk = () => {
 
}
 
const printObj = ref({
    id: "printMe",
    beforeOpenCallback(vue) {
        console.log('打开之前')
    },
    openCallback(vue) {
        console.log('执行了打印')
    },
    closeCallback(vue) {
        console.log('关闭了打印工具')
    }
});
 
defineExpose({
    open,
    printData,
})
</script>
 
<template>
    <a-modal v-model:open="open" :title="formatMessage('db.man_zpallet_barcode.batchPrint', '批量打印')" @ok="handleOk">
        <div style="height: 500px;overflow-x: hidden;overflow-y: scroll;">
            <div style="display: flex;justify-content: center;">
                <a-radio-group v-model:value="selectTemplate" button-style="solid">
                    <a-radio-button value="Template1">
                        {{ formatMessage('common.template', '模板') }} 1
                    </a-radio-button>
                    <a-radio-button value="Template2">
                        {{ formatMessage('common.template', '模板') }} 2
                    </a-radio-button>
                </a-radio-group>
            </div>
            <div style="display: flex;justify-content: center;margin-top: 20px;">
                <div style="width: 140px;text-align: center;">
                    {{ formatMessage('common.repeatNum', '重复数量') }}<a-input-number :min="1" v-model:value="repeatNum" :placeholder="formatMessage('common.repeatNum', '重复数量')" />
                </div>
            </div>
            <div style="margin-top: 20px;">
                <component :is="template[selectTemplate]" ref="printChild" :list="printData" :repeatNum="repeatNum" />
            </div>
        </div>
        <template #footer>
            <a-button key="submit" type="primary" v-print="printObj" @click="handleOk">
                {{ formatMessage('common.print', '打印') }}
            </a-button>
        </template>
    </a-modal>
</template>
 
<style></style>