ApprovalButton.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <script setup lang="ts">
  2. import router from "@r"
  3. const props = withDefaults(
  4. defineProps<{
  5. id?: string
  6. status?: string
  7. pageType?: string
  8. buttonLoading?: boolean
  9. }>(),
  10. {
  11. id: "",
  12. status: "",
  13. pageType: "",
  14. buttonLoading: false
  15. }
  16. )
  17. const emits = defineEmits<{
  18. (e: "submit", v: string): void
  19. (e: "approvalVerify"): void
  20. (e: "approvalRecord"): void
  21. }>()
  22. //校验提交按钮是否显示
  23. const submitButtonShow = computed(() => {
  24. return (
  25. props.pageType === "add" ||
  26. (props.pageType === "update" &&
  27. props.status &&
  28. (props.status === "draft" || props.status === "cancel" || props.status === "back"))
  29. )
  30. })
  31. //校验审批按钮是否显示
  32. const approvalButtonShow = computed(() => {
  33. return props.pageType === "approval" && props.status && props.status === "waiting"
  34. })
  35. function handleSubmit(type: string) {
  36. emits("submit", type)
  37. }
  38. //审批
  39. function handleApprovalVerifyOpen() {
  40. emits("approvalVerify")
  41. }
  42. //审批记录
  43. const handleApprovalRecord = () => {
  44. emits("approvalRecord")
  45. }
  46. //返回
  47. const goBack = () => {
  48. router.go(-1)
  49. }
  50. function init() {
  51. //
  52. }
  53. //暂存,提交
  54. onMounted(init)
  55. </script>
  56. <template>
  57. <div style="display: flex; justify-content: space-between">
  58. <div>
  59. <el-button
  60. v-if="submitButtonShow"
  61. :loading="props.buttonLoading"
  62. type="info"
  63. @click="handleSubmit('draft')">
  64. 暂存
  65. </el-button>
  66. <el-button
  67. v-if="submitButtonShow"
  68. :loading="props.buttonLoading"
  69. type="primary"
  70. @click="handleSubmit('submit')">
  71. 提 交
  72. </el-button>
  73. <el-button
  74. v-if="approvalButtonShow"
  75. :loading="props.buttonLoading"
  76. type="primary"
  77. @click="handleApprovalVerifyOpen">
  78. 审批
  79. </el-button>
  80. <el-button
  81. v-if="props.id && props.status !== 'draft'"
  82. type="primary"
  83. @click="handleApprovalRecord">
  84. 流程进度
  85. </el-button>
  86. <slot />
  87. </div>
  88. <div>
  89. <el-button style="float: right" @click="goBack()">返回</el-button>
  90. </div>
  91. </div>
  92. </template>