index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <script setup lang="ts" name="ProcessInstance">
  2. import dayjs from 'dayjs'
  3. import { DICT_TYPE } from '@/utils/dict'
  4. import { useTable } from '@/hooks/web/useTable'
  5. import type { ProcessInstanceVO } from '@/api/bpm/processInstance/types'
  6. import { allSchemas } from './process.data'
  7. import * as ProcessInstanceApi from '@/api/bpm/processInstance'
  8. import { ElMessageBox } from 'element-plus'
  9. const { t } = useI18n() // 国际化
  10. const message = useMessage()
  11. // ========== 列表相关 ==========
  12. const { register, tableObject, methods } = useTable<ProcessInstanceVO>({
  13. getListApi: ProcessInstanceApi.getMyProcessInstancePageApi
  14. })
  15. const { getList, setSearchParams } = methods
  16. // ========== CRUD 相关 ==========
  17. const dialogVisible = ref(false) // 是否显示弹出层
  18. // 发起流程
  19. const handleAdd = () => {
  20. console.info('add')
  21. }
  22. // 取消操作
  23. const handleCancel = (row: ProcessInstanceVO) => {
  24. ElMessageBox.prompt('请输入取消原因?', '取消流程', {
  25. confirmButtonText: t('common.ok'),
  26. cancelButtonText: t('common.cancel'),
  27. type: 'warning',
  28. inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/, // 判断非空,且非空格
  29. inputErrorMessage: '取消原因不能为空'
  30. }).then(async ({ value }) => {
  31. await ProcessInstanceApi.cancelProcessInstanceApi(row.id, value)
  32. message.success('取消成功')
  33. getList()
  34. })
  35. }
  36. // ========== 详情相关 ==========
  37. const detailData = ref() // 详情 Ref
  38. // 详情操作
  39. const handleDetail = async (row: ProcessInstanceVO) => {
  40. // 设置数据
  41. detailData.value = row
  42. dialogVisible.value = true
  43. }
  44. // ========== 初始化 ==========
  45. getList()
  46. </script>
  47. <template>
  48. <!-- 搜索工作区 -->
  49. <ContentWrap>
  50. <Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
  51. </ContentWrap>
  52. <ContentWrap>
  53. <!-- 操作工具栏 -->
  54. <div class="mb-10px">
  55. <el-button type="primary" v-hasPermi="['bpm:process-instance:query']" @click="handleAdd">
  56. <Icon icon="ep:zoom-in" class="mr-5px" /> {{ t('action.add') }}
  57. </el-button>
  58. </div>
  59. <!-- 列表 -->
  60. <Table
  61. :columns="allSchemas.tableColumns"
  62. :selection="false"
  63. :data="tableObject.tableList"
  64. :loading="tableObject.loading"
  65. :pagination="{
  66. total: tableObject.total
  67. }"
  68. v-model:pageSize="tableObject.pageSize"
  69. v-model:currentPage="tableObject.currentPage"
  70. @register="register"
  71. >
  72. <template #status="{ row }">
  73. <DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
  74. </template>
  75. <template #createTime="{ row }">
  76. <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
  77. </template>
  78. <template #action="{ row }">
  79. <el-button
  80. link
  81. type="primary"
  82. v-hasPermi="['bpm:process-instance:query']"
  83. @click="handleDetail(row)"
  84. >
  85. <Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }}
  86. </el-button>
  87. <el-button
  88. link
  89. type="primary"
  90. v-hasPermi="['bpm:process-instance:cancel']"
  91. @click="handleCancel(row)"
  92. >
  93. <Icon icon="ep:delete" class="mr-1px" /> {{ t('action.del') }}
  94. </el-button>
  95. </template>
  96. </Table>
  97. </ContentWrap>
  98. <XModal v-model="dialogVisible" :title="t('action.detail')">
  99. <!-- 对话框(详情) -->
  100. <Descriptions :schema="allSchemas.detailSchema" :data="detailData" />
  101. <!-- 操作按钮 -->
  102. <template #footer>
  103. <el-button @click="dialogVisible = false">{{ t('dialog.close') }}</el-button>
  104. </template>
  105. </XModal>
  106. </template>