2021-12-20 14:29:29 +08:00
|
|
|
|
import { icon } from '@/plugins'
|
|
|
|
|
import { dialogIconSize, maskClosable } from '@/settings/designSetting'
|
|
|
|
|
const { InformationCircleIcon } = icon.ionicons5
|
|
|
|
|
import { renderIcon } from '@/utils'
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* * render 弹出确认框
|
|
|
|
|
* @param { Function } dialogFn dialog函数,暂时必须从页面传过来
|
|
|
|
|
* @param { Object} params 配置参数
|
|
|
|
|
*/
|
|
|
|
|
export const goDialog = (
|
|
|
|
|
dialogFn: Function,
|
|
|
|
|
params: {
|
|
|
|
|
// 基本
|
|
|
|
|
type: 'delete'
|
|
|
|
|
message?: string
|
|
|
|
|
onPositiveCallback?: Function
|
|
|
|
|
onNegativeCallback?: Function
|
|
|
|
|
// 渲染函数
|
|
|
|
|
render?: boolean
|
|
|
|
|
contentFn?: Function
|
|
|
|
|
actionFn?: Function
|
|
|
|
|
}
|
|
|
|
|
) => {
|
|
|
|
|
const { type, message, onPositiveCallback, onNegativeCallback } = params
|
|
|
|
|
const tip = {
|
|
|
|
|
delete: '是否删除此数据'
|
|
|
|
|
}
|
2021-12-20 16:13:26 +08:00
|
|
|
|
const instance = dialogFn({
|
2021-12-20 14:29:29 +08:00
|
|
|
|
title: '提示',
|
|
|
|
|
icon: renderIcon(InformationCircleIcon, { size: dialogIconSize }),
|
|
|
|
|
content: message || tip[type] || '',
|
|
|
|
|
positiveText: '确定',
|
|
|
|
|
negativeText: '取消',
|
|
|
|
|
maskClosable: maskClosable,
|
|
|
|
|
onPositiveClick: () => {
|
2021-12-20 16:13:26 +08:00
|
|
|
|
onPositiveCallback && onPositiveCallback(instance)
|
2021-12-20 14:29:29 +08:00
|
|
|
|
},
|
|
|
|
|
onNegativeClick: () => {
|
2021-12-20 16:13:26 +08:00
|
|
|
|
onNegativeCallback && onNegativeCallback(instance)
|
2021-12-20 14:29:29 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|