mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
parent
03fa90dd9d
commit
d3e29b7cbc
@ -75,11 +75,12 @@ VantComponent({
|
|||||||
onChange(event: Weapp.Event) {
|
onChange(event: Weapp.Event) {
|
||||||
const { index, picker, value } = event.detail;
|
const { index, picker, value } = event.detail;
|
||||||
this.code = value[index].code;
|
this.code = value[index].code;
|
||||||
this.setValues();
|
this.setValues().then(() => {
|
||||||
this.$emit('change', {
|
this.$emit('change', {
|
||||||
picker,
|
picker,
|
||||||
values: picker.getValues(),
|
values: picker.getValues(),
|
||||||
index
|
index
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -100,10 +100,12 @@ VantComponent({
|
|||||||
// set column value by index
|
// set column value by index
|
||||||
setColumnValue(index: number, value: any) {
|
setColumnValue(index: number, value: any) {
|
||||||
const column = this.getColumn(index);
|
const column = this.getColumn(index);
|
||||||
if (column) {
|
|
||||||
return column.setValue(value);
|
if (column == null) {
|
||||||
|
return Promise.reject('setColumnValue: 对应列不存在');
|
||||||
}
|
}
|
||||||
return Promise.reject('setColumnValue: 对应列不存在');
|
|
||||||
|
return column.setValue(value);
|
||||||
},
|
},
|
||||||
|
|
||||||
// get column option index by column index
|
// get column option index by column index
|
||||||
@ -114,10 +116,12 @@ VantComponent({
|
|||||||
// set column option index by column index
|
// set column option index by column index
|
||||||
setColumnIndex(columnIndex: number, optionIndex: number) {
|
setColumnIndex(columnIndex: number, optionIndex: number) {
|
||||||
const column = this.getColumn(columnIndex);
|
const column = this.getColumn(columnIndex);
|
||||||
if (column) {
|
|
||||||
return column.setIndex(optionIndex);
|
if (column == null) {
|
||||||
|
return Promise.reject('setColumnIndex: 对应列不存在');
|
||||||
}
|
}
|
||||||
return Promise.reject('setColumnIndex: 对应列不存在');
|
|
||||||
|
return column.setIndex(optionIndex);
|
||||||
},
|
},
|
||||||
|
|
||||||
// get options of column by index
|
// get options of column by index
|
||||||
@ -129,18 +133,21 @@ VantComponent({
|
|||||||
setColumnValues(index: number, options: any[], needReset = true) {
|
setColumnValues(index: number, options: any[], needReset = true) {
|
||||||
const column = this.children[index];
|
const column = this.children[index];
|
||||||
|
|
||||||
if (
|
if (column == null) {
|
||||||
column &&
|
return Promise.reject('setColumnValues: 对应列不存在');
|
||||||
JSON.stringify(column.data.options) !== JSON.stringify(options)
|
|
||||||
) {
|
|
||||||
return column.set({ options }).then(() => {
|
|
||||||
if (needReset) {
|
|
||||||
column.setIndex(0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.reject('setColumnValues: 对应列不存在');
|
const isSame = JSON.stringify(column.data.options) === JSON.stringify(options);
|
||||||
|
|
||||||
|
if (isSame) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
return column.set({ options }).then(() => {
|
||||||
|
if (needReset) {
|
||||||
|
column.setIndex(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// get values of all columns
|
// get values of all columns
|
||||||
|
Loading…
x
Reference in New Issue
Block a user