list-page.vue 5.2 KB

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