record.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. sa_projectid: 0,
  44. sa_salesforecastmodelid: this.data.content.sa_salesforecastmodelid
  45. }
  46. wx.navigateTo({
  47. url: './reportForms?item=' + JSON.stringify(data) + '&isEdit=false',
  48. })
  49. }
  50. },
  51. /* 开始搜索 */
  52. startSearch({
  53. detail
  54. }) {
  55. this.setData({
  56. 'content.where.condition': detail.trim()
  57. });
  58. this.getList(true);
  59. },
  60. cancelSearch() {
  61. this.setData({
  62. 'content.where.condition': ""
  63. });
  64. this.getList(true);
  65. },
  66. /* 展示列表 */
  67. getShowArr() {
  68. return _Http.basic({
  69. "id": 20220906150303,
  70. "version": 1,
  71. "content": {
  72. "sa_salesforecastmodelid": this.data.content.sa_salesforecastmodelid
  73. }
  74. }).then(res => {
  75. if (res.msg != '成功') return wx.showToast({
  76. title: res.data,
  77. icon: "none"
  78. })
  79. this.setData({
  80. showArr: [{
  81. label: "订单金额(万元)",
  82. value: res.data.orderamountsum
  83. }, {
  84. label: "出货金额(万元)",
  85. value: res.data.outamountsum
  86. }, {
  87. label: "开票金额(万元)",
  88. value: res.data.invoiceamountsum
  89. }, {
  90. label: "订货数量(个)",
  91. value: res.data.orderqtysum
  92. }, {
  93. label: "出货数量(个)",
  94. value: res.data.outqtysum
  95. }, {
  96. label: "开票数量(个)",
  97. value: res.data.invoiceqtysum
  98. }]
  99. })
  100. })
  101. },
  102. getList(init = false) {
  103. //init 用于初始化分页
  104. if (init.detail != undefined) init = init.detail;
  105. if (init) this.setData({
  106. ['content.pageNumber']: 1
  107. })
  108. if (this.data.content.pageNumber > this.data.content.pageTotal) return;
  109. return _Http.basic({
  110. "id": 20220906150403,
  111. "version": 1,
  112. content: this.data.content
  113. }).then(res => {
  114. console.log("列表", res)
  115. if (res.msg != '成功') return wx.showToast({
  116. title: res.data,
  117. icon: "none"
  118. })
  119. this.setData({
  120. 'content.pageNumber': res.pageNumber + 1,
  121. 'content.pageTotal': res.pageTotal,
  122. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  123. total: res.total
  124. })
  125. })
  126. },
  127. onPullDownRefresh: function () {
  128. Promise.all([this.getList(true), this.getShowArr()]).then(res => {
  129. wx.stopPullDownRefresh()
  130. })
  131. },
  132. onReachBottom() {
  133. this.getList();
  134. },
  135. onShareAppMessage() {}
  136. })