index.js 3.7 KB

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