docResource.vue 7.5 KB

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