index.js 2.9 KB

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