list-frame.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <div id="list-frame" :style="`height:${heights}px`">
  3. <el-scrollbar style="height:100%">
  4. <el-card style="background:rgb(231, 224, 235);border-radius: 60px;" shadow="hover">
  5. <el-row>
  6. <el-col :span="20" class="title">
  7. <span v-if="returns">
  8. <el-button
  9. size="mini"
  10. plan
  11. circle
  12. @click="$router.push({ path: returns })"
  13. style="box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)"
  14. >
  15. <span class="el-icon-arrow-left" style="zoom:1.5;font-weight:700"></span>
  16. </el-button>
  17. </span>
  18. <slot name="title">
  19. {{ title }}
  20. </slot>
  21. </el-col>
  22. <el-col :span="4" class="title" v-if="needAdd">
  23. <el-button type="primary" icon="el-icon-plus" size="mini" @click="$emit('add')">新增</el-button>
  24. </el-col>
  25. </el-row>
  26. <slot name="filter" v-if="needFilter">
  27. <el-form :inline="true">
  28. <el-form-item v-for="(item, index) in filter" :key="index" :label="item.label" label-width="auto">
  29. <template v-if="item.type === `select`">
  30. <el-select v-model="searchInfo[`${item.model}`]" size="mini">
  31. <el-option v-for="(select, sIndex) in item.list" :key="sIndex" :label="select.label" :value="select.value"></el-option>
  32. </el-select>
  33. </template>
  34. <template v-else>
  35. <el-input v-model="searchInfo[`${item.model}`]" size="mini"></el-input>
  36. </template>
  37. </el-form-item>
  38. <el-form-item>
  39. <el-button type="primary" size="mini">查询</el-button>
  40. </el-form-item>
  41. </el-form>
  42. </slot>
  43. <div style="padding:1.875rem;">
  44. <slot> </slot>
  45. </div>
  46. <el-row type="flex" align="middle" justify="end" v-if="needPag">
  47. <el-col :span="24" style="text-align:right;">
  48. <el-pagination
  49. background
  50. layout="total, prev, pager, next"
  51. :total="totalRow"
  52. :page-size="limit"
  53. :current-page.sync="currentPage"
  54. @current-change="changePage"
  55. >
  56. </el-pagination>
  57. </el-col>
  58. </el-row>
  59. </el-card>
  60. </el-scrollbar>
  61. </div>
  62. </template>
  63. <script>
  64. import _ from 'lodash';
  65. export default {
  66. name: 'list-frame',
  67. props: {
  68. title: { type: String },
  69. filter: { type: Array, default: () => [] },
  70. totalRow: { type: Number, default: 0 },
  71. needPag: { type: Boolean, default: true },
  72. returns: { type: null, default: null },
  73. needFilter: { type: Boolean, default: true },
  74. needAdd: { type: Boolean, default: true },
  75. },
  76. components: {},
  77. data: () => ({
  78. limit: _.get(this, `$limit`, undefined) !== undefined ? this.$limit : 15,
  79. currentPage: 1,
  80. searchInfo: {},
  81. heights: document.documentElement.clientHeight - 80,
  82. }),
  83. created() {},
  84. computed: {},
  85. mounted() {
  86. const that = this;
  87. window.onresize = () => {
  88. return (() => {
  89. window.fullHeight = document.documentElement.clientHeight - 80;
  90. that.heights = window.fullHeight;
  91. })();
  92. };
  93. },
  94. methods: {
  95. changePage(page) {
  96. this.$emit('query', { skip: (page - 1) * this.limit, limit: this.limit, ...this.searchInfo });
  97. },
  98. },
  99. };
  100. </script>
  101. <style lang="less" scoped>
  102. .title {
  103. font-size: 1rem;
  104. font-weight: 700;
  105. padding: 1rem;
  106. }
  107. /deep/.el-scrollbar__wrap {
  108. overflow-x: auto;
  109. }
  110. </style>