list-frame.vue 2.7 KB

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