docResource.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <!-- 文档资源 -->
  2. <template>
  3. <view class="docResource-component">
  4. <view class="card">
  5. <view class="card-header">
  6. <view class="header-left">
  7. <view class="card-title">实验室安全素养资源</view>
  8. </view>
  9. </view>
  10. <view class="card-body">
  11. <view class="top-table-box">
  12. <view @click="checkTable(index)"
  13. :class="topCheckIndex == index ? 'check-table-p':''"
  14. v-for="(item,index) in tableList" :key="index">
  15. {{item.disciplineName}}
  16. </view>
  17. </view>
  18. <view class="card-title-box">
  19. <view>学习资料</view>
  20. <view>查看更多</view>
  21. </view>
  22. <view class="card-for-list-box">
  23. <view class="card-for-box" v-for="(item,index) in topList" :key="'top_'+index">
  24. <view class="for-left-box">📄</view>
  25. <view class="for-center-box">
  26. <view>{{ item.coursewareName }}</view>
  27. <view>{{ item.materialType == 4?'文章':item.attachmentType.substring(1) }}</view>
  28. </view>
  29. <view class="for-right-box">{{secondsToMinutes(item.minLearningDuration)}}分钟</view>
  30. </view>
  31. <view class="null-p" v-if="!topList[0]">暂无资料</view>
  32. </view>
  33. <view class="card-title-box">
  34. <view>题库</view>
  35. <view>查看更多</view>
  36. </view>
  37. <view class="card-for-list-box-2">
  38. <view class="card-for-box" v-for="(item,index) in bottomList" :key="'bottom_'+index">
  39. <view class="for-left-box">📖</view>
  40. <view class="for-right-box">
  41. <view>{{item.knowledgePointName}}</view>
  42. <view>{{item.questionCount}} 题</view>
  43. </view>
  44. </view>
  45. <view class="null-p" v-if="!bottomList[0]">暂无资料</view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import {
  53. examElDisciplineTypeList,
  54. examUserCoursewareLearningList,
  55. examElQuestionBankGroupByKnowledgePoint,
  56. } from '@/pages_safetyEducationExamination/api/index.js'
  57. export default {
  58. // components: {
  59. // workbench,
  60. // },
  61. data() {
  62. return {
  63. topCheckIndex:0,
  64. tableList:[],
  65. topList:[],
  66. bottomList:[],
  67. }
  68. },
  69. created() {
  70. },
  71. mounted() {
  72. this.examElDisciplineTypeList();
  73. },
  74. methods: {
  75. //选项卡切换
  76. checkTable(index){
  77. if(this.topCheckIndex!=index){
  78. this.$set(this,'topCheckIndex',index);
  79. this.examUserCoursewareLearningList();
  80. this.examElQuestionBankGroupByKnowledgePoint();
  81. }
  82. },
  83. async examElDisciplineTypeList() {
  84. try {
  85. const { data } = await examElDisciplineTypeList({});
  86. if (data.code === 200) {
  87. this.$set(this, 'tableList', data.data)
  88. this.examUserCoursewareLearningList();
  89. this.examElQuestionBankGroupByKnowledgePoint();
  90. }
  91. } catch (e) { console.error('获取考试任务失败', e); }
  92. },
  93. async examUserCoursewareLearningList() {
  94. try {
  95. let obj = {
  96. page:1,
  97. pageSize:3,
  98. materialType:2,
  99. disciplineTypeId:this.tableList[this.topCheckIndex].id,
  100. }
  101. const { data } = await examUserCoursewareLearningList(obj);
  102. if (data.code === 200) {
  103. this.$set(this, 'topList', data.data.records)
  104. }
  105. } catch (e) { console.error('获取文章失败', e); }
  106. },
  107. async examElQuestionBankGroupByKnowledgePoint() {
  108. try {
  109. let obj = {
  110. page:1,
  111. pageSize:2,
  112. disciplineTypeId:this.tableList[this.topCheckIndex].id,
  113. }
  114. const { data } = await examElQuestionBankGroupByKnowledgePoint(obj);
  115. if (data.code === 200) {
  116. this.$set(this, 'bottomList', data.data.records)
  117. }
  118. } catch (e) { console.error('获取知识点题库失败', e); }
  119. },
  120. //换算分钟
  121. secondsToMinutes(totalSeconds) {
  122. if (typeof totalSeconds !== 'number' || totalSeconds <= 0) {
  123. return 1;
  124. }
  125. return Math.ceil(totalSeconds / 60);
  126. },
  127. },
  128. }
  129. </script>
  130. <style lang="stylus" scoped>
  131. .docResource-component {
  132. margin: 0 32rpx 32rpx;
  133. .card {
  134. background: #fff;
  135. border-radius: 24rpx;
  136. overflow: hidden;
  137. margin-bottom: 24rpx;
  138. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.03);
  139. border: 1px solid #dde3ed;
  140. }
  141. .card-header {
  142. padding: 20rpx 28rpx;
  143. display: flex;
  144. justify-content: space-between;
  145. align-items: center;
  146. .card-title {
  147. font-size: 28rpx;
  148. color: #333;
  149. }
  150. .header-subtitle{
  151. margin-top:10rpx;
  152. font-size:22rpx;
  153. color:#8896a7;
  154. }
  155. .header-link {
  156. font-size: 24rpx;
  157. color: #1857d4;
  158. }
  159. }
  160. .card-body{
  161. padding-bottom:30rpx;
  162. .top-table-box{
  163. padding:0 28rpx;
  164. display: flex;
  165. view{
  166. flex:1;
  167. text-align: center;
  168. line-height:50rpx;
  169. padding:0 10rpx;
  170. font-size:24rpx;
  171. border-bottom:4rpx solid #dedede;
  172. }
  173. .check-table-p{
  174. font-weight:600;
  175. color:#1857d4;
  176. border-bottom: 4rpx solid #1857d4;
  177. }
  178. }
  179. .card-title-box{
  180. display: flex;
  181. padding:0 28rpx 0;
  182. margin-top:10rpx;
  183. view{
  184. height:80rpx;
  185. line-height:80rpx;
  186. }
  187. view:nth-child(1){
  188. font-size:24rpx;
  189. flex:1;
  190. }
  191. view:nth-child(2){
  192. font-size:22rpx;
  193. color:#1857d4;
  194. }
  195. }
  196. .card-for-list-box{
  197. .null-p{
  198. text-align: center;
  199. color:#999;
  200. font-size:24rpx;
  201. line-height:100rpx;
  202. }
  203. .card-for-box:nth-child(1){
  204. margin-top:0;
  205. }
  206. .card-for-box{
  207. margin:20rpx 28rpx;
  208. padding: 20rpx 16rpx;
  209. background-color: #f4f6fa;
  210. border-radius: 12rpx;
  211. display: flex;
  212. .for-left-box{
  213. width:50rpx;
  214. font-size:30rpx;
  215. line-height:56rpx;
  216. text-align: center;
  217. margin-right:10rpx;
  218. }
  219. .for-center-box{
  220. flex:1;
  221. height:56rpx;
  222. view:nth-child(1){
  223. font-size:24rpx;
  224. line-height:24rpx;
  225. margin-bottom:10rpx;
  226. }
  227. view:nth-child(2){
  228. font-size:22rpx;
  229. line-height:22rpx;
  230. color:#8896a7;
  231. }
  232. }
  233. .for-right-box{
  234. font-size:24rpx;
  235. line-height:56rpx;
  236. color:#8896a7;
  237. margin-right:15rpx;
  238. }
  239. }
  240. }
  241. .card-for-list-box-2{
  242. padding:0 28rpx;
  243. .null-p{
  244. text-align: center;
  245. color:#999;
  246. font-size:24rpx;
  247. line-height:100rpx;
  248. }
  249. .card-for-box:nth-child(even) {
  250. margin-left:20rpx;
  251. }
  252. .card-for-box{
  253. width:264rpx;
  254. padding: 20rpx;
  255. border-radius: 12rpx;
  256. background-color: #f4f6fa;
  257. margin-bottom:20rpx;
  258. display: inline-block;
  259. .for-left-box{
  260. width:60rpx;
  261. font-size:40rpx;
  262. line-height:56rpx;
  263. text-align: center;
  264. margin-right:20rpx;
  265. display: inline-block;
  266. overflow: hidden;
  267. margin-top:5rpx;
  268. }
  269. .for-right-box{
  270. display: inline-block;
  271. height:56rpx;
  272. view:nth-child(1){
  273. font-size:24rpx;
  274. line-height:24rpx;
  275. margin-bottom:10rpx;
  276. }
  277. view:nth-child(2){
  278. font-size:22rpx;
  279. line-height:22rpx;
  280. color:#8896a7;
  281. }
  282. }
  283. }
  284. }
  285. }
  286. }
  287. </style>