mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-26 03:26:35 +08:00
fix(datetime-picker): update value with origin column after change (#3352)
This commit is contained in:
parent
44194c711e
commit
fa54a19805
@ -103,7 +103,7 @@ VantComponent({
|
|||||||
methods: {
|
methods: {
|
||||||
updateValue() {
|
updateValue() {
|
||||||
const { data } = this;
|
const { data } = this;
|
||||||
const val = this.correctValue(this.data.value);
|
const val = this.correctValue(data.value);
|
||||||
const isEqual = val === data.innerValue;
|
const isEqual = val === data.innerValue;
|
||||||
if (!isEqual) {
|
if (!isEqual) {
|
||||||
this.updateColumnValue(val).then(() => {
|
this.updateColumnValue(val).then(() => {
|
||||||
@ -291,13 +291,17 @@ VantComponent({
|
|||||||
let value;
|
let value;
|
||||||
|
|
||||||
const picker = this.getPicker();
|
const picker = this.getPicker();
|
||||||
|
const originColumns = this.getOriginColumns();
|
||||||
|
|
||||||
if (data.type === 'time') {
|
if (data.type === 'time') {
|
||||||
const indexes = picker.getIndexes();
|
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]]}`;
|
.values[indexes[1]]}`;
|
||||||
} else {
|
} 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 year = getTrueValue(values[0]);
|
||||||
const month = getTrueValue(values[1]);
|
const month = getTrueValue(values[1]);
|
||||||
const maxDate = getMonthEndDay(year, month);
|
const maxDate = getMonthEndDay(year, month);
|
||||||
@ -324,7 +328,8 @@ VantComponent({
|
|||||||
|
|
||||||
updateColumnValue(value) {
|
updateColumnValue(value) {
|
||||||
let values = [];
|
let values = [];
|
||||||
const { type, formatter = defaultFormatter } = this.data;
|
const { type } = this.data;
|
||||||
|
const formatter = this.data.formatter || defaultFormatter;
|
||||||
const picker = this.getPicker();
|
const picker = this.getPicker();
|
||||||
|
|
||||||
if (type === 'time') {
|
if (type === 'time') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user