main.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <div class="container" v-loading="loading">
  3. <div class="tips-info" v-if="tips">
  4. <slot name="tips"></slot>
  5. </div>
  6. <div v-if="toolbar" class="toolbar">
  7. <slot name="toolbar"></slot>
  8. </div>
  9. <el-table :max-height="height" v-bind="$attrs" v-on="$listeners" ref="table" :data="tableData" :row-key="rowKey" :stripe="stripe"
  10. :header-cell-style="{ textAlign: 'center' }" :style="{ width: '100%', minHeight: height + 'px' }"
  11. @selection-change="selectionChange" highlight-current-row>
  12. <slot name="table-columns"></slot>
  13. </el-table>
  14. <div v-if="pagination" class="pagination">
  15. <div class="pagination-toolbar">
  16. <slot name="pagination-toolbar"></slot>
  17. </div>
  18. <slot name="pagination"></slot>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. export default {
  24. name: 'EnTableLayout',
  25. props: {
  26. /** 是否显示斑纹 */
  27. stripe: {
  28. type: Boolean,
  29. default: true
  30. },
  31. /** 行数据的 Key */
  32. rowKey: {
  33. type: [String, Function],
  34. default: null
  35. },
  36. /** 是否显示工具栏 */
  37. toolbar: {
  38. type: Boolean,
  39. default: true
  40. },
  41. /** 是否显示操作提示 */
  42. tips: {
  43. type: Boolean,
  44. default: false
  45. },
  46. /** 是否显示分页 */
  47. pagination: {
  48. type: Boolean,
  49. default: true
  50. },
  51. /** 表格数据 */
  52. tableData: {
  53. default: function() {
  54. return []
  55. }
  56. },
  57. /** 加载状态 */
  58. loading: {
  59. type: Boolean,
  60. default: false
  61. },
  62. /** 当选择项发生变化 */
  63. selectionChange: {
  64. type: Function,
  65. default: function() {
  66. return []
  67. }
  68. }
  69. },
  70. data() {
  71. return {
  72. height: `${document.body.clientHeight - 260}`
  73. }
  74. }
  75. }
  76. </script>
  77. <style type="text/scss" lang="scss" scoped>
  78. .container {
  79. width: 100%;
  80. height: 100%;
  81. position: relative;
  82. background: #e9eef3;
  83. }
  84. /** 工具栏样式 */
  85. .toolbar {
  86. display: flex;
  87. align-items: center;
  88. height: 44px;
  89. border-bottom: 1px solid #e6ebf5;
  90. background-color: #fff;
  91. }
  92. .inner-toolbar {
  93. display: flex;
  94. width: 100%;
  95. justify-content: space-between;
  96. padding: 0 20px;
  97. }
  98. .toolbar-search {
  99. margin-right: 10px;
  100. }
  101. /** 分页样式 */
  102. .pagination {
  103. display: flex;
  104. justify-content: space-between;
  105. padding: 5px 20px;
  106. text-align: right;
  107. background-color: #ffffff;
  108. .pagination-toolbar {
  109. display: flex;
  110. align-items: center;
  111. }
  112. }
  113. /deep/ .el-table td:not(.is-left) {
  114. text-align: center;
  115. }
  116. /** 操作提示样式 */
  117. .tips-info {
  118. background: #fff;
  119. color: #31708f;
  120. padding: 1px 10px;
  121. margin-bottom: 10px;
  122. border-radius: 4px;
  123. h4 {
  124. font-weight: 500;
  125. margin: 20px 0;
  126. }
  127. ul {
  128. margin: 20px 0;
  129. padding-left: 40px;
  130. display: block;
  131. li {
  132. font-size: 12px;
  133. list-style-type: disc;
  134. }
  135. }
  136. }
  137. </style>