expenses.vue 13 KB

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