selectMixins.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. uni.navigateTo({
  91. url: "/pageMy/login/login",
  92. });
  93. }
  94. },
  95. // 下拉选择的确定事件
  96. replacementConfirm() {
  97. const arr = [];
  98. const str = [];
  99. this.listChartPermission &&
  100. this.listChartPermission.forEach((key) => {
  101. if (key.IsChoose) {
  102. arr.push(key.ChartPermissionId);
  103. str.push(key.PermissionName);
  104. }
  105. });
  106. if ((str.length == 6 && this.listChartPermission.length == 6) || str.length <= 0) {
  107. this.chartPermissionName = "所有行业";
  108. } else {
  109. this.chartPermissionName = str.join(",");
  110. }
  111. this.chartPermissionIds = arr.join(",");
  112. this.getActivityList();
  113. this.selectComponent("#industry").toggle(false);
  114. },
  115. // 下拉的选择的重置事件
  116. replacementBtn() {
  117. this.listChartPermission = this.listChartPermissionInit;
  118. this.chartPermissionIds = "";
  119. this.isShowJurisdiction = false;
  120. this.listChartPermission.map((item) => (item.IsChoose = false));
  121. this.chartPermissionName = "所有行业";
  122. this.getActivityList();
  123. },
  124. // 选择的选中事件
  125. overallClick(item) {
  126. if (this.isShowJurisdiction) return;
  127. item.IsChoose = !item.IsChoose;
  128. },
  129. // 本周上周、本月上月的筛选
  130. monthWeekHandler(item) {
  131. if (this.$refs["select-conyent"]) {
  132. this.selectComponent("#industry").toggle(false);
  133. }
  134. if (this.dateType !== item.type) {
  135. this.dateType = item.type;
  136. this.activityMonthWeekList.forEach((key) => {
  137. if (key.type !== item.type) {
  138. }
  139. key.IsChoose = false;
  140. });
  141. }
  142. item.IsChoose = !item.IsChoose;
  143. let val = this.obtainSelectId(this.activityMonthWeekList);
  144. this.whichDay = val;
  145. this.getActivityList();
  146. },
  147. // 今日、明日、专家、分析师的筛选
  148. selectMultipleHandler(item, type) {
  149. if (this.$refs["select-conyent"]) {
  150. this.selectComponent("#industry").toggle(false);
  151. }
  152. item.IsChoose = !item.IsChoose;
  153. let val = this.obtainSelectId(type == "类型" ? this.activityTypeList : this.activityTimeList);
  154. type == "类型" ? (this.selectActiveId = val) : (this.whichDay = val);
  155. this.getActivityList();
  156. },
  157. // 获取筛选后的id
  158. obtainSelectId(value) {
  159. let arr = [];
  160. value.forEach((item) => {
  161. if (item.IsChoose) {
  162. arr.push(item.Id);
  163. }
  164. });
  165. return arr.join(",");
  166. },
  167. },
  168. onLoad() {
  169. // this.$nextTick(() => {
  170. setTimeout(() => {
  171. this.getUserSearchContent();
  172. });
  173. // });
  174. },
  175. };