selectMixins.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. import { activity, User } from "@/config/api.js";
  2. let app = getApp();
  3. export default {
  4. data() {
  5. return {
  6. isShowJurisdiction: false, // 权限
  7. isGetJurisdiction: 0, // 权限
  8. listChartPermission: [], // 行业
  9. listChartPermissionInit: [],
  10. chartPermissionName: "所有行业",
  11. chartPermissionIds: "",
  12. whichDay: "", //选择今日/明日\本、上周 月
  13. selectActiveId: "", //专家、分析师的id
  14. activityTimeList: [
  15. { Id: 1, IsChoose: false, StatusName: "今日活动" },
  16. { Id: 2, IsChoose: false, StatusName: "明日活动" },
  17. ],
  18. activityTypeList: [
  19. { Id: 1, IsChoose: false, StatusName: "专家电话会" },
  20. { Id: 2, IsChoose: false, StatusName: "分析师电话会" },
  21. ],
  22. activityMonthWeekList: [
  23. { Id: 3, IsChoose: false, StatusName: "本周", type: "week" },
  24. { Id: 4, IsChoose: false, StatusName: "上周", type: "week" },
  25. { Id: 5, IsChoose: false, StatusName: "本月", type: "month" },
  26. { Id: 6, IsChoose: false, StatusName: "上月", type: "month" },
  27. ],
  28. };
  29. },
  30. methods: {
  31. // 获取权限、所有的行业
  32. async getUserSearchContent() {
  33. const res = await activity.getUserSearchContent({
  34. IsShowJurisdiction: this.isGetJurisdiction,
  35. });
  36. if (res.Ret === 200) {
  37. this.isShowJurisdiction = res.Data.IsShowJurisdiction;
  38. this.listChartPermission = res.Data.ListChartPermission;
  39. this.listChartPermissionInit = res.Data.ListChartPermission2;
  40. this.clickPermission();
  41. if (this.chartPermissionIds) {
  42. this.closeTheWindow();
  43. }
  44. }
  45. },
  46. // 点击后有权限的
  47. clickPermission() {
  48. if (this.isShowJurisdiction) {
  49. const arr = [];
  50. this.listChartPermission &&
  51. this.listChartPermission.forEach((key) => {
  52. if (key.IsChoose) {
  53. arr.push(key.ChartPermissionId);
  54. }
  55. });
  56. this.chartPermissionIds = arr.join(",");
  57. }
  58. },
  59. // 下拉的选择的关闭事件
  60. closeTheWindow() {
  61. const types = this.chartPermissionIds ? this.chartPermissionIds.split(",").map(Number) : [];
  62. if (types.length > 0) {
  63. const str = [];
  64. this.listChartPermission.forEach((item) => {
  65. if (types.includes(item.ChartPermissionId)) {
  66. item.IsChoose = true;
  67. str.push(item.PermissionName);
  68. } else {
  69. item.IsChoose = false;
  70. }
  71. });
  72. this.chartPermissionName = str.length == 6 ? "所有行业" : str.join(",");
  73. }
  74. },
  75. // 是否有权限的点击事件
  76. async permissioActivity() {
  77. if (!this.$store.state.isAuth && !this.$store.state.isBind) {
  78. this.selectComponent("#industry").toggle(false);
  79. this.isShowJurisdiction = !this.isShowJurisdiction;
  80. this.isGetJurisdiction = this.isShowJurisdiction ? 1 : 2;
  81. await this.getUserSearchContent();
  82. if (this.isShowJurisdiction) {
  83. this.getActivityList();
  84. this.replacementConfirm();
  85. } else {
  86. this.replacementBtn();
  87. }
  88. } else {
  89. //已授权未绑定
  90. this.$store.dispatch('checkHandle')
  91. }
  92. },
  93. // 下拉选择的确定事件
  94. replacementConfirm() {
  95. const arr = [];
  96. const str = [];
  97. this.listChartPermission &&
  98. this.listChartPermission.forEach((key) => {
  99. if (key.IsChoose) {
  100. arr.push(key.ChartPermissionId);
  101. str.push(key.PermissionName);
  102. }
  103. });
  104. if ((str.length == 6 && this.listChartPermission.length == 6) || str.length <= 0) {
  105. this.chartPermissionName = "所有行业";
  106. } else {
  107. this.chartPermissionName = str.join(",");
  108. }
  109. this.chartPermissionIds = arr.join(",");
  110. this.getActivityList();
  111. this.selectComponent("#industry").toggle(false);
  112. },
  113. // 下拉的选择的重置事件
  114. replacementBtn() {
  115. this.listChartPermission = this.listChartPermissionInit;
  116. this.chartPermissionIds = "";
  117. this.isShowJurisdiction = false;
  118. this.listChartPermission.map((item) => (item.IsChoose = false));
  119. this.chartPermissionName = "所有行业";
  120. this.getActivityList();
  121. },
  122. // 选择的选中事件
  123. overallClick(item) {
  124. if (this.isShowJurisdiction) return;
  125. item.IsChoose = !item.IsChoose;
  126. },
  127. // 本周上周、本月上月的筛选
  128. monthWeekHandler(item) {
  129. if (this.$refs["select-conyent"]) {
  130. this.selectComponent("#industry").toggle(false);
  131. }
  132. if (this.dateType !== item.type) {
  133. this.dateType = item.type;
  134. this.activityMonthWeekList.forEach((key) => {
  135. if (key.type !== item.type) {
  136. }
  137. key.IsChoose = false;
  138. });
  139. }
  140. item.IsChoose = !item.IsChoose;
  141. let val = this.obtainSelectId(this.activityMonthWeekList);
  142. this.whichDay = val;
  143. this.getActivityList();
  144. },
  145. // 今日、明日、专家、分析师的筛选
  146. selectMultipleHandler(item, type) {
  147. if (this.$refs["select-conyent"]) {
  148. this.selectComponent("#industry").toggle(false);
  149. }
  150. item.IsChoose = !item.IsChoose;
  151. let val = this.obtainSelectId(type == "类型" ? this.activityTypeList : this.activityTimeList);
  152. type == "类型" ? (this.selectActiveId = val) : (this.whichDay = val);
  153. this.getActivityList();
  154. },
  155. // 获取筛选后的id
  156. obtainSelectId(value) {
  157. let arr = [];
  158. value.forEach((item) => {
  159. if (item.IsChoose) {
  160. arr.push(item.Id);
  161. }
  162. });
  163. return arr.join(",");
  164. },
  165. },
  166. onLoad() {
  167. // this.$nextTick(() => {
  168. setTimeout(() => {
  169. this.getUserSearchContent();
  170. });
  171. // });
  172. },
  173. };