List.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <div class="new-list">
  3. <div class="serch-wrapper">
  4. <div class="search">
  5. <input type="text" v-model="keyword" placeholder="请输入内容进行搜索" class="" @keyup.enter="getList(keyword)" />
  6. <img src="../../../assets/img/search.png" class="hand" @click="getList(keyword)">
  7. </div>
  8. </div>
  9. <div class="empty" v-if="newList.length == 0">
  10. 暂无数据
  11. </div>
  12. <div class="new-item hand" v-for="item in newList" :key="item.id" @click="navTo('/cause/cells/detail?id='+ item.id)">
  13. <div class="title clamp">
  14. <span class="title-icon"></span>
  15. {{ item.title }}
  16. </div>
  17. <div class="time">{{ item.release_time?item.release_time:item.add_time | time }}</div>
  18. </div>
  19. <el-pagination layout="prev, pager, next" :total="total" background prev-text="上一页" next-text="下一页"
  20. @current-change="currentChange" :page-size="15" hide-on-single-page></el-pagination>
  21. </div>
  22. </template>
  23. <script>
  24. import {
  25. getList
  26. } from '../../../request/api.js';
  27. export default {
  28. data() {
  29. return {
  30. newList: [],
  31. total: 0,
  32. page: 1,
  33. limit: 15,
  34. keyword: ''
  35. };
  36. },
  37. filters: {
  38. time(val) {
  39. let arr = val.split(' ')
  40. let str = arr[0]
  41. str = str.replace(/-/g, '.')
  42. return str
  43. }
  44. },
  45. created() {
  46. this.getList()
  47. },
  48. methods: {
  49. navTo(url) {
  50. this.$router.push(url);
  51. },
  52. currentChange(e) {
  53. this.page = e
  54. this.getList()
  55. },
  56. getList(keyword) {
  57. let obj = this
  58. if (keyword) {
  59. obj.page = 1
  60. }
  61. getList({
  62. page: obj.page,
  63. limit: obj.limit,
  64. name: obj.keyword
  65. },67).then(res => {
  66. obj.newList = res.data.list.sort(this.compare('id'))
  67. obj.total = res.data.count
  68. })
  69. },
  70. compare(attribute) {
  71. return function(obj1, obj2) {
  72. var val1 = obj1[attribute];
  73. var val2 = obj2[attribute];
  74. if (val1 < val2) {
  75. return 1;
  76. } else if (val1 > val2) {
  77. return -1;
  78. } else {
  79. return 0;
  80. }
  81. }
  82. }
  83. }
  84. };
  85. </script>
  86. <style lang="scss" scoped>
  87. .new-list {
  88. position: relative;
  89. .empty {
  90. text-align: center;
  91. color: #999;
  92. height: 400px;
  93. line-height: 400px;
  94. }
  95. .new-item {
  96. display: flex;
  97. justify-content: space-between;
  98. font-size: 18px;
  99. font-family: PingFang SC;
  100. font-weight: 500;
  101. color: #666666;
  102. height: 40px;
  103. border-bottom: 1px solid #E5E5E5;
  104. line-height: 40px;
  105. &:hover {
  106. color: red;
  107. .title {
  108. .title-icon {
  109. border-left-color: red;
  110. }
  111. }
  112. }
  113. .title {
  114. width: 500px;
  115. .title-icon {
  116. display: inline-block;
  117. width: 0;
  118. height: 0;
  119. width: 0;
  120. height: 0;
  121. border-top: 6px solid transparent;
  122. border-left: 8px solid #d2d2d2;
  123. border-bottom: 6px solid transparent;
  124. }
  125. }
  126. }
  127. }
  128. /deep/ .el-pagination {
  129. margin-top: 50px;
  130. text-align: center;
  131. }
  132. .serch-wrapper {
  133. display: flex;
  134. height: 33px;
  135. position: absolute;
  136. top: -80px;
  137. right: -50px;
  138. .search {
  139. padding-left: 13px;
  140. padding-right: 13px;
  141. width: 295px;
  142. height: 33px;
  143. line-height: 33px;
  144. background: #FFFFFF;
  145. border: 1px solid #CCCCCC;
  146. border-radius: 10px;
  147. // margin-bottom: 10px;
  148. display: flex;
  149. justify-content: space-between;
  150. align-items: center;
  151. input {
  152. width: 235px;
  153. font-size: 16px;
  154. font-family: PingFang SC;
  155. font-weight: bold;
  156. outline: none;
  157. border: none;
  158. }
  159. img {
  160. width: 20px;
  161. height: 20px;
  162. }
  163. }
  164. }
  165. </style>