historyProcessList.vue 3.6 KB

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