ListContainer.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <div class="list_container">
  3. <div class="title">
  4. <el-row>
  5. <el-col v-for="(item, index) in listField" :key="index" :span="item.span">
  6. <div v-if="item.name == 'select'">
  7. <el-checkbox></el-checkbox>
  8. </div>
  9. <div v-else>{{ item.alias }}</div>
  10. </el-col>
  11. </el-row>
  12. </div>
  13. <div class="list_content">
  14. <div class="noHaveData" v-if="listData.length == 0">
  15. <el-row>
  16. <el-col :span="24">
  17. <div>
  18. <i class="el-icon-warning"></i>
  19. {{ noDataTip }}
  20. </div>
  21. </el-col>
  22. </el-row>
  23. </div>
  24. <div class="haveData" v-else>
  25. <el-row v-for="(item, index) in listData" :key="index">
  26. <el-col v-for="(item_, index_) in listField" :key="index_" :span="item_.span">
  27. <div
  28. v-if="item_.name.toLowerCase().indexOf('time') >= 0"
  29. :title="transDateFormat(item[item_.name], 'yyyy-MM-DD hh:mm:ss')"
  30. >{{ transDateFormat(item[item_.name], 'yyyy-MM-DD hh:mm:ss') }}</div>
  31. <!-- <div
  32. v-else-if="item_.name.toLowerCase().indexOf('request') >= 0"
  33. :title="item[item_.name]"
  34. >{{ JSON.parse(item[item_.name]).request }}</div>-->
  35. <div :title="item[item_.name]" v-else>{{ item[item_.name] || '—' }}</div>
  36. </el-col>
  37. </el-row>
  38. </div>
  39. </div>
  40. <div class="page_content">
  41. <el-pagination
  42. background
  43. :page-size="pageSize"
  44. :pager-count="11"
  45. :current-page="currentPage"
  46. layout="prev, pager, next"
  47. :total="total"
  48. @current-change="changeCurrentPage($event)"
  49. ></el-pagination>
  50. </div>
  51. </div>
  52. </template>
  53. <script>
  54. export default {
  55. props: {
  56. listField: {
  57. type: Array,
  58. },
  59. listData: {
  60. type: Array,
  61. default: [],
  62. },
  63. noDataTip: {
  64. type: String,
  65. default: "暂无数据"
  66. },
  67. total: {
  68. type: Number,
  69. default: 0
  70. },
  71. pageSize: {
  72. type: Number,
  73. default: 10
  74. },
  75. currentPage: {
  76. type: Number,
  77. default: 1
  78. },
  79. searchData: {
  80. type: Function
  81. },
  82. functionObj: {
  83. type: Object
  84. }
  85. },
  86. methods: {
  87. changeCurrentPage(currentPage) {
  88. this.searchData(currentPage);
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="less" scoped>
  94. .list_container {
  95. width: 100%;
  96. height: 100%;
  97. .el-row {
  98. height: 32px;
  99. line-height: 32px;
  100. font-size: 16px;
  101. text-align: center;
  102. margin: 4px;
  103. border-radius: 4px;
  104. width: 100%;
  105. display: inline-block;
  106. .el-col {
  107. > div {
  108. position: relative;
  109. padding: 0 10px;
  110. box-sizing: border-box;
  111. overflow: hidden;
  112. white-space: nowrap;
  113. text-overflow: ellipsis;
  114. cursor: default;
  115. &::before,
  116. &::after {
  117. content: "";
  118. position: absolute;
  119. width: 4px;
  120. height: 100%;
  121. border-radius: 4px;
  122. background: #3f67c366;
  123. }
  124. &::before {
  125. top: 0;
  126. left: -2px;
  127. }
  128. &::after {
  129. top: 0;
  130. right: -2px;
  131. }
  132. }
  133. &:last-child div::after {
  134. background: transparent;
  135. }
  136. &:first-child div::before {
  137. background: transparent;
  138. }
  139. }
  140. }
  141. .title {
  142. box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.4);
  143. border-radius: 5px;
  144. background: #ffffff;
  145. overflow: hidden;
  146. height: 40px;
  147. .el-row {
  148. margin-left: 0px;
  149. margin-right: 0px;
  150. }
  151. }
  152. .list_content {
  153. margin-top: 10px;
  154. box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.4);
  155. border-radius: 5px;
  156. background: #ffffff;
  157. height: calc(100% - 86px);
  158. > div {
  159. height: 100%;
  160. overflow: hidden;
  161. overflow-y: auto;
  162. }
  163. .noHaveData {
  164. color: #d8d8d8;
  165. }
  166. .haveData {
  167. .el-row:hover {
  168. background: #efefef;
  169. cursor: pointer;
  170. }
  171. }
  172. }
  173. }
  174. .page_content {
  175. margin-top: 10px;
  176. overflow: hidden;
  177. .el-pagination {
  178. float: right;
  179. }
  180. }
  181. </style>