internshipReport.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view style="padding: 20rpx 30rpx;">
  3. <view v-if="items.length > 0" class="wrapper">
  4. <view v-for="(item,index) in items" :key="index" style="margin: 0 0 50rpx 0;">
  5. <uni-section :title="item.date" type="line"></uni-section>
  6. <view>
  7. <image v-for="(url, i) in item.arr" :key="i" class="img" :src="url" mode="scaleToFill" @click="previewImage(item.arr,i)"></image>
  8. </view>
  9. </view>
  10. </view>
  11. <view v-else class="nodata-img-parent">
  12. <image src="https://minio.citupro.com/dev/static/nodata.png" mode="widthFix" class="nodata-img-child"></image>
  13. </view>
  14. <view class="bottom-sticky">
  15. <button type="primary" size="default" class="recomm-button" @click="addReport">新增实习报告</button>
  16. </view>
  17. </view>
  18. </template>
  19. <script setup>
  20. import { ref } from 'vue'
  21. import { getStudentReportList, getStudentPracticeCompanyList } from '@/api/student.js'
  22. import { onLoad, onShow } from '@dcloudio/uni-app'
  23. import { formatName } from '@/utils/index.js'
  24. const enterpriseId = ref(null)
  25. const items = ref([])
  26. const getCompanyList = async () => {
  27. try {
  28. const { data } = await getStudentPracticeCompanyList()
  29. data.forEach(e => {
  30. e.id = e.id.toString()
  31. e.enterpriseName = formatName(e.anotherName || e.name)
  32. })
  33. console.log(data, '实习企业列表')
  34. } catch {}
  35. }
  36. // 实习报告列表
  37. const getList = async () => {
  38. items.value = []
  39. try {
  40. const { data } = await getStudentReportList(enterpriseId.value ? { enterpriseId: enterpriseId.value } : {})
  41. if (!data || !Object.keys(data).length) return
  42. for (let item in data) {
  43. items.value.push({ date: item, arr: data[item].map(e => e.url) })
  44. }
  45. } catch {}
  46. }
  47. onShow(() => {
  48. console.log('onSHow11111111')
  49. getCompanyList()
  50. })
  51. onLoad((options) => {
  52. console.log(options, 'options-实习报告')
  53. if (options.enterpriseId) {
  54. enterpriseId.value = options.enterpriseId
  55. }
  56. getList()
  57. })
  58. const addReport = () => {}
  59. // 预览图片
  60. const previewImage = (url, i) => {
  61. uni.previewImage({
  62. current: i,
  63. urls: url,
  64. longPressActions : {
  65. itemList: ['发送给朋友', '保存图片', '收藏']
  66. }
  67. })
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. .img{
  72. width: 28%;
  73. height: 200rpx;
  74. margin: 10rpx;
  75. border: 1px solid #f4f4f4;
  76. }
  77. .wrapper{
  78. height: 84vh;
  79. overflow: auto;
  80. }
  81. :deep(.uni-section .uni-section-header__decoration) {
  82. background-color: #00B760 !important;
  83. }
  84. </style>