list-page.vue 5.2 KB

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