index.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../utils/currency"),
  3. CNY = value => currency(value, {
  4. symbol: "¥",
  5. precision: 2
  6. }).format();
  7. Page({
  8. data: {
  9. detail: {},
  10. list: [],
  11. "content": {
  12. "where": {
  13. "condition": ""
  14. },
  15. "pageNumber": 1,
  16. "pageTotal": 1,
  17. "pageSize": 20
  18. }
  19. },
  20. onLoad(options) {
  21. this.data.content.ownertable = options.ownertable;
  22. this.data.content.ownerid = options.ownerid;
  23. console.log("options.isAdmin",options.isAdmin)
  24. this.setData({
  25. isAdmin: options.isAdmin == 'true',
  26. detail: JSON.parse(options.item)
  27. })
  28. this.getList(true);
  29. _Http.updateExpenseBreakdownList = function () {
  30. let content = this.data.content;
  31. content.pageSize = content.pageSize * (content.pageNumber - 1)
  32. content.pageNumber = 1;
  33. content.pageTotal = 1;
  34. _Http.basic({
  35. id: "20240629082704",
  36. content,
  37. }).then((res) => {
  38. console.log("更新费用明细列表", res);
  39. if (res.msg == '成功') this.setData({
  40. list: res.data.map(v => {
  41. v.showAmount = CNY(v.amount)
  42. return v
  43. })
  44. })
  45. });
  46. let params = {
  47. "id": 20221026085601,
  48. "content": {
  49. "sys_datafollowupid": this.data.content.ownerid
  50. }
  51. }
  52. if (this.data.content.ownertable == 'sat_orderclue') params = {
  53. "id": 20240702102404,
  54. "content": {
  55. "sat_ordercluefollowuplogid": this.data.content.ownerid
  56. }
  57. }
  58. _Http.basic(params).then(res => {
  59. if (res.msg == '成功') {
  60. this.setData({
  61. "detail.salesfeesamount": res.data.salesfeesamount,
  62. "detail.showsalesfeesamount": CNY(res.data.salesfeesamount),
  63. })
  64. _Http.updateEBList && _Http.updateEBList(res.data.salesfeesamount, CNY(res.data.salesfeesamount))
  65. }
  66. })
  67. }.bind(this)
  68. },
  69. getList(init = false) {
  70. if (init.detail != undefined) init = init.detail;
  71. let content = this.data.content;
  72. if (init) content.pageNumber = 1;
  73. if (content.pageNumber > content.pageTotal) return;
  74. _Http.basic({
  75. "id": 20240629082704,
  76. content
  77. }).then(res => {
  78. console.log("费用明细列表", res)
  79. this.selectComponent('#ListBox').RefreshToComplete();
  80. res.data = res.data.map(v => {
  81. v.showAmount = CNY(v.amount)
  82. return v
  83. })
  84. this.setData({
  85. list: res.pageNumber == 1 ? res.data : this.data.list.concat(this.data.list),
  86. "content.pageNumber": res.pageNumber + 1,
  87. "content.pageTotal": res.pageTotal,
  88. "content.sort": res.sort
  89. })
  90. })
  91. },
  92. startSearch({
  93. detail
  94. }) {
  95. this.setData({
  96. 'content.where.condition': detail
  97. })
  98. this.getList(true);
  99. },
  100. editItem(e) {
  101. const {
  102. item
  103. } = e.currentTarget.dataset;
  104. item.ownertable = this.data.content.ownertable;
  105. item.ownerid = this.data.content.ownerid;
  106. wx.navigateTo({
  107. url: `/packageA/expenseBreakdown/edit?item=${JSON.stringify(item)}`,
  108. })
  109. },
  110. deleteItem(e) {
  111. const {
  112. item
  113. } = e.currentTarget.dataset,
  114. that = this;
  115. console.log(item)
  116. wx.showModal({
  117. title: '提醒',
  118. content: '是否确定删除该明细',
  119. complete: ({
  120. confirm
  121. }) => {
  122. if (confirm) _Http.basic({
  123. "id": 20240611095304,
  124. "content": {
  125. "sa_salesfeesid": item.sa_salesfeesid,
  126. "sa_salesfeesdetails": [{
  127. "sa_salesfeesdetailid": item.sa_salesfeesdetailid,
  128. "followupdate": item.followupdate
  129. }]
  130. }
  131. }).then(res => {
  132. console.log("删除明细", res)
  133. if (res.msg != '成功') return
  134. wx.showToast({
  135. title: res.msg != '成功' ? res.msg : '删除成功',
  136. icon: "none"
  137. })
  138. if (res.msg != '成功') return;
  139. _Http.updateExpenseBreakdownList();
  140. })
  141. }
  142. })
  143. },
  144. onReady() {
  145. this.setListHeight()
  146. },
  147. toInsertion() {
  148. let salesfeesdetail = {
  149. "ownertable": this.data.content.ownertable,
  150. "ownerid": this.data.content.ownerid,
  151. "followupdate": this.data.detail.createdate,
  152. }
  153. wx.navigateTo({
  154. url: `/packageA/expenseBreakdown/insertion?salesfeesdetail=${JSON.stringify(salesfeesdetail)}`,
  155. })
  156. },
  157. /* 设置页面高度 */
  158. setListHeight() {
  159. this.selectComponent("#ListBox").setHeight(".search", this);
  160. },
  161. onUnload() {
  162. delete _Http.updateEBList
  163. delete _Http.updateExpenseBreakdownList
  164. getCurrentPages().forEach(v => {
  165. v.getDetail && v.getDetail()
  166. })
  167. }
  168. })