honorDetail.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <view class="page_body">
  3. <!-- 头部 -->
  4. <nav-bar height="96" :title="state.honorName" :onlyTitle="true" :showHeaderborder="true" @GoBack="GoBack"></nav-bar>
  5. <view class="page_content">
  6. <view class="row_item">
  7. <view class="row_label">荣誉类型:</view>
  8. <view class="row_value">{{state.detail?.honorTypeName}}</view>
  9. </view>
  10. <view class="row_item" v-for="item in (state.detail?.honorDataList || [])" :key="item.id">
  11. <view class="row_label">{{item?.honorDictLibName ?? ''}}:</view>
  12. <view class="row_value">{{item?.honorDictLibValue ?? ''}}</view>
  13. </view>
  14. <view class="row_item">
  15. <view class="row_label">荣誉证书:</view>
  16. <view class="row_value img_list">
  17. <!-- <view class="img_item" v-for="item in (state.detail?.honorDataCertList || [])" :key="item.id">
  18. <image class="pic" mode="aspectFit" :src="item.picUrl"></image>
  19. </view> -->
  20. <uv-upload :maxCount="state.detail?.honorDataCertList?.length || 0" :deletable="false" :fileList="state.detail?.honorDataCertList" width="240rpx" height="140rpx" multiple :previewFullImage="true">
  21. </uv-upload>
  22. </view>
  23. </view>
  24. <view class="row_item">
  25. <view class="row_label">佐证材料:</view>
  26. <view class="row_value document_list">
  27. <view class="document_item" v-for="item in (state.detail?.supportDocumentList || [])" :key="item.id">
  28. <image class="file" src="@/static/image/icon/file.png"></image>
  29. <view class="file_name">
  30. <view class="name">{{item.documentName}}</view>
  31. <view class="file_size_date">
  32. <view class="file_size">{{item.fileSize}}</view>
  33. <view class="file_date">{{item.createdAt}}</view>
  34. </view>
  35. </view>
  36. <!-- #ifdef APP-PLUS -->
  37. <!-- app端处理 -->
  38. <template v-if="['word','excel','pdf','txt'].includes(getFileTypeBySuffix(item?.fileNameSuffix || ''))">
  39. <cjx-previewOffice :value="item.documentUrl" :name="item.documentName" :type="getFileTypeBySuffix(item?.fileNameSuffix || '')">
  40. <view class="preview_btn" @click="OpenPreviewFileDialog(item)">预览</view>
  41. </cjx-previewOffice>
  42. </template>
  43. <view v-else class="preview_btn" @click="OpenPreviewFileDialog(item)">预览</view>
  44. <!-- #endif -->
  45. <!-- #ifndef APP-PLUS -->
  46. <!-- 不包含app端 -->
  47. <view class="preview_btn" @click="OpenPreviewFileDialog(item)">预览</view>
  48. <!-- #endif -->
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 图片 视频预览 -->
  55. <popupPreviewFile ref="imgVideoPreview" :fileType="state.previewPopup.fileType" :fileName="state.previewPopup.fileName" :filePath="state.previewPopup.filePath" @ToDownloadFile="ToDownloadFile"></popupPreviewFile>
  56. <!-- 默认指H5端 此插件只支持h5 PDF、Word、Excel、PPTX、TXT预览-->
  57. <!-- #ifdef H5 -->
  58. <wg-h5-preview-file ref="webPreviewFile" />
  59. <!-- #endif -->
  60. <!-- 文件、图片下载 -->
  61. <ss-download ref="ssdownload"></ss-download>
  62. </template>
  63. <script setup>
  64. import navBar from '@/components/navBar.vue';
  65. import uvUpload from '@/uni_modules/uv-upload/components/uv-upload/uv-upload.vue';
  66. import ssDownload from '@/uni_modules/ss-download/components/ss-download/ss-download.vue';
  67. import popupPreviewFile from '@/components/popupPreviewFile.vue';//图片 音视频 zip等预览
  68. // #ifdef H5
  69. import wgH5PreviewFile from '@/components/wg-h5-preview-file/wg-h5-preview-file.vue';//web端文件预览 'word','excel','pptx','pdf','txt'
  70. // #endif
  71. // #ifdef APP-PLUS
  72. import cjxPreviewOffice from '@/uni_modules/cjx-previewOffice/components/cjx-previewOffice/cjx-previewOffice.vue';//APP端文件预览 'word','excel','pdf','txt'
  73. // #endif
  74. import {queryHonorTeacherDetail} from '@/reqApi/teacherHonor.js';
  75. import { getFileTypeBySuffix } from '@/common/common.js';
  76. import {
  77. reactive,
  78. ref,
  79. nextTick
  80. } from 'vue';
  81. import { onLoad } from '@dcloudio/uni-app';
  82. const state = reactive({
  83. id:'',//id
  84. honorName:'',
  85. loading:false,
  86. detail:{},
  87. previewPopup:{//文件预览弹框
  88. fileType:'',
  89. filePath:'',
  90. fileName:''
  91. }
  92. })
  93. const popupDelDialogRef = ref(null);
  94. const ssdownload = ref(null);
  95. const imgVideoPreview = ref(null);//图片 视频
  96. const webPreviewFile = ref(null);//web端文件预览
  97. const appPreviewOfficeRef = ref(null);//APP端文件预览
  98. onLoad((option) => {
  99. state.id = option.id;
  100. state.honorName = decodeURIComponent(option.honorName);
  101. GetHonorTeacherDetail();
  102. })
  103. //查询荣誉审核资质信息详情数据接口
  104. const GetHonorTeacherDetail = () => {
  105. queryHonorTeacherDetail(state.id).then(res=>{
  106. if(res.code == 200){
  107. const resdata = res.data || null;
  108. const honorDataCertList = resdata?.honorDataCertList || [];
  109. resdata.honorDataCertList = honorDataCertList.map(item=>({
  110. ...item,
  111. url:item.picUrl
  112. }))
  113. const supportDocumentList = resdata?.supportDocumentList || [];
  114. resdata.supportDocumentList = supportDocumentList.map(item=>{
  115. const fileNameSuffix = GetFileNameSuffix(item.documentName);
  116. return{
  117. ...item,
  118. fileNameSuffix
  119. }
  120. })
  121. state.detail = resdata;
  122. }
  123. })
  124. }
  125. //获取文件后缀名称
  126. const GetFileNameSuffix = (documentName) => {
  127. const documentNameArr = documentName?.split('.') || [];
  128. const lens = documentNameArr.length;
  129. const fileNameSuffix = lens?documentNameArr[lens - 1]:'';
  130. return fileNameSuffix
  131. }
  132. //预览
  133. const OpenPreviewFileDialog = (item) => {
  134. const fileType = getFileTypeBySuffix(item.fileNameSuffix);
  135. state.previewPopup.fileType = fileType?fileType:item.fileNameSuffix;
  136. state.previewPopup.filePath = item.documentUrl;
  137. state.previewPopup.fileName = item.documentName;
  138. if(['word','excel','pptx','pdf','txt'].includes(fileType)){
  139. // #ifdef H5
  140. nextTick(()=>{//h5文件预览
  141. webPreviewFile.value && webPreviewFile.value.preview({
  142. url: item.documentUrl,
  143. type: fileType
  144. });
  145. })
  146. // #endif
  147. // #ifdef APP-PLUS
  148. if(fileType == 'pptx'){
  149. imgVideoPreview.value.OpenDialog();
  150. }
  151. // #endif
  152. }else{
  153. imgVideoPreview.value.OpenDialog();
  154. }
  155. }
  156. //下载
  157. const ToDownloadFile = (item) => {
  158. const fileType = getFileTypeBySuffix(item.fileType);//文件类型
  159. let type = '';
  160. if(fileType == 'image'){
  161. type = '1';//1:图片 2 文档
  162. }else if(['word','excel','pptx','pdf','txt'].includes(fileType)){
  163. type = '2';
  164. }else if(fileType == 'video'){
  165. type = '3';
  166. }else {
  167. type = '';
  168. }
  169. ssdownload?.value?.toDownload({
  170. type:type,
  171. src:item.filePath,
  172. fileName:item.fileName
  173. });
  174. }
  175. const GoBack = () => {
  176. uni.navigateBack({
  177. delta: 1
  178. });
  179. }
  180. </script>
  181. <style lang="scss" scoped>
  182. .page_body{
  183. height: 100%;
  184. min-height: auto;
  185. }
  186. .page_content{
  187. height: calc(100% - 96rpx);
  188. flex-direction: column;
  189. flex-wrap: initial;
  190. overflow: auto;
  191. .row_item{
  192. display: flex;
  193. width: 100%;
  194. padding: 32rpx 0;
  195. border-bottom: 2rpx solid #F3F3F3;
  196. .row_label{
  197. font-weight: 400;
  198. font-size: 28rpx;
  199. color: #666666;
  200. flex-shrink: 0;
  201. margin-right: 10rpx;
  202. }
  203. .row_value{
  204. flex: 1;
  205. font-weight: 400;
  206. font-size: 28rpx;
  207. color: #333333;
  208. text-align: right;
  209. display: flex;
  210. justify-content: flex-end;
  211. word-break: break-all;
  212. flex-wrap: wrap;
  213. &.img_list{
  214. gap: 32rpx 24rpx;
  215. .img_item{
  216. width: 240rpx;
  217. height: 140rpx;
  218. background-color: #FFFFFF;
  219. border-radius: 12rpx;
  220. border: 2rpx solid #CED1D8;
  221. display: inline-flex;
  222. align-items: center;
  223. justify-content: center;
  224. .pic{
  225. width: 240rpx;
  226. height: 140rpx;
  227. }
  228. }
  229. }
  230. &.document_list{
  231. gap: 24rpx;
  232. .document_item{
  233. width: 100%;
  234. padding: 20rpx 0 18rpx 15rpx;
  235. display: flex;
  236. background-color: #FFFFFF;
  237. border-radius: 20rpx;
  238. border: 2rpx solid #EBEEF5;
  239. .file{
  240. width: 80rpx;
  241. height: 80rpx;
  242. margin-right: 16rpx;
  243. flex-shrink: 0;
  244. }
  245. .file_name{
  246. flex: 1;
  247. display: flex;
  248. flex-direction: column;
  249. .name{
  250. font-weight: 500;
  251. font-size: 28rpx;
  252. text-align: left;
  253. color: #333333;
  254. }
  255. .file_size_date{
  256. display: flex;
  257. width: 100%;
  258. text-align: left;
  259. font-weight: 400;
  260. font-size: 24rpx;
  261. color: #999999;
  262. margin-top: 8rpx;
  263. gap: 20rpx;
  264. .file_size{
  265. white-space: nowrap;
  266. }
  267. .file_date{
  268. white-space: nowrap;
  269. }
  270. }
  271. }
  272. :deep(.container){
  273. width: auto;
  274. .file_content{
  275. width: auto;
  276. }
  277. }
  278. .preview_btn{
  279. width: 96rpx;
  280. box-sizing: border-box;
  281. text-align: left;
  282. font-weight: 400;
  283. font-size: 28rpx;
  284. color: #2E64FA;
  285. padding:20rpx 0 0 16rpx;
  286. }
  287. }
  288. }
  289. }
  290. }
  291. }
  292. </style>