remitDetail.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. // packageA/remitVoucher/modules/remitDetail.js
  2. const _Http = getApp().globalData.http
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. properties: {
  8. detail: {
  9. type: Object
  10. }
  11. },
  12. options: {
  13. addGlobalClass:true
  14. },
  15. /**
  16. * 组件的初始数据
  17. */
  18. data: {
  19. content: {
  20. nocache: true,
  21. pageNumber: 1,
  22. pageTotal: 1,
  23. total: null
  24. }
  25. },
  26. /**
  27. * 组件的方法列表
  28. */
  29. methods: {
  30. getList(id, init) {
  31. let content = this.data.content;
  32. content.sa_paybillid = id;
  33. if (init) content.pageNumber = 1;
  34. _Http.basic({
  35. "id": "20221227092804",
  36. content
  37. }).then(res => {
  38. console.log("打款明细", res)
  39. if (res.msg != '成功') return wx.showToast({
  40. title: res.msg,
  41. icon: "none"
  42. })
  43. this.setData({
  44. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  45. "content.pageNumber": res.pageNumber + 1,
  46. "content.pageSize": res.pageSize,
  47. "content.pageTotal": res.pageTotal,
  48. "content.total": res.total,
  49. sa_paybillid: id
  50. })
  51. })
  52. },
  53. /* 添加明细 */
  54. addProduct () {
  55. wx.navigateTo({
  56. url: `/packageA/remitVoucher/modules/selectAccount/index?params=${
  57. JSON.stringify({
  58. "id": 20221228085004,
  59. "content": {
  60. "pageNumber": 1,
  61. "pageSize": 20,
  62. "sa_paybillid":getCurrentPages()[getCurrentPages().length - 1].data.sa_paybillid,
  63. "where": {
  64. "condition": ""
  65. }
  66. }
  67. })
  68. }`,
  69. })
  70. getApp().globalData.handleSelect = this.handleSelect.bind(this)
  71. },
  72. /* 操作选中的账户信息 */
  73. async handleSelect (data) {
  74. wx.navigateBack()
  75. let paybilldetails = data.list.map(item => {
  76. return {
  77. "sa_paybilldetailid": 0,
  78. "sa_accountclassid": item.sa_accountclassid,
  79. "amount": item.amount
  80. }
  81. }),page = getCurrentPages()[getCurrentPages().length - 2]
  82. let res = await _Http.basic({
  83. "id":20221227092904,
  84. "content": {
  85. sa_paybillid:page.data.sa_paybillid,
  86. paybilldetails
  87. }
  88. })
  89. if( res.msg == '成功' ) {
  90. this.getList(page.data.sa_paybillid,true)
  91. }
  92. },
  93. /* 金额改变 */
  94. async priceChange (e) {
  95. console.log(e);
  96. let data = e.currentTarget.dataset.data
  97. if (e.detail.value == data.amount) return
  98. let res = await _Http.basic({
  99. "id":20221227092904,
  100. "content": {
  101. sa_paybillid:data.sa_paybillid,
  102. paybilldetails: [
  103. {
  104. "sa_paybilldetailid": data.sa_paybilldetailid,
  105. "sa_accountclassid":data.sa_accountclassid,
  106. "amount":e.detail.value,
  107. }
  108. ]
  109. }
  110. })
  111. if (res.msg == '成功') {
  112. this.triggerEvent('onSuccess')
  113. } else {
  114. wx.showToast({
  115. title: res.msg,
  116. icon:'none'
  117. })
  118. }
  119. },
  120. /* 删除明细 */
  121. deleteProduct (e) {
  122. if (this.properties.detail.status != '新建') return wx.showToast({
  123. title: '非新建状态无法删除',
  124. icon:'none'
  125. })
  126. wx.showModal({
  127. title:'提示',
  128. content:'是否删除当前打款明细?',
  129. complete: async (res) => {
  130. console.log(res);
  131. if (res.confirm) {
  132. let res = await _Http.basic({
  133. "id": 20221227093004,
  134. "content": {
  135. "sa_paybillid":e.currentTarget.dataset.data.sa_paybillid,
  136. "sa_paybilldetailids":[e.currentTarget.dataset.data.sa_paybilldetailid]
  137. }
  138. })
  139. if ( res.msg == '成功' ) {
  140. this.getList(getCurrentPages()[getCurrentPages().length - 1].data.sa_paybillid,true)
  141. } else {
  142. console.log('出发');
  143. wx.showToast({
  144. title: res.msg,
  145. icon:'none'
  146. })
  147. }
  148. }
  149. }
  150. })
  151. }
  152. }
  153. })