expenses.vue 12 KB

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