KtTableOperation.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <div>
  3. <!--表格栏-->
  4. <el-table :data="data.content" :highlight-current-row="highlightCurrentRow" @selection-change="selectionChange" @row-click="rowClick"
  5. @current-change="handleCurrentChange" v-loading="loading" :element-loading-text="$t('action.loading')" :border="border" :stripe="stripe"
  6. :show-overflow-tooltip="showOverflowTooltip" :max-height="maxHeight" :height="height" :size="size" :align="align" style="width:100%;" >
  7. <!-- <el-table-column type="selection" width="40" v-if="showBatchDelete & showOperation"></el-table-column> -->
  8. <el-table-column type="index" label="序号" align="center" ></el-table-column>
  9. <el-table-column v-for="column in columns" header-align="center" align="left"
  10. :prop="column.prop" :label="column.label" :width="column.width" :min-width="column.minWidth"
  11. :fixed="column.fixed" :key="column.prop" :type="column.type" :formatter="column.formatter"
  12. :sortable="column.sortable==null?true:column.sortable">
  13. </el-table-column>
  14. <el-table-column :label="$t('action.operation')" width="185" fixed="right" v-if="showOperation" header-align="center" align="center">
  15. <template slot-scope="scope">
  16. <kt-button icon="fa fa-edit" :label="operationText" type="primary" :perms="permsOperation" :size="size" @click="handleOperation(scope.$index, scope.row)" />
  17. </template>
  18. </el-table-column>
  19. </el-table>
  20. <!--分页栏-->
  21. <div class="toolbar" style="padding:10px;" v-show="isshowpagination">
  22. <kt-button :label="$t('action.batchDelete')" :perms="permsOperation" :size="size" type="danger" @click="handleBatchDelete()"
  23. :disabled="this.selections.length===0" style="float:left;" v-if="showBatchDelete & showOperation"/>
  24. <el-pagination layout="total, prev, pager, next, jumper" @current-change="refreshPageRequest"
  25. :current-page="pageRequest.pageNum" :page-size="pageRequest.pageSize" :total="data.totalSize" style="float:right;">
  26. </el-pagination>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import KtButton from "@/views/Core/KtButton"
  32. export default {
  33. name: 'KtTableSh',
  34. components:{
  35. KtButton
  36. },
  37. props: {
  38. isshowpagination: { //是否显示分页栏
  39. type: Boolean,
  40. default: true
  41. },
  42. keyName: String, //主键字段名
  43. columns: Array, // 表格列配置
  44. data: Object, // 表格分页数据
  45. permsOperation: String, // 审核权限标识
  46. operationText: { //操作button的文字
  47. type: String,
  48. default: '操作'
  49. },
  50. size: { // 尺寸样式
  51. type: String,
  52. default: 'mini'
  53. },
  54. align: { // 文本对齐方式
  55. type: String,
  56. default: 'left'
  57. },
  58. maxHeight: { // 表格最大高度
  59. type: Number,
  60. default: 420
  61. },
  62. height: { // 表格最大高度
  63. type: Number,
  64. default: 250
  65. },
  66. showOperation: { // 是否显示操作组件
  67. type: Boolean,
  68. default: true
  69. },
  70. border: { // 是否显示边框
  71. type: Boolean,
  72. default: true
  73. },
  74. stripe: { // 是否显示斑马线
  75. type: Boolean,
  76. default: true
  77. },
  78. highlightCurrentRow: { // // 是否高亮当前行
  79. type: Boolean,
  80. default: true
  81. },
  82. showOverflowTooltip: { // 是否单行显示
  83. type: Boolean,
  84. default: true
  85. },
  86. showBatchDelete: { // 是否显示操作组件
  87. type: Boolean,
  88. default: true
  89. }
  90. },
  91. data() {
  92. return {
  93. // 分页信息
  94. pageRequest: {
  95. pageNum: 1,
  96. pageSize: 10
  97. },
  98. loading: false, // 加载标识
  99. selections: [] // 列表选中列
  100. }
  101. },
  102. methods: {
  103. // 分页查询
  104. findPage: function () {
  105. this.loading = true
  106. let callback = res => {
  107. this.loading = false
  108. }
  109. this.$emit('findPage', {pageRequest:this.pageRequest, callback:callback})
  110. },
  111. // 选择切换
  112. selectionChange: function (selections) {
  113. this.selections = selections
  114. this.$emit('selectionChange', {selections:selections})
  115. },
  116. // 选择切换
  117. handleCurrentChange: function (val) {
  118. this.$emit('handleCurrentChange', {val:val})
  119. },
  120. rowClick: function(row){
  121. this.$emit('rowClick', {row:row})
  122. },
  123. // 换页刷新
  124. refreshPageRequest: function (pageNum) {
  125. this.pageRequest.pageNum = pageNum
  126. this.findPage()
  127. },
  128. // 审核
  129. handleOperation: function (index, row) {
  130. this.$emit('handleOperation', {index:index, row:row})
  131. }
  132. },
  133. mounted() {
  134. this.refreshPageRequest(1)
  135. }
  136. }
  137. </script>
  138. <style scoped>
  139. </style>