提交 6da1ef18 编写于 作者: zcdtk's avatar zcdtk

请求方法异步处理

上级 24459a0d
......@@ -241,25 +241,25 @@ import echarts from 'echarts';
/**
* 获取图表数据
*
* @returns {*}
*
* @param {*} [opt]
* @returns {Promise<any>}
* @memberof ${srfclassname('${ctrl.name}')}
*/
public load(opt?:any) {
public async load(opt?: any): Promise<any> {
let _this = this;
const arg: any = { ...opt };
const parentdata: any = {};
this.$emit('beforeload', parentdata);
Object.assign(arg, parentdata);
Object.assign(arg,{viewparams:this.viewparams});
this.service.search(this.fetchAction,JSON.parse(JSON.stringify(this.context)),arg,this.showBusyIndicator).then((res) => {
if (res) {
_this.chartOption = _this.deepObjectMerge(_this.defaultConfig, res.data);
_this.drawCharts();
}
}).catch((error) => {
console.error(error);
});
Object.assign(arg, { viewparams: this.viewparams });
const response = await this.service.search(this.fetchAction, { ...this.context }, arg, this.showBusyIndicator);
if (response && response.status === 200) {
_this.chartOption = _this.deepObjectMerge(_this.defaultConfig, response.data);
_this.drawCharts();
} else {
console.error(response);
}
}
/**
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册