expenses.vue 10 KB

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