reportExternalDetail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <!-- 原项目丢了 省事直接cv一下老项目代码 -->
  2. <template>
  3. <div class="wrapper" ref="wrapper">
  4. <div id="reportdtl" v-if="isshow">
  5. <header>
  6. <p>{{reportInfo.OutsideReportBO.Title}}</p>
  7. </header>
  8. <div
  9. style="
  10. padding: 0rem 0.8rem;
  11. box-sizing: border-box;
  12. color: #666;
  13. font-size: 0.66rem;
  14. overflow: hidden;
  15. "
  16. >
  17. <span><!-- {{ reportInfo.OutsideReportBO.SysUserName }} --></span>
  18. <span style="float: right">{{ reportInfo.OutsideReportBO.CreateTime }}</span>
  19. </div>
  20. <div style="padding: 0.6rem; box-sizing: border-box; overflow: hidden">
  21. <div class="abstract_cont" v-if="reportInfo.OutsideReportBO.Abstract">摘要:{{reportInfo.OutsideReportBO.Abstract}}</div>
  22. <div id="resetcss" style="overflow:hidden;" v-html="reportInfo.OutsideReportBO.Content" v-if="reportInfo.OutsideReportBO.Content"></div>
  23. <div id="tipsAlert">
  24. <div
  25. style="
  26. width: 100%;
  27. max-width:1200px;
  28. margin:0 auto;
  29. padding: 0.8rem 0.66rem 2.2rem;
  30. box-sizing: border-box;
  31. font: 0.52rem/0.8rem 'PingFang-SC-Regular';
  32. color: #666;
  33. background: #fff;
  34. overflow: scroll;
  35. position: relative;
  36. border-radius: 0.2rem;
  37. "
  38. >
  39. <h1
  40. style="
  41. font: 0.64rem 'PingFang-SC-Regular';
  42. color: #333;
  43. text-align: center;
  44. margin-bottom: 0.34rem;
  45. "
  46. >
  47. 免责声明
  48. </h1>
  49. <div class="disclaimer" v-html="configInfo.Disclaimer"></div>
  50. <p
  51. @click="hideTips"
  52. style="
  53. position: absolute;
  54. bottom: 0;
  55. left: 0;
  56. right: 0;
  57. font-size: 0.56rem;
  58. line-height: 1.6rem;
  59. color: #2680eb;
  60. text-align: center;
  61. border-top: 1px solid #eaeaea;
  62. "
  63. >
  64. 知道了
  65. </p>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. <div style="width:30px; position:fixed; right:0.6rem; bottom:2.4rem; z-index:10000;">
  71. <img src="~@/assets/img/returntop.png" @click="goTop" style="width:30px; margin-bottom:0.2rem;" />
  72. </div>
  73. <FloatingPanel
  74. :content-draggable="false"
  75. v-if="attachmentsList.length"
  76. v-model:height="panelHeight"
  77. :anchors="configAnchors"
  78. >
  79. <div class="attachments-cont">
  80. <h3>
  81. <svg t="1725848947745" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5160" width="18" height="18"><path d="M607.934444 417.856853c-6.179746-6.1777-12.766768-11.746532-19.554358-16.910135l-0.01228 0.011256c-6.986111-6.719028-16.47216-10.857279-26.930349-10.857279-21.464871 0-38.864146 17.400299-38.864146 38.864146 0 9.497305 3.411703 18.196431 9.071609 24.947182l-0.001023 0c0.001023 0.001023 0.00307 0.00307 0.005117 0.004093 2.718925 3.242857 5.953595 6.03853 9.585309 8.251941 3.664459 3.021823 7.261381 5.997598 10.624988 9.361205l3.203972 3.204995c40.279379 40.229237 28.254507 109.539812-12.024871 149.820214L371.157763 796.383956c-40.278355 40.229237-105.761766 40.229237-146.042167 0l-3.229554-3.231601c-40.281425-40.278355-40.281425-105.809861 0-145.991002l75.93546-75.909877c9.742898-7.733125 15.997346-19.668968 15.997346-33.072233 0-23.312962-18.898419-42.211381-42.211381-42.211381-8.797363 0-16.963347 2.693342-23.725354 7.297197-0.021489-0.045025-0.044002-0.088004-0.066515-0.134053l-0.809435 0.757247c-2.989077 2.148943-5.691629 4.669346-8.025791 7.510044l-78.913281 73.841775c-74.178443 74.229608-74.178443 195.632609 0 269.758863l3.203972 3.202948c74.178443 74.127278 195.529255 74.127278 269.707698 0l171.829484-171.880649c74.076112-74.17435 80.357166-191.184297 6.282077-265.311575L607.934444 417.856853z" fill="#666666" p-id="5161"></path><path d="M855.61957 165.804257l-3.203972-3.203972c-74.17742-74.178443-195.528232-74.178443-269.706675 0L410.87944 334.479911c-74.178443 74.178443-78.263481 181.296089-4.085038 255.522628l3.152806 3.104711c3.368724 3.367701 6.865361 6.54302 10.434653 9.588379 2.583848 2.885723 5.618974 5.355985 8.992815 7.309476 0.025583 0.020466 0.052189 0.041956 0.077771 0.062422l0.011256-0.010233c5.377474 3.092431 11.608386 4.870938 18.257829 4.870938 20.263509 0 36.68962-16.428158 36.68962-36.68962 0-5.719258-1.309832-11.132548-3.645017-15.95846l0 0c-4.850471-10.891048-13.930267-17.521049-20.210297-23.802102l-3.15383-3.102664c-40.278355-40.278355-24.982998-98.79612 15.295358-139.074476l171.930791-171.830507c40.179095-40.280402 105.685018-40.280402 145.965419 0l3.206018 3.152806c40.279379 40.281425 40.279379 105.838513 0 146.06775l-75.686796 75.737962c-10.296507 7.628748-16.97358 19.865443-16.97358 33.662681 0 23.12365 18.745946 41.87062 41.87062 41.87062 8.048303 0 15.563464-2.275833 21.944801-6.211469 0.048095 0.081864 0.093121 0.157589 0.141216 0.240477l1.173732-1.083681c3.616364-2.421142 6.828522-5.393847 9.529027-8.792247l79.766718-73.603345C929.798013 361.334535 929.798013 239.981676 855.61957 165.804257z" fill="#666666" p-id="5162"></path></svg>
  82. 附件{{attachmentsList.length}}个({{formatSize(totalSize)}})
  83. </h3>
  84. <ul class="list-cont">
  85. <li class="item" v-for="(item,index) in attachmentsList" :key="index" @click="handlePreviewAttachment(item)">
  86. <img :src="getFileIcon(item.Title)" alt="" class="file-icon">
  87. <div class="right-info">
  88. <p class="file-title van-ellipsis">{{item.Title}}</p>
  89. <span style="color:#999">{{formatSize(item.FileSize)}}</span>
  90. </div>
  91. </li>
  92. </ul>
  93. </div>
  94. </FloatingPanel>
  95. </div>
  96. </template>
  97. <script>
  98. import {
  99. getExternalReport
  100. } from "@/api/api.js";
  101. import _ from 'lodash';
  102. import {wxShare} from '../utils/wxShare.js';
  103. import { FloatingPanel } from "vant"
  104. import { Watermark,BlindWatermark } from 'watermark-js-plus'
  105. import { Base64 } from 'js-base64';
  106. import PdfIcon from '@/assets/img/file/pdf_icon.png'
  107. import ExcelIcon from '@/assets/img/file/excel_icon.png'
  108. import ImgIcon from '@/assets/img/file/img_icon.png'
  109. import WordIcon from '@/assets/img/file/word_icon.png'
  110. export default {
  111. components: { FloatingPanel },
  112. computed: {
  113. totalSize() {
  114. let size = 0;
  115. if(this.attachmentsList.length) {
  116. this.attachmentsList.forEach(item => {
  117. size +=item.FileSize
  118. })
  119. }
  120. return size
  121. },
  122. },
  123. data() {
  124. return {
  125. id: this.$route.query.code || '',
  126. isshow: false,
  127. reportInfo: {},
  128. reportlist: [],
  129. totalContent: [],
  130. realContent: [],
  131. page_no: 0,
  132. pageSize: 50, //默认初始加载50个p标签
  133. total_page: 0,
  134. configInfo: {},
  135. attachmentsList: [],
  136. configAnchors: [
  137. 140,
  138. Math.round(0.7 * window.innerHeight),
  139. ],
  140. panelHeight: 140
  141. };
  142. },
  143. created() {
  144. wx.ready(function(){
  145. wx.hideOptionMenu();
  146. });
  147. },
  148. mounted() {
  149. this.getreportdetail()
  150. },
  151. updated() {
  152. $("#resetcss")
  153. .find("img")
  154. .css({ display: "block", margin: "0 auto", maxWidth: "100%",height:'auto' });
  155. $("#resetcss")
  156. .find("video")
  157. .css({ display: "block", margin: "0 auto", maxWidth: "100%" });
  158. $("#resetcss")
  159. .find("p")
  160. .css({
  161. margin: "0 auto 0",
  162. wordBreak: 'break-all'
  163. });
  164. $("#resetcss")
  165. .find("table")
  166. .css({
  167. width:'100%',
  168. tableLayout: 'fixed',
  169. overflow:'auto'
  170. });
  171. $("#resetcss")
  172. .find("pre")
  173. .css({ display: "block", whiteSpace: "pre-wrap" });
  174. },
  175. methods: {
  176. showTips() {
  177. //免责声明显示
  178. $("#tipsAlert").animate({ top: 0 });
  179. },
  180. hideTips() {
  181. //免责声明收起
  182. $("#tipsAlert").animate({ top: "-9999px" });
  183. },
  184. goTop() {
  185. document.body.scrollTop = document.documentElement.scrollTop = 0;
  186. },
  187. async getreportdetail() {
  188. const { Data,Ret } = await getExternalReport({ ReportCode: this.id });
  189. document.title=Data.Title || "研报"
  190. if (Ret !== 200) return
  191. this.reportInfo = Data;
  192. this.configInfo = {
  193. ...Data,
  194. Report:null
  195. };
  196. this.attachmentsList = Data.OutsideReportBO.AttachmentList || []
  197. this.isshow = true;
  198. wxShare(document.location.href,Data.H5ShareName,Data.OutsideReportBO.Title,Data.H5ReportShareImg,0);
  199. //水印
  200. localStorage.setItem('waterMarkStr',this.$route.query.flag||'')
  201. const temwaterMarkStr=this.$route.query.flag||localStorage.getItem('waterMarkStr')
  202. let waterMarkStr=Base64.decode(temwaterMarkStr)
  203. waterMarkStr=decodeURIComponent(waterMarkStr)
  204. this.$nextTick(()=>{
  205. if(Data.WatermarkReport==='true'){
  206. this.setWaterMark(waterMarkStr)
  207. }
  208. this.setBlindWaterMark(waterMarkStr)
  209. })
  210. },
  211. setWaterMark(str){
  212. const text=str||''
  213. const target=document.getElementById('resetcss')
  214. const canvas = document.createElement("canvas");
  215. const ctx = canvas.getContext("2d");
  216. ctx.font = "18px Arial";
  217. ctx.rotate((-45 * Math.PI) / 200);
  218. ctx.fillStyle='#f1f1f1'
  219. ctx.fillText(text, 30, 200);
  220. ctx.fillText(text, -40, 100);
  221. // 将canvas的内容转换为base64编码
  222. const data = canvas.toDataURL("image/png");
  223. target.style.background = "url(" + data + ") repeat";
  224. },
  225. // 设置水印
  226. setBlindWaterMark(str){
  227. const blindwatermark = new BlindWatermark({
  228. content: str||'',
  229. width: 200,
  230. height: 200,
  231. onSuccess: () => {
  232. // success callback
  233. }
  234. })
  235. blindwatermark.create()
  236. },
  237. handlePreviewAttachment(row) {
  238. // // 预览文件
  239. let href;
  240. if(row.Url.endsWith('.doc') || row.Url.endsWith('.docx')||row.Url.endsWith('.xlsx')){
  241. href = 'https://view.officeapps.live.com/op/view.aspx?src='+row.Url
  242. }else{
  243. href=row.Url
  244. }
  245. window.open(href, "_blank")
  246. },
  247. formatSize(size) {
  248. if (size >= 1024 * 1024) { // 超过1MB
  249. return (size / (1024 * 1024)).toFixed(2) + ' MB';
  250. } else if (size >= 1024) { // 超过1KB
  251. return (size / 1024).toFixed(2) + ' KB';
  252. } else {
  253. return size + ' B'; // 小于1KB
  254. }
  255. },
  256. getFileIcon(name){
  257. let fileUrl=name.toLocaleLowerCase()
  258. if(fileUrl.endsWith('.pdf')){
  259. return PdfIcon
  260. }else if(fileUrl.endsWith('.xlsx')){
  261. return ExcelIcon
  262. }else if(fileUrl.endsWith('.png') || fileUrl.endsWith('.jpg')){
  263. return ImgIcon
  264. }else if(fileUrl.endsWith('.doc') || fileUrl.endsWith('.docx')){
  265. return WordIcon
  266. }else{
  267. return ''
  268. }
  269. },
  270. },
  271. };
  272. </script>
  273. <style lang="scss">
  274. .wrapper {
  275. position: relative;
  276. overflow: hidden;
  277. height: 100%;
  278. font-size: 18px;
  279. #noaccess {
  280. width: 100%;
  281. height: 12rem;
  282. padding: 5rem 0.6rem 1rem;
  283. box-sizing: border-box;
  284. text-align: center;
  285. position: absolute;
  286. bottom: 0;
  287. background: url(~@/assets/img/accessbg.png) no-repeat;
  288. background-size: 100% auto;
  289. overflow: hidden;
  290. > a,
  291. button {
  292. width: 12rem;
  293. height: 2rem;
  294. background: url(~@/assets/img/newbtn600.png) no-repeat;
  295. background-size: 100% 100%;
  296. font-size: 0.48rem;
  297. color: #fff;
  298. border: none;
  299. margin-top: 1.5rem;
  300. }
  301. }
  302. }
  303. #reportdtl {
  304. background: #fff;
  305. overflow: auto;
  306. max-width: 1200px;
  307. margin: 0 auto 150px;
  308. position: relative;
  309. z-index: -1;
  310. header {
  311. padding: 0.6rem;
  312. box-sizing: border-box;
  313. text-align: left;
  314. background: #fff;
  315. display: flex;
  316. justify-content: space-between;
  317. p {
  318. font-size: 0.84rem;
  319. font-weight: 600;
  320. color: #000;
  321. }
  322. .logo {
  323. flex-shrink: 0;
  324. height: fit-content;
  325. }
  326. }
  327. .abstract_cont {
  328. padding:5px 20px;
  329. margin: 10px 0;
  330. position: relative;
  331. &::after {
  332. position: absolute;
  333. width: 5px;
  334. height: 100%;
  335. content: '';
  336. background:#007aff;
  337. top: 0;
  338. left: 0;
  339. }
  340. }
  341. #noaccess {
  342. width: 100%;
  343. height: 12rem;
  344. padding: 5rem 0.6rem 1rem;
  345. box-sizing: border-box;
  346. text-align: center;
  347. position: relative;
  348. top: -4rem;
  349. background: url(~@/assets/img/accessbg.png) no-repeat;
  350. background-size: 100% auto;
  351. margin-bottom: -4rem;
  352. overflow: hidden;
  353. > a,
  354. button {
  355. width: 12rem;
  356. height: 2rem;
  357. background: url(~@/assets/img/newbtn600.png) no-repeat;
  358. background-size: 100% 100%;
  359. font-size: 0.48rem;
  360. color: #fff;
  361. border: none;
  362. margin-top: 1.5rem;
  363. }
  364. }
  365. /* table {
  366. border-top: 1px solid #ccc;
  367. border-left: 1px solid #ccc;
  368. border-collapse: collapse;
  369. th,
  370. td {
  371. border-right: 1px solid #ccc;
  372. border-bottom: 1px solid #ccc;
  373. padding: 0.1rem 0.2rem;
  374. box-sizing: border-box;
  375. }
  376. } */
  377. #resetcss {
  378. pre {
  379. white-space: pre-wrap;
  380. }
  381. }
  382. #tipsAlert {
  383. width: 100%;
  384. height: 100%;
  385. padding: 15% 1rem;
  386. box-sizing: border-box;
  387. position: fixed;
  388. top: -9999px;
  389. left: 0;
  390. background: rgba(0, 0, 0, 0.6);
  391. z-index: 200;
  392. .disclaimer{
  393. font-size: 0.58rem;
  394. }
  395. }
  396. }
  397. .van-floating-panel {
  398. box-shadow: 0 -4px 8px rgba($color: #000000, $alpha: 0.2);
  399. }
  400. .attachments-cont {
  401. padding: 10px 15px;
  402. .list-cont {
  403. margin-top: 15px;
  404. font-size: 14px;
  405. display: flex;
  406. align-items: center;
  407. flex-wrap: wrap;
  408. gap:10px;
  409. .item{
  410. width: 100%;
  411. max-width: 500px;
  412. display: flex;
  413. border: 1px solid #dcdcdc;
  414. padding: 4px 12px;
  415. border-radius: 4px;
  416. overflow: hidden;
  417. .right-info {
  418. margin-left: 10px;
  419. flex: 1;
  420. }
  421. .file-icon {
  422. width: 45px;
  423. height: 45px;
  424. }
  425. .file-title {
  426. max-width: 80%;
  427. }
  428. }
  429. }
  430. }
  431. @media screen and (max-width:650px) {
  432. #resetcss table {
  433. p,span {
  434. font-size: 10px !important;
  435. }
  436. }
  437. .attachments-cont {
  438. .list-cont .item{
  439. /* max-width: 100%; */
  440. }
  441. }
  442. }
  443. </style>