invoiceStock.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. // miniprogram/pages/invoiceStock/invoiceStock.js
  2. const utils = require('../../utils/util.js')
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. list: [],
  9. invoiceType: ['增值税普通纸质发票', '增值税专用纸质发票', '增值税普通电子发票', '增值税专用电子发票'],
  10. invoiceTypeIndex: 0,
  11. invoiceStatus: '3',
  12. finish: false,
  13. isNoData: false,
  14. userInfo: '',
  15. company: '',
  16. invoiceData: {}
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. this.getUser()
  23. },
  24. //获取企业信息(当前登录用户的默认企业信息)
  25. getUser() {
  26. this.setData({
  27. userInfo: utils.getInfo(),
  28. company:utils.getCurrEntInfo()
  29. })
  30. this.getInvoiceInfo()
  31. // utils.getCompany().then(res => {
  32. // let result = res.data
  33. // this.setData({
  34. // company: result
  35. // })
  36. // this.getInvoiceInfo()
  37. // })
  38. },
  39. //发票类型
  40. setInvoiceType(e) {
  41. let value = Number(e.detail.value)
  42. let status = ''
  43. if (value === 0) {
  44. status = 3
  45. }
  46. if (value === 1) {
  47. status = 4
  48. }
  49. if (value === 2) {
  50. status = 1
  51. }
  52. if (value === 3) {
  53. status = 2
  54. }
  55. this.setData({
  56. invoiceTypeIndex: value,
  57. invoiceStatus: status
  58. })
  59. this.toFresh()
  60. },
  61. //发票库存查询
  62. getInvoiceInfo(type) {
  63. let params = {
  64. entTaxId: this.data.company.entTaxId,
  65. deviceType: this.data.company.defaultDeviceInfo.deviceType,
  66. taxDiscId: this.data.company.defaultDeviceInfo.taxDiscId,
  67. invoiceCategory: this.data.invoiceStatus,
  68. }
  69. utils.axios({
  70. method: 'get',
  71. url: '/sys/invoiceExt/purchaseQuery',
  72. data: params,
  73. sendBefore() {
  74. wx.showLoading({
  75. title: '加载中...'
  76. })
  77. },
  78. complete() {
  79. wx.hideLoading()
  80. wx.stopPullDownRefresh()
  81. },
  82. success: res => {
  83. this.setData({
  84. invoiceData: res.data
  85. })
  86. if (res.data.purchaseDetailVOs.length > 0) {
  87. this.setData({
  88. isNoData: false
  89. })
  90. } else {
  91. this.setData({
  92. isNoData: true
  93. })
  94. }
  95. }
  96. })
  97. },
  98. toFresh() {
  99. this.setData({
  100. pageNum: 1,
  101. pages: '',
  102. finish: false
  103. })
  104. wx.pageScrollTo({
  105. scrollTop: 0,
  106. duration: 300
  107. })
  108. this.getInvoiceInfo('toFresh')
  109. },
  110. /**
  111. * 生命周期函数--监听页面初次渲染完成
  112. */
  113. onReady: function () {
  114. },
  115. /**
  116. * 生命周期函数--监听页面显示
  117. */
  118. onShow: function () {
  119. },
  120. /**
  121. * 生命周期函数--监听页面隐藏
  122. */
  123. onHide: function () {
  124. },
  125. /**
  126. * 生命周期函数--监听页面卸载
  127. */
  128. onUnload: function () {
  129. },
  130. /**
  131. * 页面相关事件处理函数--监听用户下拉动作
  132. */
  133. onPullDownRefresh: function () {
  134. this.toFresh()
  135. },
  136. /**
  137. * 页面上拉触底事件的处理函数
  138. */
  139. onReachBottom: function () {
  140. },
  141. /**
  142. * 用户点击右上角分享
  143. */
  144. onShareAppMessage: function () {
  145. return {
  146. title: '诺信云',
  147. path: '/pages/index/index'
  148. }
  149. }
  150. })