chenhaozhe
2025-11-27 cc33c00a94f0c74c769abf052f32709f56f222cd
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
86
87
88
89
90
91
92
93
94
95
96
97
98
<template>
    <div>
        <div id="report_holder"> </div>
    </div>
</template>
<script>
import { webapp_ws_ajax_run, webapp_urlprotocol_startup, urlAddRandomNo } from "@/utils/grwebapp";
import axios from 'axios'
 
export default {
    name: 'HBarPlanPrint',
    data() {
        return {
            handleMessage: this.$route.query,
            baseURL: 'http://47.96.97.237/API',
            //实际应用中,data应该为程序中通过各种途径获取到的数据,最后要将数据转换为报表需要的XML或JSON格式的字符串数据
            json_data: {
                recordset: []
            },
 
        }
    },
    mounted() {
        this.ws_both_from_object()
 
    },
    // created() {
    //     this.ws_both_from_object()
    // },
    methods: {
        // 获取参数_传递的JSON格式参数
        getUrlVars_JSON() {
            var datajson;
            var str = this.propsData; //获取链接中传递的参数
            var arr = str.substring(str.lastIndexOf("=") + 1);
            datajson = JSON.parse(decodeURI(arr));
            return datajson;
        },
        ws_both_from_object() {
            let OpenTmp = decodeURIComponent(this.$route.query.OpenTmp)
            let apIUrl = ''
            if (this.$route.query.Type == 'Kf_SellOutBillList') {
                apIUrl = '/Kf_SellOutBill/cx'
                axios.get(this.baseURL + apIUrl, {
                    params: {
                        "HInterID": this.handleMessage.linterid
                        // , "HSubID": data[i].hsubid
                    },
                }).then(response => {
                    let result = response.data
                    this.json_data.recordset = result.data
                    //参数具体说明请参考帮助文档中的“WEB报表(B/S报表)->WEB报表客户端->启动参数说明”部分
                    var args = {
                        type: "preview", //设置不同的属性可以执行不同的任务,如:preview print pdf xls csv txt rtf img grd
                        // report: this.json_report, //report: JSON.stringify(json_report),
                        report: urlAddRandomNo('./static/grf/' + OpenTmp + '.grf'),
                        data: this.json_data //data: JSON.stringify(json_data)
                    };
                    webapp_ws_ajax_run(args);
                    // var reportViewer = rubylong.grhtml5.insertReportViewer("report_holder", "./static/grf/销售出库单.grf", this.json_data);
                    // reportViewer.start();
                }).catch(error => {
                    this.$modal.msgError("接口请求失败!");
                });
            } else if (this.$route.query.Type == 'HGy_BarCodeBill') {
                apIUrl = '/CommonModel/searchMethod'
                axios.get(this.baseURL + apIUrl, {
                    params: {
                        "sql": "select * from h_v_IF_BarCodeBillList where hmainid in(" + this.handleMessage.linterid.toString() + ") order by hmainid desc",
                        "user": sessionStorage["HUserName"],
                        "ModRightNameCheck": ''
                        // , "HSubID": data[i].hsubid
                    },
                }).then(response => {
                    let result = response.data
                    this.json_data.recordset = result.data
                    //参数具体说明请参考帮助文档中的“WEB报表(B/S报表)->WEB报表客户端->启动参数说明”部分
                    var args = {
                        type: "preview", //设置不同的属性可以执行不同的任务,如:preview print pdf xls csv txt rtf img grd
                        // report: this.json_report, //report: JSON.stringify(json_report),
                        report: urlAddRandomNo('./static/grf/' + OpenTmp + '.grf'),
                        data: this.json_data //data: JSON.stringify(json_data)
                    };
                    console.log(args,this.json_data)
                    webapp_ws_ajax_run(args);
                    // var reportViewer = rubylong.grhtml5.insertReportViewer("report_holder", "./static/grf/销售出库单.grf", this.json_data);
                    // reportViewer.start();
                }).catch(error => {
                    console.log(22222, error)
                    this.$modal.msgError("接口请求失败!");
                });
            }
 
        }
    },
}
 
</script>