selectMixins.js 6.1 KB

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