remitDetail.js 4.2 KB

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