提交 | 用户 | 时间
|
820397
|
1 |
import { ElMessage, ElMessageBox, ElNotification } from 'element-plus' |
H |
2 |
import { useI18n } from './useI18n' |
|
3 |
export const useMessage = () => { |
|
4 |
const { t } = useI18n() |
|
5 |
return { |
|
6 |
// 消息提示 |
|
7 |
info(content: string) { |
|
8 |
ElMessage.info(content) |
|
9 |
}, |
|
10 |
// 错误消息 |
|
11 |
error(content: string) { |
|
12 |
ElMessage.error(content) |
|
13 |
}, |
|
14 |
// 成功消息 |
|
15 |
success(content: string) { |
|
16 |
ElMessage.success(content) |
|
17 |
}, |
|
18 |
// 警告消息 |
|
19 |
warning(content: string) { |
|
20 |
ElMessage.warning(content) |
|
21 |
}, |
|
22 |
// 弹出提示 |
|
23 |
alert(content: string) { |
|
24 |
ElMessageBox.alert(content, t('common.confirmTitle')) |
|
25 |
}, |
|
26 |
// 错误提示 |
|
27 |
alertError(content: string) { |
|
28 |
ElMessageBox.alert(content, t('common.confirmTitle'), { type: 'error' }) |
|
29 |
}, |
|
30 |
// 成功提示 |
|
31 |
alertSuccess(content: string) { |
|
32 |
ElMessageBox.alert(content, t('common.confirmTitle'), { type: 'success' }) |
|
33 |
}, |
|
34 |
// 警告提示 |
|
35 |
alertWarning(content: string) { |
|
36 |
ElMessageBox.alert(content, t('common.confirmTitle'), { type: 'warning' }) |
|
37 |
}, |
|
38 |
// 通知提示 |
|
39 |
notify(content: string) { |
|
40 |
ElNotification.info(content) |
|
41 |
}, |
|
42 |
// 错误通知 |
|
43 |
notifyError(content: string) { |
|
44 |
ElNotification.error(content) |
|
45 |
}, |
|
46 |
// 成功通知 |
|
47 |
notifySuccess(content: string) { |
|
48 |
ElNotification.success(content) |
|
49 |
}, |
|
50 |
// 警告通知 |
|
51 |
notifyWarning(content: string) { |
|
52 |
ElNotification.warning(content) |
|
53 |
}, |
|
54 |
// 确认窗体 |
|
55 |
confirm(content: string, tip?: string) { |
|
56 |
return ElMessageBox.confirm(content, tip ? tip : t('common.confirmTitle'), { |
|
57 |
confirmButtonText: t('common.ok'), |
|
58 |
cancelButtonText: t('common.cancel'), |
|
59 |
type: 'warning' |
|
60 |
}) |
|
61 |
}, |
|
62 |
// 删除窗体 |
|
63 |
delConfirm(content?: string, tip?: string) { |
|
64 |
return ElMessageBox.confirm( |
|
65 |
content ? content : t('common.delMessage'), |
|
66 |
tip ? tip : t('common.confirmTitle'), |
|
67 |
{ |
|
68 |
confirmButtonText: t('common.ok'), |
|
69 |
cancelButtonText: t('common.cancel'), |
|
70 |
type: 'warning' |
|
71 |
} |
|
72 |
) |
|
73 |
}, |
|
74 |
// 导出窗体 |
|
75 |
exportConfirm(content?: string, tip?: string) { |
|
76 |
return ElMessageBox.confirm( |
|
77 |
content ? content : t('common.exportMessage'), |
|
78 |
tip ? tip : t('common.confirmTitle'), |
|
79 |
{ |
|
80 |
confirmButtonText: t('common.ok'), |
|
81 |
cancelButtonText: t('common.cancel'), |
|
82 |
type: 'warning' |
|
83 |
} |
|
84 |
) |
|
85 |
}, |
|
86 |
// 提交内容 |
|
87 |
prompt(content: string, tip: string) { |
|
88 |
return ElMessageBox.prompt(content, tip, { |
|
89 |
confirmButtonText: t('common.ok'), |
|
90 |
cancelButtonText: t('common.cancel'), |
|
91 |
type: 'warning' |
|
92 |
}) |
616b13
|
93 |
}, |
J |
94 |
// 启用窗体 |
|
95 |
enableConfirm(ids, content?: string, tip?: string) { |
|
96 |
return ElMessageBox.confirm( |
|
97 |
content ? content : t('确定启用选中的'+ ids.length +'项数据?'), |
|
98 |
tip ? tip : t('common.confirmTitle'), |
|
99 |
{ |
|
100 |
confirmButtonText: t('common.ok'), |
|
101 |
cancelButtonText: t('common.cancel'), |
|
102 |
type: 'warning' |
|
103 |
} |
|
104 |
) |
|
105 |
}, |
|
106 |
// 禁用窗体 |
|
107 |
disableConfirm(ids, content?: string, tip?: string) { |
|
108 |
return ElMessageBox.confirm( |
|
109 |
content ? content : t('确定禁用选中的'+ ids.length +'项数据?'), |
|
110 |
tip ? tip : t('common.confirmTitle'), |
|
111 |
{ |
|
112 |
confirmButtonText: t('common.ok'), |
|
113 |
cancelButtonText: t('common.cancel'), |
|
114 |
type: 'warning' |
|
115 |
} |
|
116 |
) |
820397
|
117 |
} |
H |
118 |
} |
|
119 |
} |