plugin.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { icon } from '@/plugins'
  2. import { dialogIconSize, maskClosable } from '@/settings/designSetting'
  3. const { InformationCircleIcon } = icon.ionicons5
  4. import { renderIcon } from '@/utils'
  5. /**
  6. * * render 弹出确认框
  7. * @param { Function } dialogFn dialog函数,暂时必须从页面传过来
  8. * @param { Object} params 配置参数
  9. */
  10. export const goDialog = (
  11. dialogFn: Function,
  12. params: {
  13. // 基本
  14. type: 'delete'
  15. message?: string
  16. onPositiveCallback?: Function
  17. onNegativeCallback?: Function
  18. // 渲染函数
  19. render?: boolean
  20. contentFn?: Function
  21. actionFn?: Function
  22. }
  23. ) => {
  24. const { type, message, onPositiveCallback, onNegativeCallback } = params
  25. const tip = {
  26. delete: '是否删除此数据'
  27. }
  28. const instance = dialogFn({
  29. title: '提示',
  30. icon: renderIcon(InformationCircleIcon, { size: dialogIconSize }),
  31. content: message || tip[type] || '',
  32. positiveText: '确定',
  33. negativeText: '取消',
  34. maskClosable: maskClosable,
  35. onPositiveClick: () => {
  36. onPositiveCallback && onPositiveCallback(instance)
  37. },
  38. onNegativeClick: () => {
  39. onNegativeCallback && onNegativeCallback(instance)
  40. }
  41. })
  42. }