expenses.vue 8.6 KB

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