ApplyList.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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. <u-swipe-action-item v-for="(row) in dataList" @click="({index}) => commit(index, row)" :key="row.id" :threshold="60" duration="500"
  7. :options="getOptions(row)">
  8. <u-cell-group>
  9. <u-cell @click="toDetail(row)">
  10. <view slot="title" class="content">
  11. <view class="text-bold text-grey">
  12. <view class="ellipsis-description">
  13. 标题:{{row.vars.title}}
  14. </view>
  15. </view>
  16. <view class="text-grey text-sm">
  17. <view class="ellipsis-description">
  18. 当前环节:{{row.taskName}}
  19. </view>
  20. </view>
  21. <view class="text-grey text-sm">
  22. 执行时间:{{row.startTime | formatDate}}
  23. </view>
  24. </view>
  25. <view slot="right-icon">
  26. <u-tag :text="row.status" plain shape="circle" :type="row.level === 'danger'? 'error':row.level"></u-tag>
  27. </view>
  28. </u-cell>
  29. </u-cell-group>
  30. </u-swipe-action-item>
  31. </u-swipe-action>
  32. </view>
  33. <u-loadmore :status="status" @loadmore="loadmore" :line="true" />
  34. <u-gap height="20" bgColor="#fff"></u-gap>
  35. <u-back-top :scrollTop="0" mode="square"></u-back-top>
  36. </view>
  37. </template>
  38. <script>
  39. import taskService from "@/api/flowable/taskService"
  40. import processService from "@/api/flowable/processService"
  41. import userSelect from '@/components/user-select/user-select.vue'
  42. import pick from 'lodash.pick'
  43. export default {
  44. components:{
  45. userSelect
  46. },
  47. data() {
  48. return {
  49. status: 'loadmore',
  50. searchForm: {
  51. titile: ''
  52. },
  53. dataList: [],
  54. tablePage: {
  55. pages: 0,
  56. currentPage: 0,
  57. pageSize: 10,
  58. orders: [{ column: "a.create_time", asc: false }],
  59. },
  60. loading: false,
  61. }
  62. },
  63. onLoad() {
  64. this.loadmore()
  65. },
  66. methods: {
  67. // 输入监听
  68. inputWord(e){
  69. this.searchTimer && clearTimeout(this.searchTimer)
  70. this.searchTimer = setTimeout(()=>{
  71. this.doSearch()
  72. },300)
  73. },
  74. // 搜索
  75. doSearch(){
  76. this.dataList = [];
  77. this.tablePage.currentPage = 0;
  78. this.tablePage.pageSize = 10;
  79. this.tablePage.pages = 0;
  80. this.loadmore()
  81. },
  82. getOptions(row){
  83. return row.code === 1?[ {
  84. text: '催办',
  85. style: {
  86. backgroundColor: '#3c9cff'
  87. }
  88. }, {
  89. text: '撤销',
  90. style: {
  91. backgroundColor: '#f56c6c'
  92. }
  93. }, {
  94. text: '历史',
  95. style: {
  96. backgroundColor: '#5ac725'
  97. }
  98. }]:row.code === 3 || row.code === 4 ?[{
  99. text: '历史',
  100. style: {
  101. backgroundColor: '#5ac725'
  102. }
  103. },{
  104. text: '编辑',
  105. style: {
  106. backgroundColor: '#3c9cff'
  107. }
  108. }]:[{
  109. text: '历史',
  110. style: {
  111. backgroundColor: '#5ac725'
  112. }
  113. }]
  114. },
  115. onReachBottom() {
  116. this.loadmore()
  117. },
  118. loadmore() {
  119. if(this.tablePage.currentPage!==0 && this.tablePage.pages <= this.tablePage.currentPage ) {
  120. this.status = 'nomore';
  121. return;
  122. }
  123. this.tablePage.currentPage = ++ this.tablePage.currentPage;
  124. //联网加载数据
  125. this.status = 'loading';
  126. taskService.myApplyedList({
  127. current: this.tablePage.currentPage,
  128. size: this.tablePage.pageSize,
  129. orders: this.tablePage.orders,
  130. ...this.searchForm
  131. }).then((data)=>{
  132. //追加新数据
  133. this.dataList=this.dataList.concat(data.records);
  134. this.tablePage.pages = data.pages;
  135. if(this.tablePage.pages <= this.tablePage.currentPage){
  136. this.status = 'nomore'
  137. } else {
  138. this.status = 'loadmore'
  139. }
  140. })
  141. },
  142. commit(index, row){
  143. if(row.code === 1) {
  144. if(index === 0){
  145. this.urge(row)
  146. }else if(index === 1){
  147. this.callback(row)
  148. }else if(index === 2){
  149. this.toDetail(row)
  150. }
  151. } else if(row.code === 3 || row.code === 4) {
  152. if(index === 0){
  153. this.urge(row)
  154. }else if(index === 1){
  155. this.restart(row)
  156. }
  157. } else {
  158. if(index === 0){
  159. this.toDetail(row)
  160. }
  161. }
  162. },
  163. // 撤销申请
  164. callback (row) {
  165. uni.showModal({
  166. title: '提示',
  167. content: '确定要撤销该流程吗?',
  168. success: (res)=>{
  169. if (res.confirm) {
  170. processService.revokeProcIns(row.processInstanceId, '用户撤销').then((data) => {
  171. uni.showToast({
  172. title:data
  173. })
  174. this.doSearch(this.curWord)
  175. })
  176. } else if (res.cancel) {
  177. uni.hideLoading()
  178. }
  179. },
  180. fail() {
  181. }
  182. });
  183. },
  184. urge (row) {
  185. uni.showToast({
  186. title: '催办成功!'
  187. })
  188. },
  189. // 重新填写
  190. restart(row) {
  191. // 读取流程表单
  192. taskService
  193. .getTaskDef({
  194. procInsId: row.processInstanceId,
  195. procDefId: row.processDefinitionId,
  196. })
  197. .then((data) => {
  198. let query = {
  199. status: "start",
  200. title: row.vars.title,
  201. formTitle: row.vars.title,
  202. ...pick(
  203. data,
  204. "formType",
  205. "formUrl",
  206. "procDefKey",
  207. "taskDefKey",
  208. "procInsId",
  209. "procDefId",
  210. "taskId",
  211. "status",
  212. "title",
  213. "businessId"
  214. )
  215. }
  216. uni.navigateTo({
  217. url: '/pages/workbench/task/TaskFormEdit?flow='+JSON.stringify(query)
  218. })
  219. });
  220. },
  221. toDetail (row) {
  222. taskService.getTaskDef({
  223. procInsId: row.processInstanceId,
  224. procDefId: row.processDefinitionId
  225. }).then((data) => {
  226. let query = {readOnly: true, title: row.vars.title, formTitle: row.vars.title, ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId')}
  227. uni.navigateTo({
  228. url: '/pages/workbench/task/TaskFormDetail?flow='+JSON.stringify(query)
  229. })
  230. })
  231. },
  232. }
  233. }
  234. </script>