cosey 0.4.45 → 0.4.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { createVNode, mergeProps,
|
|
2
|
-
import {
|
|
1
|
+
import { defineComponent, ref, createVNode, mergeProps, isVNode } from 'vue';
|
|
2
|
+
import { ElSwitch, ElMessage, ElLink, ElTag } from 'element-plus';
|
|
3
3
|
import { get } from 'lodash-es';
|
|
4
4
|
import { LongText as _LongText } from '../../long-text/index.js';
|
|
5
5
|
import { MediaCard as _MediaCard } from '../../media-card/index.js';
|
|
6
6
|
import { MediaCardGroup as _MediaCardGroup } from '../../media-card-group/index.js';
|
|
7
7
|
import { isEmpty, isString } from '../../../utils/is.js';
|
|
8
|
-
import { Scope, getVNodeText } from '../../../utils/vue.js';
|
|
9
8
|
import { formatToDate, formatToDateTime } from '../../../utils/date.js';
|
|
9
|
+
import { getVNodeText } from '../../../utils/vue.js';
|
|
10
10
|
import { toArray } from '../../../utils/array.js';
|
|
11
11
|
|
|
12
12
|
function _isSlot(s) {
|
|
@@ -25,6 +25,37 @@ const mapRendererColumnProps = {
|
|
|
25
25
|
className: "is-tag"
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
+
const AsyncSwitch = defineComponent({
|
|
29
|
+
props: {
|
|
30
|
+
value: [String, Number, Boolean],
|
|
31
|
+
props: Object,
|
|
32
|
+
api: Function,
|
|
33
|
+
row: Object,
|
|
34
|
+
t: Function
|
|
35
|
+
},
|
|
36
|
+
setup(props) {
|
|
37
|
+
const loading = ref(false);
|
|
38
|
+
const value = ref(props.value);
|
|
39
|
+
return () => createVNode(ElSwitch, mergeProps(props.props, {
|
|
40
|
+
"model-value": value.value,
|
|
41
|
+
"loading": loading.value,
|
|
42
|
+
"validateEvent": false,
|
|
43
|
+
"onChange": async val => {
|
|
44
|
+
if (loading.value) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
loading.value = true;
|
|
48
|
+
try {
|
|
49
|
+
await props.api?.(val, props.row);
|
|
50
|
+
value.value = val;
|
|
51
|
+
ElMessage.success(props.t?.("co.common.editSuccess"));
|
|
52
|
+
} catch {} finally {
|
|
53
|
+
loading.value = false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}), null);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
28
59
|
function renderer({
|
|
29
60
|
cellValue,
|
|
30
61
|
row,
|
|
@@ -74,28 +105,13 @@ function renderer({
|
|
|
74
105
|
}, obj.props), null);
|
|
75
106
|
case "switch":
|
|
76
107
|
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"onChange": async val => {
|
|
85
|
-
if (loading.value) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
loading.value = true;
|
|
89
|
-
try {
|
|
90
|
-
await obj.api?.(val, row);
|
|
91
|
-
value.value = val;
|
|
92
|
-
ElMessage.success(t("co.common.editSuccess"));
|
|
93
|
-
} catch {} finally {
|
|
94
|
-
loading.value = false;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}), null)]
|
|
98
|
-
});
|
|
108
|
+
return createVNode(AsyncSwitch, {
|
|
109
|
+
"value": cellValue,
|
|
110
|
+
"props": obj.props,
|
|
111
|
+
"api": obj.api,
|
|
112
|
+
"row": row,
|
|
113
|
+
"t": t
|
|
114
|
+
}, null);
|
|
99
115
|
}
|
|
100
116
|
case "click":
|
|
101
117
|
return createVNode(ElLink, mergeProps({
|