myDraft.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <ibps-layout ref="layout">
  3. <div slot="west">
  4. <ibps-type-tree
  5. :width="width"
  6. :height="height"
  7. title="任务分类"
  8. category-key="FLOW_TYPE"
  9. @node-click="handleNodeClick"
  10. @expand-collapse="handleExpandCollapse"
  11. />
  12. </div>
  13. <ibps-crud
  14. ref="crud"
  15. :style="{ marginLeft: width+'px' }"
  16. :height="height"
  17. :data="listData"
  18. :toolbars="listConfig.toolbars"
  19. :search-form="listConfig.searchForm"
  20. :pk-key="pkKey"
  21. :columns="listConfig.columns"
  22. display-field="我的暂存"
  23. :pagination="pagination"
  24. :loading="loading"
  25. :index-row="false"
  26. @action-event="handleAction"
  27. @sort-change="handleSortChange"
  28. @column-link-click="handleLinkClick"
  29. @pagination-change="handlePaginationChange"
  30. />
  31. <bpmn-formrender
  32. :visible="dialogFormVisible"
  33. :def-id="defId"
  34. :pro-inst-id="proInstId"
  35. :title="flowName"
  36. @callback="search"
  37. @close="visible => dialogFormVisible = visible"
  38. />
  39. </ibps-layout>
  40. </template>
  41. <script>
  42. import { myDraft, removeDraft } from '@/api/platform/office/bpmInitiated'
  43. import ActionUtils from '@/utils/action'
  44. import FixHeight from '@/mixins/height'
  45. import IbpsTypeTree from '@/business/platform/cat/type/tree'
  46. import BpmnFormrender from '@/business/platform/bpmn/form/dialog'
  47. export default {
  48. components: {
  49. IbpsTypeTree,
  50. BpmnFormrender
  51. },
  52. mixins: [FixHeight],
  53. data() {
  54. return {
  55. width: 200,
  56. height: document.clientHeight,
  57. dialogFormVisible: false, // 弹窗
  58. defId: '',
  59. proInstId: '',
  60. flowName:'',
  61. pkKey: 'id', // 主键 如果主键不是pk需要传主键
  62. typeId: '',
  63. loading: false,
  64. listData: [],
  65. listConfig: {
  66. // 工具栏
  67. toolbars: [
  68. { key: 'search' },
  69. { key: 'remove' }
  70. ],
  71. // 查询条件
  72. searchForm: {
  73. forms: [
  74. { prop: 'Q^subject_^SL', label: '请求标题' },
  75. { prop: 'Q^proc_def_name_^SL', label: '流程名称' }
  76. ]
  77. },
  78. // 表格字段配置
  79. columns: [
  80. { prop: 'taskSubjectName', label: '请求标题', link: 'dialog' },
  81. { prop: 'procDefName', label: '流程名称', width: 250 },
  82. { prop: 'createTime', label: '创建时间', width: 200 }
  83. ]
  84. },
  85. pagination: {},
  86. sorts: {}
  87. }
  88. },
  89. created() {
  90. this.loadData()
  91. },
  92. methods: {
  93. /**
  94. * 加载数据
  95. */
  96. loadData() {
  97. this.loading = true
  98. myDraft(this.getFormatParams()).then(response => {
  99. response.data.dataResult.forEach((item) => {
  100. const taskSubject = item.subject.split('#')
  101. this.$set(item, 'taskSubjectName', taskSubject[0] +'#'+ taskSubject[1]+'#')
  102. })
  103. ActionUtils.handleListData(this, response.data)
  104. this.loading = false
  105. }).catch(() => {
  106. this.loading = false
  107. })
  108. },
  109. /**
  110. * 获取格式化参数
  111. */
  112. getFormatParams() {
  113. const params = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
  114. if (this.$utils.isNotEmpty(this.typeId)) {
  115. params['Q^TYPE_ID_^S'] = this.typeId
  116. }
  117. return ActionUtils.formatParams(
  118. params,
  119. this.pagination,
  120. this.sorts)
  121. },
  122. /**
  123. * 处理分页事件
  124. */
  125. handlePaginationChange(page) {
  126. ActionUtils.setPagination(this.pagination, page)
  127. this.loadData()
  128. },
  129. /**
  130. * 处理排序
  131. */
  132. handleSortChange(sort) {
  133. ActionUtils.setSorts(this.sorts, sort)
  134. this.loadData()
  135. },
  136. search() {
  137. this.loadData()
  138. },
  139. /**
  140. * 重置查询条件
  141. */
  142. reset() {
  143. this.$refs['crud'].handleReset()
  144. },
  145. /**
  146. * 点击链接
  147. */
  148. handleLinkClick(data, columns) {
  149. this.flowName = data.name
  150. this.defId = data.procDefId || ''
  151. this.proInstId = data.id || ''
  152. this.dialogFormVisible = true
  153. },
  154. /**
  155. * 处理按钮事件
  156. */
  157. handleAction(command, position, selection, data) {
  158. switch (command) {
  159. case 'search':// 查询
  160. ActionUtils.setFirstPagination(this.pagination)
  161. this.search()
  162. break
  163. case 'remove':// 删除
  164. ActionUtils.removeRecord(selection).then((ids) => {
  165. this.handleRemove(ids)
  166. }).catch(() => { })
  167. break
  168. default:
  169. break
  170. }
  171. },
  172. /**
  173. * 处理删除
  174. */
  175. handleRemove(ids) {
  176. removeDraft({ ids: ids }).then(response => {
  177. ActionUtils.removeSuccessMessage()
  178. this.search()
  179. }).catch(() => {
  180. })
  181. },
  182. handleNodeClick(typeId) {
  183. this.typeId = typeId
  184. this.loadData()
  185. },
  186. handleExpandCollapse(isExpand) {
  187. this.width = isExpand ? 230 : 30
  188. }
  189. }
  190. }
  191. </script>