historyProcessList.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <el-dialog v-model="visibleDialog" class="le-dialog" title="历史版本" width="700" destroy-on-close :close-on-click-modal="false">
  3. <!-- LeTable 组件使用 -->
  4. <LeTable
  5. ref="tableRef"
  6. v-model:searchParams="tableOpts.searchParams"
  7. v-bind="tableOpts"
  8. v-model:curRow="tableOpts.curRow"
  9. :columns="activeColumns"
  10. >
  11. <template #processIconSlot="scope">
  12. <LeIcon class="group_itemIcon" :icon-class="`${flowIconPrefix}${scope.row.processIcon}`" />
  13. </template>
  14. <template #processVersionSlot="scope">
  15. <el-tag round>V{{ scope.row.processVersion }}</el-tag>
  16. </template>
  17. <template #actionSlot="scope">
  18. <el-tooltip content="签出" placement="bottom" effect="light">
  19. <el-icon class="ibt0" @click="checkoutHistoryEv(scope.row)">
  20. <Edit />
  21. </el-icon>
  22. </el-tooltip>
  23. <el-divider direction="vertical"></el-divider>
  24. <el-tooltip content="预览" placement="bottom" effect="light">
  25. <el-icon class="ibt0">
  26. <View />
  27. </el-icon>
  28. </el-tooltip>
  29. </template>
  30. </LeTable>
  31. </el-dialog>
  32. </template>
  33. <script setup>
  34. import { computed, watch } from 'vue'
  35. import process from '@/api/flow/process'
  36. import { useTablePage } from '@/hooks/useTablePage'
  37. import { flowIconPrefix } from '@/utils/index'
  38. import { ElMessage } from 'element-plus'
  39. const props = defineProps({
  40. modelValue: {
  41. type: Boolean,
  42. default: false
  43. },
  44. processId: {
  45. type: String,
  46. default: undefined
  47. }
  48. })
  49. // 同步值
  50. const $myEmit = defineEmits(['update:modelValue'])
  51. // 关闭弹窗
  52. const closeDialog = () => {
  53. $myEmit('update:modelValue', false)
  54. }
  55. // 获取历史版本 table
  56. const queryList = async () => {
  57. const { options, searchParams } = tableOpts
  58. options.loading = true
  59. try {
  60. const { records: list, total } = await process.pageHistoryListApi({...searchParams, data: { processId: props.processId } })
  61. tableOpts.total = total
  62. tableOpts.list = list
  63. } catch {
  64. tableOpts.total = 0
  65. tableOpts.list = []
  66. options.loading = false // 更改加载中的 loading值
  67. } finally {
  68. options.loading = false
  69. }
  70. }
  71. // table 参数
  72. const columns = [
  73. {
  74. prop: 'processIcon',
  75. label: '图标',
  76. minWidth: 80,
  77. slots: {
  78. default: 'processIconSlot'
  79. }
  80. },
  81. {
  82. prop: 'processName',
  83. label: '流程名称',
  84. minWidth: 60
  85. },
  86. {
  87. prop: 'processVersion',
  88. label: '流程版本',
  89. minWidth: 100,
  90. slots: {
  91. default: 'processVersionSlot'
  92. }
  93. },
  94. {
  95. prop: 'remark',
  96. label: '备注',
  97. minWidth: 100
  98. },
  99. {
  100. prop: 'action',
  101. label: '操作',
  102. width: 100,
  103. fixed: 'right',
  104. slots: {
  105. default: 'actionSlot'
  106. }
  107. }
  108. ]
  109. const { searchData, tableOpts, activeColumns, updateParams } = useTablePage(
  110. {
  111. options: {
  112. showIndex: false,
  113. defaultExpandAll: true
  114. },
  115. // 需要展示的列
  116. columns,
  117. // 控制列配置
  118. columnsConfig: {
  119. columns
  120. }
  121. },
  122. {
  123. queryList,
  124. fetchImmediate: false
  125. }
  126. )
  127. // 签出按钮操作
  128. const checkoutHistoryEv = async row => {
  129. try {
  130. await process.checkoutHistoryApi(row.processId)
  131. ElMessage({ message: '签出成功', type: 'success' })
  132. closeDialog()
  133. } catch (e) {
  134. ElMessage({ message: '签出失败', type: 'error' })
  135. }
  136. }
  137. // 弹窗显隐
  138. const visibleDialog = computed({
  139. get() {
  140. return props.modelValue
  141. },
  142. set(val) {
  143. $myEmit('update:modelValue', val)
  144. }
  145. })
  146. watch(
  147. () => visibleDialog.value,
  148. val => {
  149. console.log(val)
  150. if (val) {
  151. queryList()
  152. }
  153. },
  154. {
  155. immediate: true
  156. }
  157. )
  158. </script>
  159. <style></style>