homeworklist.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <view class="container">
  3. <!-- 返回按钮 -->
  4. <back text="详情列表"></back>
  5. <view style="margin: 20rpx;">
  6. <u-skeleton :rows="detailList.length" :rowsHeight="height" :loading="loading">
  7. </u-skeleton>
  8. </view>
  9. <view class="detail-box" v-if="!loading">
  10. <view class="detail-item" v-for="(item,index) in detailList" :key="index">
  11. <view class="flex" style="width: 100%;height: 90rpx;">
  12. <view class="flex" style="margin: -30rpx 0 0 10rpx;">
  13. <view class="index" :style="{backgroundColor: item.work.progress === 'finish'? '#23b46c': '#ff8caf' }"></view>
  14. <view class="name">{{item.work.name}}</view>
  15. </view>
  16. <view class="t-icon t-icon-yiwancheng1" v-if="item.work.progress === 'finish'"
  17. style="margin-left: auto; width: 90rpx; height: 90rpx;"></view>
  18. <view class="t-icon t-icon-jinhangzhong-copy1" v-if="item.work.progress === 'going'"
  19. style="margin-left: auto; width: 90rpx; height: 90rpx;"></view>
  20. </view>
  21. <!-- 正文 -->
  22. <view class="content-box">
  23. <view class="flex-colum" style="padding: 0 30rpx;">
  24. <rich-text class="subtitle-info" style="margin-bottom: 15rpx;" :nodes="item.work.description"></rich-text>
  25. <view class="flex">
  26. <view class="subtitle">布置老师:</view>
  27. <view class="subtitle-info" style="margin-left: 10rpx;">{{item.work.creatorId}}</view>
  28. <view class="subtitle" style="margin-left: 20rpx;">截止时间:</view>
  29. <view class="subtitle-info" style="margin-left: 10rpx;">{{$timestampToTime(item.work.endTime)}}</view>
  30. </view>
  31. </view>
  32. <view class="content-detail-box" style="padding: 0 20rpx;">
  33. <view class="title-box" :style="{backgroundColor: item.work.progress === 'finish'? '#23b46c': '#ff8caf',top: -15 +'rpx' }">
  34. <view class="content-subtitle">作业附件</view>
  35. </view>
  36. <view v-for="(attachment,i) in item.work.attachments" :key="i" style="margin-bottom: 20rpx;">
  37. <view class="attachment-box" @click="openDocument(attachment.url)">
  38. <view v-if="attachment.type == 'word'" class="t-icon t-icon-WORD"></view>
  39. <view v-if="attachment.type == 'excel'" class="t-icon t-icon-ECEL"></view>
  40. <view v-if="attachment.type == 'pdf'" class="t-icon t-icon-PDF"></view>
  41. <view v-if="attachment.type == 'image'" class="t-icon t-icon-tupianziliao"></view>
  42. <view class="flex-colum" style="margin-left: 20rpx;">
  43. <view class="content-detail">文件名: {{attachment.name}}</view>
  44. <view class="content-subtitle" style="color: #aaa;">文件大小: {{fixNum(attachment.size/8/1024)}}KB</view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import {
  56. mapState,
  57. mapMutations
  58. } from 'vuex'
  59. export default {
  60. computed: {
  61. ...mapState('m_children', ['detailList'])
  62. },
  63. data() {
  64. return {
  65. //骨架页配置
  66. loading: true,
  67. height: ['200px', '200px', '200px', '200px', '200px', '200px', '200px', '200px', '200px', '200px'],
  68. };
  69. },
  70. onLoad(options) {
  71. uni.$u.sleep(1500).then(() => {
  72. this.loading = false
  73. })
  74. },
  75. methods: {
  76. fixNum(num){
  77. return num.toFixed(2)
  78. },
  79. openDocument(url) {
  80. //下载并打开文档
  81. uni.downloadFile({
  82. url: url,
  83. success: function(res) {
  84. var filePath = res.tempFilePath;
  85. uni.openDocument({
  86. filePath: filePath,
  87. success: function(res) {
  88. console.log('打开文档成功');
  89. }
  90. });
  91. }
  92. })
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang="scss">
  98. @import '@/subpkg/common/detailpage.scss';
  99. .attachment-box{
  100. display: flex;
  101. align-items: center;
  102. padding: 15rpx 20rpx;
  103. background-color: #FFF;
  104. border-radius: 10rpx;
  105. }
  106. .flex-colum{
  107. display: flex;
  108. flex-direction: column;
  109. }
  110. </style>