index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <div class="y-page-list-layout">
  3. <div class="y-info" v-if="$slots.left || $slots.right">
  4. <div class="y-left">
  5. <slot name="left"></slot>
  6. </div>
  7. <div class="y-right">
  8. <slot name="right"></slot>
  9. <el-dropdown trigger="click" v-show="showExportBox">
  10. <el-button type="primary" round>
  11. 导出<i class="el-icon-arrow-down el-icon--right"></i>
  12. </el-button>
  13. <el-dropdown-menu slot="dropdown">
  14. <div class="y-page-list-export-box" ref="exportBtnBox"></div>
  15. </el-dropdown-menu>
  16. </el-dropdown>
  17. </div>
  18. </div>
  19. <div class="y-twostart">
  20. <slot name="twostart"></slot>
  21. </div>
  22. <template>
  23. <slot name="table"></slot>
  24. </template>
  25. <pagination style="border: 1px solid #EBECED" v-if="pageList.total>0" :total="pageList.total" :page.sync="pagePara.current" :limit.sync="pagePara.size" @pagination="getPageList" />
  26. </div>
  27. </template>
  28. <script>
  29. import Pagination from '@/components/Pagination'
  30. export default {
  31. name: "y-page-list-layout",
  32. components: {Pagination},
  33. props: {
  34. pageList: {
  35. type: Object,
  36. default:function () {
  37. return {
  38. total:0
  39. }
  40. }
  41. },
  42. pagePara:{
  43. type: Object,
  44. default:function () {
  45. return {}
  46. }
  47. },
  48. getPageList: {
  49. type: Function,
  50. default: function(){
  51. }
  52. },
  53. },
  54. data(){
  55. return{
  56. showExportBox:false
  57. }
  58. },
  59. mounted(){
  60. const that = this
  61. if (that.$slots.right && that.$slots.right.length > 0){
  62. let exportCount = 0
  63. that.$slots.right.forEach(function (item) {
  64. if (item.elm.innerText && item.elm.innerText.indexOf('导出') > -1) {
  65. exportCount++
  66. }
  67. })
  68. if (exportCount > 1){
  69. that.$slots.right.forEach(function (item) {
  70. if (item.elm.innerText && item.elm.innerText.indexOf('导出') > -1) {
  71. that.$refs.exportBtnBox.append(item.elm)
  72. }
  73. })
  74. that.showExportBox = true
  75. }
  76. }
  77. },
  78. }
  79. </script>
  80. <style lang="scss">
  81. .y-page-list-layout{
  82. .y-left {
  83. .el-input--small .el-input__inner {
  84. border-radius: 20px;
  85. }
  86. .el-input-group {
  87. .el-input__inner {
  88. border-radius: 0 !important;
  89. }
  90. }
  91. }
  92. }
  93. .y-page-list-export-box{
  94. padding: 15px;
  95. }
  96. </style>
  97. <style lang="scss" scoped>
  98. .y-page-list-layout{
  99. margin-top: 8px;
  100. background-color: #fff;
  101. padding: 17px;
  102. .y-info{
  103. display: flex;
  104. justify-content:space-between;
  105. margin-bottom: 12px;
  106. }
  107. }
  108. .y-twostart{
  109. margin-left: 20px;
  110. margin-bottom: 10px;
  111. }
  112. </style>