index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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="log">
  19. <basic-container>
  20. <avue-crud
  21. ref="crud"
  22. :page="page"
  23. :data="tableData"
  24. :table-loading="tableLoading"
  25. :option="tableOption"
  26. :permission="permissionList"
  27. @on-load="getList"
  28. @search-change="searchChange"
  29. @refresh-change="refreshChange"
  30. @size-change="sizeChange"
  31. @current-change="currentChange"
  32. @row-del="handleDel"/>
  33. </basic-container>
  34. </div>
  35. </template>
  36. <script>
  37. import {delObj, fetchList} from '@/api/admin/log'
  38. import {tableOption} from '@/const/crud/admin/log'
  39. import {mapGetters} from 'vuex'
  40. export default {
  41. name: 'Log',
  42. data() {
  43. return {
  44. tableData: [],
  45. searchForm: {},
  46. page: {
  47. total: 0, // 总页数
  48. currentPage: 1, // 当前页数
  49. pageSize: 20 // 每页显示多少条
  50. },
  51. tableLoading: false,
  52. tableOption: tableOption
  53. }
  54. },
  55. computed: {
  56. ...mapGetters(['permissions']),
  57. permissionList() {
  58. return {
  59. delBtn: this.vaildData(this.permissions.sys_log_del, false)
  60. }
  61. }
  62. },
  63. methods: {
  64. getList(page, params) {
  65. this.tableLoading = true
  66. fetchList(Object.assign({
  67. descs: 'create_time',
  68. current: page.currentPage,
  69. size: page.pageSize
  70. }, params, this.searchForm)).then(response => {
  71. this.tableData = response.data.data.records
  72. this.page.total = response.data.data.total
  73. this.tableLoading = false
  74. })
  75. },
  76. handleDel: function (row) {
  77. this.$confirm('是否确认删除ID为"' + row.id + '"的日志?', '警告', {
  78. confirmButtonText: '确定',
  79. cancelButtonText: '取消',
  80. type: 'warning'
  81. }).then(function () {
  82. return delObj(row.id)
  83. }).then(() => {
  84. this.getList(this.page)
  85. this.$message.success('删除成功')
  86. })
  87. },
  88. searchChange(form, done) {
  89. this.searchForm = form
  90. this.getList(this.page, form)
  91. done()
  92. },
  93. sizeChange(pageSize) {
  94. this.page.pageSize = pageSize
  95. },
  96. currentChange(current) {
  97. this.page.currentPage = current
  98. },
  99. refreshChange() {
  100. this.getList(this.page)
  101. }
  102. }
  103. }
  104. </script>