import { MessageBox } from 'element-ui'; import { SourceConfig } from '../model' interface ConfirmConfig { title?: string message?: string, showClose?: boolean, formatMessage?: Function, okText?: string, cancelText?: string, onOk?: Function, onCancel?: Function, sourceConfigs?: SourceConfig } const defaultMessage: ConfirmConfig = { title: '提示', message: '提示内容', showClose: false }; /** * 内容提示框 * author tanxj * @param config 消息配置参数 */ export default function (config?: ConfirmConfig) { config = config || {}; Object.keys(defaultMessage).forEach((key: string) => { if (config[key] === undefined) config[key] = defaultMessage[key]; }); MessageBox.confirm(config.message, config.title, { confirmButtonText: config.okText || '确定', cancelButtonText: config.cancelText || '取消', showClose: config.showClose, customClass: "mu-confirm" }).then(() => { if (config.onOk) config.onOk(); }).catch(() => { if (config.onCancel) config.onCancel(); }); }