index.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 #tasks_default="{ row }">
  17. <el-button v-for="task in row.tasks" :key="task.id" type="text">
  18. <span>{{ task.name }}</span>
  19. </el-button>
  20. </template>
  21. <!-- 操作 -->
  22. <template #actionbtns_default="{ row }">
  23. <XButton preIcon="ep:view" :title="t('action.detail')" @click="handleDetail(row)" />
  24. <XButton
  25. preIcon="ep:delete"
  26. title="取消"
  27. v-if="row.result === 1"
  28. @click="handleCancel(row)"
  29. />
  30. </template>
  31. </XTable>
  32. </ContentWrap>
  33. </template>
  34. <script setup lang="ts">
  35. // 全局相关的 import
  36. import { ElMessageBox } from 'element-plus'
  37. // 业务相关的 import
  38. import * as ProcessInstanceApi from '@/api/bpm/processInstance'
  39. import { allSchemas } from './process.data'
  40. const router = useRouter() // 路由
  41. const message = useMessage() // 消息弹窗
  42. const { t } = useI18n() // 国际化
  43. // ========== 列表相关 ==========
  44. const [registerTable, { reload }] = useXTable({
  45. allSchemas: allSchemas,
  46. getListApi: ProcessInstanceApi.getMyProcessInstancePageApi
  47. })
  48. /** 发起流程操作 **/
  49. const handleCreate = () => {
  50. router.push({
  51. name: 'BpmProcessInstanceCreate'
  52. })
  53. }
  54. // 列表操作
  55. const handleDetail = (row) => {
  56. router.push({
  57. name: 'BpmProcessInstanceDetail',
  58. query: {
  59. id: row.processInstanceId
  60. }
  61. })
  62. }
  63. /** 取消按钮操作 */
  64. const handleCancel = (row) => {
  65. ElMessageBox.prompt('请输入取消原因', '取消流程', {
  66. confirmButtonText: t('common.ok'),
  67. cancelButtonText: t('common.cancel'),
  68. inputPattern: /^[\s\S]*.*\S[\s\S]*$/, // 判断非空,且非空格
  69. inputErrorMessage: '取消原因不能为空'
  70. }).then(async ({ value }) => {
  71. await ProcessInstanceApi.cancelProcessInstanceApi(row.id, value)
  72. message.success('取消成功')
  73. reload()
  74. })
  75. }
  76. </script>