cosey 0.4.44 → 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, ref, isVNode } from 'vue';
2
- import { ElLink, ElSwitch, ElMessage, ElTag } from 'element-plus';
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,25 +105,13 @@ function renderer({
74
105
  }, obj.props), null);
75
106
  case "switch":
76
107
  {
77
- const loading = ref(false);
78
- const value = ref(cellValue);
79
- return createVNode(Scope, null, {
80
- default: () => [createVNode(ElSwitch, mergeProps(obj.props, {
81
- "model-value": value.value,
82
- "loading": loading.value,
83
- "validateEvent": false,
84
- "onChange": async val => {
85
- loading.value = true;
86
- try {
87
- await obj.api?.(val, row);
88
- value.value = val;
89
- ElMessage.success(t("co.common.editSuccess"));
90
- } catch {} finally {
91
- loading.value = false;
92
- }
93
- }
94
- }), null)]
95
- });
108
+ return createVNode(AsyncSwitch, {
109
+ "value": cellValue,
110
+ "props": obj.props,
111
+ "api": obj.api,
112
+ "row": row,
113
+ "t": t
114
+ }, null);
96
115
  }
97
116
  case "click":
98
117
  return createVNode(ElLink, mergeProps({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosey",
3
- "version": "0.4.44",
3
+ "version": "0.4.46",
4
4
  "description": "基于 Vue3 + vite 的后台管理系统框架",
5
5
  "type": "module",
6
6
  "main": "index.js",