TodoList.vue 8.0 KB

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