Skip to content

Commit

Permalink
fix(form): date组件初始值 不显示
Browse files Browse the repository at this point in the history
  • Loading branch information
roymondchen authored and jia000 committed Jul 7, 2022
1 parent dd1a8e2 commit 8d5eab0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 26 deletions.
28 changes: 12 additions & 16 deletions packages/form/src/fields/Date.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
<template>
<div v-if="model">
<el-date-picker
v-model="model[modelName]"
type="date"
:size="size"
:placeholder="config.placeholder"
:disabled="disabled"
:format="config.format"
:value-format="config.format || 'YYYY-MM-DD HH:mm:ss'"
@change="changeHandler"
></el-date-picker>
</div>
<el-date-picker
v-model="model[name]"
type="date"
:size="size"
:placeholder="config.placeholder"
:disabled="disabled"
:format="config.format"
:value-format="config.format || 'YYYY-MM-DD HH:mm:ss'"
@change="changeHandler"
></el-date-picker>
</template>

<script lang="ts">
import { computed, defineComponent, PropType } from 'vue';
import { defineComponent, PropType } from 'vue';
import { datetimeFormatter } from '@tmagic/utils';
Expand All @@ -38,10 +36,8 @@ export default defineComponent({
setup(props, { emit }) {
useAddField(props.prop);
const modelName = computed(() => props.prop || props.config.name || '');
props.model[modelName.value] = datetimeFormatter(props.model[modelName.value], '');
props.model[props.name] = datetimeFormatter(props.model[props.name], '');
return {
modelName,
changeHandler(v: string) {
emit('change', v);
},
Expand Down
18 changes: 8 additions & 10 deletions packages/form/src/fields/Time.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<template>
<div>
<el-time-picker
v-model="model[name]"
:size="size"
value-format="HH:mm:ss"
:placeholder="config.placeholder"
:disabled="disabled"
@change="changeHandler"
></el-time-picker>
</div>
<el-time-picker
v-model="model[name]"
:size="size"
value-format="HH:mm:ss"
:placeholder="config.placeholder"
:disabled="disabled"
@change="changeHandler"
></el-time-picker>
</template>

<script lang="ts">
Expand Down

0 comments on commit 8d5eab0

Please sign in to comment.