myDraft.vue 4.8 KB

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