list-page.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <div id="list-page">
  3. <el-row>
  4. <el-col :span="24" class="main">
  5. <el-col :span="24" class="top">
  6. <el-col :span="3" class="left">
  7. <span>|</span> <span>{{ title }}</span>
  8. </el-col>
  9. <el-col :span="21" class="right">
  10. <el-row type="flex" justify="end">
  11. <el-col :span="12" class="tabs" v-if="useTab">
  12. <tabs :displayList="displayList" :dropList="dropList" @toSearch="change"></tabs>
  13. </el-col>
  14. <el-col :span="12" class="search" v-if="useSearch">
  15. <search @toSearch="toSearch"></search>
  16. </el-col>
  17. </el-row>
  18. </el-col>
  19. </el-col>
  20. <el-col :span="24" class="down">
  21. <slot></slot>
  22. <!-- <el-col :span="24" class="list" v-for="(item, index) in list" :key="index">
  23. <el-col :span="21" class="name" @click.native="clickDetail(item.id)">
  24. {{ item.p1 }}
  25. </el-col>
  26. <el-col :span="3" class="date">
  27. {{ getDate(item.p2) }}
  28. </el-col>
  29. <el-col :span="24" class="brief"> 成果简介:{{ item.p3 || '暂无' }} </el-col>
  30. </el-col> -->
  31. </el-col>
  32. <el-col :span="24" class="page" v-if="usePage">
  33. <el-pagination @current-change="search" :current-page="currentPage" layout="total, prev, pager, next, jumper" :total="total" :page-size="pageSize">
  34. </el-pagination>
  35. </el-col>
  36. </el-col>
  37. </el-row>
  38. </div>
  39. </template>
  40. <script>
  41. import tabs from './tabs.vue';
  42. import search from './search.vue';
  43. import { mapState, createNamespacedHelpers } from 'vuex';
  44. export default {
  45. name: 'list-page',
  46. props: {
  47. useTab: { type: Boolean, default: false },
  48. useSearch: { type: Boolean, default: true },
  49. displayList: { type: Array, default: () => [] },
  50. dropList: { type: Array, default: () => [] },
  51. list: { type: Array, default: () => [] },
  52. searchModel: { type: String, default: 'title' },
  53. title: { type: String },
  54. total: { type: Number, default: 0 },
  55. pageSize: { type: Number, default: 5 },
  56. usePage: { type: Boolean, default: true },
  57. },
  58. components: { tabs, search },
  59. data: function() {
  60. return {
  61. searchInfo: '',
  62. currentPage: 1,
  63. condition: {},
  64. };
  65. },
  66. created() {},
  67. methods: {
  68. search(page = 1) {
  69. this.currentPage = page;
  70. const skip = (this.currentPage - 1) * this.pageSize;
  71. let condition = { skip, limit: this.pageSize, ...this.condition };
  72. if (this.searchInfo && this.searchInfo !== '') condition[this.searchModel] = this.searchInfo;
  73. this.$emit('toSearch', condition);
  74. },
  75. toSearch(condition) {
  76. if (condition && condition !== '') {
  77. this.$set(this, `searchInfo`, condition);
  78. }
  79. this.currentPage = 1;
  80. this.search();
  81. },
  82. change(condition) {
  83. this.$set(this, `condition`, condition);
  84. this.$emit('toChangeTab', condition);
  85. },
  86. },
  87. computed: {
  88. ...mapState(['user', 'menuParams']),
  89. pageTitle() {
  90. return `${this.$route.meta.title}`;
  91. },
  92. },
  93. metaInfo() {
  94. return { title: this.$route.meta.title };
  95. },
  96. };
  97. </script>
  98. <style lang="less" scoped>
  99. .main {
  100. .top {
  101. height: 49px;
  102. border-bottom: 1px solid #ccc;
  103. padding: 5px 0 0 0;
  104. .left {
  105. text-align: left;
  106. span:first-child {
  107. color: #22529a;
  108. font-weight: bold;
  109. font-size: 25px;
  110. }
  111. span:last-child {
  112. color: #22529a;
  113. font-size: 20px;
  114. font-weight: bold;
  115. }
  116. }
  117. .right {
  118. .tabs {
  119. span {
  120. font-size: 16px;
  121. padding: 8px 10px;
  122. display: inline-block;
  123. font-weight: bold;
  124. }
  125. span:hover {
  126. cursor: pointer;
  127. color: #409eff;
  128. }
  129. .btn {
  130. padding: 0px 0 0 0;
  131. position: relative;
  132. top: 1px;
  133. i {
  134. font-size: 20px;
  135. font-weight: bold;
  136. }
  137. }
  138. }
  139. .search {
  140. /deep/.el-input__inner {
  141. height: 35px;
  142. line-height: 35px;
  143. }
  144. }
  145. }
  146. }
  147. .down {
  148. height: 500px;
  149. overflow: hidden;
  150. .list {
  151. padding: 10px 0;
  152. .name {
  153. font-size: 18px;
  154. font-weight: bold;
  155. }
  156. .date {
  157. font-size: 16px;
  158. text-align: center;
  159. }
  160. .brief {
  161. font-size: 16px;
  162. overflow: hidden;
  163. text-overflow: ellipsis;
  164. -webkit-line-clamp: 2;
  165. word-break: break-all;
  166. display: -webkit-box;
  167. -webkit-box-orient: vertical;
  168. margin: 10px 0 0 0;
  169. max-height: 42px;
  170. }
  171. }
  172. .list:hover {
  173. cursor: pointer;
  174. .name {
  175. -webkit-transform: translateY(-3px);
  176. -ms-transform: translateY(-3px);
  177. transform: translateY(-3px);
  178. -webkit-box-shadow: 0 0 6px #999;
  179. box-shadow: 0 0 6px #999;
  180. -webkit-transition: all 0.5s ease-out;
  181. transition: all 0.5s ease-out;
  182. color: #0085d2;
  183. }
  184. }
  185. }
  186. .page {
  187. text-align: center;
  188. height: 30px;
  189. overflow: hidden;
  190. }
  191. }
  192. </style>