Skip to content

Commit 6330f5c

Browse files
修复移动端volform日期组件日期第一次默认值不能自动选中的问题
1 parent 2f1c5e1 commit 6330f5c

File tree

1 file changed

+31
-24
lines changed

1 file changed

+31
-24
lines changed

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

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@
7272
</view>
7373

7474
<view class="f-form-content" v-else-if="item.type=='number'">
75-
<input :focus="item.focus" :ref="item.field" placeholder-style="color:rgb(192 196 204);font-size:15px;" type="number"
76-
v-model="formFields[item.field]" border="none"
75+
<input :focus="item.focus" :ref="item.field" placeholder-style="color:rgb(192 196 204);font-size:15px;"
76+
type="number" v-model="formFields[item.field]" border="none"
7777
:placeholder="item.placeholder||('请输入'+item.title)"></input>
7878
</view>
7979
<view class="f-form-content" v-else-if="item.type=='decimal'">
80-
<input :focus="item.focus" :ref="item.field" placeholder-style="color:rgb(192 196 204);font-size:15px;" type="digit"
81-
v-model="formFields[item.field]" border="none"
80+
<input :focus="item.focus" :ref="item.field" placeholder-style="color:rgb(192 196 204);font-size:15px;"
81+
type="digit" v-model="formFields[item.field]" border="none"
8282
:placeholder="item.placeholder||('请输入'+item.title)"></input>
8383
</view>
8484
<view class="f-form-content" v-else-if="item.type=='switch'">
@@ -110,7 +110,8 @@
110110
:placeholder="item.placeholder||('请输入'+item.title)"></input>
111111
</view>
112112
<view v-if="item.extra" @click="extraClick(item,inFormFields)">
113-
<u-icon v-if="item.extra.icon" :name="item.extra.icon" :color="item.extra.clor||'#ffff'" size="20"></u-icon>
113+
<u-icon v-if="item.extra.icon" :name="item.extra.icon" :color="item.extra.clor||'#ffff'" size="20">
114+
</u-icon>
114115
<text :style="item.extra.style">{{item.extra.text}}</text>
115116
</view>
116117
</view>
@@ -127,16 +128,15 @@
127128
<view class="vol-action-sheet-select-title">请选择{{actionSheetCurrentItem.title}}
128129
<text class="vol-action-sheet-select-confirm" @click="actionConfirmClick">确定</text>
129130
</view>
130-
<!-- 超过10个下拉框选项默认开启搜索 -->
131-
<view class="vol-action-sheet-select-filter" v-show="actionSheetCurrentItem.data&&actionSheetCurrentItem.data.length>=10">
132-
<view
133-
style="padding-left:20rpx;flex:1;font-size: 22px;color: #909399;background: white;">
131+
<!-- 超过10个下拉框选项默认开启搜索 -->
132+
<view class="vol-action-sheet-select-filter"
133+
v-show="actionSheetCurrentItem.data&&actionSheetCurrentItem.data.length>=10">
134+
<view style="padding-left:20rpx;flex:1;font-size: 22px;color: #909399;background: white;">
134135
<u--input placeholder="请输入关键字搜索" v-model="searchText">
135136
</u--input>
136137
</view>
137138
<view class="search-btn">
138-
<u-button type="primary" icon="trash" @click="searchText=''"
139-
size="small">清除</u-button>
139+
<u-button type="primary" icon="trash" @click="searchText=''" size="small">清除</u-button>
140140
</view>
141141
</view>
142142
<view class="vol-action-sheet-select-content">
@@ -201,7 +201,10 @@
201201
pickerCurrentItem: {}, //当前选项
202202
pickerCurrentRangeIndex: 0,
203203
actionSheetModel: false,
204-
actionSheetCurrentItem: {}, //当前选项
204+
actionSheetCurrentItem: {
205+
min: 633715200000,
206+
max: 0
207+
}, //当前选项
205208
actionSheetSelectValues: [], //当前选中的项
206209
numberModel: false,
207210
numberType: 'number',
@@ -223,10 +226,13 @@
223226
} else if (option.max && typeof option.max == 'string') {
224227
option.max = Number(new Date(option.max.replace(/-/g, "/")))
225228
}
229+
if (!this.pickerCurrentItem.max) {
230+
this.pickerCurrentItem.max = option.max;
231+
}
226232
}
227-
228-
if(option.hasOwnProperty('focus')){
229-
option.focus=false;
233+
234+
if (option.hasOwnProperty('focus')) {
235+
option.focus = false;
230236
}
231237
})
232238
this.inFormOptions = this.formOptions;
@@ -296,7 +302,7 @@
296302
this.$emit('dicInited', result);
297303
},
298304
showActionSheet(item) {
299-
this.searchText='';
305+
this.searchText = '';
300306
this.actionSheetSelectValues = [];
301307
this.actionSheetCurrentItem = item;
302308
var value = this.inFormFields[item.field];
@@ -603,8 +609,8 @@
603609
deletePic(item, event) {
604610
this.inFormFields[item.field].splice(event.index, 1)
605611
},
606-
extraClick(item,inFormFields){
607-
this.$emit('extraClick',item,inFormFields)
612+
extraClick(item, inFormFields) {
613+
this.$emit('extraClick', item, inFormFields)
608614
}
609615
},
610616
// #ifdef MP-WEIXIN
@@ -670,13 +676,14 @@
670676
// }
671677
// }
672678
.vol-action-sheet-select-filter {
673-
display: flex;
674-
background: #ffff;
675-
padding: 10rpx;
676-
border-bottom: 1px solid #eeee;
679+
display: flex;
680+
background: #ffff;
681+
padding: 10rpx;
682+
border-bottom: 1px solid #eeee;
683+
677684
.search-btn {
678-
position: relative;
679-
top: 3px;
685+
position: relative;
686+
top: 3px;
680687
// margin-left: 20rpx;
681688
// padding-right: 20rpx;
682689
// width: 100rpx;

0 commit comments

Comments
 (0)