expenses.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <!--
  2. * @Description:
  3. * @Author: 欧阳承珺
  4. * @LastEditors: 欧阳承珺
  5. * @Date: 2022-11-01 19:27:42
  6. * @LastEditTime: 2022-11-17 09:31:51
  7. -->
  8. <template>
  9. <div>
  10. <div class="expenses-date-tips flex content-center py-6px min-w-700px">
  11. <img src="http://cn-file.17pdf.com/website/common/ic_notice.svg" class="align-middle">
  12. <div class="text-container" ref="wrap">
  13. <span class="text">
  14. 转档后的文件支持在云端保留24小时,<span v-if="userInfo?.subscriberType === 1">会员尊享5G容量,</span>请在24小时内下载文件至本地永久保存
  15. </span>
  16. <span v-if="userInfo?.subscriberType === 1" class="vip tip">
  17. <img src="http://cn-file.17pdf.com/website/common/ic_info.svg" alt="">
  18. <div class="tip-text">
  19. 若已有文件大小超出5G,将按转档时间计算(从最近一次转档往过去推算),即保留最近的5G容量文件,超出部分文件将不再保留
  20. </div>
  21. </span>
  22. </div>
  23. </div>
  24. <div class="py-15px">
  25. <p class="text-[20px] leading-28px text-[#333]">我的转档</p>
  26. <div class="mt-10px mb-16px">
  27. <button class="btn btn-download" :disabled="isDownload" @click="downloadFiles">下载</button>
  28. <button class="btn btn-delete" :disabled="isDelete" @click="showDelate">删除</button>
  29. </div>
  30. </div>
  31. <client-only>
  32. <el-table :data="tableData" @selection-change="handleSelectionChange" stripe="true">
  33. <el-table-column type="selection" width="50" align="center"></el-table-column>
  34. <el-table-column prop="format" label="格式转换" class-name="style-change"></el-table-column>
  35. <el-table-column prop="outFilename" label="目标文件" show-overflow-tooltip filter-placement="bottom">
  36. <!-- <el-table-column prop="outFilename" label="目标文件"> -->
  37. <template slot-scope="scope">
  38. <span v-html="scope.row.outFilename"></span>
  39. </template>
  40. </el-table-column>
  41. <el-table-column prop="convertSize" label="文件大小" align="center">
  42. <template slot-scope="scope">
  43. <span v-html="scope.row.convertSize"></span>
  44. </template>
  45. </el-table-column>
  46. <el-table-column prop="price" label="消耗券数" align="center">
  47. <template slot-scope="scope">
  48. <span v-html="scope.row.price"></span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column prop="status" label="状态" width="120px" align="center">
  52. <template slot-scope="scope">
  53. <div class="bottom">
  54. <el-tooltip class="item" effect="dark" placement="bottom">
  55. <div slot="content">
  56. {{'转换时间: ' +scope.row.createdAt}}
  57. <br/>
  58. <div v-if="scope.row.failReason">
  59. {{scope.row.failReason}}
  60. </div>
  61. </div>
  62. <span v-html="scope.row.status" class="cursor-default"></span>
  63. </el-tooltip>
  64. </div>
  65. </template>
  66. </el-table-column>
  67. <el-table-column prop="path" label="" width="50px">
  68. <template slot-scope="scope">
  69. <a v-if="scope.row.path" :href="scope.row.path" class="downloadBtn"></a>
  70. </template>
  71. </el-table-column>
  72. <!-- 表格无数据显示 -->
  73. <div slot="empty">
  74. <div class="table-empty"></div>
  75. <p class="text-14px" style="color:rgba(0,0,0,0.54)">没有任何消费记录</p>
  76. <p class="leading-20px mt-8px mb-100px text-14px" style="color:rgba(0,0,0,0.38)">每一分钱都花在了刀刃上</p>
  77. </div>
  78. </el-table>
  79. <div v-show="totalNum>25">
  80. <el-pagination
  81. class="text-center mt-50px"
  82. background
  83. layout="prev, pager, next"
  84. :total="totalNum"
  85. :page-size="25"
  86. @current-change="handleCurrentChange">
  87. </el-pagination>
  88. </div>
  89. <el-dialog :visible.sync="ifSureDelate" width="384px" append-to-body center top = "35vh" >
  90. <div class="mt-[-20px]">
  91. <div class="text-[18px] leading-22px font-medium text-[#000000e6]">您确认要删除选中文档么?</div>
  92. <div class="text-[14px] leading-[18px] text-[#00000099] mt-20px">该转换文档将永久删除,删除后将无法找回</div>
  93. <div class="flex mt-20px flex-row-reverse">
  94. <button class="block w-64px h-32px text-[12px] text-[#fff] bg-[#FF4F4F] leading-16px ml-20px mt-10px text-center border border-[#FF4F4F] border-solid rounded-4px" @click="deleteChangeFileRecord">删除</button>
  95. <button class="block w-64px h-32px text-[12px] text-[#FF4F4F] leading-16px ml-0px mt-10px text-center border border-[#FF4F4F] border-solid rounded-4px" @click="showDelate">取消</button>
  96. </div>
  97. </div>
  98. </el-dialog>
  99. </client-only>
  100. </div>
  101. </template>
  102. <script>
  103. import { mapState } from 'vuex'
  104. export default {
  105. layout: 'userCenter',
  106. middleware: ['auth','user'],
  107. data() {
  108. return {
  109. tableData:[],
  110. tableDataSelection: [],
  111. totalNum: 0,
  112. isDownload: true,
  113. isDelete: true,
  114. ifSureDelate: false
  115. }
  116. },
  117. head() {
  118. return {
  119. title: '17PDF Reader - 个人中心',
  120. meta: [
  121. {
  122. name: 'keywords',
  123. content: 'PDFReader,pdfreader,17PDF Reader,pdf软件,PDF阅读器,文件扫描'
  124. },
  125. {
  126. hid: 'description',
  127. content: '17PDF Reader是行走的PDF阅读器和文件扫描仪,并提供免费的PDF文件格式转换工具,支持pdf转word,pdf转doc,pdf转ppt,pdf转图片等。17PDF Reader被用户誉为“亚洲的Adobe”,拥有自主产权的PDF核心技术,为商务精英、教育族群及企业提供全方位的PDF文件解决方案。'
  128. },
  129. ]
  130. }
  131. },
  132. computed: {
  133. ...mapState([
  134. 'userInfo',
  135. ]),
  136. },
  137. mounted () {
  138. this.getChangeFileRecord(1)
  139. },
  140. methods: {
  141. // 用户转档记录分页查询
  142. getChangeFileRecord (page) {
  143. this.$axios.get(`/missionFile/page?page=${page}`).then((res) => {
  144. if(res.code === 200) {
  145. this.tableData = res.result.list
  146. this.totalNum = res.result.total
  147. for (let i = 0; i < this.tableData.length; i++) {
  148. this.$set(this.tableData[i], 'format', this.getFormat(this.tableData[i].inputType, this.tableData[i].outputType))
  149. this.tableData[i].outFilename = this.getFileFileName(this.tableData[i].outFilename,this.tableData[i].statusName,this.tableData[i])
  150. this.tableData[i].convertSize = this.getfilesize(this.tableData[i].convertSize,this.tableData[i].status)
  151. this.tableData[i].price = this.getfilePrice(this.tableData[i].price,this.tableData[i].status)
  152. this.tableData[i].status = this.getFileStatus(this.tableData[i].status)
  153. }
  154. }
  155. })
  156. },
  157. // 计算文件大小函数(保留两位小数),Size为字节大小
  158. getfilesize (convertSize,status) {
  159. if(status=== 3){
  160. return `<span style="color: #9599b1">0KB</span>`
  161. }
  162. if (!convertSize) {
  163. return "0KB"
  164. }
  165. const num = 1024.00 // byte
  166. if (convertSize < num) {
  167. return convertSize + "B"
  168. }
  169. if (convertSize < Math.pow(num, 2)) {
  170. return (convertSize / num).toFixed(2) + "KB"
  171. }
  172. if (convertSize < Math.pow(num, 3)) {
  173. return (convertSize / Math.pow(num, 2)).toFixed(2) + "MB"
  174. }
  175. if (convertSize < Math.pow(num, 4)) {
  176. return (convertSize / Math.pow(num, 3)).toFixed(2) + "GB"
  177. }
  178. else {
  179. return (convertSize / Math.pow(num, 4)).toFixed(2) + "TB"
  180. }
  181. },
  182. //计算文件消耗劵
  183. getfilePrice(price,status){
  184. if(status=== 3){
  185. return `<span style="color: #9599b1">0</span>`
  186. }
  187. return price
  188. },
  189. // 判断文件状态
  190. getFileStatus (status) {
  191. switch (status) {
  192. case 0:
  193. return '转档中'
  194. case 1:
  195. return '转档中'
  196. case 2:
  197. return '<span style="color: #0dd299">转档成功</span>'
  198. case 3:
  199. return '<span style="color: gray">转档失败</span>'
  200. case 4:
  201. return '<span style="color: #0dd299">转档成功</span>'
  202. }
  203. },
  204. //文件转换失败,文件置灰
  205. getFileFileName(outFilename,statusName,item){
  206. let name = item.fileName
  207. let num= name.lastIndexOf(".")
  208. let output = ""
  209. if(item.outputType === "png" || item.outputType === "jpg"){
  210. output = "zip"
  211. }else {
  212. output = item.outputType
  213. }
  214. const outFilenames = name.slice(0,num)+"."+output
  215. if(outFilename){
  216. if(statusName === "failed"){
  217. return `<span style="color: #9599b1" class="style-ellipsis">${outFilename}</span>`
  218. } else {
  219. return `<span style="color: #333" class="style-ellipsis">${outFilename}</span>`
  220. }
  221. }else{
  222. return `<span style="color: #9599b1" class="style-ellipsis">${outFilenames}</span>`
  223. }
  224. },
  225. // 格式转换
  226. getFormat (input, output) {
  227. return input.toUpperCase() + '-->' + output.toUpperCase()
  228. },
  229. // 选中的数据行
  230. handleSelectionChange(val) {
  231. this.tableDataSelection = val
  232. if (this.tableDataSelection.length === 0) {
  233. this.isDownload = true
  234. this.isDelete = true
  235. } else {
  236. this.isDelete = false
  237. }
  238. for (const file of this.tableDataSelection) {
  239. if (file.status === '<span style="color: #0dd299">转档成功</span>') {
  240. this.isDownload = false
  241. return
  242. } else {
  243. this.isDownload = true
  244. }
  245. }
  246. },
  247. // 删除转档记录
  248. deleteChangeFileRecord () {
  249. const data = new FormData()
  250. for (const file of this.tableDataSelection) {
  251. data.append('ids', file.id)
  252. }
  253. const config = {
  254. headers: {
  255. 'Content-Type': 'multipart/form-data;'
  256. }
  257. }
  258. this.$axios.post('/missionFile/delete', data, config).then((res) => {
  259. if(res.code === 200) {
  260. this.getChangeFileRecord(1)
  261. this.isDelete = true
  262. this.ifSureDelate = false
  263. }
  264. })
  265. },
  266. // 分页器
  267. handleCurrentChange(val) {
  268. this.getChangeFileRecord(val)
  269. window.scrollTo(0, 0)
  270. },
  271. // 下载文件
  272. downloadFiles () {
  273. // for (const file of this.tableDataSelection) {
  274. // if (file.status !== 2 || file.status !== 4) {
  275. // this.isDownload = true
  276. // }
  277. // }
  278. this.tableDataSelection.forEach(item => {
  279. this.downloadFile(item.path)
  280. })
  281. },
  282. downloadFile (url) {
  283. const iframe = document.createElement("iframe");
  284. iframe.style.display = "none"; // 防止影响页面
  285. iframe.style.height = 0; // 防止影响页面
  286. iframe.src = url;
  287. document.body.appendChild(iframe);
  288. setTimeout(()=>{
  289. iframe.remove();
  290. }, 5 * 60 * 1000);
  291. },
  292. //展示删除框
  293. showDelate(){
  294. this.ifSureDelate = !this.ifSureDelate
  295. }
  296. }
  297. }
  298. </script>
  299. <style lang="scss" scoped>
  300. .expenses-date-tips {
  301. display: flex;
  302. align-items: center;
  303. padding: 12px;
  304. background: linear-gradient(90deg, #FFFAFA 10.37%, rgba(255, 243, 243, 0) 91.75%), linear-gradient(90deg, #FFF2F6 2.26%, rgba(255, 242, 246, 0.21) 101.41%);
  305. border: 1px solid rgba(255, 79, 79, 0.2);
  306. border-radius: 12px;
  307. .text-container {
  308. display: flex;
  309. align-items: center;
  310. margin-left: 16px;
  311. img {
  312. margin-left: 8px;
  313. }
  314. }
  315. span {
  316. font-size: 14px;
  317. line-height: 24px;
  318. vertical-align: middle;
  319. }
  320. .text {
  321. display: inline-flex;
  322. align-items: center;
  323. }
  324. .tip {
  325. position: relative;
  326. font-size: 0;
  327. .tip-text {
  328. display: none;
  329. position: absolute;
  330. left: -3px;
  331. width: 258px;
  332. padding: 15px 14px 10px 10px;
  333. background: url('http://cn-file.17pdf.com/website/members/ic_tip.svg') left top no-repeat;
  334. background-size: auto 100%;
  335. font-size: 12px;
  336. line-height: 18px;
  337. color: #fff;
  338. border-radius: 4px;
  339. }
  340. &:hover .tip-text {
  341. display: block;
  342. }
  343. }
  344. }
  345. .btn {
  346. height: 30px;
  347. line-height: 28px;
  348. font-size: 12px;
  349. border-radius: 2px;
  350. display: inline-block;
  351. padding: 0px 9px 0px 33px;
  352. &-download {
  353. color: #fff;
  354. background: #FF4F4F url(http://cn-file.17pdf.com/website/members/ic_download.svg) no-repeat 8px center;
  355. margin-right: 7px;
  356. &_disabled {
  357. background-color: #FFA7A7;
  358. }
  359. }
  360. &-delete {
  361. border: 1px solid #d8d8d9;
  362. color: #666;
  363. background: url(http://cn-file.17pdf.com/website/members/ic_delete_normal.png) no-repeat 8px 5px;
  364. &_disabled {
  365. color: #ccc;
  366. border-color: #ccc;
  367. }
  368. }
  369. }
  370. ::v-deep .el-table {
  371. th {
  372. background-color: #f4f4f4 !important;
  373. font-size: 16px;
  374. color: #666666;
  375. font-weight: normal;
  376. }
  377. .style-change{
  378. color: #333;
  379. }
  380. .style-ellipsis{
  381. width:100%;
  382. display: inline-block;
  383. white-space: nowrap!important;
  384. overflow:hidden;
  385. text-overflow:ellipsis;
  386. }
  387. .cell{
  388. white-space: nowrap;
  389. }
  390. }
  391. .table-empty {
  392. margin-top: 50px;
  393. height: 200px;
  394. background: url(http://cn-file.17pdf.com/website/members/pic_noconsumption.png) no-repeat center center;
  395. }
  396. .el-table__row:hover .downloadBtn {
  397. display: inline-block;
  398. width: 13px;
  399. height: 13px;
  400. background: url(http://cn-file.17pdf.com/website/members/ic_download_gray.svg) center no-repeat;
  401. }
  402. .btn-download:disabled,.btn-delete:disabled {
  403. opacity: 0.5;
  404. pointer-events: none;
  405. }
  406. ::v-deep .el-table__header,
  407. ::v-deep .el-table__body,
  408. ::v-deep .el-table__footer {
  409. // 使表格兼容safari,不错位
  410. // width: 100%;
  411. table-layout: fixed !important;
  412. }
  413. //兼容Safari,el-tooltip不出现蓝框
  414. ::v-deep .el-tooltip:focus:hover,
  415. ::v-deep .el-tooltip:focus:not(.focusing){
  416. outline:none;
  417. -webkit-tap-highlight-color:rgba(0,0,0,0);
  418. }
  419. </style>