2121import {ElTree } from ' element-plus'
2222import type Node from ' element-plus/es/components/tree/src/model/node'
2323import type {AllowDropType , NodeDropType } from ' element-plus/es/components/tree/src/tree.type'
24- import {type CartItemEditingChild , type CartItemPresetChild , type CartItemSimple , type CartItemComplex , type CartItemComposition , type CartItemEditing , type CartItem , type CartChildItem , useCartStore , CartItemAlternate , CartItemCompositionChild } from ' ../stores/cart'
24+ import {type CartItemEditingChild , type CartItemPresetChild , type CartItemSimple , type CartItemComplex , type CartItemEditing , type CartItem , type CartChildItem , useCartStore , type CartItemAlternate } from ' ../stores/cart'
2525import CartItemComponent from ' ./CartItem.vue'
2626
2727const props = defineProps <{
@@ -70,7 +70,6 @@ function allowDrop(draggingNode: Node, dropNode: Node, type: AllowDropType) {
7070 * 6. 出:mixture拖干净,需要删掉mixture
7171 * 7. 入:有simple标签拖进free的simple标签,创建editing
7272 * 8. ~~出:alternate和editing移出,需要补一个weight~~ - 这个weight现在不丢了 所以不需要补
73- * 9. 入:拖入 composite的非group应当套一层group
7473 *
7574 * 最后需要把parent改了,标签类型修正了
7675 *
@@ -101,15 +100,14 @@ function dropPostProcess(draggingNode: Node, dropNode: Node, type: NodeDropType)
101100 })
102101 }
103102 }
104- } else if (draggingNode .data .parent ?.type === ' composite'
105- || draggingNode .data .parent ?.type === ' alternate'
103+ } else if (draggingNode .data .parent ?.type === ' alternate'
106104 || draggingNode .data .parent ?.type === ' group' ) {
107105 // 6. 出:mixture拖干净,需要删掉mixture
108106 if (draggingNode .data .parent .children .length === 0 ) {
109107 cartStore .removeCartItem (props .direction , draggingNode .data .parent )
110108 } else if (draggingNode .data .parent ?.type !== ' group' && draggingNode .data .parent .children .length === 1 ) {
111109 // 除 group 以外剩下一个就解散
112- cartStore .dismissCartItem (props .direction , draggingNode .data .parent as CartItemComposition | CartItemAlternate )
110+ cartStore .dismissCartItem (props .direction , draggingNode .data .parent as CartItemAlternate )
113111 skipReParent = true
114112 }
115113 }
@@ -131,14 +129,6 @@ function dropPostProcess(draggingNode: Node, dropNode: Node, type: NodeDropType)
131129 const dropCartItem = dropNode .data as CartItemSimple
132130 // 7. 入:有simple标签拖进free的simple标签,创建editing
133131 cartStore .createMixtureFromTag (props .direction , dropCartItem )
134- } else if (dropNode .data .type === ' composition' && type === ' inner' ) {
135- const draggingCartItem = draggingNode .data as CartItemCompositionChild
136- const dropCartItem = dropNode .data as CartItemComposition
137- // 9. 入:拖入 composite的非group应当套一层group
138- draggingCartItem .parent = dropCartItem
139- if (draggingCartItem .type !== ' group' ) {
140- cartStore .wrapCompositionChild (draggingCartItem )
141- }
142132 } else if (dropNode .data .parent ?.type === ' editing' && type !== ' inner' ) {
143133 const dropCartItem = dropNode .data as CartItemEditingChild
144134 if (dropCartItem .parent .children .length > 2 ) {
@@ -151,16 +141,7 @@ function dropPostProcess(draggingNode: Node, dropNode: Node, type: NodeDropType)
151141 cartStore .switchMixtureType (props .direction , dropCartItem .parent , ' alternate' )
152142 }
153143 }
154- } else if (dropNode .data .parent ?.type === ' composition' && type !== ' inner' ) {
155- const draggingCartItem = draggingNode .data as CartItemCompositionChild
156- const dropCartItem = dropNode .data as CartItemCompositionChild
157- // 9. 入:拖入 composite的非group应当套一层group
158- draggingCartItem .parent = dropCartItem .parent
159- if (draggingCartItem .type !== ' group' ) {
160- cartStore .wrapCompositionChild (draggingCartItem )
161- skipReParent = true
162- }
163- }
144+ }
164145
165146 if (! skipReParent ) {
166147 if (type === ' before' || type === ' after' ) {
0 commit comments