oaNotifyList.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <template>
  2. <view v-show="i === index">
  3. <view :style="[{'margin-top': CustomBar - 10 + 'px'}]">
  4. <view class="cu-bar search">
  5. <view class="search-form bg-white round">
  6. <text class="cuIcon-search"></text>
  7. <input type="text" placeholder="搜索" v-model="curWord" confirm-type="search" @input="inputWord"></input>
  8. </view>
  9. </view>
  10. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" :up="upOption" @up="upCallback">
  11. <view class="cu-list menu-avatar">
  12. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(notify, index) in list" :key="index"
  13. @touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
  14. <view @click="toDetail(notify)" class="cu-avatar cuIcon-notification bg-blue round">
  15. </view>
  16. <view @click="toDetail(notify)" class="content">
  17. <view class="text-bold text-grey">
  18. <view class="ellipsis-description">
  19. <text v-if="notify.readFlag === '0'" class='cuIcon-title text-blue'></text>
  20. 标题: {{notify.title}}
  21. </view>
  22. </view>
  23. <view class=" text-gray text-sm">
  24. <view class="ellipsis-description">
  25. 发布者:{{notify.createBy.name}},内容:{{notify.content}}
  26. </view>
  27. </view>
  28. </view>
  29. <view @click="toDetail(notify)" class="action">
  30. <view class="text-grey text-xs" >{{notify.createDate}}</view>
  31. <view :class="notify.status === '1'?'bg-green':'bg-red'" class="cu-tag round sm">
  32. {{$dictUtils.getDictLabel('oa_notify_status', notify.status ,'')}}</view>
  33. </view>
  34. <view class="move" >
  35. <view class="bg-red" @click="del(notify.id)">删除</view>
  36. </view>
  37. </view>
  38. </view>
  39. </mescroll-body>
  40. </view>
  41. <uni-fab
  42. v-if="$auth.hasPermission('notify:add')"
  43. :pattern=" {
  44. color: '#7A7E83',
  45. backgroundColor: '#fff',
  46. selectedColor: '#007AFF',
  47. buttonColor: '#007AFF'
  48. }"
  49. horizontal="right"
  50. vertical="bottom"
  51. @fabClick="toAdd"
  52. ></uni-fab>
  53. </view>
  54. </template>
  55. <script>
  56. import uniFab from '@/components/uni-fab/uni-fab.vue';
  57. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  58. import MescrollMoreItemMixin from "@/components/mescroll-uni/mixins/mescroll-more-item.js";
  59. import notifyService from "@/api/notify/notifyService";
  60. export default {
  61. mixins: [MescrollMixin,MescrollMoreItemMixin], // 使用mixin (在main.js注册全局组件)
  62. props:{
  63. i: Number, // 每个tab页的专属下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
  64. index: { // 当前tab的下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
  65. type: Number,
  66. default(){
  67. return 0
  68. }
  69. },
  70. tabs: { // 为了请求数据,演示用,可根据自己的项目判断是否要传
  71. type: Array,
  72. default(){
  73. return []
  74. }
  75. }
  76. },
  77. components:{
  78. uniFab
  79. },
  80. data() {
  81. return {
  82. upOption: {
  83. // auto: false, //是否在初始化后,自动执行上拉回调callback; 默认true
  84. // page: {
  85. // num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  86. // size: 10 // 每页数据的数量
  87. // }
  88. noMoreSize: 3, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看
  89. empty: {
  90. tip: '~ 搜索无结果 ~' // 提示
  91. }
  92. },
  93. CustomBar: this.CustomBar,
  94. list: [], // 数据列表
  95. modalName: null,
  96. TabCur: 1,
  97. curWord:"" //当前搜索关键词
  98. }
  99. },
  100. methods: {
  101. // 跳转到详细页面
  102. toDetail (notify) {
  103. if(notify.status === '1'){
  104. uni.navigateTo({
  105. url: '/pages/apps/notification/notificationDetail?id='+notify.id
  106. })
  107. }else{
  108. this.toEdit(notify)
  109. }
  110. },
  111. toEdit (notify) {
  112. uni.navigateTo({
  113. url: '/pages/apps/notification/oaNotifyForm?id='+notify.id
  114. })
  115. },
  116. toAdd (){
  117. uni.navigateTo({
  118. url: '/pages/apps/notification/oaNotifyForm'
  119. })
  120. },
  121. tabSelect(e) {
  122. this.TabCur = e.currentTarget.dataset.id;
  123. this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
  124. },
  125. TabSelect(e) {
  126. this.tabCur = e.currentTarget.dataset.id;
  127. this.mainCur = e.currentTarget.dataset.id;
  128. this.verticalNavTop = (e.currentTarget.dataset.id - 1) * 50
  129. },
  130. // 输入监听
  131. inputWord(e){
  132. // this.curWord = e.detail.value // 已使用v-model,无需再次赋值
  133. // 节流,避免输入过快多次请求
  134. this.searchTimer && clearTimeout(this.searchTimer)
  135. this.searchTimer = setTimeout(()=>{
  136. this.doSearch(this.curWord)
  137. },300)
  138. },
  139. // 搜索
  140. doSearch(word){
  141. this.curWord = word
  142. this.list = []; // 先清空列表,显示加载进度
  143. this.mescroll.resetUpScroll();
  144. },
  145. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  146. upCallback(page) {
  147. //联网加载数据
  148. notifyService.list({
  149. current: page.num,
  150. size: page.size,
  151. title: this.curWord
  152. }).then(({data})=>{
  153. let curPageData = data.records
  154. this.mescroll.endBySize(curPageData.length, data.total);
  155. //如果是第一页需手动制空列表
  156. if(page.num == 1)
  157. this.list = [];
  158. //追加新数据
  159. this.list=this.list.concat(curPageData);
  160. }).catch(e=>{
  161. //联网失败, 结束加载
  162. this.mescroll.endErr();
  163. })
  164. },
  165. del (id) {
  166. notifyService.delete(id).then(({data})=>{
  167. uni.showToast({
  168. title: data,
  169. icon:"success"
  170. })
  171. this.doSearch(this.curWord)
  172. })
  173. },
  174. VerticalMain(e) {
  175. // #ifdef MP-ALIPAY
  176. return false //支付宝小程序暂时不支持双向联动
  177. // #endif
  178. let that = this;
  179. let tabHeight = 0;
  180. if (this.load) {
  181. for (let i = 0; i < this.list.length; i++) {
  182. let view = uni.createSelectorQuery().select("#main-" + this.list[i].id);
  183. view.fields({
  184. size: true
  185. }, data => {
  186. this.list[i].top = tabHeight;
  187. tabHeight = tabHeight + data.height;
  188. this.list[i].bottom = tabHeight;
  189. }).exec();
  190. }
  191. this.load = false
  192. }
  193. let scrollTop = e.detail.scrollTop + 10;
  194. for (let i = 0; i < this.list.length; i++) {
  195. if (scrollTop > this.list[i].top && scrollTop < this.list[i].bottom) {
  196. this.verticalNavTop = (this.list[i].id - 1) * 50
  197. this.tabCur = this.list[i].id
  198. console.log(scrollTop)
  199. return false
  200. }
  201. }
  202. },
  203. InputFocus(e) {
  204. this.InputBottom = e.detail.height
  205. },
  206. InputBlur(e) {
  207. this.InputBottom = 0
  208. },
  209. showModal(e) {
  210. this.modalName = e.currentTarget.dataset.target
  211. },
  212. hideModal(e) {
  213. this.modalName = null
  214. },
  215. Gridchange(e) {
  216. this.gridCol = e.detail.value
  217. },
  218. Gridswitch(e) {
  219. this.gridBorder = e.detail.value
  220. },
  221. MenuBorder(e) {
  222. this.menuBorder = e.detail.value
  223. },
  224. MenuArrow(e) {
  225. this.menuArrow = e.detail.value
  226. },
  227. MenuCard(e) {
  228. this.menuCard = e.detail.value
  229. },
  230. SwitchSex(e) {
  231. this.skin = e.detail.value
  232. },
  233. // ListTouch触摸开始
  234. ListTouchStart(e) {
  235. this.listTouchStart = e.touches[0].pageX
  236. },
  237. // ListTouch计算方向
  238. ListTouchMove(e) {
  239. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart > -60? 'right' : 'left'
  240. },
  241. // ListTouch计算滚动
  242. ListTouchEnd(e) {
  243. if (this.listTouchDirection == 'left') {
  244. this.modalName = e.currentTarget.dataset.target
  245. } else {
  246. this.modalName = null
  247. }
  248. this.listTouchDirection = null
  249. }
  250. }
  251. }
  252. </script>
  253. <style>
  254. .ellipsis-description {
  255. font-size: 12px;
  256. line-height: $line-height-base;
  257. display: -webkit-box;/*作为弹性伸缩盒子模型显示*/
  258. -webkit-line-clamp: 1; /*显示的行数;如果要设置2行加...则设置为2*/
  259. overflow: hidden; /*超出的文本隐藏*/
  260. text-overflow: ellipsis; /* 溢出用省略号*/
  261. -webkit-box-orient: vertical;/*伸缩盒子的子元素排列:从上到下*/
  262. }
  263. /*关键词搜索*/
  264. .item{
  265. padding: 20rpx;
  266. }
  267. .tip{
  268. font-size: 30rpx;
  269. vertical-align: middle;
  270. }
  271. .hot-word{
  272. font-size: 24rpx;
  273. margin-left: 30rpx;
  274. padding: 6rpx 40rpx;
  275. border: 2rpx solid #FF6990;
  276. border-radius: 100rpx;
  277. vertical-align: middle;
  278. color: #FF6990;
  279. }
  280. .word-input{
  281. display: inline-block;
  282. width: 60%;
  283. height: 50rpx;
  284. line-height: 50rpx;
  285. font-size: 24rpx;
  286. margin-left: 30rpx;
  287. border: 2rpx solid #18B4FE;
  288. border-radius: 60rpx;
  289. text-align: center;
  290. background-color: #fff;
  291. vertical-align: middle;
  292. }
  293. .top-warp{
  294. z-index: 9990;
  295. position: fixed;
  296. /* top: --window-top; /* css变量 */
  297. left: 0;
  298. width: 100%;
  299. height: 120upx;
  300. background-color: white;
  301. }
  302. .cu-bar .search-form{
  303. background-color: white;
  304. }
  305. </style>