zhangxiaoxu123456
2021-12-06 f32f7d699607bb159d25dcf441942370aba2c968
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<template>
    <view class="u-demo">
        <view class="u-demo-wrap">
            <view class="u-demo-title">演示效果</view>
            <view class="u-demo-area">
                <u-select @click="show = true" :default-value="defaultValue" :mode="mode" v-model="show" :list="list" @confirm="confirm" @cancel="cancel"></u-select>
                <view class="u-demo-result-line">select值:{{ result }}</view>
            </view>
        </view>
        <view class="u-config-wrap">
            <view class="u-config-title u-border-bottom">参数配置</view>
            <view class="u-config-item">
                <view class="u-item-title">状态</view>
                <u-subsection :current="current" :list="['打开', '收起']" @change="statusChange"></u-subsection>
            </view>
            <view class="u-config-item">
                <view class="u-item-title">模式</view>
                <u-subsection :list="['单列', '多列独立', '多列联动']" @change="modeChange"></u-subsection>
            </view>
        </view>
    </view>
</template>
 
<script>
export default {
    data() {
        return {
            show: false,
            result: '尚未选择',
            defaultValue: [3],
            mode: 'single-column', // single-column, mutil-column, mutil-column-auto
            list: [],
            list1: [
                {
                    value: '江',
                    label: '江'
                },
                {
                    value: '湖',
                    label: '湖'
                },
                {
                    value: '夜',
                    label: '夜'
                },
                {
                    value: '雨',
                    label: '雨'
                },
                {
                    value: '十',
                    label: '十'
                },
                {
                    value: '年',
                    label: '年'
                },
                {
                    value: '灯',
                    label: '灯'
                }
            ],
            list2: [
                [
                    {
                        value: '昔',
                        label: '昔'
                    },
                    {
                        value: '去',
                        label: '去'
                    },
                    {
                        value: '雪',
                        label: '雪'
                    },
                    {
                        value: '如',
                        label: '如'
                    },
                    {
                        value: '花',
                        label: '花'
                    }
                ],
                [
                    {
                        value: '今',
                        label: '今'
                    },
                    {
                        value: '来',
                        label: '来'
                    },
                    {
                        value: '花',
                        label: '花'
                    },
                    {
                        value: '似',
                        label: '似'
                    },
                    {
                        value: '雪',
                        label: '雪'
                    }
                ]
            ],
            list3: [
                {
                    label: '中国',
                    value: '1',
                    children: [
                        {
                            label: '广西',
                            value: '2',
                            children: [
                                {
                                    label: '南宁',
                                    value: '3'
                                },
                                {
                                    label: '梧州',
                                    value: '3'
                                },
                                {
                                    label: '柳州',
                                    value: '3'
                                }
                            ]
                        },
                        {
                            label: '广东',
                            value: '2',
                            children: [
                                {
                                    label: '深圳',
                                    value: '3'
                                },
                                {
                                    label: '惠州',
                                    value: '3'
                                },
                                {
                                    label: '清远',
                                    value: '3'
                                }
                            ]
                        }
                    ]
                },
                {
                    label: '美国',
                    value: '1',
                    children: [
                        {
                            label: '纽约',
                            value: '2',
                            children: [
                                {
                                    label: '皇后街道',
                                    value: '3'
                                }
                            ]
                        }
                    ]
                }
            ]
        };
    },
    onLoad() {
        this.list = this.list1;
    },
    computed: {
        current() {
            return this.show ? 0 : 1;
        }
    },
    methods: {
        statusChange(index) {
            this.show = !index;
        },
        modeChange(index) {
            let type = ['single-column', 'mutil-column', 'mutil-column-auto'];
            this.mode = type[index];
            this.list = index == 0 ? this.list1 : index == 1 ? this.list2 : this.list3;
            this.show = true;
        },
        confirm(e) {
            this.result = '';
            e.map((val, index) => {
                this.result += this.result == '' ? val.label : '-' + val.label;
            })
        },
        cancel(e) {
            console.log(e);
        }
    }
};
</script>
 
<style scoped lang="scss">
.badge-button {
    padding: 4rpx 6rpx;
    background-color: $u-type-error;
    color: #fff;
    border-radius: 10rpx;
    font-size: 22rpx;
    line-height: 1;
}
</style>