Skip to content

Commit

Permalink
perf: 时间选择器新增默认值功能,高级查询表单交互几处细节优化 @0.9.4-6
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Apr 29, 2021
1 parent 758a8bd commit 2c753b9
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "element-pro-crud",
"version": "0.9.4-5",
"version": "0.9.4-6",
"author": "BoBo<[email protected]>",
"main": "lib/pro-crud.js",
"files": [
Expand Down
3 changes: 2 additions & 1 deletion src/component/form-designer/src/WidgetConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
elementConfig.type == 'color' ||
elementConfig.type == 'switch' ||
elementConfig.type == 'date' ||
elementConfig.type == 'time' ||
elementConfig.type == 'select' ||
elementConfig.type == 'html')
"
Expand All @@ -246,7 +247,7 @@
>清空</el-button
>
<el-color-picker v-if="elementConfig.type == 'color'" v-model="elementConfig.options.defaultValue" :show-alpha="elementConfig.options.showAlpha"></el-color-picker>
<el-switch v-if="elementConfig.type == 'switch' || elementConfig.type == 'date'" v-model="elementConfig.options.defaultValue"></el-switch>
<el-switch v-else-if="elementConfig.type == 'switch' || elementConfig.type == 'date' || elementConfig.type == 'time'" v-model="elementConfig.options.defaultValue"></el-switch>
</el-form-item>
<el-form-item label="最多输入" v-if="elementConfig.options.maxLength !== undefined">
<el-input v-model="elementConfig.options.maxLength" placeholder="请输入最大长度">
Expand Down
6 changes: 3 additions & 3 deletions src/component/form-designer/src/componentsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export const basicComponents = [
icon: 'clock',
options: {
hiddenLabel: false,
defaultValue: '',
defaultValue: false,
readonly: false,
disabled: false,
editable: true,
Expand All @@ -172,7 +172,7 @@ export const basicComponents = [
startPlaceholder: '',
endPlaceholder: '',
type: 'datetime',
format: 'yyyy-MM-dd hh:mm:ss',
format: 'hh:mm:ss',
timestamp: false,
required: false,
width: '100%',
Expand Down Expand Up @@ -686,4 +686,4 @@ export const elementComponentConfig = {
};

// 表单类组件枚举
export const formElement = ['input', 'textarea', 'number', 'radio', 'checkbox', 'date', 'rate', 'color', 'select', 'switch', 'slider', 'cascader', 'treeselect', 'richtext'];
export const formElement = ['input', 'textarea', 'number', 'radio', 'checkbox', 'date', 'time', 'rate', 'color', 'select', 'switch', 'slider', 'cascader', 'treeselect', 'richtext'];
8 changes: 5 additions & 3 deletions src/component/pro-form/src/ProForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import { Component, Vue, Prop, Watch } from 'vue-property-decorator';
import { AnyObject } from '@/types/common';
import { formElement } from '@/component/form-designer/src/componentsConfig';
import dayjs from 'dayjs';
import ProLayout from './ProLayout.vue';

@Component({
Expand Down Expand Up @@ -280,11 +281,12 @@ export default class ProForm extends Vue {
// 表单默认值回填单独拉出来封装
setDefaultValue(config) {
// 如果时间选择器需要默认值,默认回填当前日期
if (config.type === 'date') {
if (config.type === 'date' || config.type === 'time') {
if (config.options.defaultValue) {
const { format } = config.options;
if (format && format !== '') {
this.models[config.model] = this.dayjs().format(format.toUpperCase());
if (format) {
console.log(format);
this.models[config.model] = dayjs().format(config.type === 'time' ? format : format.toUpperCase());
}
} else {
this.models[config.model] = null;
Expand Down
3 changes: 3 additions & 0 deletions src/component/pro-table/src/SearchForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export default defineComponent({
},
];
}
// 一键搜需要清空高级查询条件
paramsTips.value = [];
emit('update:searchFormCondition', params);
};

Expand Down Expand Up @@ -151,6 +153,7 @@ export default defineComponent({
operator: item.operator,
label: seachableColumns.value.find((s) => s.prop === item.field)!.label,
}));
searchContent.value = '';
emit('update:searchFormCondition', params);
emit('click');
};
Expand Down
2 changes: 1 addition & 1 deletion src/component/pro-table/src/SeniorSearchForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<span>高级查询</span>
</div>
<div>
<ProForm ref="generateDialogForm" :data="formDesign" :remote="remoteFuncs" :entity.sync="entity" />
<ProForm v-if="visible" ref="generateDialogForm" :data="formDesign" :remote="remoteFuncs" :entity.sync="entity" />
<div style="float: right">
<el-button size="small" type="primary" icon="el-icon-search" @click="getSearchFormData()">查询</el-button>
<el-button size="small" style="margin-right: 10px" icon="el-icon-close" @click="resetForm">关闭</el-button>
Expand Down

0 comments on commit 2c753b9

Please sign in to comment.