|
@@ -50,7 +50,11 @@ watch(() => props.modelValue, val => {
|
|
|
|
|
|
const checkStrategy = value => {
|
|
|
state.children.forEach(item => {
|
|
|
- item.selected = state.selectedValue.indexOf(item.value) > -1
|
|
|
+ if (typeof item.value === 'object') {
|
|
|
+ item.selected = state.selectedValue.filter(selected => selected.id === item.value.id).length > 0
|
|
|
+ } else{
|
|
|
+ item.selected = state.selectedValue.indexOf(item.value) > -1
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
const updateChildren = child => {
|
|
@@ -58,7 +62,18 @@ const updateChildren = child => {
|
|
|
checkStrategy()
|
|
|
}
|
|
|
const updateValue = value => {
|
|
|
- const index = state.selectedValue.indexOf(value)
|
|
|
+ let index = -1
|
|
|
+
|
|
|
+ if (typeof value === 'object') {
|
|
|
+ state.selectedValue.forEach((item, key) => {
|
|
|
+ if(item.id === value.id) {
|
|
|
+ index = key
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else{
|
|
|
+ index = state.selectedValue.indexOf(value)
|
|
|
+ }
|
|
|
+
|
|
|
if (state.selectedValue.length < props.max || props.max === -1) {
|
|
|
if (index === -1) {
|
|
|
state.selectedValue.push(value)
|