index.js 3.0 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. getApp().globalData.Language.getLanguagePackage(this, '销售预测');
  31. },
  32. getList(init = false) {
  33. //init 用于初始化分页
  34. if (init.detail != undefined) init = init.detail;
  35. if (init) this.setData({
  36. ['content.pageNumber']: 1
  37. })
  38. if (this.data.content.pageNumber > this.data.content.pageTotal) return;
  39. _Http.basic({
  40. "id": 20220906154403,
  41. "version": 1,
  42. content: this.data.content
  43. }).then(res => {
  44. this.selectComponent('#ListBox').RefreshToComplete();
  45. if (res.code != '1') return wx.showToast({
  46. title: res.data,
  47. icon: "none"
  48. })
  49. this.setData({
  50. 'content.pageNumber': res.pageNumber + 1,
  51. 'content.pageTotal': res.pageTotal,
  52. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  53. })
  54. })
  55. },
  56. toDetail(e) {
  57. const {
  58. item
  59. } = e.currentTarget.dataset;
  60. _Http.basic({
  61. "id": 20220916134103,
  62. "version": 1,
  63. "content": {
  64. "sa_salesforecastmodelid": item.sa_salesforecastmodelid,
  65. "sa_salesforecastbillid": 0,
  66. "sa_projectids": [0]
  67. }
  68. }).then(res => {
  69. if (res.code != '1') return wx.showToast({
  70. title: res.msg,
  71. icon: "none"
  72. })
  73. if (item.baseonproject == 1) {
  74. wx.navigateTo({
  75. url: `./detail?id=${res.data[0].sa_salesforecastbillid}&mId=${item.sa_salesforecastmodelid}&my=true`,
  76. })
  77. } else {
  78. const data = {
  79. sa_salesforecastbillid: res.data[0].sa_salesforecastbillid,
  80. sa_projectid: 0,
  81. sa_salesforecastmodelid: item.sa_salesforecastmodelid
  82. }
  83. wx.navigateTo({
  84. url: './reportForms?item=' + JSON.stringify(data) + '&isEdit=true',
  85. })
  86. }
  87. })
  88. },
  89. onReady() {
  90. this.selectComponent("#ListBox").setHeight('#placeholder', this);
  91. }
  92. })