Skip to content

Commit a134407

Browse files
committed
修复移动端volform下拉框选择部分苹果手机不兼容的问题,重新开放下拉框搜索功能
1 parent b313438 commit a134407

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

vol.uniapp/components/vol-form/vol-form.vue

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@
113113
v-model="inFormFields[item.field]" border="none" :ref="item.field"
114114
:placeholder="item.placeholder||('请输入'+item.title)"></input>
115115
</view>
116-
<view v-if="item.extra" :style="item.extra.style" style="display: flex;" @click="extraClick(item,inFormFields)">
117-
<u-icon v-if="item.extra.icon" :name="item.extra.icon" :color="item.extra.color" :size="item.extra.size">
116+
<view v-if="item.extra" :style="item.extra.style" style="display: flex;"
117+
@click="extraClick(item,inFormFields)">
118+
<u-icon v-if="item.extra.icon" :name="item.extra.icon" :color="item.extra.color"
119+
:size="item.extra.size">
118120
</u-icon>
119121
<text>{{item.extra.text}}</text>
120122
</view>
@@ -128,21 +130,20 @@
128130
<!-- 下拉框 -->
129131
<u-popup @touchmove.prevent class="form-popup" :zIndex="999999" :show="actionSheetModel"
130132
@close="actionSheetModel=false;">
131-
<view class="vol-action-sheet-select-container" :style="{'max-height':(maxHeight+'px')}">
133+
<view class="vol-action-sheet-select-container" :style="{'height':(popupHeight+'px')}">
132134
<view class="vol-action-sheet-select-title">请选择{{actionSheetCurrentItem.title}}
133135
<text class="vol-action-sheet-select-confirm" @click="actionConfirmClick">确定</text>
134136
</view>
135137
<!-- 超过10个下拉框选项默认开启搜索 -->
136-
<!-- <view class="vol-action-sheet-select-filter"
137-
v-show="actionSheetCurrentItem.data&&actionSheetCurrentItem.data.length>=10">
138-
<view style="padding-left:20rpx;flex:1;font-size: 22px;color: #909399;background: white;">
139-
<u--input placeholder="请输入关键字搜索" v-model="searchText">
138+
<view v-if="showFilter" class="vol-action-sheet-select-filter" >
139+
<view style="padding-left:20rpx;flex:1;font-size: 22px;color: #909399;background: white;">
140+
<u--input placeholder="请输入关键字搜索" v-model="searchText">
140141
</u--input>
141142
</view>
142143
<view class="search-btn">
143-
<u-button type="primary" icon="trash" @click="searchText=''" size="small">清除</u-button>
144+
<u-button :plain="true" :hairline="true" :customStyle="{padding:'10rpx 20rpx'}" shape="circle" type="primary" icon="trash" @click="searchText=''" size="small">清除</u-button>
144145
</view>
145-
</view> -->
146+
</view>
146147
<view class="vol-action-sheet-select-content">
147148
<view :class="{'vol-action-sheet-select-actived':actionSheetModel&&isActionSelected(item)}"
148149
@click="actionClick(item)"
@@ -196,10 +197,12 @@
196197
name: "vol-form",
197198
data() {
198199
return {
200+
showFilter:false,
199201
searchText: '', //搜索的内容
200202
inFormFields: {},
201203
inFormOptions: [],
202204
maxHeight: 400,
205+
popupHeight: 0,
203206
pickerValue: '',
204207
pickerModel: false, //日期组件
205208
pickerCurrentItem: {}, //当前选项
@@ -270,7 +273,7 @@
270273
var _this = this;
271274
uni.getSystemInfo({
272275
success: function(res) {
273-
_this.maxHeight = res.screenHeight * 0.75;
276+
_this.maxHeight = res.screenHeight * 0.85;
274277
}
275278
});
276279
},
@@ -321,7 +324,9 @@
321324
this.actionSheetSelectValues.push(value);
322325
}
323326
}
324-
327+
this.showFilter = item.data.length > 15;
328+
let height = (item.data.length + 1+(this.showFilter?1:0)) * 50;
329+
this.popupHeight = height > this.maxHeight ? this.maxHeight : height;
325330
this.actionSheetModel = true;
326331
},
327332
actionClick(item) {
@@ -796,6 +801,7 @@
796801
797802
.f-form-group-content {}
798803
}
804+
799805
/deep/ .u-icon {
800806
display: inline-flex;
801807
}

vol.uniapp/pages/form/form2.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@
155155
},
156156
methods: {
157157
extraClick(item){
158+
//点击后给表字段设置值
159+
this.editFormFields.customInput=~~(Math.random()*10000000)
158160
this.$toast('表单按钮点击:'+item.title)
159161
},
160162
onChange(field, value) { //日期与下拉框选择事件

0 commit comments

Comments
 (0)