selectMixins.js 6.2 KB

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