Skip to content

Commit

Permalink
[feature]{datetimepicker}: 新增选择范围功能,支持设置大于等于、小于等于当前日期
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Oct 27, 2019
1 parent 615fdef commit 8146fff
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/components/FormDesigner/GenerateFormItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@
:clearable="widget.options.clearable"
:value-format="widget.options.timestamp ? 'timestamp' : widget.options.format"
:format="widget.options.format"
:style="{width: widget.options.width}" />
:style="{width: widget.options.width}"
:picker-options="pickerOptions"/>
</template>

<template v-if="widget.type =='rate'">
Expand Down Expand Up @@ -186,7 +187,23 @@ export default {
dataModel: this.models[this.widget.model],
};
},
computed: {
// 日期选择器pickOptions
pickerOptions() {
const { range } = this.widget.options;
if (range != null && range !== '') {
return {
disabledDate(time) {
if (range === 'smaller') {
return time.getTime() <= Date.now();
}
return time.getTime() >= Date.now();
},
};
}
return {};
},
},
watch: {
dataModel: {
deep: true,
Expand Down
8 changes: 8 additions & 0 deletions src/components/FormDesigner/WidgetConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,14 @@
<el-switch
v-model="data.options.isRange"
/>
</el-form-item>
<!-- 日期选择器选择范围 暂时只提供大于当前时间 小于当前时间 -->
<el-form-item label="选择范围"
v-if="data.type == 'date'">
<el-select v-model="data.options.range" clearable placeholder="暂时只支持跟当前时间比对">
<el-option label="小于等于当前日期" value="smaller"></el-option>
<el-option label="大于等于当前日期" value="greater"></el-option>
</el-select>
</el-form-item>
<el-form-item
v-if="data.type == 'date'"
Expand Down

0 comments on commit 8146fff

Please sign in to comment.