guoyujie
2025-12-04 03627defbc56d0498e7778523da255eb972db6a4
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<template>
    <view>
        <uni-section :title="'玻璃信息:'+projectNo" type="line">
            <template v-slot:right>
                                <button @click="printInfo">打印</button>
            </template>
            
            <uni-list>
                <uni-list-item v-for='(item,keys) in title' :title="item+':'" :note="glassInfo[keys]"  />
            </uni-list>
        </uni-section>
    </view>
</template>
 
<script setup>
 
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import request from '../../utils/request';
    let projectNo = ref(null)
    let glassInfo = ref({})
    let title = {
        orderId:'订单编号',
        customerName:'客户名称',
        productName:'产品名称',
        glassChild:'小片名称',
        size:'尺寸',
        processId:'流程卡号',
        orderNumber:'订单序号',
        technologyNumber:'小片序号',
        area:"面积",
        buildingNumber:'楼号',
        processingNote:'加工要求',
        //remarks:'备注'
        
    }
    const mPrinter = uni.requireNativePlugin('HikPrinter')
    
    onLoad(async (option)=>{
          projectNo.value = option.projectNo
            await getGlassInfo(option.projectNo)
    })
    
    const getGlassInfo = async (projectNo) => {
        await request.post(`/order/scannerGlassInfo/${projectNo}`).then(res => {
            if (res.code == 200) {
                glassInfo.value = res.data
            }
        }).catch(err => {
            uni.showModal({
                title: '提示',
                content: err,
                showCancel:false
            });
        })
    }
    const printInfo = () => {
        mPrinter.openPort()
        mPrinter.resetPrinter()
        //设置对齐方式 0,1,2 左中右
        mPrinter.setAlignment(1)
        mPrinter.printTextGBK("炉内编号:"+projectNo.value+'\n')
        mPrinter.printTextGBK(`订单(序号/小片):${glassInfo.value.orderId}(${glassInfo.value.orderNumber}/${glassInfo.value.technologyNumber})\n`)
        mPrinter.printTextGBK(`尺寸:${glassInfo.value.size}\n`)
        mPrinter.printTextGBK(`客户:${glassInfo.value.customerName}\n`)
        mPrinter.printTextGBK(`小片名称:${glassInfo.value.glassChild}\n`)
        mPrinter.printTextGBK(`${glassInfo.value.productName}\n`)
        mPrinter.printTextGBK(`${glassInfo.value.buildingNumber}\n`)
        mPrinter.printTextGBK(`${glassInfo.value.processingNote}\n`)
        //mPrinter.printTextGBK(`备注:${glassInfo.value.remarks}\n`)
        mPrinter.printTextGBK("\n")
        mPrinter.printTextGBK("\n")
        // mPrinter.printTextGBK("\n")
        
        if(mPrinter.queryPrintResult(5000)){
            mPrinter.closePort()
        }
    
         
    }
</script>
 
<style>
 
</style>