ApplyList.vue 6.6 KB

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