print-layout.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*******************************************************************************
  2. * Copyright(c) 2024 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:
  5. * 2.功能描述:票据打印画面
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 周兴 2022-11-22 1.00 新建
  9. *******************************************************************************/
  10. const api = require('@/utils/api.js');
  11. const config = require('@/config/config.js');
  12. const app = getApp()
  13. Page({
  14. /**
  15. * 页面的初始数据
  16. */
  17. data: {
  18. // 加入企业的列表
  19. tableList: [],
  20. // 业务单据ID
  21. dataId:null,
  22. // 单据类型
  23. docName:null,
  24. // 语言包
  25. $t: app.globalData.lang,
  26. },
  27. /**
  28. * @desc : 调取打印
  29. * @author : 周兴
  30. * @date : 2024/4/22
  31. */
  32. print(e) {
  33. let layoutId = e.currentTarget.dataset.item.layoutId;
  34. let docName = this.data.docName;
  35. let dataId = this.data.dataId;
  36. let url = config.image_url.replace('/file','');
  37. wx.navigateTo({
  38. url: '/package-base-select/pages/web-view-select/web-view-select',
  39. success: function (res) {
  40. res.eventChannel.emit('url', url + '/wx-print?svc_code=' + app.globalData.company.svcCode
  41. + '&cp_id=' + app.globalData.company.cpId + '&doc=' + docName + '&layout_id=' + layoutId + '&data_id=' + dataId);
  42. }
  43. })
  44. },
  45. /**
  46. * 生命周期函数--监听页面加载
  47. */
  48. onLoad(options) {
  49. // 接收父页面传递的参数
  50. const eventChannel = this.getOpenerEventChannel();
  51. if (eventChannel && JSON.stringify(eventChannel) !== '{}') {
  52. let _this = this;
  53. // 指定类型
  54. eventChannel.once('print', function (data) {
  55. _this.setData({
  56. tableList: data.data,
  57. dataId:data.dataId,
  58. docName:data.docName
  59. })
  60. })
  61. }
  62. },
  63. })