expenses.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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"></el-table-column>
  34. <el-table-column prop="format" label="格式转换" class-name="style-change"></el-table-column>
  35. <el-table-column prop="outFilename" label="目标文件" class-name="style-ellipsis">
  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">转换文档将永久从 17PDF 删除,且此操作无法恢复</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. created () {
  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. if(status=== 3){
  169. return `<span style="color: #9599b1">0B</span>`
  170. }
  171. return size + "B"
  172. }
  173. if (size < Math.pow(num, 2)) {
  174. return (size / num).toFixed(2) + "KB"
  175. }
  176. if (size < Math.pow(num, 3)) {
  177. return (size / Math.pow(num, 2)).toFixed(2) + "MB"
  178. }
  179. if (size < Math.pow(num, 4)) {
  180. return (size / Math.pow(num, 3)).toFixed(2) + "GB"
  181. }
  182. else {
  183. return (size / Math.pow(num, 4)).toFixed(2) + "TB"
  184. }
  185. },
  186. //计算文件消耗劵
  187. getfilePrice(price,status){
  188. if(status=== 3){
  189. return `<span style="color: #9599b1">0</span>`
  190. }
  191. return price
  192. },
  193. // 判断文件状态
  194. getFileStatus (status) {
  195. switch (status) {
  196. case 0:
  197. return '转档中'
  198. case 1:
  199. return '转档中'
  200. case 2:
  201. return '<span style="color: #0dd299">转档成功</span>'
  202. case 3:
  203. return '<span style="color: gray">转档失败</span>'
  204. case 4:
  205. return '<span style="color: #0dd299">转档成功</span>'
  206. }
  207. },
  208. //文件转换失败,文件置灰
  209. getFileFileName(outFilename,statusName,item){
  210. let name = item.fileName
  211. let num= name.lastIndexOf(".")
  212. const outFilenames = name.slice(0,num)+"."+item.outputType
  213. if(outFilename){
  214. if(statusName === "failed"){
  215. return `<span style="color: #9599b1" title="${outFilename}" class="style-ellipsis">${outFilename}</span>`
  216. } else {
  217. return `<span style="color: #333" title="${outFilename}" class="style-ellipsis">${outFilename}</span>`
  218. }
  219. }else{
  220. return `<span style="color: #9599b1" title="${outFilenames}" class="style-ellipsis">${outFilenames}</span>`
  221. }
  222. },
  223. // 格式转换
  224. getFormat (input, output) {
  225. return input.toUpperCase() + '-->' + output.toUpperCase()
  226. },
  227. // 选中的数据行
  228. handleSelectionChange(val) {
  229. this.tableDataSelection = val
  230. if (this.tableDataSelection.length === 0) {
  231. this.isDownload = true
  232. this.isDelete = true
  233. } else {
  234. this.isDelete = false
  235. }
  236. for (const file of this.tableDataSelection) {
  237. if (file.status === '转档中' || file.status === '<span style=\"color: gray\">转档失败</span>') {
  238. this.isDownload = true
  239. } else {
  240. this.isDownload = false
  241. }
  242. }
  243. },
  244. // 删除转档记录
  245. deleteChangeFileRecord () {
  246. const data = new FormData()
  247. for (const file of this.tableDataSelection) {
  248. data.append('ids', file.id)
  249. }
  250. const config = {
  251. headers: {
  252. 'Content-Type': 'multipart/form-data;'
  253. }
  254. }
  255. this.$axios.post('/missionFile/delete', data, config).then((res) => {
  256. if(res.code === 200) {
  257. this.getChangeFileRecord(1)
  258. this.isDelete = true
  259. this.ifSureDelate = false
  260. }
  261. })
  262. },
  263. // 分页器
  264. handleCurrentChange(val) {
  265. this.getChangeFileRecord(val)
  266. window.scrollTo(0, 0)
  267. },
  268. // 下载文件
  269. downloadFiles () {
  270. // for (const file of this.tableDataSelection) {
  271. // if (file.status !== 2 || file.status !== 4) {
  272. // this.isDownload = true
  273. // }
  274. // }
  275. this.tableDataSelection.forEach(item => {
  276. this.downloadFile(item.path)
  277. })
  278. },
  279. downloadFile (url) {
  280. const iframe = document.createElement("iframe");
  281. iframe.style.display = "none"; // 防止影响页面
  282. iframe.style.height = 0; // 防止影响页面
  283. iframe.src = url;
  284. document.body.appendChild(iframe);
  285. setTimeout(()=>{
  286. iframe.remove();
  287. }, 5 * 60 * 1000);
  288. },
  289. //展示删除框
  290. showDelate(){
  291. this.ifSureDelate = !this.ifSureDelate
  292. }
  293. }
  294. }
  295. </script>
  296. <style lang="scss" scoped>
  297. .expenses-date-tips {
  298. display: flex;
  299. align-items: center;
  300. padding: 12px;
  301. 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%);
  302. border: 1px solid rgba(255, 79, 79, 0.2);
  303. border-radius: 12px;
  304. .text-container {
  305. display: flex;
  306. align-items: center;
  307. margin-left: 16px;
  308. img {
  309. margin-left: 8px;
  310. }
  311. }
  312. span {
  313. font-size: 14px;
  314. line-height: 24px;
  315. vertical-align: middle;
  316. }
  317. .text {
  318. display: inline-flex;
  319. align-items: center;
  320. }
  321. .tip {
  322. position: relative;
  323. font-size: 0;
  324. .tip-text {
  325. display: none;
  326. position: absolute;
  327. left: -3px;
  328. width: 258px;
  329. padding: 15px 14px 10px 10px;
  330. background: url('http://cn-file.17pdf.com/website/members/ic_tip.svg') left top no-repeat;
  331. background-size: auto 100%;
  332. font-size: 12px;
  333. line-height: 18px;
  334. color: #fff;
  335. border-radius: 4px;
  336. }
  337. &:hover .tip-text {
  338. display: block;
  339. }
  340. }
  341. }
  342. .btn {
  343. height: 30px;
  344. line-height: 28px;
  345. font-size: 12px;
  346. border-radius: 2px;
  347. display: inline-block;
  348. padding: 0px 9px 0px 33px;
  349. &-download {
  350. color: #fff;
  351. background: #FF4F4F url(http://cn-file.17pdf.com/website/members/ic_download.svg) no-repeat 8px center;
  352. margin-right: 7px;
  353. &_disabled {
  354. background-color: #FFA7A7;
  355. }
  356. }
  357. &-delete {
  358. border: 1px solid #d8d8d9;
  359. color: #666;
  360. background: url(http://cn-file.17pdf.com/website/members/ic_delete_normal.png) no-repeat 8px 5px;
  361. &_disabled {
  362. color: #ccc;
  363. border-color: #ccc;
  364. }
  365. }
  366. }
  367. ::v-deep .el-table {
  368. th {
  369. background-color: #f4f4f4 !important;
  370. font-size: 16px;
  371. color: #666666;
  372. font-weight: normal;
  373. }
  374. .style-change{
  375. color: #333;
  376. }
  377. .style-ellipsis{
  378. width:100%;
  379. white-space:nowrap;
  380. overflow:hidden;
  381. text-overflow:ellipsis;
  382. }
  383. }
  384. .table-empty {
  385. margin-top: 50px;
  386. height: 200px;
  387. background: url(http://cn-file.17pdf.com/website/members/pic_noconsumption.png) no-repeat center center;
  388. }
  389. .el-table__row:hover .downloadBtn {
  390. display: inline-block;
  391. width: 13px;
  392. height: 13px;
  393. background: url(http://cn-file.17pdf.com/website/members/ic_download_gray.svg) center no-repeat;
  394. }
  395. .btn-download:disabled,.btn-delete:disabled {
  396. opacity: 0.5;
  397. pointer-events: none;
  398. }
  399. </style>