utils.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. import ActionUtils from '@/utils/action'
  2. export default {
  3. components: {
  4. 'bpmn-formrender': () => import('@/business/platform/bpmn/form/dialog'),
  5. 'ibps-type-tree': () => import('@/business/platform/cat/type/tree'),
  6. 'ibps-card-list': () => import('@/components/ibps-card-list/list'),
  7. 'form-rights': () => import('@/business/platform/form/form-rights'),
  8. 'form-builder': () => import('@/business/platform/form/formbuilder/dialog'),
  9. 'formrender-preview': () =>
  10. import('@/business/platform/form/formrender/preview/index')
  11. },
  12. data() {
  13. const { userList = [], deptList = [] } = this.$store.getters
  14. const defaultWidth = 360
  15. return {
  16. userList,
  17. deptList,
  18. defaultWidth,
  19. width: defaultWidth,
  20. height: document.clientHeight,
  21. createText: '创建表单',
  22. query: '',
  23. typeId: '',
  24. pkKey: 'id', // 主键 如果主键不是pk需要传主键
  25. loading: false,
  26. dialogFormVisible: false,
  27. copyDialogFormVisible: false,
  28. rightsDialogFormVisible: false,
  29. formbuilderDialogVisible: false,
  30. formrenderDialogVisible: false,
  31. importFormVisible: false,
  32. formPrintDialogVisible: false,
  33. defId: '',
  34. taskId: '',
  35. editId: '',
  36. proInstId: '',
  37. instanceId: '',
  38. flowName: '',
  39. formKey: '',
  40. searchField: '',
  41. searchName: '',
  42. listData: [],
  43. pagination: {},
  44. sorts: {}
  45. }
  46. },
  47. methods: {
  48. /**
  49. * 获取格式化参数
  50. */
  51. getFormatParams(args) {
  52. let params = this.$refs['crud']
  53. ? this.$refs['crud'].getSearcFormData()
  54. : {}
  55. if (this.$utils.isNotEmpty(this.typeId)) {
  56. params['Q^TYPE_ID_^S'] = this.typeId
  57. }
  58. params = {
  59. ...params,
  60. ...args
  61. }
  62. return ActionUtils.formatParams(params, this.pagination, this.sorts)
  63. },
  64. /**
  65. * 处理分页事件
  66. */
  67. handlePaginationChange(page) {
  68. ActionUtils.setPagination(this.pagination, page)
  69. this.loadData()
  70. },
  71. /**
  72. * 处理排序
  73. */
  74. handleSortChange(sort) {
  75. ActionUtils.setSorts(this.sorts, sort)
  76. this.loadData()
  77. },
  78. search() {
  79. this.loadData()
  80. },
  81. /**
  82. * 重置查询条件
  83. */
  84. reset() {
  85. this.$refs['crud'].handleReset()
  86. },
  87. handleNodeClick(typeId) {
  88. this.typeId = typeId
  89. this.loadData()
  90. },
  91. handleExpandCollapse(isExpand) {
  92. this.width = isExpand ? this.defaultWidth : 30
  93. },
  94. getTaskDesc(v) {
  95. if (!v.includes('#')) {
  96. return ''
  97. }
  98. return v.split('#')[1] || ''
  99. },
  100. getTaskInfo(val, arg = 'dept') {
  101. const arr = val.split('#')
  102. if (!arr[2]) {
  103. return ''
  104. }
  105. arr[2] = arr[2].replace(':', ':')
  106. let result = {}
  107. try {
  108. result = JSON.parse(`{${arr[2]}}`)
  109. } catch (error) {
  110. console.log(val)
  111. }
  112. if (!result.dept) {
  113. return ''
  114. }
  115. const depts = result.dept.split(',')
  116. const deptNames = []
  117. depts.forEach((item) => {
  118. const t = this.deptList.find((i) => i.positionId === item)
  119. deptNames.push(t ? t.positionName : result.dept)
  120. })
  121. result.deptName = deptNames.join(',')
  122. return result[arg]
  123. },
  124. /**
  125. * 点击表格
  126. */
  127. handleLinkClick(data) {
  128. this.instanceId = data.id || ''
  129. this.dialogFormVisible = true
  130. },
  131. /**
  132. * 数据转换,用户、部门
  133. */
  134. getTransformData(val, dataset, from, to) {
  135. if (!val) {
  136. return ''
  137. }
  138. const temp = this[dataset].find((u) => u[from] === val)
  139. return temp ? temp[to] : ''
  140. }
  141. }
  142. }