index.js 2.7 KB

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