list-frame.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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="21" 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="3" 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">
  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. <slot name="options" v-bind="{ item }"></slot>
  33. </el-select>
  34. </template>
  35. <template v-else>
  36. <el-input v-model="searchInfo[`${item.model}`]" size="mini"></el-input>
  37. </template>
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button type="primary" size="mini">查询</el-button>
  41. </el-form-item>
  42. </el-form>
  43. </slot>
  44. <div style="padding:1.875rem;">
  45. <slot> </slot>
  46. </div>
  47. <el-row type="flex" align="middle" justify="end" v-if="needPag">
  48. <el-col :span="24" style="text-align:right;">
  49. <el-pagination
  50. background
  51. layout="total, prev, pager, next"
  52. :total="total"
  53. :page-size="limit"
  54. :current-page.sync="currentPage"
  55. @current-change="changePage"
  56. >
  57. </el-pagination>
  58. </el-col>
  59. </el-row>
  60. </el-card>
  61. </el-scrollbar>
  62. </div>
  63. </template>
  64. <script>
  65. import _ from 'lodash';
  66. export default {
  67. name: 'list-frame',
  68. props: {
  69. title: { type: String },
  70. filter: { type: Array, default: () => [] },
  71. total: { type: Number, default: 0 },
  72. needPag: { type: Boolean, default: true },
  73. returns: { type: null, default: null },
  74. needFilter: { type: Boolean, default: true },
  75. needAdd: { type: Boolean, default: true },
  76. },
  77. components: {},
  78. data: () => ({
  79. limit: _.get(this, `$limit`, undefined) !== undefined ? this.$limit : process.env.VUE_APP_LIMIT * 1,
  80. currentPage: 1,
  81. searchInfo: {},
  82. heights: document.documentElement.clientHeight - 80,
  83. }),
  84. created() {},
  85. computed: {},
  86. mounted() {
  87. const that = this;
  88. window.onresize = () => {
  89. return (() => {
  90. window.fullHeight = document.documentElement.clientHeight - 80;
  91. that.heights = window.fullHeight;
  92. })();
  93. };
  94. },
  95. methods: {
  96. changePage(page) {
  97. this.$emit('query', { skip: (page - 1) * this.limit, limit: this.limit, ...this.searchInfo });
  98. },
  99. },
  100. };
  101. </script>
  102. <style lang="less" scoped>
  103. .title {
  104. font-size: 1rem;
  105. font-weight: 700;
  106. padding: 1rem;
  107. }
  108. /deep/.el-scrollbar__wrap {
  109. overflow-x: auto;
  110. }
  111. </style>