实现效果:动态刷新选择框下拉列表的数据。
data() {
return {
selectAlgal: [],
optionAlgal: {
{
label: "调查站位",
prop: "stationId",
type: "select",
search: true,
dicData: this.selectAlgal, //使用dicData模式
rules: [{
required: true,
message: "请输入关联站位信息",
trigger: "blur"
}]
},
}
}
}
methods: {
selectDataAlgal(type){ //更新下拉框列表数据
selectData(type).then(res => {
this.selectAlgal = res.data.data.map(m => {
return {
value: m.id,
label: m.name
}
});
let stationIdColumn = this.findObject(
this.optionAlgal.column,"stationId"
);//找到该对象
stationIdColumn.dicData = this.selectAlgal;//赋值
})
},
onLoadAlgal(page, params = {}) {
this.selectDataAlgal(1); //查询的时候更新列表
this.loadingAlgal = true;
getListAlgal(page.currentPage, page.pageSize, Object.assign(params, this.queryAlgal)).then(res => {
const data = res.data.data;
this.pageAlgal.total = data.total;
this.dataAlgal = data.records;
this.loadingAlgal = false;
this.selectionClearAlgal();
this.rowSortAlgal()
this.rowCalcAlgal();
});
},
}