useOpen.ts 476 B

123456789101112131415161718192021
  1. import { ref } from 'vue'
  2. import { t } from '/admin/support/helper'
  3. export function useOpen() {
  4. const visible = ref<boolean>(false)
  5. const id = ref(null)
  6. const title = ref<string>('')
  7. const open = (primary: any = null) => {
  8. title.value = primary ? t('system.edit') : t('system.add')
  9. id.value = primary
  10. visible.value = true
  11. }
  12. const close = (func: Function) => {
  13. visible.value = false
  14. func()
  15. }
  16. return { open, close, title, visible, id }
  17. }