list.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view>
  3. <u-toast ref="uToast"/>
  4. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  5. <view @click="goDetail(item)" class="card" v-for="(item,index) in dataList" :key="index">
  6. <view class="title">
  7. <view class="text-cut-1">
  8. <text class="text-bold">标题:</text>
  9. <text class="">{{item.title}}</text>
  10. </view>
  11. <view class="time">
  12. <text class="cuIcon-time padding-right-10"></text>
  13. <text>{{new Date(item.createTime).getTime() | date('yyyy-mm-dd') }}</text>
  14. </view>
  15. </view>
  16. <view class="content ">
  17. <text class="text-cut-2">{{item.notice | formatHtml}}</text>
  18. </view>
  19. <view class="bottom">
  20. <view @click.stop="delItem(item)" class="cu-btn line-red round sm">
  21. <u-icon top="-1" name="trash-fill" size="25"></u-icon>
  22. <text class="padding-left-10">删除公告</text>
  23. </view>
  24. </view>
  25. </view>
  26. </mescroll-body>
  27. <!-- <view @click="add" style="position: fixed;bottom: 25%;right: 20rpx;">
  28. <view class="cuIcon cu-btn base-bg-color" style="width: 80rpx;height: 80rpx;">
  29. <text class="cuIcon-add" style="font-size: 60rpx;"></text>
  30. </view>
  31. </view> -->
  32. <wm-list-add ref="add" @clickAdd="add"/>
  33. </view>
  34. </template>
  35. <script>
  36. import wmListAdd from '@/components/wm-list-add/wm-list-add';
  37. import MescrollMixin from "@/components/mescroll-body/mescroll-mixins.js";
  38. export default {
  39. mixins:[MescrollMixin],
  40. components:{
  41. wmListAdd
  42. },
  43. data() {
  44. return {
  45. agencyId:'',
  46. isFirst:false,
  47. dataList:[],
  48. downOption: {
  49. use: true,
  50. auto: false
  51. },
  52. upOption: {
  53. auto: false,
  54. page: {
  55. page: 0,
  56. size: 10
  57. },
  58. noMoreSize: 3,
  59. empty: {
  60. tip: '暂无相关数据'
  61. }
  62. },
  63. }
  64. },
  65. filters: {
  66. formatHtml (str) {
  67. return str.replace(/<[^>]+>/g, "");
  68. }
  69. },
  70. onShow() {
  71. this.mescroll.resetUpScroll()
  72. },
  73. onLoad() {
  74. },
  75. methods: {
  76. goDetail(item){
  77. getApp().globalData.noticeDetail=item
  78. uni.navigateTo({
  79. url:"/pages/index/notice/detail",
  80. })
  81. },
  82. delItem(item){
  83. this.$showModel('确定要删除该公告吗?').then(res=>{
  84. this.$api.notice.remove(item.id).then(res=>{
  85. if (res.success) {
  86. this.$showToast('删除成功')
  87. setTimeout(()=>{
  88. this.mescroll.resetUpScroll()
  89. },500)
  90. }
  91. })
  92. })
  93. },
  94. add(){
  95. uni.navigateTo({
  96. url:"/pages/index/notice/add"
  97. })
  98. },
  99. /**
  100. * 下拉回调
  101. */
  102. downCallback(){
  103. setTimeout(()=>{
  104. this.mescroll.resetUpScroll()
  105. },1500)
  106. },
  107. /**
  108. * 上拉回调
  109. * @param {Object} mescroll
  110. */
  111. upCallback(mescroll) {
  112. try{
  113. let params={
  114. agencyId:this.$cache.get('agencyId'),
  115. current:mescroll.num,
  116. size:mescroll.size
  117. }
  118. this.$api.notice.page(params).then(res=>{
  119. let data=res.data.records
  120. let length=data.length
  121. let total=res.data.total
  122. mescroll.endBySize(length, total);
  123. if(mescroll.num == 1) this.dataList = [];
  124. this.dataList=this.dataList.concat(data);
  125. })
  126. }catch(e){
  127. mescroll.endErr();
  128. }
  129. },
  130. }
  131. }
  132. </script>
  133. <style lang="scss">
  134. .line-red{
  135. border: 1rpx solid #dc0000;
  136. color: #dc0000;
  137. }
  138. .card{
  139. background-color: #FFFFFF;
  140. border-radius: 20rpx;
  141. margin: 20rpx;
  142. .title{
  143. display: flex;
  144. justify-content: space-between;
  145. padding: 20rpx;
  146. font-size: 30rpx;
  147. border-bottom: 0.5rpx solid #e6e5e8;
  148. .time{
  149. padding-top: 8rpx;
  150. font-size: 28rpx;
  151. color: #8d8d8d;
  152. }
  153. }
  154. .content{
  155. color: #737373;
  156. height: 150rpx;
  157. padding:30rpx 20rpx;
  158. border-bottom: 1rpx dashed #e6e5e8;
  159. }
  160. .bottom{
  161. padding: 20rpx;
  162. display: flex;
  163. justify-content: flex-end;
  164. }
  165. }
  166. </style>