remitDetail.js 4.2 KB

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