@cmeslib/components 0.1.13 → 0.3.0-beta.0
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.
- package/es/_virtual/_plugin-vue_export-helper.mjs +9 -0
- package/es/components/demo/index.mjs +2 -4
- package/es/components/demo/src/demo-button-setup-tsx.vue.mjs +3 -3
- package/es/components/demo/src/demo-button-setup-tsx.vue2.mjs +6 -10
- package/es/components/demo/src/demo-button.vue.mjs +4 -4
- package/es/components/demo/src/demo-button.vue2.mjs +5 -5
- package/es/components/hifleet/index.d.ts +4 -0
- package/es/components/hifleet/index.mjs +1 -0
- package/es/components/hifleet/src/helper.d.ts +32 -0
- package/es/components/hifleet/src/helper.mjs +261 -0
- package/es/components/hifleet/src/index.vue.d.ts +37 -0
- package/es/components/hifleet/src/index.vue.mjs +6 -0
- package/es/components/hifleet/src/index.vue2.mjs +123 -0
- package/es/components/hifleet/src/map-data.d.ts +18 -0
- package/es/components/hifleet/src/map-data.mjs +238 -0
- package/es/components/hifleet/src/types.d.ts +28 -0
- package/es/components/hifleet/src/types.mjs +1 -0
- package/es/components/index.d.ts +2 -0
- package/es/components/index.mjs +4 -3
- package/es/components/selectors/index.d.ts +6 -0
- package/es/components/selectors/index.mjs +2 -0
- package/es/components/selectors/src/DeptTreeSelect.vue.d.ts +13 -0
- package/es/components/selectors/src/DeptTreeSelect.vue.mjs +5 -0
- package/es/components/selectors/src/DeptTreeSelect.vue2.mjs +63 -0
- package/es/components/selectors/src/UserTreeSelect.vue.d.ts +13 -0
- package/es/components/selectors/src/UserTreeSelect.vue.mjs +5 -0
- package/es/components/selectors/src/UserTreeSelect.vue2.mjs +82 -0
- package/es/components/selectors/src/types.d.ts +27 -0
- package/es/components/selectors/src/types.mjs +1 -0
- package/es/directives/demo/index.d.ts +2 -0
- package/es/directives/demo/index.mjs +8 -0
- package/es/directives/index.d.ts +1 -1
- package/es/directives/index.mjs +1 -5
- package/es/hooks/common/index.d.ts +1 -0
- package/es/hooks/common/index.mjs +1 -0
- package/es/hooks/common/src/globalSingleFlight.d.ts +27 -0
- package/es/hooks/common/src/globalSingleFlight.mjs +108 -0
- package/es/hooks/demo/index.d.ts +1 -0
- package/es/hooks/demo/index.mjs +5 -0
- package/es/hooks/index.d.ts +2 -0
- package/es/hooks/index.mjs +2 -0
- package/es/index.css +63 -0
- package/es/index.d.ts +1 -0
- package/es/index.mjs +7 -4
- package/es/types/env.d.mjs +1 -0
- package/lib/_virtual/_plugin-vue_export-helper.js +13 -0
- package/lib/components/demo/index.js +4 -6
- package/lib/components/demo/src/demo-button-setup-tsx.vue.js +1 -1
- package/lib/components/demo/src/demo-button-setup-tsx.vue2.js +5 -9
- package/lib/components/demo/src/demo-button.vue.js +3 -3
- package/lib/components/demo/src/demo-button.vue2.js +3 -3
- package/lib/components/hifleet/index.d.ts +4 -0
- package/lib/components/hifleet/index.js +7 -0
- package/lib/components/hifleet/src/helper.d.ts +32 -0
- package/lib/components/hifleet/src/helper.js +272 -0
- package/lib/components/hifleet/src/index.vue.d.ts +37 -0
- package/lib/components/hifleet/src/index.vue.js +10 -0
- package/lib/components/hifleet/src/index.vue2.js +127 -0
- package/lib/components/hifleet/src/map-data.d.ts +18 -0
- package/lib/components/hifleet/src/map-data.js +241 -0
- package/lib/components/hifleet/src/types.d.ts +28 -0
- package/lib/components/hifleet/src/types.js +2 -0
- package/lib/components/index.d.ts +3 -0
- package/lib/components/index.js +8 -4
- package/lib/components/selectors/index.d.ts +6 -0
- package/lib/components/selectors/index.js +9 -0
- package/lib/components/selectors/src/DeptTreeSelect.vue.d.ts +13 -0
- package/lib/components/selectors/src/DeptTreeSelect.vue.js +9 -0
- package/lib/components/selectors/src/DeptTreeSelect.vue2.js +67 -0
- package/lib/components/selectors/src/UserTreeSelect.vue.d.ts +13 -0
- package/lib/components/selectors/src/UserTreeSelect.vue.js +9 -0
- package/lib/components/selectors/src/UserTreeSelect.vue2.js +86 -0
- package/lib/components/selectors/src/types.d.ts +27 -0
- package/lib/components/selectors/src/types.js +2 -0
- package/lib/directives/demo/index.d.ts +2 -0
- package/lib/directives/demo/index.js +10 -0
- package/lib/directives/index.d.ts +1 -1
- package/lib/directives/index.js +4 -4
- package/lib/hooks/common/index.d.ts +1 -0
- package/lib/hooks/common/index.js +8 -0
- package/lib/hooks/common/src/globalSingleFlight.d.ts +27 -0
- package/lib/hooks/common/src/globalSingleFlight.js +111 -0
- package/lib/hooks/demo/index.d.ts +1 -0
- package/lib/hooks/demo/index.js +7 -0
- package/lib/hooks/index.d.ts +2 -0
- package/lib/hooks/index.js +10 -0
- package/lib/index.css +63 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +15 -6
- package/lib/types/env.d.js +2 -0
- package/package.json +5 -3
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
const solidLineData = {
|
|
2
|
+
code: 0,
|
|
3
|
+
message: "Operation successful",
|
|
4
|
+
data: [
|
|
5
|
+
{
|
|
6
|
+
mmsi: "477369300",
|
|
7
|
+
posTime: "2023-10-29 03:25:45",
|
|
8
|
+
lon: 118.5243,
|
|
9
|
+
lat: 38.912063333333336,
|
|
10
|
+
cog: 172.4,
|
|
11
|
+
heading: 142,
|
|
12
|
+
sog: 1.6
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
mmsi: "477369300",
|
|
16
|
+
posTime: "2023-10-29 04:11:24",
|
|
17
|
+
lon: 118.53505666666666,
|
|
18
|
+
lat: 38.81549,
|
|
19
|
+
cog: 100.9,
|
|
20
|
+
heading: 90,
|
|
21
|
+
sog: 6.2
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
mmsi: "477369300",
|
|
25
|
+
posTime: "2023-10-29 08:22:33",
|
|
26
|
+
lon: 119.56675666666666,
|
|
27
|
+
lat: 38.656101666666665,
|
|
28
|
+
cog: 102.1,
|
|
29
|
+
heading: 103,
|
|
30
|
+
sog: 13.7
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
mmsi: "477369300",
|
|
34
|
+
posTime: "2023-10-29 13:30:16",
|
|
35
|
+
lon: 120.90525166666667,
|
|
36
|
+
lat: 38.548535,
|
|
37
|
+
cog: 106.1,
|
|
38
|
+
heading: 110,
|
|
39
|
+
sog: 10.1
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
mmsi: "477369300",
|
|
43
|
+
posTime: "2023-10-29 23:10:36",
|
|
44
|
+
lon: 123.23456833333333,
|
|
45
|
+
lat: 37.906578333333336,
|
|
46
|
+
cog: 138.9,
|
|
47
|
+
heading: 152,
|
|
48
|
+
sog: 11.5
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
mmsi: "477369300",
|
|
52
|
+
posTime: "2023-10-30 12:21:45",
|
|
53
|
+
lon: 124.29332166666667,
|
|
54
|
+
lat: 35.12784166666667,
|
|
55
|
+
cog: 161.1,
|
|
56
|
+
heading: 161,
|
|
57
|
+
sog: 14.2
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
mmsi: "477369300",
|
|
61
|
+
posTime: "2023-10-30 20:44:22",
|
|
62
|
+
lon: 124.38431333333334,
|
|
63
|
+
lat: 33.36606833333333,
|
|
64
|
+
cog: 165.3,
|
|
65
|
+
heading: 166,
|
|
66
|
+
sog: 13.7
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
mmsi: "477369300",
|
|
70
|
+
posTime: "2023-10-30 23:57:29",
|
|
71
|
+
lon: 124.81396333333333,
|
|
72
|
+
lat: 32.739425,
|
|
73
|
+
cog: 164.3,
|
|
74
|
+
heading: 174,
|
|
75
|
+
sog: 12.4
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
mmsi: "477369300",
|
|
79
|
+
posTime: "2023-10-31 05:52:03",
|
|
80
|
+
lon: 124.58296666666666,
|
|
81
|
+
lat: 31.652378333333335,
|
|
82
|
+
cog: 169,
|
|
83
|
+
heading: 176,
|
|
84
|
+
sog: 12.1
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
mmsi: "477369300",
|
|
88
|
+
posTime: "2023-10-31 10:56:44",
|
|
89
|
+
lon: 124.68107333333333,
|
|
90
|
+
lat: 30.575655,
|
|
91
|
+
cog: 182.3,
|
|
92
|
+
heading: 181,
|
|
93
|
+
sog: 13.5
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
mmsi: "477369300",
|
|
97
|
+
posTime: "2023-11-01 00:18:34",
|
|
98
|
+
lon: 124.40846333333333,
|
|
99
|
+
lat: 27.75289666666667,
|
|
100
|
+
cog: 186.2,
|
|
101
|
+
heading: 185,
|
|
102
|
+
sog: 14.2
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
mmsi: "477369300",
|
|
106
|
+
posTime: "2023-11-02 03:17:47",
|
|
107
|
+
lon: 121.78017333333334,
|
|
108
|
+
lat: 22.797838333333335,
|
|
109
|
+
cog: 206.8,
|
|
110
|
+
heading: 211,
|
|
111
|
+
sog: 9.8
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
mmsi: "477369300",
|
|
115
|
+
posTime: "2023-11-02 08:58:37",
|
|
116
|
+
lon: 121.27895166666667,
|
|
117
|
+
lat: 22.077688333333334,
|
|
118
|
+
cog: 216.7,
|
|
119
|
+
heading: 215,
|
|
120
|
+
sog: 12
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
mmsi: "477369300",
|
|
124
|
+
posTime: "2023-11-06 02:03:42",
|
|
125
|
+
lon: 109.54603833333333,
|
|
126
|
+
lat: 8.047503333333333,
|
|
127
|
+
cog: 219.5,
|
|
128
|
+
heading: 211,
|
|
129
|
+
sog: 10.5
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
mmsi: "477369300",
|
|
133
|
+
posTime: "2023-11-06 18:25:08",
|
|
134
|
+
lon: 107.35896,
|
|
135
|
+
lat: 5.659675,
|
|
136
|
+
cog: 223.6,
|
|
137
|
+
heading: 227,
|
|
138
|
+
sog: 11.1
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
mmsi: "477369300",
|
|
142
|
+
posTime: "2023-11-07 14:01:39",
|
|
143
|
+
lon: 105.202815,
|
|
144
|
+
lat: 2.75397,
|
|
145
|
+
cog: 206.5,
|
|
146
|
+
heading: 208,
|
|
147
|
+
sog: 12.2
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
mmsi: "477369300",
|
|
151
|
+
posTime: "2023-11-07 20:17:59",
|
|
152
|
+
lon: 104.70786833333334,
|
|
153
|
+
lat: 1.6842033333333333,
|
|
154
|
+
cog: 215.5,
|
|
155
|
+
heading: 220,
|
|
156
|
+
sog: 10.8
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
mmsi: "477369300",
|
|
160
|
+
posTime: "2023-11-07 23:56:59",
|
|
161
|
+
lon: 104.325975,
|
|
162
|
+
lat: 1.3168566666666666,
|
|
163
|
+
cog: 234.4,
|
|
164
|
+
heading: 251,
|
|
165
|
+
sog: 9.4
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
mmsi: "477369300",
|
|
169
|
+
posTime: "2023-11-10 13:11:37",
|
|
170
|
+
lon: 103.73402833333333,
|
|
171
|
+
lat: 1.1395083333333333,
|
|
172
|
+
cog: 261.9,
|
|
173
|
+
heading: 272,
|
|
174
|
+
sog: 13.6
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
mmsi: "477369300",
|
|
178
|
+
posTime: "2023-11-10 14:34:37",
|
|
179
|
+
lon: 103.428255,
|
|
180
|
+
lat: 1.237375,
|
|
181
|
+
cog: 291.2,
|
|
182
|
+
heading: 295,
|
|
183
|
+
sog: 14.6
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
mmsi: "477369300",
|
|
187
|
+
posTime: "2023-11-11 02:36:10",
|
|
188
|
+
lon: 101.00935666666666,
|
|
189
|
+
lat: 2.8190866666666667,
|
|
190
|
+
cog: 300.9,
|
|
191
|
+
heading: 312,
|
|
192
|
+
sog: 15.3
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
mmsi: "477369300",
|
|
196
|
+
posTime: "2023-11-11 19:15:43",
|
|
197
|
+
lon: 98.24982166666666,
|
|
198
|
+
lat: 5.475786666666667,
|
|
199
|
+
cog: 314.8,
|
|
200
|
+
heading: 318,
|
|
201
|
+
sog: 14
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
mmsi: "477369300",
|
|
205
|
+
posTime: "2023-11-12 08:16:26",
|
|
206
|
+
lon: 95.25469833333334,
|
|
207
|
+
lat: 6.300505,
|
|
208
|
+
cog: 279.7,
|
|
209
|
+
heading: 276,
|
|
210
|
+
sog: 14.4
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
mmsi: "477369300",
|
|
214
|
+
posTime: "2023-11-12 18:43:17",
|
|
215
|
+
lon: 93.50505333333334,
|
|
216
|
+
lat: 4.995748333333333,
|
|
217
|
+
cog: 229.6,
|
|
218
|
+
heading: 227,
|
|
219
|
+
sog: 12.4
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
mmsi: "477369300",
|
|
223
|
+
posTime: "2023-11-14 00:53:22",
|
|
224
|
+
lon: 88.72558,
|
|
225
|
+
lat: 0.30146666666666666,
|
|
226
|
+
cog: 225.3,
|
|
227
|
+
heading: 223,
|
|
228
|
+
sog: 13.8
|
|
229
|
+
}
|
|
230
|
+
]
|
|
231
|
+
};
|
|
232
|
+
const dottedLineData = {
|
|
233
|
+
code: 0,
|
|
234
|
+
data: '{"end":"12.0785,-5.4461","nmile":6367,"passAvoidArea":[],"start":"89.234732,0.804882","status":"success","viewpoint":"","waypoints":[[89.234732,0.804882],[62.0255,-18.196],[48.0322,-25.3639],[27.6297,-33.9707],[25.719,-34.3117],[20.2773,-35.0008],[19.6545,-34.9715],[18.3334,-34.4477],[18.1645,-34.0675],[18.0931,-33.8567],[17.9723,-33.5551],[17.7718,-33.1134],[17.6385,-32.9557],[17.1826,-32.3614],[13.3744,-24.9273],[12.7153,-23.3643],[12.1222,-21.599],[10.6348,-18.0519],[11.451,-12.6654],[11.5191,-6.4184],[11.7499,-6.2607],[12.1928,-6.0322],[12.0785,-5.4461]]}',
|
|
235
|
+
message: "Operation successful"
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export { dottedLineData, solidLineData };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as Leaflet from 'leaflet';
|
|
2
|
+
export interface LineOptions {
|
|
3
|
+
weight: number;
|
|
4
|
+
color?: string;
|
|
5
|
+
decorator?: string;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
export interface MapInfo {
|
|
9
|
+
readonly app: object;
|
|
10
|
+
readonly map: object;
|
|
11
|
+
EVENT: object;
|
|
12
|
+
}
|
|
13
|
+
export type LatlngInfoObj = {
|
|
14
|
+
lng: string | number;
|
|
15
|
+
lat: string | number;
|
|
16
|
+
lngDegree: string | number;
|
|
17
|
+
latDegree: string | number;
|
|
18
|
+
} & Record<string, any>;
|
|
19
|
+
export interface MapObj {
|
|
20
|
+
mapInfo: MapInfo;
|
|
21
|
+
latlngInfoObj: object;
|
|
22
|
+
layerGroup: object;
|
|
23
|
+
}
|
|
24
|
+
export interface HiFleetMapInitResponse {
|
|
25
|
+
app: any;
|
|
26
|
+
map: any;
|
|
27
|
+
L: typeof Leaflet;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/es/components/index.d.ts
CHANGED
package/es/components/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import './demo/src/demo-button.vue.mjs';
|
|
2
|
-
export { default as DemoButton } from './demo/src/demo-button.vue2.mjs';
|
|
3
|
-
import './demo/src/demo-button-setup-tsx.vue.mjs';
|
|
4
1
|
export { default as DemoButtonSetupTsx } from './demo/src/demo-button-setup-tsx.vue2.mjs';
|
|
2
|
+
export { default as DeptTreeSelect } from './selectors/src/DeptTreeSelect.vue2.mjs';
|
|
3
|
+
export { default as UserTreeSelect } from './selectors/src/UserTreeSelect.vue2.mjs';
|
|
4
|
+
export { default as DemoButton } from './demo/src/demo-button.vue.mjs';
|
|
5
5
|
export { default as DemoButtonTsx } from './demo/src/demo-button-tsx.mjs';
|
|
6
|
+
export { default as HiFleetMap } from './hifleet/src/index.vue.mjs';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import UserTreeSelect from './src/UserTreeSelect.vue';
|
|
2
|
+
export { UserTreeSelect };
|
|
3
|
+
export type { UserTreeSelectProps, UserDataNode } from './src/types';
|
|
4
|
+
import DeptTreeSelect from './src/DeptTreeSelect.vue';
|
|
5
|
+
export { DeptTreeSelect };
|
|
6
|
+
export type { DeptTreeSelectProps, DeptDataNode } from './src/types';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DeptTreeSelectProps } from './types';
|
|
2
|
+
type __VLS_Props = DeptTreeSelectProps;
|
|
3
|
+
type __VLS_ModelProps = {
|
|
4
|
+
modelValue?: any;
|
|
5
|
+
};
|
|
6
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
8
|
+
"update:modelValue": (value: any) => any;
|
|
9
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
10
|
+
"onUpdate:modelValue"?: (value: any) => any;
|
|
11
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { defineComponent, useModel, ref, computed, onMounted, openBlock, createBlock, unref, mergeProps, mergeModels } from 'vue';
|
|
2
|
+
import { ElTreeSelect } from 'element-plus';
|
|
3
|
+
|
|
4
|
+
var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
5
|
+
...{ name: "DeptTreeSelect" },
|
|
6
|
+
__name: "DeptTreeSelect",
|
|
7
|
+
props: /* @__PURE__ */ mergeModels({
|
|
8
|
+
placeholder: { type: String, required: false },
|
|
9
|
+
multiple: { type: Boolean, required: false, default: false },
|
|
10
|
+
filterable: { type: Boolean, required: false, default: true },
|
|
11
|
+
hasMinWidth: { type: Boolean, required: false },
|
|
12
|
+
getData: { type: Function, required: true },
|
|
13
|
+
disabledIds: { type: [String, Array, Number], required: false }
|
|
14
|
+
}, {
|
|
15
|
+
"modelValue": { type: null, ...{
|
|
16
|
+
required: false
|
|
17
|
+
} },
|
|
18
|
+
"modelModifiers": {}
|
|
19
|
+
}),
|
|
20
|
+
emits: ["update:modelValue"],
|
|
21
|
+
setup(__props) {
|
|
22
|
+
const defaultProps = {
|
|
23
|
+
children: "children",
|
|
24
|
+
label: "name",
|
|
25
|
+
value: "id"
|
|
26
|
+
};
|
|
27
|
+
const props = __props;
|
|
28
|
+
const model = useModel(__props, "modelValue");
|
|
29
|
+
const deptList = ref([]);
|
|
30
|
+
const deptListWithDisabled = computed(() => {
|
|
31
|
+
if (!props.disabledIds) return deptList.value;
|
|
32
|
+
const disabledIdsSet = new Set(Array.isArray(props.disabledIds) ? props.disabledIds : [props.disabledIds]);
|
|
33
|
+
return markDisabled(deptList.value, disabledIdsSet);
|
|
34
|
+
});
|
|
35
|
+
const markDisabled = (nodes, disabledIdsSet) => {
|
|
36
|
+
return nodes.map((node) => {
|
|
37
|
+
const isDisabled = disabledIdsSet.has(node.id);
|
|
38
|
+
const newNode = { ...node, disabled: isDisabled };
|
|
39
|
+
if (node.children) {
|
|
40
|
+
newNode.children = markDisabled(node.children, disabledIdsSet);
|
|
41
|
+
}
|
|
42
|
+
return newNode;
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
onMounted(async () => {
|
|
46
|
+
const data = await props.getData();
|
|
47
|
+
deptList.value = data;
|
|
48
|
+
});
|
|
49
|
+
return (_ctx, _cache) => {
|
|
50
|
+
return openBlock(), createBlock(unref(ElTreeSelect), mergeProps({
|
|
51
|
+
modelValue: model.value,
|
|
52
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
|
|
53
|
+
data: deptListWithDisabled.value,
|
|
54
|
+
props: defaultProps,
|
|
55
|
+
filterable: props.filterable,
|
|
56
|
+
"node-key": "id",
|
|
57
|
+
placeholder: props.placeholder || "\u8BF7\u9009\u62E9"
|
|
58
|
+
}, _ctx.$attrs), null, 16, ["modelValue", "data", "filterable", "placeholder"]);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { UserTreeSelectProps } from './types';
|
|
2
|
+
type __VLS_Props = UserTreeSelectProps;
|
|
3
|
+
type __VLS_ModelProps = {
|
|
4
|
+
modelValue?: any;
|
|
5
|
+
};
|
|
6
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
8
|
+
"update:modelValue": (value: any) => any;
|
|
9
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
10
|
+
"onUpdate:modelValue"?: (value: any) => any;
|
|
11
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { defineComponent, useModel, ref, onMounted, resolveComponent, openBlock, createBlock, unref, mergeProps, withCtx, createElementVNode, createCommentVNode, toDisplayString, mergeModels } from 'vue';
|
|
2
|
+
import { ElTreeSelect } from 'element-plus';
|
|
3
|
+
|
|
4
|
+
const _hoisted_1 = { class: "custom-tree-node" };
|
|
5
|
+
var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
6
|
+
...{ name: "UserTreeSelect" },
|
|
7
|
+
__name: "UserTreeSelect",
|
|
8
|
+
props: /* @__PURE__ */ mergeModels({
|
|
9
|
+
placeholder: { type: String, required: false },
|
|
10
|
+
multiple: { type: Boolean, required: false },
|
|
11
|
+
filterable: { type: Boolean, required: false },
|
|
12
|
+
hasMinWidth: { type: Boolean, required: false },
|
|
13
|
+
getData: { type: Function, required: true }
|
|
14
|
+
}, {
|
|
15
|
+
"modelValue": { type: null, ...{
|
|
16
|
+
required: false
|
|
17
|
+
} },
|
|
18
|
+
"modelModifiers": {}
|
|
19
|
+
}),
|
|
20
|
+
emits: ["update:modelValue"],
|
|
21
|
+
setup(__props) {
|
|
22
|
+
const props = __props;
|
|
23
|
+
const model = useModel(__props, "modelValue");
|
|
24
|
+
const defaultProps = ref({
|
|
25
|
+
children: "children",
|
|
26
|
+
label: "name",
|
|
27
|
+
value: "id"
|
|
28
|
+
});
|
|
29
|
+
const filter = (nodes) => {
|
|
30
|
+
return nodes.filter((node) => {
|
|
31
|
+
if (node.visible === false) return false;
|
|
32
|
+
if (node.children) {
|
|
33
|
+
node.id = `parent-${node.id}`;
|
|
34
|
+
node.children = filter(node.children);
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
const userList = ref();
|
|
40
|
+
onMounted(async () => {
|
|
41
|
+
const data = await props.getData();
|
|
42
|
+
userList.value = filter(data);
|
|
43
|
+
});
|
|
44
|
+
return (_ctx, _cache) => {
|
|
45
|
+
const _component_Icon = resolveComponent("Icon");
|
|
46
|
+
return openBlock(), createBlock(unref(ElTreeSelect), mergeProps({
|
|
47
|
+
modelValue: model.value,
|
|
48
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
|
|
49
|
+
data: userList.value,
|
|
50
|
+
props: defaultProps.value,
|
|
51
|
+
multiple: props.multiple,
|
|
52
|
+
"show-checkbox": props.multiple,
|
|
53
|
+
filterable: props.filterable,
|
|
54
|
+
class: props.hasMinWidth ? "min-w-240px" : "",
|
|
55
|
+
"collapse-tags": "",
|
|
56
|
+
"node-key": "id",
|
|
57
|
+
placeholder: props.placeholder || "\u8BF7\u9009\u62E9"
|
|
58
|
+
}, _ctx.$attrs), {
|
|
59
|
+
default: withCtx(({ node, data }) => [
|
|
60
|
+
createElementVNode("span", _hoisted_1, [
|
|
61
|
+
data.userFlag ? (openBlock(), createBlock(_component_Icon, {
|
|
62
|
+
key: 0,
|
|
63
|
+
class: "mr-5px",
|
|
64
|
+
icon: "ep-user-filled"
|
|
65
|
+
})) : createCommentVNode("v-if", true),
|
|
66
|
+
createElementVNode(
|
|
67
|
+
"span",
|
|
68
|
+
null,
|
|
69
|
+
toDisplayString(node.label),
|
|
70
|
+
1
|
|
71
|
+
/* TEXT */
|
|
72
|
+
)
|
|
73
|
+
])
|
|
74
|
+
]),
|
|
75
|
+
_: 1
|
|
76
|
+
/* STABLE */
|
|
77
|
+
}, 16, ["modelValue", "data", "props", "multiple", "show-checkbox", "filterable", "class", "placeholder"]);
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface UserTreeSelectProps {
|
|
2
|
+
placeholder?: string;
|
|
3
|
+
multiple?: boolean;
|
|
4
|
+
filterable?: boolean;
|
|
5
|
+
hasMinWidth?: boolean;
|
|
6
|
+
getData: () => Promise<UserDataNode[]>;
|
|
7
|
+
}
|
|
8
|
+
export interface DeptTreeSelectProps {
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
multiple?: boolean;
|
|
11
|
+
filterable?: boolean;
|
|
12
|
+
hasMinWidth?: boolean;
|
|
13
|
+
getData: () => Promise<DeptDataNode[]>;
|
|
14
|
+
disabledIds?: string | string[] | number | number[];
|
|
15
|
+
}
|
|
16
|
+
export interface UserDataNode {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
children?: UserDataNode[];
|
|
20
|
+
visible?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface DeptDataNode {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
children?: DeptDataNode[];
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/es/directives/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './demo';
|
package/es/directives/index.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useGlobalSingleFlight, clearSingleFlightRegistry } from './src/globalSingleFlight';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { clearSingleFlightRegistry, useGlobalSingleFlight } from './src/globalSingleFlight.mjs';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
3
|
+
export interface SingleFlightOptions<T> {
|
|
4
|
+
/** true=永久缓存;number=TTL 毫秒;false=不缓存 */
|
|
5
|
+
cache?: boolean | number;
|
|
6
|
+
/** 命中缓存时是否返回克隆,避免外部改动污染缓存 */
|
|
7
|
+
cloneOnHit?: boolean;
|
|
8
|
+
/** 自定义克隆 */
|
|
9
|
+
cloner?: (v: T) => T;
|
|
10
|
+
/** 可选:根据参数生成二级 key(实现“按参数去重”),默认不并入参数 */
|
|
11
|
+
argsKey?: (...args: unknown[]) => string;
|
|
12
|
+
}
|
|
13
|
+
interface Entry<T, Args extends unknown[] = unknown[]> {
|
|
14
|
+
promise: Ref<Promise<T> | null>;
|
|
15
|
+
value: Ref<T | undefined>;
|
|
16
|
+
error: Ref<unknown>;
|
|
17
|
+
startedAt: Ref<number | null>;
|
|
18
|
+
isRunning: Readonly<Ref<boolean>>;
|
|
19
|
+
isDone: Readonly<Ref<boolean>>;
|
|
20
|
+
run: (...args: Args) => Promise<T>;
|
|
21
|
+
invalidate: () => void;
|
|
22
|
+
reset: () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function useGlobalSingleFlight<TArgs extends unknown[], TResult>(baseKey: string, runner: (...args: TArgs) => MaybePromise<TResult>, options?: SingleFlightOptions<TResult>): Entry<TResult, TArgs>;
|
|
25
|
+
/** 可选工具:手动清理全局注册表(如在登出时) */
|
|
26
|
+
export declare function clearSingleFlightRegistry(): void;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ref, computed } from 'vue';
|
|
2
|
+
|
|
3
|
+
const registry = /* @__PURE__ */ new Map();
|
|
4
|
+
function now() {
|
|
5
|
+
return Date.now();
|
|
6
|
+
}
|
|
7
|
+
function makeFullKey(baseKey, options, args) {
|
|
8
|
+
if (!(options == null ? void 0 : options.argsKey) || !(args == null ? void 0 : args.length)) return baseKey;
|
|
9
|
+
return `${baseKey}::${options.argsKey(...args)}`;
|
|
10
|
+
}
|
|
11
|
+
function defaultClone(v) {
|
|
12
|
+
return JSON.parse(JSON.stringify(v));
|
|
13
|
+
}
|
|
14
|
+
function useGlobalSingleFlight(baseKey, runner, options = {}) {
|
|
15
|
+
function ensureEntry(fullKey) {
|
|
16
|
+
let e = registry.get(fullKey);
|
|
17
|
+
if (e) return e;
|
|
18
|
+
const promise = ref(null);
|
|
19
|
+
const value = ref();
|
|
20
|
+
const error = ref();
|
|
21
|
+
const startedAt = ref(null);
|
|
22
|
+
const isRunning = computed(() => promise.value !== null);
|
|
23
|
+
const isDone = computed(() => value.value !== void 0 && !isRunning.value);
|
|
24
|
+
const hasValidCache = () => {
|
|
25
|
+
const { cache = false } = options;
|
|
26
|
+
if (value.value === void 0) return false;
|
|
27
|
+
if (cache === true) return true;
|
|
28
|
+
if (typeof cache === "number") {
|
|
29
|
+
if (!startedAt.value) return false;
|
|
30
|
+
return now() - startedAt.value < cache;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
const cloneValue = (v) => options.cloneOnHit ? options.cloner ? options.cloner(v) : defaultClone(v) : v;
|
|
35
|
+
async function run(...args) {
|
|
36
|
+
if (hasValidCache()) {
|
|
37
|
+
return Promise.resolve(cloneValue(value.value));
|
|
38
|
+
}
|
|
39
|
+
if (promise.value) return promise.value;
|
|
40
|
+
error.value = void 0;
|
|
41
|
+
const p = (async () => {
|
|
42
|
+
try {
|
|
43
|
+
const ret = await runner(...args);
|
|
44
|
+
value.value = ret;
|
|
45
|
+
startedAt.value = now();
|
|
46
|
+
return ret;
|
|
47
|
+
} catch (e2) {
|
|
48
|
+
value.value = void 0;
|
|
49
|
+
startedAt.value = null;
|
|
50
|
+
error.value = e2;
|
|
51
|
+
throw e2;
|
|
52
|
+
} finally {
|
|
53
|
+
promise.value = null;
|
|
54
|
+
}
|
|
55
|
+
})();
|
|
56
|
+
promise.value = p;
|
|
57
|
+
return p;
|
|
58
|
+
}
|
|
59
|
+
function invalidate() {
|
|
60
|
+
value.value = void 0;
|
|
61
|
+
startedAt.value = null;
|
|
62
|
+
}
|
|
63
|
+
function reset() {
|
|
64
|
+
promise.value = null;
|
|
65
|
+
value.value = void 0;
|
|
66
|
+
error.value = void 0;
|
|
67
|
+
startedAt.value = null;
|
|
68
|
+
}
|
|
69
|
+
e = { promise, value, error, startedAt, isRunning, isDone, run, invalidate, reset };
|
|
70
|
+
registry.set(fullKey, e);
|
|
71
|
+
return e;
|
|
72
|
+
}
|
|
73
|
+
const proxy = {
|
|
74
|
+
promise: ref(null),
|
|
75
|
+
value: ref(),
|
|
76
|
+
error: ref(),
|
|
77
|
+
startedAt: ref(null),
|
|
78
|
+
isRunning: ref(false),
|
|
79
|
+
isDone: ref(false),
|
|
80
|
+
async run(...args) {
|
|
81
|
+
const fullKey = makeFullKey(baseKey, options, args);
|
|
82
|
+
const e = ensureEntry(fullKey);
|
|
83
|
+
proxy.promise = e.promise;
|
|
84
|
+
proxy.value = e.value;
|
|
85
|
+
proxy.error = e.error;
|
|
86
|
+
proxy.startedAt = e.startedAt;
|
|
87
|
+
proxy.isRunning = e.isRunning;
|
|
88
|
+
proxy.isDone = e.isDone;
|
|
89
|
+
return e.run(...args);
|
|
90
|
+
},
|
|
91
|
+
invalidate() {
|
|
92
|
+
const fullKey = makeFullKey(baseKey, options);
|
|
93
|
+
const e = registry.get(fullKey);
|
|
94
|
+
e == null ? void 0 : e.invalidate();
|
|
95
|
+
},
|
|
96
|
+
reset() {
|
|
97
|
+
const fullKey = makeFullKey(baseKey, options);
|
|
98
|
+
const e = registry.get(fullKey);
|
|
99
|
+
e == null ? void 0 : e.reset();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
return proxy;
|
|
103
|
+
}
|
|
104
|
+
function clearSingleFlightRegistry() {
|
|
105
|
+
registry.clear();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export { clearSingleFlightRegistry, useGlobalSingleFlight };
|