index.vue 3.6 KB

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