|
@@ -28,7 +28,7 @@
|
|
|
@update:modelValue="modelValueUpDate"
|
|
|
>
|
|
|
</v-text-field>
|
|
|
- <v-menu activator="#menu-activator" :close-on-content-click="closeOnContentClick" >
|
|
|
+ <v-menu activator="#menu-activator" :close-on-content-click="closeOnContentClick">
|
|
|
<listGroup
|
|
|
:list="item.items"
|
|
|
:option="option"
|
|
@@ -64,22 +64,27 @@ const modelValueUpDate = () => {
|
|
|
let static_selectLabel = ''; const model_selectLabel = ref('')
|
|
|
const value = ref(propsData.modelValue) // selectValue // modelValue
|
|
|
const clickUpdate = (val) => {
|
|
|
- static_selectLabel = model_selectLabel.value = val[option.itemText]
|
|
|
- value.value = val[option.itemValue]
|
|
|
+ static_selectLabel = model_selectLabel.value = val[option.itemText || 'label']
|
|
|
+ value.value = val[option.itemValue || 'value']
|
|
|
emit('update:modelValue', value.value)
|
|
|
emit('change', value.value)
|
|
|
}
|
|
|
const closeOnContentClick = ref(false) // multiple
|
|
|
|
|
|
-const labelUpdateDeal = (txt) => {
|
|
|
- static_selectLabel = model_selectLabel.value = txt
|
|
|
+// 回显label
|
|
|
+const chosen = ref(null)
|
|
|
+const traverse = (nodes) => {
|
|
|
+ for (const node of nodes) {
|
|
|
+ if (node[option.itemValue || value] === value.value) {
|
|
|
+ chosen.value = node
|
|
|
+ }
|
|
|
+ if (node.children) {
|
|
|
+ traverse(node.children)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
-// // 回显label
|
|
|
-// if (item?.items?.length) {
|
|
|
-// const options = item.items
|
|
|
-
|
|
|
-// }
|
|
|
+if (item?.items?.length && value.value) traverse(item.items)
|
|
|
+if (chosen.value) clickUpdate(chosen.value)
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
.showOnTop {
|