expenses.vue 9.8 KB

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