selectMixins.js 6.0 KB

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