index.js 3.1 KB

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