record.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. list: [],
  8. showArr: [],
  9. "content": {
  10. "sa_salesforecastmodelid": null,
  11. "pageNumber": 1,
  12. "pageSize": 20,
  13. "pageTotal": 1,
  14. "where": {
  15. "condition": ""
  16. }
  17. },
  18. total: 0
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad(options) {
  24. this.setData({
  25. 'content.sa_salesforecastmodelid': options.id,
  26. userid: wx.getStorageSync("userMsg").userid
  27. })
  28. this.getList();
  29. this.getShowArr();
  30. },
  31. /* 去详情 */
  32. toDetail(e) {
  33. const {
  34. item
  35. } = e.currentTarget.dataset;
  36. if (item.baseonproject == 1) {
  37. wx.navigateTo({
  38. url: './detail?id=' + item.sa_salesforecastbillid,
  39. })
  40. } else {
  41. const data = {
  42. sa_salesforecastbillid: item.sa_salesforecastbillid,
  43. projectname: item.title,
  44. projectnum: item.billnum,
  45. sa_projectid: 0,
  46. address: "",
  47. sa_salesforecastmodelid: this.data.content.sa_salesforecastmodelid
  48. }
  49. wx.navigateTo({
  50. url: './reportForms?item=' + JSON.stringify(data) + '&isEdit=false',
  51. })
  52. }
  53. },
  54. /* 开始搜索 */
  55. startSearch({
  56. detail
  57. }) {
  58. this.setData({
  59. 'content.where.condition': detail.trim()
  60. });
  61. this.getList(true);
  62. },
  63. cancelSearch() {
  64. this.setData({
  65. 'content.where.condition': ""
  66. });
  67. this.getList(true);
  68. },
  69. /* 展示列表 */
  70. getShowArr() {
  71. return _Http.basic({
  72. "id": 20220906150303,
  73. "version": 1,
  74. "content": {
  75. "sa_salesforecastmodelid": this.data.content.sa_salesforecastmodelid
  76. }
  77. }).then(res => {
  78. if (res.msg != '成功') return wx.showToast({
  79. title: res.data,
  80. icon: "none"
  81. })
  82. this.setData({
  83. showArr: [{
  84. label: "订单金额(万元)",
  85. value: res.data.orderamountsum
  86. }, {
  87. label: "出货金额(万元)",
  88. value: res.data.outamountsum
  89. }, {
  90. label: "开票金额(万元)",
  91. value: res.data.invoiceamountsum
  92. }, {
  93. label: "订货数量(个)",
  94. value: res.data.orderqtysum
  95. }, {
  96. label: "出货数量(个)",
  97. value: res.data.outqtysum
  98. }, {
  99. label: "开票数量(个)",
  100. value: res.data.invoiceqtysum
  101. }]
  102. })
  103. })
  104. },
  105. getList(init = false) {
  106. //init 用于初始化分页
  107. if (init.detail != undefined) init = init.detail;
  108. if (init) this.setData({
  109. ['content.pageNumber']: 1
  110. })
  111. if (this.data.content.pageNumber > this.data.content.pageTotal) return;
  112. return _Http.basic({
  113. "id": 20220906150403,
  114. "version": 1,
  115. content: this.data.content
  116. }).then(res => {
  117. console.log("列表", res)
  118. if (res.msg != '成功') return wx.showToast({
  119. title: res.data,
  120. icon: "none"
  121. })
  122. this.setData({
  123. 'content.pageNumber': res.pageNumber + 1,
  124. 'content.pageTotal': res.pageTotal,
  125. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  126. total: res.total
  127. })
  128. })
  129. },
  130. onPullDownRefresh: function () {
  131. Promise.all([this.getList(true), this.getShowArr()]).then(res => {
  132. wx.stopPullDownRefresh()
  133. })
  134. },
  135. onReachBottom() {
  136. this.getList();
  137. },
  138. onShareAppMessage() {}
  139. })