HistoryList.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view>
  3. <u-search :show-action="false" v-model="searchForm.title" @change="inputWord" margin="20rpx 50rpx"></u-search>
  4. <view>
  5. <u-swipe-action>
  6. <view
  7. v-for="(row, index) in dataList"
  8. :key="index">
  9. <u-swipe-action-item @click="({index}) => commit(index, row)" :key="row.id" :threshold="60" duration="500"
  10. :options="getOptions">
  11. <u-cell-group>
  12. <u-cell @click="toDetail(row)">
  13. <view slot="title" class="content">
  14. <view class="text-bold text-grey">
  15. <view class="ellipsis-description">
  16. 实例标题:{{row.vars.title}}
  17. </view>
  18. </view>
  19. <view class="text-grey text-sm">
  20. <view class="ellipsis-description">
  21. 流程名称:{{row.processDefinitionName}}
  22. </view>
  23. </view>
  24. <view class="text-grey text-sm">
  25. <view class="ellipsis-description">
  26. 任务:{{row.name}}
  27. </view>
  28. </view>
  29. <view class="text-grey text-sm">
  30. 执行时间:{{row.createTime | formatDate}}
  31. </view>
  32. </view>
  33. <view slot="right-icon" class="action">
  34. <u-tag :text="row.status" plain shape="circle" :type="row.level === 'danger'? 'error':row.level"></u-tag>
  35. </view>
  36. </u-cell>
  37. </u-cell-group>
  38. </u-swipe-action-item>
  39. </view>
  40. </u-swipe-action>
  41. </view>
  42. <u-loadmore :status="status" @loadmore="loadmore" :line="true" />
  43. <u-gap height="20" bgColor="#fff"></u-gap>
  44. <u-back-top :scrollTop="0" mode="square"></u-back-top>
  45. </view>
  46. </template>
  47. <script>
  48. import taskService from "@/api/flowable/taskService"
  49. import pick from 'lodash.pick'
  50. export default {
  51. data() {
  52. return {
  53. status: 'loadmore',
  54. searchForm: {
  55. title: ''
  56. },
  57. dataList: [],
  58. tablePage: {
  59. pages: 0,
  60. currentPage: 0,
  61. pageSize: 10,
  62. orders: [{ column: "a.create_time", asc: false }],
  63. },
  64. loading: false,
  65. }
  66. },
  67. onLoad() {
  68. this.loadmore()
  69. },
  70. methods: {
  71. getOptions (row) {
  72. return row.back?[ {
  73. text: '撤回',
  74. style: {
  75. backgroundColor: '#f56c6c'
  76. }
  77. }, {
  78. text: '历史',
  79. style: {
  80. backgroundColor: '#5ac725'
  81. }
  82. }]:[ {
  83. text: '历史',
  84. style: {
  85. backgroundColor: '#5ac725'
  86. }
  87. }]
  88. },
  89. commit(index, row){
  90. if(row.back) {
  91. if(index === 0){
  92. this.callback(row)
  93. }else if(index === 1){
  94. this.toDetail(row)
  95. }
  96. } else {
  97. if(index === 0){
  98. this.toDetail(row)
  99. }
  100. }
  101. },
  102. // 跳转到详细页面
  103. toDetail (row) {
  104. taskService.getTaskDef({
  105. taskDefKey: row.taskDefinitionKey,
  106. procInsId: row.processInstanceId,
  107. procDefId: row.processDefinitionId
  108. }).then((data) => {
  109. let query = {readOnly: true, taskId: row.executionId, title: `${row.name}【${row.name}】`, formTitle: `${row.name}`, ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId')}
  110. uni.navigateTo({
  111. url: '/pages/workbench/task/TaskFormDetail?flow='+JSON.stringify(query)
  112. })
  113. })
  114. },
  115. // 取回
  116. callback (row) {
  117. uni.showModal({
  118. title: '提示',
  119. content: '确定撤销该已办任务吗?',
  120. success: (res) => {
  121. if (res.confirm) {
  122. uni.showLoading()
  123. taskService.callback({'processInstanceId': row.processInstanceId,
  124. 'preTaskDefKey': row.taskDefinitionKey,
  125. 'preTaskId': row.id,
  126. 'currentTaskId': row.currentTask.id,
  127. 'currentTaskDefKey': row.currentTask.taskDefinitionKey
  128. }).then((data) => {
  129. uni.showToast({
  130. title:data.msg
  131. })
  132. this.doSearch(this.curWord)
  133. })
  134. } else if (res.cancel) {
  135. uni.hideLoading()
  136. }
  137. }
  138. });
  139. },
  140. // 输入监听
  141. inputWord(e){
  142. this.searchTimer && clearTimeout(this.searchTimer)
  143. this.searchTimer = setTimeout(()=>{
  144. this.doSearch()
  145. },300)
  146. },
  147. // 搜索
  148. doSearch(){
  149. this.dataList = [];
  150. this.tablePage.currentPage = 0;
  151. this.tablePage.pageSize = 10;
  152. this.tablePage.pages = 0;
  153. this.loadmore()
  154. },
  155. onReachBottom() {
  156. this.loadmore()
  157. },
  158. loadmore() {
  159. if(this.tablePage.currentPage!==0 && this.tablePage.pages <= this.tablePage.currentPage ) {
  160. this.status = 'nomore';
  161. return;
  162. }
  163. this.tablePage.currentPage = ++ this.tablePage.currentPage;
  164. //联网加载数据
  165. this.status = 'loading';
  166. taskService.historicList({
  167. current: this.tablePage.currentPage,
  168. size: this.tablePage.pageSize,
  169. orders: this.tablePage.orders,
  170. ...this.searchForm
  171. }).then((data)=>{
  172. //追加新数据
  173. this.dataList=this.dataList.concat(data.records);
  174. this.tablePage.pages = data.pages;
  175. if(this.tablePage.pages <= this.tablePage.currentPage){
  176. this.status = 'nomore'
  177. } else {
  178. this.status = 'loadmore'
  179. }
  180. })
  181. }
  182. }
  183. }
  184. </script>