myDraft.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. :height="height"
  16. :style="{ marginLeft: width + 'px' }"
  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. :display-field="title"
  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 CommonData from '../mixin/utils'
  46. export default {
  47. mixins: [FixHeight, CommonData],
  48. data() {
  49. return {
  50. title: '我的暂存',
  51. listConfig: {
  52. // 工具栏
  53. toolbars: [{ key: 'search' }, { key: 'remove' }],
  54. // 查询条件
  55. searchForm: {
  56. forms: [
  57. { prop: 'Q^proc_def_name_^SL', label: '事务名称' },
  58. { prop: 'Q^subject_^SL', label: '事务说明' },
  59. {
  60. prop: ['Q^create_time_^DL', 'Q^create_time_^DG'],
  61. label: '创建时间',
  62. fieldType: 'daterange'
  63. }
  64. ]
  65. },
  66. // 表格字段配置
  67. columns: [
  68. {
  69. prop: 'procDefName',
  70. label: '事务名称',
  71. width: 200,
  72. link: 'dialog'
  73. },
  74. { prop: 'subject', label: '事务说明', minWidth: 200 },
  75. {
  76. prop: 'createTime',
  77. label: '创建时间',
  78. width: 150,
  79. sortable: true
  80. }
  81. ]
  82. }
  83. }
  84. },
  85. created() {
  86. this.loadData()
  87. },
  88. methods: {
  89. /**
  90. * 加载数据
  91. */
  92. loadData() {
  93. this.loading = true
  94. myDraft(this.getFormatParams())
  95. .then((response) => {
  96. const { data } = response || {}
  97. data.dataResult.forEach((item, i) => {
  98. item.subject = this.getTaskDesc(item.subject)
  99. })
  100. ActionUtils.handleListData(this, data)
  101. this.loading = false
  102. })
  103. .catch(() => {
  104. this.loading = false
  105. })
  106. },
  107. /**
  108. * 点击链接
  109. */
  110. handleLinkClick(data, columns) {
  111. this.flowName = data.name
  112. this.defId = data.procDefId || ''
  113. this.proInstId = data.id || ''
  114. this.dialogFormVisible = true
  115. },
  116. /**
  117. * 处理按钮事件
  118. */
  119. handleAction(command, position, selection, data) {
  120. switch (command) {
  121. case 'search': // 查询
  122. ActionUtils.setFirstPagination(this.pagination)
  123. this.search()
  124. break
  125. case 'remove': // 删除
  126. ActionUtils.removeRecord(selection)
  127. .then((ids) => {
  128. this.handleRemove(data)
  129. })
  130. .catch(() => {})
  131. break
  132. default:
  133. break
  134. }
  135. },
  136. /**
  137. * 处理删除
  138. */
  139. // handleRemove (ids) {
  140. // removeDraft({ ids: ids }).then(response => {
  141. // ActionUtils.removeSuccessMessage()
  142. // this.search()
  143. // })
  144. // },
  145. handleRemove(datas, selection) {
  146. this.$confirm(
  147. '将删除选中暂存记录与对应数据表数据,删除之后无法恢复, 是否确定?',
  148. '提示',
  149. {
  150. confirmButtonText: '确定',
  151. cancelButtonText: '取消',
  152. type: 'warning',
  153. showClose: false,
  154. closeOnClickModal: false
  155. }
  156. ).then(() => {
  157. const defKeyArr = []
  158. const delList = {}
  159. const idList = []
  160. datas.forEach((item) => {
  161. const { id, bizKey, procDefKey } = item
  162. idList.push(id)
  163. if (!delList[procDefKey]) {
  164. delList[procDefKey] = []
  165. defKeyArr.push(procDefKey)
  166. }
  167. delList[procDefKey].push(bizKey)
  168. })
  169. console.log(idList, delList, defKeyArr)
  170. // const sql = `select bo_code_, def_key_ from ibps_bpm_def where find_in_set(def_key_, '${defKeyArr.join(',')}')`
  171. // const sql = `select a.bo_code_, b.key_ from ibps_form_bo a, ibps_form_def b where a.form_id_ = b.id_ and find_in_set(b.key_, '${formKeyArr.join(',')}')`
  172. this.$common
  173. .request('query', {
  174. key: 'getDraftBoData',
  175. params: [defKeyArr.join(',')]
  176. })
  177. .then((res) => {
  178. const { data = [] } = res.variables || {}
  179. if (!data.length) {
  180. return
  181. }
  182. const codes = {}
  183. data.forEach((item) => {
  184. const { bo_code_, def_key_ } = item
  185. codes[def_key_] = bo_code_
  186. })
  187. // 删除选中记录
  188. removeDraft({ ids: idList.join(',') }).then((res) => {
  189. if (res.state === 103) {
  190. this.$message.warning(res.message)
  191. } else {
  192. ActionUtils.removeSuccessMessage()
  193. this.selection = []
  194. // 循环删除对应数据表数据
  195. defKeyArr.forEach((k) => {
  196. const deleteParams = {
  197. tableName: `t_${codes[k]}`,
  198. paramWhere: { id_: delList[k].join(',') }
  199. }
  200. this.$common.request('delete', deleteParams, 'post', true)
  201. })
  202. this.$message.success('删除成功!')
  203. this.search()
  204. }
  205. })
  206. })
  207. .catch(() => {
  208. this.$message.error('获取数据表key值出错,请联系开发人员!')
  209. })
  210. })
  211. }
  212. }
  213. }
  214. </script>