| 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
 | | <script setup> |  | import {ref, toRaw} from 'vue'; |  | import { formatMessage } from '@/utils/localeUtils'; |  | import Template1 from './template/template1.vue'; |  |   |  | const template = { |  |     Template1 |  | } |  |   |  | const printChild = ref(null); |  | const selectTemplate = ref('Template1'); |  | let open = ref(false); |  | let data = ref({}) |  | let printData = ref([]); |  | let repeatNum = ref(1); |  | let orderNo = ref(''); |  | const handleOk = () => { |  |   |  | } |  |   |  | const printObj = ref({ |  |     id: "printOrder", |  |     beforeOpenCallback(vue) { |  |         // console.log(toRaw(printData.value)) |  |     }, |  |     openCallback(vue) { |  |         console.log('执行了打印') |  |     }, |  |     closeCallback(vue) { |  |         console.log('关闭了打印工具') |  |     }, |  |   |  | }); |  |   |  | defineExpose({ |  |     open, |  |     orderNo, |  |     data, |  |     printData |  | }) |  | </script> |  |   |  | <template> |  |     <a-modal v-model:open="open" :title="formatMessage('', '订单打印')" @ok="handleOk" :width="'80%'" v-if="open"> |  |         <div style="height: 500px;overflow-x: hidden;overflow-y: scroll;"> |  |             <div style="margin-top: 20px;"> |  |                 <Component :is="template[selectTemplate]" ref="printChild" :list="printData" :repeatNum="repeatNum" :orderNo="orderNo" :data="data"/> |  |             </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> | 
 |