index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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="app-container pull-auto">
  19. <basic-container>
  20. <avue-crud ref="crud"
  21. :page="page"
  22. :data="tableData"
  23. :table-loading="tableLoading"
  24. :option="tableOption"
  25. @on-load="getList"
  26. @refresh-change="refreshChange"
  27. @row-del="rowDel">
  28. <template slot-scope="scope"
  29. slot="menu">
  30. <el-button type="danger"
  31. v-if="permissions.sys_client_del"
  32. icon="el-icon-delete"
  33. size="mini"
  34. plain
  35. @click="handleDel(scope.row,scope.index)">删除</el-button>
  36. </template>
  37. </avue-crud>
  38. </basic-container>
  39. </div>
  40. </template>
  41. <script>
  42. import { fetchList, delObj } from '@/api/token'
  43. import { tableOption } from '@/const/crud/token'
  44. import { mapGetters } from 'vuex'
  45. export default {
  46. name: 'token',
  47. data() {
  48. return {
  49. tableData: [],
  50. page: {
  51. total: 0, // 总页数
  52. currentPage: 1, // 当前页数
  53. pageSize: 20 // 每页显示多少条
  54. },
  55. tableLoading: false,
  56. tableOption: tableOption
  57. }
  58. },
  59. created() {
  60. },
  61. mounted: function() { },
  62. computed: {
  63. ...mapGetters(['permissions'])
  64. },
  65. methods: {
  66. getList(page,params) {
  67. this.tableLoading = true
  68. fetchList(Object.assign({
  69. current: page.currentPage,
  70. size: page.pageSize
  71. }, params)).then(response => {
  72. this.tableData = response.data.data.records
  73. this.page.total = response.data.data.total
  74. this.tableLoading = false
  75. })
  76. },
  77. handleDel(row, index) {
  78. this.$refs.crud.rowDel(row, index)
  79. },
  80. rowDel: function(row, index) {
  81. var _this = this
  82. this.$confirm('是否确认删除ID为' + row.token_value, '提示', {
  83. confirmButtonText: '确定',
  84. cancelButtonText: '取消',
  85. type: 'warning'
  86. })
  87. .then(function() {
  88. return delObj(row.token_value)
  89. })
  90. .then(data => {
  91. _this.tableData.splice(index, 1)
  92. _this.$message({
  93. showClose: true,
  94. message: '删除成功',
  95. type: 'success'
  96. })
  97. })
  98. .catch(function(err) { })
  99. },
  100. /**
  101. * 刷新回调
  102. */
  103. refreshChange() {
  104. this.getList(this.page)
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. </style>