index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. Page({
  2. data: {
  3. active: "",
  4. page: null,
  5. ops: [],
  6. unfolds: [],
  7. showFiltrate: false,
  8. type: 0,
  9. isleave: 1,
  10. },
  11. onLoad(options) {
  12. getApp().globalData.Language.getLanguagePackage(this, '数据总览');
  13. let organization = this.selectComponent("#organization");
  14. organization.initDepAndUser()
  15. const ops = wx.getStorageSync('auth').wdataoverview.options.filter(v => ["Clue", "Client", "Project", "Cost"].includes(v))
  16. this.setData({
  17. active: ops[0],
  18. unfolds: [ops[0]],
  19. dataid: wx.getStorageSync('userMsg').userid,
  20. username: wx.getStorageSync('userMsg').name,
  21. })
  22. this.setData({
  23. ops: ops.map(v => {
  24. return {
  25. name: v,
  26. title: {
  27. "Clue": "线索",
  28. "Client": "客户",
  29. "Project": "项目",
  30. "Cost": "营销费用"
  31. } [v]
  32. }
  33. }),
  34. })
  35. },
  36. onChange(event) {
  37. const active = event.detail.name;
  38. if (!this.data.unfolds.includes(active)) {
  39. this.data.unfolds.push(active);
  40. }
  41. this.setData({
  42. active,
  43. unfolds: this.data.unfolds
  44. });
  45. this.getList({
  46. detail: active
  47. });
  48. },
  49. getList({
  50. detail
  51. }) {
  52. if (detail && this.data.active == "") return setTimeout(() => {
  53. this.getList({
  54. detail: detail
  55. })
  56. })
  57. if (detail && this.data.active != detail) return;
  58. const page = this.selectComponent("#" + this.data.active);
  59. if (page) {
  60. const {
  61. dataid,
  62. type,
  63. username,
  64. isleave
  65. } = this.data;
  66. let content = {};
  67. try {
  68. content = page.data.model.data.content;
  69. } catch (error) {
  70. content = page.getContent()
  71. }
  72. if (content.dataid != dataid || content.type != type || content.where.isleave != isleave) page.data.init = false
  73. content.dataid = dataid;
  74. content.type = type;
  75. content.username = username;
  76. content.where.isleave = isleave;
  77. if (!page.data.init) page.getList();
  78. }
  79. },
  80. openFiltrate() {
  81. this.setData({
  82. showFiltrate: true
  83. })
  84. },
  85. handleFilter({
  86. detail
  87. }) {
  88. if (detail.name == "close") return;
  89. if (detail.name == 'reset') {
  90. this.selectComponent("#organization").setData({
  91. isleave: 1
  92. })
  93. this.selectComponent("#organization").initDepAndUser()
  94. this.setData({
  95. dataid: wx.getStorageSync('userMsg').userid,
  96. 'type': 0,
  97. isleave: 1,
  98. username: wx.getStorageSync('userMsg').name
  99. })
  100. } else {
  101. let active = this.selectComponent("#organization").data.result,
  102. isleave = this.selectComponent("#organization").data.isleave;
  103. let type = active.userid ? 0 : 1,
  104. dataid = type == 0 ? active.userid : active.sa_saleareaid
  105. this.setData({
  106. isleave,
  107. dataid,
  108. type,
  109. username: active.name
  110. })
  111. }
  112. this.getList({
  113. detail: this.data.active
  114. });
  115. },
  116. })