index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <!--
  2. - Copyright (c) 2018-2025, lengleng All rights reserved.
  3. -
  4. - Redistribution and use in source and binary forms, with or without
  5. - modification, are permitted provided that the following conditions are met:
  6. -
  7. - Redistributions of source code must retain the above copyright notice,
  8. - this list of conditions and the following disclaimer.
  9. - Redistributions in binary form must reproduce the above copyright
  10. - notice, this list of conditions and the following disclaimer in the
  11. - documentation and/or other materials provided with the distribution.
  12. - Neither the name of the pig4cloud.com developer nor the names of its
  13. - contributors may be used to endorse or promote products derived from
  14. - this software without specific prior written permission.
  15. - Author: lengleng (wangiegie@gmail.com)
  16. -->
  17. <template>
  18. <div class="execution">
  19. <basic-container>
  20. <avue-crud
  21. ref="crud"
  22. :page="page"
  23. :data="tableData"
  24. :permission="permissionList"
  25. :table-loading="tableLoading"
  26. :option="tableOption"
  27. :upload-after="uploadAfter"
  28. @on-load="getList"
  29. @search-change="searchChange"
  30. @refresh-change="refreshChange"
  31. @size-change="sizeChange"
  32. @current-change="currentChange"
  33. @row-del="rowDel">
  34. <template
  35. slot="menu"
  36. slot-scope="scope">
  37. <el-button
  38. type="text"
  39. size="small"
  40. icon="el-icon-download"
  41. @click="download(scope.row,scope.index)">下载
  42. </el-button>
  43. </template>
  44. </avue-crud>
  45. </basic-container>
  46. </div>
  47. </template>
  48. <script>
  49. import { delObj, fetchList } from '@/api/admin/sys-file'
  50. import { tableOption } from '@/const/crud/admin/sys-file'
  51. import { mapGetters } from 'vuex'
  52. import { handleDown } from '@/util/util'
  53. export default {
  54. name: 'sys-file',
  55. data() {
  56. return {
  57. searchForm: {},
  58. tableData: [],
  59. page: {
  60. total: 0, // 总页数
  61. currentPage: 1, // 当前页数
  62. pageSize: 20 // 每页显示多少条
  63. },
  64. tableLoading: false,
  65. tableOption: tableOption
  66. }
  67. },
  68. created() {
  69. },
  70. mounted: function() {
  71. },
  72. computed: {
  73. ...mapGetters(['permissions']),
  74. permissionList() {
  75. return {
  76. addBtn: this.vaildData(this.permissions.sys_file_add, true),
  77. delBtn: this.vaildData(this.permissions.sys_file_del, true),
  78. editBtn: this.vaildData(this.permissions.sys_file_edit, false)
  79. }
  80. }
  81. },
  82. methods: {
  83. getList(page, params) {
  84. this.tableLoading = true
  85. fetchList(Object.assign({
  86. descs: 'create_time',
  87. current: page.currentPage,
  88. size: page.pageSize
  89. }, params, this.searchForm)).then(response => {
  90. this.tableData = response.data.data.records
  91. this.page.total = response.data.data.total
  92. this.tableLoading = false
  93. }).catch(() => {
  94. this.tableLoading = false
  95. })
  96. },
  97. rowDel: function(row, index) {
  98. var _this = this
  99. this.$confirm('是否确认删除ID为' + row.id, '提示', {
  100. confirmButtonText: '确定',
  101. cancelButtonText: '取消',
  102. type: 'warning'
  103. }).then(function() {
  104. return delObj(row.id)
  105. }).then(data => {
  106. _this.$message.success('删除成功')
  107. this.getList(this.page)
  108. })
  109. },
  110. searchChange(form, done) {
  111. this.page.currentPage = 1
  112. this.getList(this.page, form)
  113. done()
  114. },
  115. refreshChange() {
  116. this.searchForm = this.form
  117. this.getList(this.page)
  118. },
  119. sizeChange(pageSize){
  120. this.page.pageSize = pageSize
  121. },
  122. currentChange(current){
  123. this.page.currentPage = current
  124. },
  125. download: function(row, index) {
  126. handleDown(row.fileName, row.bucketName)
  127. },
  128. uploadAfter(res, done, loading) {
  129. this.$message.success('上传成功')
  130. done()
  131. this.getList(this.page)
  132. },
  133. }
  134. }
  135. </script>