Blame view

pages/extUI/data-picker/data-picker.nvue 2.63 KB
4b045f7c   刘淇   江阴初始化项目
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
  <template>
  	<view class="container">
  		<uni-card is-full :is-shadow="false">
  			<text class="uni-h6">标签组件多用于商品分类、重点内容显示等场景。</text>
  		</uni-card>
  
  
  		<!-- <view class="title">
        <text>uni-data-picker</text>
      </view>
      <uni-data-picker placeholder="请选择地址" popup-title="请选择所在地区" :preload="true" :step-searh="true" self-field="code"
        parent-field="parent_code" collection="opendb-city-china" orderby="value asc" field="code as value, name as text, eq(['$type', 2]) as isleaf" @nodeclick="onnodeclick" @change="onchange">
      </uni-data-picker>
  
      <view class="title">
        <text>uni-data-picker 有默认值</text>
      </view>
      <uni-data-picker placeholder="请选择地址" popup-title="请选择所在地区" :preload="true" :step-searh="true" self-field="code"
        parent-field="parent_code" collection="opendb-city-china" orderby="value asc" field="code as value, name as text, eq(['$type', 2]) as isleaf"
        v-model="address">
      </uni-data-picker> -->
  		<uni-section title="本地数据" type="line" padding style="height: calc(100vh - 100px);">
  			<uni-data-picker placeholder="请选择班级" popup-title="请选择所在地区" :localdata="dataTree" v-model="classes"
  				@change="onchange" @nodeclick="onnodeclick" @popupopened="onpopupopened" @popupclosed="onpopupclosed">
  			</uni-data-picker>
  		</uni-section>
  	</view>
  </template>
  
  <script>
  	export default {
  		data() {
  			return {
  				classes: '1-2',
  				dataTree: [{
  						text: "一年级",
  						value: "1-0",
  						children: [{
  								text: "1.1班",
  								value: "1-1"
  							},
  							{
  								text: "1.2班",
  								value: "1-2"
  							}
  						]
  					},
  					{
  						text: "二年级",
  						value: "2-0",
  						children: [{
  								text: "2.1班",
  								value: "2-1"
  							},
  							{
  								text: "2.2班",
  								value: "2-2"
  							}
  						]
  					},
  					{
  						text: "三年级",
  						value: "3-0",
  						disable: true
  					}
  				]
  			}
  		},
  		methods: {
  			onnodeclick(e) {
  				console.log(e);
  			},
  			onpopupopened(e) {
  				console.log('popupopened');
  			},
  			onpopupclosed(e) {
  				console.log('popupclosed');
  			},
  			onchange(e) {
  				console.log('---------onchange:', e);
  			}
  		}
  	}
  </script>
  
  <style>
  	.title {
  		font-size: 14px;
  		font-weight: bold;
  		margin: 20px 0 5px 0;
  	}
  
  	.data-pickerview {
  		height: 400px;
  		border: 1px #e5e5e5 solid;
  	}
  
  	.popper__arrow {
  		top: -6px;
  		left: 50%;
  		margin-right: 3px;
  		border-top-width: 0;
  		border-bottom-color: #EBEEF5;
  	}
  
  	.popper__arrow {
  		top: -6px;
  		left: 50%;
  		margin-right: 3px;
  		border-top-width: 0;
  		border-bottom-color: #EBEEF5;
  	}
  </style>