ticketWait.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. // pages/ticketWait/ticketWait.js
  2. const utils = require('../../utils/util.js')
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. list: [],
  9. pageNum: 1,
  10. pageSize: 10,
  11. pages: '',
  12. finish: false,
  13. customerName: '',
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. this.getList()
  20. },
  21. //获取待开抬头
  22. getList(type) {
  23. let params = {
  24. mobile: utils.getInfo().mobile,
  25. // reqChannel: 5,
  26. belongEntTaxId: wx.getStorageSync('entTaxId'),
  27. pageNum: this.data.pageNum,
  28. pageSize: this.data.pageSize
  29. }
  30. let customerName = utils.trimAll(this.data.customerName)
  31. if (customerName !== '') {
  32. params.customerName = customerName
  33. }
  34. utils.axios({
  35. method: 'get',
  36. url: '/sys/taitou/todo/findPage',
  37. data: params,
  38. sendBefore() {
  39. wx.showLoading({
  40. title: '加载中...'
  41. })
  42. },
  43. complete() {
  44. wx.hideLoading()
  45. wx.stopPullDownRefresh()
  46. },
  47. success: res => {
  48. let result = res.data
  49. if (type === 'toFresh') {
  50. this.setData({
  51. list: result.records,
  52. pages: result.pages
  53. })
  54. } else {
  55. let list = this.data.list
  56. list = list.concat(result.records)
  57. this.setData({
  58. list,
  59. pages: result.pages
  60. })
  61. }
  62. if (result.total <= this.data.pageSize) {
  63. this.setData({
  64. finish: true
  65. })
  66. }
  67. }
  68. })
  69. },
  70. toFresh() {
  71. this.setData({
  72. pageNum: 1,
  73. pages: '',
  74. finish: false
  75. })
  76. wx.pageScrollTo({
  77. scrollTop: 0,
  78. duration: 300
  79. })
  80. this.getList('toFresh')
  81. },
  82. //搜素
  83. search(e) {
  84. let customerName = e.detail.value
  85. this.setData({
  86. customerName
  87. })
  88. this.toFresh()
  89. },
  90. //确认框
  91. showDel(e) {
  92. let params = {
  93. mobile: utils.getInfo().mobile,
  94. reqChannel: 5,
  95. delList: [{
  96. recordId: e.currentTarget.dataset.recordid,
  97. belongEntTaxId: e.currentTarget.dataset.belong
  98. }]
  99. }
  100. let index = Number(e.currentTarget.dataset.index)
  101. wx.showModal({
  102. content: '确定删除该条数据吗?',
  103. confirmColor: '#007dff',
  104. success: res => {
  105. if (res.confirm) {
  106. this.del(params, index)
  107. }
  108. }
  109. })
  110. },
  111. //删除
  112. del(params, index) {
  113. utils.axios({
  114. method: 'post',
  115. url: '/sys/taitou/todo/delete',
  116. data: params,
  117. sendBefore() {
  118. wx.showLoading({
  119. title: '删除中...',
  120. mask: true
  121. })
  122. },
  123. complete() {
  124. wx.hideLoading()
  125. },
  126. success: res => {
  127. let list = this.data.list
  128. list.splice(index, 1)
  129. this.setData({
  130. list
  131. })
  132. utils.toast('删除成功')
  133. }
  134. })
  135. },
  136. //点击开票
  137. toTicket(e) {
  138. let index = e.currentTarget.dataset.index
  139. let item = this.data.list[index]
  140. wx.setStorageSync('ticketMakeData', item)
  141. wx.navigateTo({
  142. url: '/pages/ticketMake/ticketMake'
  143. })
  144. },
  145. /**
  146. * 生命周期函数--监听页面初次渲染完成
  147. */
  148. onReady: function () {
  149. },
  150. /**
  151. * 生命周期函数--监听页面显示
  152. */
  153. onShow: function () {
  154. },
  155. /**
  156. * 生命周期函数--监听页面隐藏
  157. */
  158. onHide: function () {
  159. },
  160. /**
  161. * 生命周期函数--监听页面卸载
  162. */
  163. onUnload: function () {
  164. },
  165. /**
  166. * 页面相关事件处理函数--监听用户下拉动作
  167. */
  168. onPullDownRefresh: function () {
  169. this.toFresh()
  170. },
  171. /**
  172. * 页面上拉触底事件的处理函数
  173. */
  174. onReachBottom: function () {
  175. let pageNum = this.data.pageNum
  176. let pages = this.data.pages
  177. pageNum++
  178. if (pageNum <= pages) {
  179. this.setData({
  180. pageNum
  181. })
  182. this.getList()
  183. } else {
  184. this.setData({
  185. finish: true
  186. })
  187. return
  188. }
  189. },
  190. /**
  191. * 用户点击右上角分享
  192. */
  193. onShareAppMessage: function () {
  194. return {
  195. title: '诺信云',
  196. path: '/pages/index/index'
  197. }
  198. }
  199. })