@@ -30,11 +30,8 @@ const note = ref('请选择地址');
30
30
31
31
const onPick = (value : string ) => {
32
32
const values = JSON .parse (JSON .stringify (value ));
33
- if (
34
- options .value [values .index ] &&
35
- values .value === options .value [values .index ].value &&
36
- options .value [values .index ].children ?.length === 0
37
- ) {
33
+ console .log (' onPick' , values );
34
+ const showToast = () => {
38
35
Toast ({
39
36
theme: ' loading' ,
40
37
message: ' 加载中...' ,
@@ -43,25 +40,46 @@ const onPick = (value: string) => {
43
40
duration: 10000 ,
44
41
preventScrollThrough: true ,
45
42
});
43
+ };
44
+
45
+ if (values .level === 1 && data .value [0 ].children [values .index ]?.children ?.length === 0 ) {
46
+ showToast ();
47
+ setTimeout (() => {
48
+ const current = data .value [0 ].children [values .index ];
49
+ current .children = [{ value: ` ${current .value }01 ` , label: ` ${current .label }街道 ` }];
50
+ Toast .clear ();
51
+ }, 1000 );
52
+ return ;
53
+ }
54
+
55
+ if (
56
+ options .value [values .index ] &&
57
+ values .value === options .value [values .index ].value &&
58
+ options .value [values .index ].children ?.length === 0
59
+ ) {
60
+ showToast ();
46
61
// 模拟数据请求
47
62
setTimeout (() => {
48
63
data .value [0 ].children = [
49
- { value: ' 440304' , label: ' 福田区' },
50
- { value: ' 440303' , label: ' 罗湖区' },
51
- { value: ' 440305' , label: ' 南山区' },
52
- { value: ' 440306' , label: ' 宝安区' },
53
- { value: ' 440307' , label: ' 龙岗区' },
54
- { value: ' 440308' , label: ' 盐田区' },
55
- { value: ' 440309' , label: ' 龙华区' },
56
- { value: ' 440310' , label: ' 坪山区' },
57
- { value: ' 440311' , label: ' 光明区' },
64
+ { value: ' 440304' , label: ' 福田区' , children: [] },
65
+ { value: ' 440303' , label: ' 罗湖区' , children: [] },
66
+ { value: ' 440305' , label: ' 南山区' , children: [] },
67
+ { value: ' 440306' , label: ' 宝安区' , children: [] },
68
+ { value: ' 440307' , label: ' 龙岗区' , children: [] },
69
+ { value: ' 440308' , label: ' 盐田区' , children: [] },
70
+ { value: ' 440309' , label: ' 龙华区' , children: [] },
71
+ { value: ' 440310' , label: ' 坪山区' , children: [] },
72
+ { value: ' 440311' , label: ' 光明区' , children: [] },
58
73
];
59
74
Toast .clear ();
60
75
}, 1000 );
61
76
}
62
77
};
63
78
const onChange = (value : string , options : any ) => {
64
- note .value = options ?.map ((item : any ) => item .label ).join (' /' );
79
+ note .value = options
80
+ ?.filter ((item ? : Array <{ label: string }>) => item )
81
+ ?.map ((item : any ) => item .label )
82
+ .join (' /' );
65
83
visible .value = false ;
66
84
};
67
85
0 commit comments