[bugfix] DatetimePicker: incorrect confirm param when use formatter (#3969)

This commit is contained in:
neverland 2019-07-26 10:01:07 +08:00 committed by GitHub
parent c72ac6edcd
commit a7d1690311
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,12 +3,7 @@ import { range } from '../utils/format/number';
import { padZero } from '../utils/format/string'; import { padZero } from '../utils/format/string';
import Picker from '../picker'; import Picker from '../picker';
import { pickerProps } from '../picker/shared'; import { pickerProps } from '../picker/shared';
import { import { times, isValidDate, getTrueValue, getMonthEndDay } from './utils';
times,
isValidDate,
getTrueValue,
getMonthEndDay
} from './utils';
const [createComponent, bem] = createNamespace('datetime-picker'); const [createComponent, bem] = createNamespace('datetime-picker');
const currentYear = new Date().getFullYear(); const currentYear = new Date().getFullYear();
@ -109,21 +104,15 @@ export default createComponent({
]; ];
} }
const { const { maxYear, maxDate, maxMonth, maxHour, maxMinute } = this.getBoundary(
maxYear, 'max',
maxDate, this.innerValue
maxMonth, );
maxHour,
maxMinute
} = this.getBoundary('max', this.innerValue);
const { const { minYear, minDate, minMonth, minHour, minMinute } = this.getBoundary(
minYear, 'min',
minDate, this.innerValue
minMonth, );
minHour,
minMinute
} = this.getBoundary('min', this.innerValue);
const result = [ const result = [
{ {
@ -153,11 +142,11 @@ export default createComponent({
return result; return result;
}, },
columns() { originColumns() {
const results = this.ranges.map(({ type, range: rangeArr }) => { return this.ranges.map(({ type, range: rangeArr }) => {
let values = times(rangeArr[1] - rangeArr[0] + 1, index => { let values = times(rangeArr[1] - rangeArr[0] + 1, index => {
const value = padZero(rangeArr[0] + index); const value = padZero(rangeArr[0] + index);
return this.formatter(type, value); return value;
}); });
if (this.filter) { if (this.filter) {
@ -165,11 +154,16 @@ export default createComponent({
} }
return { return {
type,
values values
}; };
}); });
},
return results; columns() {
return this.originColumns.map(column => ({
values: column.values.map(value => this.formatter(column.type, value))
}));
} }
}, },
@ -249,7 +243,11 @@ export default createComponent({
let value; let value;
if (this.type === 'time') { if (this.type === 'time') {
value = picker.getValues().join(':'); const indexes = picker.getIndexes();
const hour = this.originColumns[0].values[indexes[0]];
const minute = this.originColumns[1].values[indexes[1]];
value = `${hour}:${minute}`;
} else { } else {
const values = picker.getValues(); const values = picker.getValues();
const year = getTrueValue(values[0]); const year = getTrueValue(values[0]);