index.vue 2.2 KB

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