loulijun2021
2022-07-14 bd3410da8a13682ec0bc888539dc35209a2196ba
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
<template>
  <div v-if="false">
    <h3>报表直接打印,通过AJAX方式获取报表模板与报表数据</h3>
    <p><a href="javascript:void" @click.prevent="printClick">直接打印</a></p>
  </div>
</template>
 
<script>
import { webapp_ws_ajax_run, webapp_urlprotocol_startup, urlAddRandomNo } from '@/utils/grwebapp'
import { MesOrderPrintSearch, MesOrderPrintSearch1 } from '@/api/utils'
import { getCookie } from '@/utils/auth'
// import a from 'public/static/grf/simple.grf'
export default {
  data() {
    return {
      OBJ: {},
      TEXT: ''
    }
  },
  mounted() {
    webapp_urlprotocol_startup()
    // const a = require('public/static/grf/simple.grf')
    // console.log(a, 1)
  },
  methods: {
    async printClick() {
      const data = {
        username: getCookie('admin'),
        mesordercode: 'PO202206280001_4'
      }
      const res = await MesOrderPrintSearch1(data)
      console.log(this.OBJ = res.data, 8989)
      if (res.code === '200') {
        this.ws_ajax_print()
      }
      // console.log(JSON.stringify(this.OBJ), 1)
    },
    ws_ajax_print() {
      // 参数具体说明请参考帮助文档中的“WEB报表(B/S报表)->WEB报表客户端->启动参数说明”部分
      var args = {
        type: 'preview', // preview  print
        showOptionDlg: false, // 如果不显示打印对话框而直接打印,将此行注释去掉即可
        report: urlAddRandomNo('./static/grf/产品流传单A4.grf'),
        data: this.OBJ
      }
 
      webapp_ws_ajax_run(args)
    }
 
  }
}
</script>
 
<style>
</style>