mainPage.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <!-- 分析报告详情总页面 -->
  3. <div class="analysis_main">
  4. <div :class="['main_header',{'full_screen':isLianXiao}]" ref="mainHeader">
  5. <div class="header_left">
  6. <span class="back_button" @click="GoBack">
  7. <i class="iconfont icon_return"></i>返回
  8. </span>
  9. <span class="header_title">{{ pageName }}</span>
  10. </div>
  11. <div class="header_right">
  12. <div class="select_list" v-if="isShowFilter">
  13. <el-select style="width: 120px" v-model="item.value" :placeholder="'请选择' + item.name"
  14. class="select_item" @change="ChangeFilters({ index: index, value: item.value })"
  15. v-for="(item, index) in filterData" :key="index" v-show="item.list.length > 1">
  16. <el-option v-for="item in item.list" :key="item.value" :label="item.label"
  17. :value="item.value"></el-option>
  18. </el-select>
  19. </div>
  20. <template v-if="isShowBtn">
  21. <el-button size="medium" @click="downloadWrongQuestions(0)">下载错题本</el-button>
  22. <el-button type="primary" size="medium" @click="downloadWrongQuestions(1)">下载个性化提升手册</el-button>
  23. </template>
  24. </div>
  25. </div>
  26. <div class="main_content">
  27. <div class="content_right" ref="rightContent" @scroll="ScrollChange">
  28. <div :class="['content_right_scroll',{'full_screen':isLianXiao}]" ref="contentRightScroll">
  29. <template v-if="isLianXiao">
  30. <div class="mm_body">
  31. <div class="left">
  32. <button class="mm_btn mb_10" :class="{ active: activeBtn === pathOne }"
  33. @click="toPage(pathOne)">成绩分析</button>
  34. <button class="mm_btn" :class="{ active: activeBtn === pathTwo }"
  35. @click="toPage(pathTwo)">个性化错题</button>
  36. </div>
  37. <div class="right">
  38. <div class="page_filter" ref="filterContent">
  39. <FiltersItem :filtersData="filterData" @selectItem="ChangeFilters"></FiltersItem>
  40. </div>
  41. <router-view ref="child"></router-view>
  42. </div>
  43. </div>
  44. </template>
  45. <template v-else>
  46. <div class="page_filter" ref="filterContent">
  47. <FiltersItem :filtersData="filterData" @selectItem="ChangeFilters"></FiltersItem>
  48. </div>
  49. <router-view ref="child"></router-view>
  50. </template>
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. </template>
  56. <script>
  57. import FiltersItem from "@/components/FiltersItem_ruoyan.vue";
  58. export default {
  59. components: { FiltersItem },
  60. computed: {
  61. pageName() {
  62. // let examName = this.$store.state.report.examSelectItem.examName;
  63. // if (examName) {
  64. // return examName.split("_")[0];
  65. // }
  66. return this.$store.state.report.examSelectItem.examName
  67. },
  68. updateScrollTop() {
  69. return this.$store.state.report.updateScrollTop;//监听改变滚动条参数
  70. },
  71. },
  72. data() {
  73. return {
  74. isShowFilter: false, //是否显示筛选条件
  75. isShowBtn: false, //是否显示下载按钮
  76. filterData: [
  77. {
  78. name: "科目名称",
  79. value: '0',
  80. type: "subjectName",
  81. list: [], //选项
  82. }
  83. ],
  84. resizeTimer: null,
  85. activeBtn: this.$route.path,
  86. pathOne: '/studentAnalysisReport/reportDetails/scrolReport',
  87. pathTwo: '/studentAnalysisReport/reportDetails/personalWrongQuestions',
  88. isLianXiao: false,//是否联校
  89. };
  90. },
  91. created() {
  92. const schoolType = sessionStorage.getItem('schoolType') || '1'; //1:单校 2:联校
  93. this.isLianXiao = schoolType === '2';
  94. if (this.$store.state.report.filterData.length > 0) {
  95. //有数据
  96. this.filterData = this.$store.state.report.filterData;
  97. }
  98. // 绑定 resize 事件
  99. window.addEventListener('resize', this.HandleWidthChange);
  100. this.$nextTick(() => {
  101. this.SetHeadWidth();
  102. })
  103. },
  104. methods: {
  105. toPage(type) {
  106. this.activeBtn = type;
  107. this.$router.push(type);
  108. },
  109. // 处理宽度变化的逻辑
  110. HandleWidthChange() {
  111. // 防抖:避免窗口 resize 时频繁触发(100ms 内只执行一次)
  112. clearTimeout(this.resizeTimer);
  113. this.resizeTimer = setTimeout(() => {
  114. this.SetHeadWidth();
  115. }, 100);
  116. },
  117. SetHeadWidth() {
  118. if (this.$refs.contentRightScroll) {
  119. let scrollDivWidth = 0;
  120. if(this.isLianXiao){
  121. scrollDivWidth = this.$refs.contentRightScroll.offsetWidth - 20;//联校
  122. }else{
  123. scrollDivWidth = this.$refs.contentRightScroll.offsetWidth;
  124. }
  125. const headDiv = this.$refs.mainHeader;
  126. headDiv.style.width = `${scrollDivWidth}px`;
  127. }
  128. },
  129. // 筛选事件
  130. ChangeFilters(e) {
  131. this.filterData[e.index].value = e.value;
  132. // 选中科目数据
  133. let courseObj = this.filterData[0].list.find(item => item.value == this.filterData[0].value);
  134. let filterObject = {
  135. examLevel: courseObj.examLevel,//1-联考 2-单校
  136. contrastExamIds: courseObj.contrastExamIds,//多次考试任务对比ID,不包含当前任务ID
  137. examId: courseObj.examId,//考试id
  138. subjectCode: courseObj.subjectCode, //科目code
  139. subjectGroupType: courseObj.subjectGroupType, //是否为组合科目 1为组合科目 0为非组合科目
  140. subjectName: courseObj.subjectName,//科目名称
  141. isTotal: courseObj.isTotal //是否为总分科目 1为总分 0为非总分
  142. };
  143. //设置是否是总分
  144. this.$store.commit("report/set_state", {
  145. key: "isTotalScore",
  146. value: courseObj.isTotal == 1 || courseObj.subjectGroupType == 1,//1为总分 0为非总分 1为组合科目 0为非组合科目
  147. });
  148. localStorage.setItem('reportExamCourseId', courseObj.subjectId);//单科的考试科目id
  149. localStorage.setItem('reportIsTotalScore', courseObj.isTotal == 1 || courseObj.subjectGroupType == 1)
  150. console.log("打印筛选数据", filterObject);
  151. this.$store.dispatch("report/UpdateFilterObject", filterObject);
  152. },
  153. // 滚动条事件
  154. ScrollChange() {
  155. const path = this.$route.path;
  156. let scrollTop = this.$refs.rightContent.scrollTop;
  157. if (path === '/studentAnalysisReport/reportDetails/scrolReport') {
  158. const filterContent = this.$refs.filterContent;
  159. let scrollHeight = 242;
  160. if (filterContent) {
  161. scrollHeight = filterContent.clientHeight;
  162. }
  163. this.isShowFilter = (scrollTop >= scrollHeight);
  164. this.$store.commit("report/set_state", {
  165. key: "isShowFilter",
  166. value: this.isShowFilter,
  167. });
  168. if (this.$refs.child && typeof this.$refs.child.GetScrollTop === 'function') {
  169. this.$refs.child.GetScrollTop(scrollTop);
  170. }
  171. }
  172. if (path === '/studentAnalysisReport/reportDetails/personalWrongQuestions') {
  173. this.isShowBtn = (scrollTop >= 250);
  174. if (this.$refs.child && typeof this.$refs.child.GetScrollTop === 'function') {
  175. this.$refs.child.GetScrollTop(scrollTop);
  176. }
  177. }
  178. },
  179. //重置滚动条
  180. ResetScroll() {
  181. this.$nextTick(() => {
  182. if (this.$refs.rightContent) {
  183. this.$refs.rightContent.scrollTop = 0;
  184. }
  185. })
  186. },
  187. downloadWrongQuestions(type) {
  188. this.$store.commit("question/SET_VARIANTION", type);
  189. },
  190. //返回按钮点击
  191. GoBack() {
  192. const schoolType = sessionStorage.getItem('schoolType');
  193. if(schoolType == 1){//单校
  194. this.$router.push("/studentAnalysisReport/list");
  195. }else{//联校
  196. this.$router.push("/jointStudentAnalysisReport/list");
  197. }
  198. },
  199. },
  200. watch: {
  201. '$route'(to, from) {
  202. this.ResetScroll();//重置滚动条
  203. },//路由变化 重置页面滚动条位置
  204. updateScrollTop: {
  205. handler(newVal) {
  206. this.ResetScroll();//重置滚动条
  207. },
  208. },
  209. },
  210. beforeUnmount() {
  211. // 解绑事件,避免内存泄漏
  212. window.removeEventListener('resize', this.HandleWidthChange);
  213. // 清除计时器
  214. clearTimeout(this.resizeTimer);
  215. }
  216. };
  217. </script>
  218. <style scoped lang="scss">
  219. .mm_body {
  220. display: flex;
  221. width: 100%;
  222. justify-content: space-between;
  223. .left {
  224. width: 170px;
  225. padding: 20px;
  226. border-radius: 10px;
  227. background-color: #ffffff;
  228. height: fit-content;
  229. box-sizing: border-box;
  230. position: sticky;
  231. top: 0px;
  232. .mb_10 {
  233. margin-bottom: 10px;
  234. }
  235. }
  236. .right {
  237. width: calc(100% - 180px);
  238. }
  239. }
  240. </style>