Skip to content

Commit

Permalink
fix(datetime-picker): update value with origin column after change (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rex-zsd committed Jul 9, 2020
1 parent 44194c7 commit fa54a19
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/datetime-picker/index.ts
Expand Up @@ -103,7 +103,7 @@ VantComponent({
methods: {
updateValue() {
const { data } = this;
const val = this.correctValue(this.data.value);
const val = this.correctValue(data.value);
const isEqual = val === data.innerValue;
if (!isEqual) {
this.updateColumnValue(val).then(() => {
Expand Down Expand Up @@ -291,13 +291,17 @@ VantComponent({
let value;

const picker = this.getPicker();
const originColumns = this.getOriginColumns();

if (data.type === 'time') {
const indexes = picker.getIndexes();
value = `${+data.columns[0].values[indexes[0]]}:${+data.columns[1]
value = `${+originColumns[0].values[indexes[0]]}:${+originColumns[1]
.values[indexes[1]]}`;
} else {
const values = picker.getValues();
const indexes = picker.getIndexes();
const values = indexes.map(
(value, index) => originColumns[index].values[value]
);
const year = getTrueValue(values[0]);
const month = getTrueValue(values[1]);
const maxDate = getMonthEndDay(year, month);
Expand All @@ -324,7 +328,8 @@ VantComponent({

updateColumnValue(value) {
let values = [];
const { type, formatter = defaultFormatter } = this.data;
const { type } = this.data;
const formatter = this.data.formatter || defaultFormatter;
const picker = this.getPicker();

if (type === 'time') {
Expand Down

0 comments on commit fa54a19

Please sign in to comment.