db-list.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <view class="leo-list">
  3. <template v-if="list.length">
  4. <view class="uni-flex uni-row leo-align-items-center leo-space-between leo-list-item" v-for="(item, index) in list"
  5. :key="index">
  6. <view class="uni-flex uni-row leo-align-items-center" v-if="item.documentornotify==='公文'" @tap="navTo('/pages/gongwen/content?businessKey='+item.businessKey+'&qianshou=false')">
  7. <view style="width: 100%;">
  8. <view class="text-line-height-1 text-title leo-ellipsis-1">
  9. <uni-tag class="tag" type="error" :text="item.documentornotify | notifyTypeFilter"
  10. size="small" />
  11. {{ item.title || "暂无数据"}}
  12. </view>
  13. <view class="text-line-height-1 text-date leo-ellipsis-1" style="margin-top: 16rpx; color: rgba(156,164,169,1);">
  14. {{item.createTime|time}}
  15. </view>
  16. </view>
  17. </view>
  18. <view class="uni-flex uni-row leo-align-items-center" v-else @tap="navTo('/pages/notify/content?id='+item.id+'&qianshou=0')">
  19. <view style="width: 100%;">
  20. <view class="text-line-height-1 text-title leo-ellipsis-1">
  21. <uni-tag class="tag" type="error" :text="item.documentornotify | notifyTypeFilter"
  22. size="small" />
  23. {{ item.title || "暂无数据"}}
  24. </view>
  25. <view class="text-line-height-1 text-date leo-ellipsis-1" style="margin-top: 16rpx; color: rgba(156,164,169,1);">
  26. {{item.createTime|time}}
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <template v-else>
  33. <view class="" style="text-align: center;">
  34. 暂无数据
  35. </view>
  36. </template>
  37. </view>
  38. </template>
  39. <script>
  40. import moment from '@/common/moment';
  41. export default {
  42. props: {
  43. list: {
  44. type:Array,
  45. default() {
  46. return []
  47. }
  48. },
  49. borderRadius: {
  50. type: [Number, String],
  51. default: 0
  52. }
  53. },
  54. filters:{
  55. time(val) {
  56. // 拿到当前时间戳和发布时的时间戳,然后得出时间戳差
  57. var curTime = new Date();
  58. var postTime = new Date(val);
  59. var timeDiff = curTime.getTime() - postTime.getTime();
  60. // 单位换算
  61. var min = 60 * 1000;
  62. var hour = min * 60;
  63. var day = hour * 24;
  64. var week = day * 7;
  65. // 计算发布时间距离当前时间的周、天、时、分
  66. var exceedWeek = Math.floor(timeDiff / week);
  67. var exceedDay = Math.floor(timeDiff / day);
  68. var exceedHour = Math.floor(timeDiff / hour);
  69. var exceedMin = Math.floor(timeDiff / min);
  70. // 最后判断时间差到底是属于哪个区间,然后return
  71. if (exceedWeek > 0) {
  72. if(curTime.getFullYear()==postTime.getFullYear()){
  73. return moment(val).format('MM-DD');
  74. }else{
  75. return moment(val).format('YYYY-MM-DD');
  76. }
  77. } else {
  78. if (exceedDay < 7 && exceedDay > 0) {
  79. return exceedDay + '天前';
  80. } else {
  81. if (exceedHour < 24 && exceedHour > 0) {
  82. return exceedHour + '小时前';
  83. } else {
  84. if(exceedMin<1){
  85. exceedMin=0
  86. }
  87. return exceedMin + '分钟前';
  88. }
  89. }
  90. }
  91. },
  92. notifyTypeFilter(val) {
  93. return val;
  94. }
  95. },
  96. data() {
  97. return {
  98. }
  99. },
  100. methods: {
  101. // 通用跳转
  102. navTo(route) {
  103. this.$mRouter.push({
  104. route
  105. });
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. .leo-list {
  112. .leo-list-item {
  113. padding: 36rpx 0rpx;
  114. border-top: #e4e7ed 2rpx solid;
  115. &:first-child {
  116. border-top: #e4e7ed 0rpx solid;
  117. }
  118. .icon {
  119. display: block;
  120. width: 64rpx;
  121. height: 64rpx;
  122. }
  123. }
  124. }
  125. .uni-flex {
  126. display: flex;
  127. flex-direction: row;
  128. }
  129. .uni-flex-item {
  130. flex: 1;
  131. }
  132. .uni-row {
  133. flex-direction: row;
  134. }
  135. .uni-column {
  136. flex-direction: column;
  137. }
  138. .leo-align-items-center {
  139. align-items: center;
  140. width: 100%;
  141. }
  142. .leo-space-between {
  143. justify-content: space-between;
  144. }
  145. .text-line-height-1 {
  146. line-height: 1 !important;
  147. }
  148. .text-title {
  149. font-size: $font-lg !important;
  150. }
  151. .text-date {
  152. font-size: $font-sm !important;
  153. float: right;
  154. }
  155. .leo-ellipsis-1 {
  156. display: -webkit-box;
  157. text-overflow: -o-ellipsis-lastline;
  158. overflow: hidden;
  159. text-overflow: ellipsis;
  160. -webkit-line-clamp: 2;
  161. line-clamp: 2;
  162. -webkit-box-orient: vertical;
  163. }
  164. .tag {
  165. position: relative;
  166. float: left;
  167. border: none;
  168. font-size: $font-sm;
  169. opacity: 0.8;
  170. margin-right: 5px;
  171. }
  172. </style>