@@ -20,6 +20,54 @@ interface SelectionState {
2020// 初始化多选节点
2121const multiSelectedStates = ref < SelectionState [ ] > ( [ ] )
2222
23+ /**
24+ * 创建TinyPopover组件结构
25+ * @param {Object } props 组件属性
26+ * @param {Node | Node[] } content 内容节点
27+ * @returns {Node } TinyPopover组件结构
28+ */
29+ const createTinyPopoverSchema = ( props : Record < string , any > = { } , content : Node | Node [ ] ) : Node => {
30+ const children = Array . isArray ( content ) ? content : [ content ]
31+
32+ return {
33+ componentName : 'TinyPopover' ,
34+ id : props . id !== undefined ? props . id : null ,
35+ props : {
36+ width : 200 ,
37+ title : '弹框标题' ,
38+ trigger : 'manual' ,
39+ modelValue : true ,
40+ ...props
41+ } ,
42+ children : [
43+ {
44+ componentName : 'Template' ,
45+ id : null ,
46+ props : {
47+ slot : 'reference'
48+ } ,
49+ children
50+ } ,
51+ {
52+ componentName : 'Template' ,
53+ id : null ,
54+ props : {
55+ slot : 'default'
56+ } ,
57+ children : [
58+ {
59+ componentName : 'div' ,
60+ id : null ,
61+ props : {
62+ placeholder : '提示内容'
63+ }
64+ }
65+ ]
66+ }
67+ ]
68+ }
69+ }
70+
2371export const useMultiSelect = ( ) => {
2472 /**
2573 * 添加state到多选列表
@@ -146,7 +194,7 @@ export const useMultiSelect = () => {
146194 const selectedNodes = indices . map ( ( index ) => parent . children [ index ] )
147195
148196 // 创建新的包装组件
149- const wrapSchema : Node = {
197+ let wrapSchema : Node = {
150198 componentName,
151199 id : utils . guid ( ) ,
152200 props : { ...props } ,
@@ -155,38 +203,7 @@ export const useMultiSelect = () => {
155203
156204 // 特殊处理 TinyPopover 等组件
157205 if ( componentName === 'TinyPopover' ) {
158- wrapSchema . props = {
159- width : 200 ,
160- title : '弹框标题' ,
161- trigger : 'manual' ,
162- modelValue : true
163- }
164- wrapSchema . children = [
165- {
166- componentName : 'Template' ,
167- id : null ,
168- props : {
169- slot : 'reference'
170- } ,
171- children : selectedNodes
172- } ,
173- {
174- componentName : 'Template' ,
175- id : null ,
176- props : {
177- slot : 'default'
178- } ,
179- children : [
180- {
181- componentName : 'div' ,
182- id : null ,
183- props : {
184- placeholder : '提示内容'
185- }
186- }
187- ]
188- }
189- ]
206+ wrapSchema = createTinyPopoverSchema ( { ...props , id : utils . guid ( ) } , selectedNodes )
190207 }
191208
192209 // 从后向前删除原来的节点,避免索引变化
@@ -229,43 +246,7 @@ export const useMultiSelect = () => {
229246
230247 // 需要对popover特殊处理
231248 if ( componentName === 'TinyPopover' ) {
232- wrapSchema = {
233- componentName,
234- id : null ,
235- props : {
236- width : 200 ,
237- title : '弹框标题' ,
238- trigger : 'manual' ,
239- modelValue : true ,
240- ...props
241- } ,
242- children : [
243- {
244- componentName : 'Template' ,
245- id : null ,
246- props : {
247- slot : 'reference'
248- } ,
249- children : [ childSchema ]
250- } ,
251- {
252- componentName : 'Template' ,
253- id : null ,
254- props : {
255- slot : 'default'
256- } ,
257- children : [
258- {
259- componentName : 'div' ,
260- id : null ,
261- props : {
262- placeholder : '提示内容'
263- }
264- }
265- ]
266- }
267- ]
268- }
249+ wrapSchema = createTinyPopoverSchema ( props , childSchema )
269250 }
270251
271252 return wrapSchema
@@ -310,7 +291,7 @@ export const useMultiSelect = () => {
310291 )
311292 } )
312293
313- return false
294+ return true
314295 }
315296
316297 return {
0 commit comments