index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <ContentWrap>
  3. <!-- 列表 -->
  4. <XTable @register="registerTable">
  5. <template #toolbar_buttons>
  6. <!-- 操作:新增 -->
  7. <XButton
  8. type="primary"
  9. preIcon="ep:zoom-in"
  10. title="发起流程"
  11. v-hasPermi="['bpm:process-instance:query']"
  12. @click="handleCreate"
  13. />
  14. </template>
  15. <!-- 流程分类 -->
  16. <template #category_default="{ row }">
  17. <DictTag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="Number(row?.category)" />
  18. </template>
  19. <!-- 当前审批任务 -->
  20. <template #tasks_default="{ row }">
  21. <el-button v-for="task in row.tasks" :key="task.id" link>
  22. <span>{{ task.name }}</span>
  23. </el-button>
  24. </template>
  25. <!-- 操作 -->
  26. <template #actionbtns_default="{ row }">
  27. <XTextButton
  28. preIcon="ep:view"
  29. :title="t('action.detail')"
  30. v-hasPermi="['bpm:process-instance:cancel']"
  31. @click="handleDetail(row)"
  32. />
  33. <XTextButton
  34. preIcon="ep:delete"
  35. title="取消"
  36. v-if="row.result === 1"
  37. v-hasPermi="['bpm:process-instance:query']"
  38. @click="handleCancel(row)"
  39. />
  40. </template>
  41. </XTable>
  42. </ContentWrap>
  43. </template>
  44. <script setup lang="ts">
  45. // 全局相关的 import
  46. import { ElMessageBox } from 'element-plus'
  47. import { DICT_TYPE } from '@/utils/dict'
  48. // 业务相关的 import
  49. import * as ProcessInstanceApi from '@/api/bpm/processInstance'
  50. import { allSchemas } from './process.data'
  51. const router = useRouter() // 路由
  52. const message = useMessage() // 消息弹窗
  53. const { t } = useI18n() // 国际化
  54. // ========== 列表相关 ==========
  55. const [registerTable, { reload }] = useXTable({
  56. allSchemas: allSchemas,
  57. getListApi: ProcessInstanceApi.getMyProcessInstancePage
  58. })
  59. /** 发起流程操作 **/
  60. const handleCreate = () => {
  61. router.push({
  62. name: 'BpmProcessInstanceCreate'
  63. })
  64. }
  65. // 列表操作
  66. const handleDetail = (row) => {
  67. router.push({
  68. name: 'BpmProcessInstanceDetail',
  69. query: {
  70. id: row.id
  71. }
  72. })
  73. }
  74. /** 取消按钮操作 */
  75. const handleCancel = (row) => {
  76. ElMessageBox.prompt('请输入取消原因', '取消流程', {
  77. confirmButtonText: t('common.ok'),
  78. cancelButtonText: t('common.cancel'),
  79. inputPattern: /^[\s\S]*.*\S[\s\S]*$/, // 判断非空,且非空格
  80. inputErrorMessage: '取消原因不能为空'
  81. }).then(async ({ value }) => {
  82. await ProcessInstanceApi.cancelProcessInstance(row.id, value)
  83. message.success('取消成功')
  84. reload()
  85. })
  86. }
  87. </script>