internshipReport.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view style="padding: 20rpx 30rpx;">
  3. <view class="d-flex align-center">
  4. <uni-section title="企业:"></uni-section>
  5. <uni-data-picker v-model="enterpriseId" class="picker" :localdata="companyList" placeholder="请选择要查看的企业" popup-title="选择企业" @change="getList" :map="{ text: 'enterpriseName', value: 'id' }"></uni-data-picker>
  6. <button type="primary" size="mini" @click="getList" style="height: 35px; line-height: 35px; margin: 0;">刷新</button>
  7. </view>
  8. <view class="line ss-m-y-20"></view>
  9. <view v-if="items.length > 0" class="wrapper">
  10. <view v-for="(item,index) in items" :key="index" style="margin: 0 0 50rpx 0;">
  11. <uni-section :title="item.date" type="line"></uni-section>
  12. <view>
  13. <image v-for="(url, i) in item.arr" :key="i" class="img" :src="url" mode="scaleToFill" @click="previewImage(item.arr,i)"></image>
  14. </view>
  15. </view>
  16. </view>
  17. <view v-else class="nodata-img-parent">
  18. <image src="https://minio.citupro.com/dev/static/nodata.png" mode="widthFix" class="nodata-img-child"></image>
  19. </view>
  20. <view class="bottom-sticky">
  21. <button type="primary" size="default" class="recomm-button" @click="addReport">新增实习报告</button>
  22. </view>
  23. </view>
  24. </template>
  25. <script setup>
  26. import { ref } from 'vue'
  27. import { getStudentReportList, getStudentPracticeCompanyList } from '@/api/student.js'
  28. import { onLoad, onShow } from '@dcloudio/uni-app'
  29. import { formatName } from '@/utils/getText'
  30. const enterpriseId = ref(null)
  31. const items = ref([])
  32. const companyList = ref([])
  33. const getCompanyList = async () => {
  34. try {
  35. const { data } = await getStudentPracticeCompanyList()
  36. data?.length && data.forEach(e => {
  37. e.id = e.id.toString()
  38. e.enterpriseName = formatName(e.anotherName || e.name)
  39. })
  40. companyList.value = data || []
  41. } catch {}
  42. }
  43. // 实习报告列表
  44. const getList = async () => {
  45. try {
  46. const { data } = await getStudentReportList(enterpriseId.value ? { enterpriseId: enterpriseId.value } : {})
  47. items.value = []
  48. if (!data || !Object.keys(data).length) return
  49. for (let item in data) {
  50. items.value.push({ date: item, arr: data[item].map(e => e.url) })
  51. }
  52. } catch {}
  53. }
  54. // 预览图片
  55. const previewImage = (url, i) => {
  56. uni.previewImage({
  57. current: i,
  58. urls: url,
  59. longPressActions : {
  60. itemList: ['发送给朋友', '保存图片', '收藏']
  61. }
  62. })
  63. }
  64. onShow(() => {
  65. getCompanyList()
  66. getList()
  67. })
  68. onLoad((options) => {
  69. if (options.enterpriseId) {
  70. enterpriseId.value = options.enterpriseId
  71. }
  72. })
  73. const addReport = () => {
  74. if (!companyList.value?.length) {
  75. uni.showToast({
  76. title: '没有查到实习企业记录!',
  77. icon: 'none'
  78. })
  79. return
  80. }
  81. const list = JSON.stringify(companyList.value)
  82. uni.navigateTo({ url: `/pagesA/student/addReport?companyList=${list}` })
  83. }
  84. </script>
  85. <style lang="scss" scoped>
  86. .img{
  87. width: 28%;
  88. height: 200rpx;
  89. margin: 10rpx;
  90. border: 1px solid #00B760;
  91. border-radius: 4px;
  92. }
  93. .wrapper{
  94. height: 84vh;
  95. overflow: auto;
  96. }
  97. :deep(.uni-section .uni-section-header__decoration) {
  98. background-color: #00B760 !important;
  99. }
  100. .line {
  101. border-top: 1px solid #ccc;
  102. }
  103. .picker {
  104. flex: 1;
  105. overflow: hidden;
  106. margin-right: 12px;
  107. }
  108. .reportPopup {
  109. width: 96vw;
  110. .uploadTip {
  111. color: #00B760;
  112. margin-bottom: 20px;
  113. font-size: 13px;
  114. }
  115. .dialog-title {
  116. display: flex;
  117. justify-content: space-between;
  118. align-items: center;
  119. color:#767a82;
  120. padding: 20rpx;
  121. .title {
  122. font-weight: bold;
  123. margin-left: 10rpx;
  124. }
  125. }
  126. .dialog-content{
  127. padding: 20rpx;
  128. padding-bottom: 50rpx;
  129. }
  130. .dialog-bottom{
  131. width: 100%;
  132. height: 44px;
  133. line-height: 44px;
  134. text-align: center;
  135. color: #fff !important;
  136. background-color: #00B760 !important;
  137. }
  138. }
  139. .upload-img{
  140. position: relative;
  141. width: 200rpx;
  142. height: 200rpx;
  143. border: 1px solid #f1f1f1;
  144. margin: 10rpx;
  145. }
  146. .upload-file{
  147. width: 200rpx;
  148. height: 200rpx;
  149. border: 1px solid #f1f1f1;
  150. margin: 10rpx;
  151. display: flex;
  152. justify-content: center;
  153. align-items: center;
  154. border-radius: 10rpx;
  155. }
  156. </style>