1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
| // +----------------------------------------------------------------------
| // | CMS [ CMS赋能开发者,助力企业发展 ]
| // +----------------------------------------------------------------------
| // | Copyright (c) 2016~2021 https://www.CMS.com All rights reserved.
| // +----------------------------------------------------------------------
| // | Licensed CMS并不是自由软件,未经许可不能去掉CMS相关版权
| // +----------------------------------------------------------------------
| // | Author: CMS Team <admin@CMS.com>
| // +----------------------------------------------------------------------
|
| import {
| Confirm as confirm,
| Alert as alert,
| Toast as toast,
| Notify as notify,
| Loading as loading
| } from "vue-ydui/dist/lib.rem/dialog";
|
| const dialog = {
| confirm,
| alert,
| toast,
| notify,
| loading
| };
|
| const icons = { error: "操作失败", success: "操作成功" };
| Object.keys(icons).reduce((dialog, key) => {
| dialog[key] = (mes, obj = {}) => {
| return new Promise(function(resolve) {
| toast({
| mes: mes || icons[key],
| timeout: 1000,
| icon: key,
| callback: () => {
| resolve();
| },
| ...obj
| });
| });
| };
| return dialog;
| }, dialog);
|
| dialog.message = (mes = "操作失败", obj = {}) => {
| return new Promise(function(resolve) {
| toast({
| mes,
| timeout: 1000,
| callback: () => {
| resolve();
| },
| ...obj
| });
| });
| };
|
| dialog.validateError = (...args) => {
| validatorDefaultCatch(...args);
| };
|
| export function validatorDefaultCatch(err, type = "message") {
| console.log(err)
| return dialog[type](err.errors[0].message);
| }
|
| export default dialog;
|
|