FlowCopyList.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-blue" backUrl="/pages/index/index" :isBack="true">
  4. <block slot="backText">返回</block>
  5. <block slot="content">抄送我的</block>
  6. </cu-custom>
  7. <view :style="[{top:CustomBar + 'px'}]">
  8. <view class="cu-bar search">
  9. <view class="search-form bg-white round">
  10. <text class="cuIcon-search"></text>
  11. <input type="text" placeholder="搜索" v-model="curWord" confirm-type="search" @input="inputWord"></input>
  12. </view>
  13. </view>
  14. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" :up="upOption" @up="upCallback">
  15. <view class="cu-list menu-avatar">
  16. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(row, index) in list" :key="index"
  17. @touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
  18. <view @tap="toDetail(row)" class="content">
  19. <view class="text-bold text-grey">
  20. <view class="ellipsis-description">
  21. {{row.createBy.name}}发起的【{{row.procInsName}}】
  22. </view>
  23. </view>
  24. </view>
  25. <view @tap="toDetail(row)" class="action">
  26. <view class="text-grey text-xs" > {{row.createDate | formatDate}}</view>
  27. </view>
  28. <view class="move" >
  29. <view class="bg-red" @tap="del(row)">删除</view>
  30. <view class="bg-blue" @tap="toDetail(row)">查阅审批</view>
  31. </view>
  32. </view>
  33. </view>
  34. </mescroll-body>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  40. import MescrollMoreItemMixin from "@/components/mescroll-uni/mixins/mescroll-more-item.js";
  41. import pick from 'lodash.pick'
  42. import flowCopyService from "@/api/flowable/flowCopyService"
  43. import taskService from "@/api/flowable/taskService"
  44. export default {
  45. mixins: [MescrollMixin,MescrollMoreItemMixin], // 使用mixin (在main.js注册全局组件)
  46. props:{
  47. i: Number, // 每个tab页的专属下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
  48. index: { // 当前tab的下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
  49. type: Number,
  50. default(){
  51. return 0
  52. }
  53. },
  54. tabs: { // 为了请求数据,演示用,可根据自己的项目判断是否要传
  55. type: Array,
  56. default(){
  57. return []
  58. }
  59. }
  60. },
  61. data() {
  62. return {
  63. upOption: {
  64. noMoreSize: 3, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看
  65. empty: {
  66. tip: '~ 搜索无结果 ~' // 提示
  67. }
  68. },
  69. CustomBar: this.CustomBar,
  70. list: [], // 数据列表
  71. modalName: null,
  72. curWord:"" //当前搜索关键词
  73. }
  74. },
  75. methods: {
  76. // 输入监听
  77. inputWord(e){
  78. // this.curWord = e.detail.value // 已使用v-model,无需再次赋值
  79. // 节流,避免输入过快多次请求
  80. this.searchTimer && clearTimeout(this.searchTimer)
  81. this.searchTimer = setTimeout(()=>{
  82. this.doSearch(this.curWord)
  83. },300)
  84. },
  85. // 搜索
  86. doSearch(word){
  87. this.curWord = word
  88. this.list = []; // 先清空列表,显示加载进度
  89. this.mescroll.resetUpScroll();
  90. },
  91. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  92. upCallback(page) {
  93. //联网加载数据
  94. flowCopyService.list({
  95. current: page.num,
  96. size: page.size,
  97. procInsName: this.curWord
  98. }).then(({data})=>{
  99. let curPageData = data.records
  100. this.mescroll.endBySize(curPageData.length, data.total);
  101. //如果是第一页需手动制空列表
  102. if(page.num == 1)
  103. this.list = [];
  104. //追加新数据
  105. this.list=this.list.concat(curPageData);
  106. }).catch(e=>{
  107. //联网失败, 结束加载
  108. this.mescroll.endErr();
  109. })
  110. },
  111. // 撤销申请
  112. del (row) {
  113. uni.showModal({
  114. title: '提示',
  115. content: '确定要删除该抄送吗?',
  116. success: (res)=>{
  117. if (res.confirm) {
  118. flowCopyService.delete(row.id).then(({data}) => {
  119. uni.showToast({
  120. title:data
  121. })
  122. this.doSearch(this.curWord)
  123. })
  124. } else if (res.cancel) {
  125. uni.hideLoading()
  126. }
  127. },
  128. fail() {
  129. }
  130. });
  131. },
  132. toDetail (row) {
  133. taskService.getTaskDef({
  134. procInsId: row.procInsId,
  135. procDefId: row.procDefId
  136. }).then(({data}) => {
  137. let query = {readOnly: true, title: row.procInsName, formTitle: row.procInsName, ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId')}
  138. uni.navigateTo({
  139. url: '/pages/workbench/task/TaskFormDetail?flow='+JSON.stringify(query)
  140. })
  141. })
  142. },
  143. // ListTouch触摸开始
  144. ListTouchStart(e) {
  145. this.listTouchStart = e.touches[0].pageX
  146. },
  147. // ListTouch计算方向
  148. ListTouchMove(e) {
  149. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart > -60? 'right' : 'left'
  150. },
  151. // ListTouch计算滚动
  152. ListTouchEnd(e) {
  153. if (this.listTouchDirection == 'left') {
  154. this.modalName = e.currentTarget.dataset.target
  155. } else {
  156. this.modalName = null
  157. }
  158. this.listTouchDirection = null
  159. }
  160. }
  161. }
  162. </script>
  163. <style>
  164. .ellipsis-description {
  165. font-size: 12px;
  166. line-height: $line-height-base;
  167. display: -webkit-box;/*作为弹性伸缩盒子模型显示*/
  168. -webkit-line-clamp: 1; /*显示的行数;如果要设置2行加...则设置为2*/
  169. overflow: hidden; /*超出的文本隐藏*/
  170. text-overflow: ellipsis; /* 溢出用省略号*/
  171. -webkit-box-orient: vertical;/*伸缩盒子的子元素排列:从上到下*/
  172. }
  173. .cu-list.menu-avatar>.cu-item .content {
  174. position: absolute;
  175. left: 29px;
  176. width: calc(100% - 77px);
  177. line-height: 1.6em;
  178. }
  179. .cu-bar .search-form{
  180. background-color: white;
  181. }
  182. .cu-list>.cu-item .move {
  183. width: 160px;
  184. }
  185. .cu-list>.cu-item.move-cur {
  186. -webkit-transform: translateX(-160px);
  187. transform: translateX(-160px);
  188. }
  189. </style>