record.js 4.0 KB

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