index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <XTable @register="registerTable">
  3. <template #toolbar_buttons>
  4. <!-- 操作:发起请假 -->
  5. <XButton type="primary" preIcon="ep:plus" title="发起请假" @click="handleCreate()" />
  6. </template>
  7. <template #actionbtns_default="{ row }">
  8. <!-- 操作: 取消请假 -->
  9. <XTextButton
  10. preIcon="ep:delete"
  11. title="取消请假"
  12. v-hasPermi="['bpm:oa-leave:create']"
  13. v-if="row.result === 1"
  14. @click="cancelLeave(row)"
  15. />
  16. <!-- 操作: 详情 -->
  17. <XTextButton preIcon="ep:delete" :title="t('action.detail')" @click="handleDetail(row)" />
  18. <!-- 操作: 审批进度 -->
  19. <XTextButton preIcon="ep:edit-pen" title="审批进度" @click="handleProcessDetail(row)" />
  20. </template>
  21. </XTable>
  22. </template>
  23. <script setup lang="ts">
  24. // 全局相关的 import
  25. import { ElMessageBox } from 'element-plus'
  26. // 业务相关的 import
  27. import { allSchemas } from './leave.data'
  28. import * as LeaveApi from '@/api/bpm/leave'
  29. import * as ProcessInstanceApi from '@/api/bpm/processInstance'
  30. const { t } = useI18n() // 国际化
  31. const message = useMessage() // 消息弹窗
  32. const router = useRouter() // 路由
  33. const [registerTable, { reload }] = useXTable({
  34. allSchemas: allSchemas,
  35. getListApi: LeaveApi.getLeavePageApi
  36. })
  37. // 发起请假
  38. const handleCreate = () => {
  39. router.push({
  40. name: 'OALeaveCreate'
  41. })
  42. }
  43. // 取消请假
  44. const cancelLeave = (row) => {
  45. ElMessageBox.prompt('请输入取消原因', '取消流程', {
  46. confirmButtonText: t('common.ok'),
  47. cancelButtonText: t('common.cancel'),
  48. inputPattern: /^[\s\S]*.*\S[\s\S]*$/, // 判断非空,且非空格
  49. inputErrorMessage: '取消原因不能为空'
  50. }).then(async ({ value }) => {
  51. await ProcessInstanceApi.cancelProcessInstanceApi(row.id, value)
  52. message.success('取消成功')
  53. reload()
  54. })
  55. }
  56. // 详情
  57. const handleDetail = (row) => {
  58. router.push({
  59. name: 'OALeaveDetail',
  60. query: {
  61. id: row.id
  62. }
  63. })
  64. }
  65. // 审批进度
  66. const handleProcessDetail = (row) => {
  67. router.push({
  68. name: 'BpmProcessInstanceDetail',
  69. query: {
  70. id: row.processInstanceId
  71. }
  72. })
  73. }
  74. </script>