list-page.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. usePage: { type: Boolean, default: true },
  56. },
  57. components: { tabs, search },
  58. data: function() {
  59. return {
  60. searchInfo: '',
  61. pageSize: 10,
  62. currentPage: 1,
  63. };
  64. },
  65. created() {},
  66. methods: {
  67. search() {
  68. const skip = (this.currentPage - 1) * this.pageSize;
  69. let condition = { skip, limit: this.pageSize };
  70. if (this.searchInfo && this.searchInfo !== '') condition[this.searchModel] = this.searchInfo;
  71. this.$emit('toSearch', condition);
  72. },
  73. toSearch(condition) {
  74. if (condition && condition !== '') {
  75. this.$set(this, `searchInfo`, condition);
  76. }
  77. this.currentPage = 1;
  78. this.search();
  79. },
  80. change(condition) {
  81. this.$emit('toChangeTab', condition);
  82. },
  83. },
  84. computed: {
  85. ...mapState(['user', 'menuParams']),
  86. pageTitle() {
  87. return `${this.$route.meta.title}`;
  88. },
  89. },
  90. metaInfo() {
  91. return { title: this.$route.meta.title };
  92. },
  93. };
  94. </script>
  95. <style lang="less" scoped>
  96. .main {
  97. .top {
  98. height: 49px;
  99. border-bottom: 1px solid #ccc;
  100. padding: 5px 0 0 0;
  101. .left {
  102. text-align: left;
  103. span:first-child {
  104. color: #22529a;
  105. font-weight: bold;
  106. font-size: 25px;
  107. }
  108. span:last-child {
  109. color: #22529a;
  110. font-size: 20px;
  111. font-weight: bold;
  112. }
  113. }
  114. .right {
  115. .tabs {
  116. span {
  117. font-size: 16px;
  118. padding: 8px 10px;
  119. display: inline-block;
  120. font-weight: bold;
  121. }
  122. span:hover {
  123. cursor: pointer;
  124. color: #409eff;
  125. }
  126. .btn {
  127. padding: 0px 0 0 0;
  128. position: relative;
  129. top: 1px;
  130. i {
  131. font-size: 20px;
  132. font-weight: bold;
  133. }
  134. }
  135. }
  136. .search {
  137. /deep/.el-input__inner {
  138. height: 35px;
  139. line-height: 35px;
  140. }
  141. }
  142. }
  143. }
  144. .down {
  145. height: 500px;
  146. overflow: hidden;
  147. .list {
  148. padding: 10px 0;
  149. .name {
  150. font-size: 18px;
  151. font-weight: bold;
  152. }
  153. .date {
  154. font-size: 16px;
  155. text-align: center;
  156. }
  157. .brief {
  158. font-size: 16px;
  159. overflow: hidden;
  160. text-overflow: ellipsis;
  161. -webkit-line-clamp: 2;
  162. word-break: break-all;
  163. display: -webkit-box;
  164. -webkit-box-orient: vertical;
  165. margin: 10px 0 0 0;
  166. max-height: 42px;
  167. }
  168. }
  169. .list:hover {
  170. cursor: pointer;
  171. .name {
  172. -webkit-transform: translateY(-3px);
  173. -ms-transform: translateY(-3px);
  174. transform: translateY(-3px);
  175. -webkit-box-shadow: 0 0 6px #999;
  176. box-shadow: 0 0 6px #999;
  177. -webkit-transition: all 0.5s ease-out;
  178. transition: all 0.5s ease-out;
  179. color: #0085d2;
  180. }
  181. }
  182. }
  183. .page {
  184. text-align: center;
  185. height: 30px;
  186. overflow: hidden;
  187. }
  188. }
  189. </style>