index.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. const _Http = getApp().globalData.http,
  2. getHeight = require("../../utils/getRheRemainingHeight");
  3. Page({
  4. data: {
  5. listHeight: null,
  6. list: [],
  7. "content": {
  8. pageNumber: 1,
  9. pageTotal: 1,
  10. pageSize: 20,
  11. "where": {
  12. "condition": ""
  13. }
  14. }
  15. },
  16. onLoad(options) {
  17. this.getList()
  18. },
  19. getList(init = false) {
  20. //init 用于初始化分页
  21. if (init.detail != undefined) init = init.detail;
  22. if (init) this.setData({
  23. ['content.pageNumber']: 1
  24. })
  25. if (this.data.content.pageNumber > this.data.content.pageTotal) return;
  26. _Http.basic({
  27. "id": 20220906154403,
  28. "version": 1,
  29. content: this.data.content
  30. }).then(res => {
  31. this.selectComponent('#ListBox').RefreshToComplete();
  32. if (res.msg != '成功') return wx.showToast({
  33. title: res.data,
  34. icon: "none"
  35. })
  36. this.setData({
  37. 'content.pageNumber': res.pageNumber + 1,
  38. 'content.pageTotal': res.pageTotal,
  39. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  40. })
  41. })
  42. },
  43. toDetail(e) {
  44. const {
  45. item
  46. } = e.currentTarget.dataset;
  47. _Http.basic({
  48. "id": 20220916134103,
  49. "version": 1,
  50. "content": {
  51. "sa_salesforecastmodelid": item.sa_salesforecastmodelid,
  52. "sa_salesforecastbillid": 0,
  53. "sa_projectids": [0]
  54. }
  55. }).then(res => {
  56. if (res.msg != '成功') return wx.showToast({
  57. title: res.data,
  58. icon: "none"
  59. })
  60. if (item.baseonproject == 1) {
  61. wx.navigateTo({
  62. url: `./detail?id=${res.data[0].sa_salesforecastbillid}&mId=${item.sa_salesforecastmodelid}&my=true`,
  63. })
  64. } else {
  65. const data = {
  66. sa_salesforecastbillid: res.data[0].sa_salesforecastbillid,
  67. projectname: item.title,
  68. projectnum: item.billnum,
  69. sa_projectid: 0,
  70. address: "",
  71. sa_salesforecastmodelid: item.sa_salesforecastmodelid
  72. }
  73. wx.navigateTo({
  74. url: './reportForms?item=' + JSON.stringify(data) + '&isEdit=true',
  75. })
  76. }
  77. })
  78. },
  79. onReady() {
  80. getHeight.getHeight('#placeholder', this).then(res => this.setData({
  81. listHeight: res
  82. }));
  83. },
  84. onShareAppMessage() {}
  85. })