record.js 3.9 KB

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