// import { notification } from 'ant-design-vue'
import { h } from 'vue'
import {
  CheckCircleFilled,
  CloseCircleFilled,
  ExclamationCircleFilled
} from '@ant-design/icons-vue'

// name:页面名称，角色、人员、系统等
// type：add，edit，del，detail
// status：success，error，warning
// desc: 描述
const option = {
  names: {
    user: '用户管理'
  },
  types: {
    // isDealWith: '标记为已处理',
    // isRead: '标记为已读'
  },
  status: { success: '成功', error: '失败', warning: '警告' }
}
const notiInfo = {
  success: {
    iconMessage: '成功通知',
    icon: CheckCircleFilled,
    iconColor: 'color:#065758',
    iconClass: 'notification-success-class'
  },
  error: {
    iconMessage: '失败通知',
    icon: CloseCircleFilled,
    iconColor: 'color:#ca4d2a',
    iconClass: 'notification-error-class'
  },
  warning: {
    iconMessage: '警告通知',
    icon: ExclamationCircleFilled,
    iconColor: 'color:#FF921B',
    iconClass: 'notification-warning-class'
  }
}
const openNotification = ({ name, type, status, desc = '' }) => {
  this.$notification[status]({
    placement: 'bottomRight',
    message: notiInfo[status].iconMessage,
    description: desc || option.names[name] + option.types[type] + option.status[status],
    icon: () =>
      h(notiInfo[status].icon, {
        style: notiInfo[status].iconColor
      }),
    style: {
      minWidth: '400px'
    },
    class: notiInfo[status].iconClass,
    duration: 2
  })
}
export default openNotification
