提交 31cfadc6 编写于 作者: KK's avatar KK

地图基础逻辑

上级 e628bd48
......@@ -10,7 +10,7 @@ import 'echarts/map/js/china.js'
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl
</#ibizinclude>
/**
* 获取多项数据
*
......@@ -21,6 +21,14 @@ import 'echarts/map/js/china.js'
return [];
}
/**
* 部件行为--fetch
*
* @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
@Prop() protected fetchAction!: string;
/**
* 获取单项树
*
......@@ -31,6 +39,114 @@ import 'echarts/map/js/china.js'
return null;
}
/**
* vue生命周期created
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public created() {
this.afterCreated();
}
/**
* 执行created后的逻辑
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
protected afterCreated(){
if (this.viewState) {
this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
if (!Object.is(this.name, tag)) {
return;
}
if (Object.is(action, "load")) {
this.load(Object.assign(data, { page: this.pageNumber, size: this.pageSize }), "init");
}
if (Object.is(action, "search")) {
this.load(Object.assign(data, { page: this.pageNumber, size: this.pageSize }), "init");
}
if (Object.is(action, "quicksearch")) {
this.load(Object.assign({ query: data }, { page: this.pageNumber, size: this.pageSize }), "init");
}
if (Object.is(action, "refresh")) {
this.refresh();
}
});
}
if(AppCenterService && AppCenterService.getMessageCenter()){
this.appStateEvent = AppCenterService.getMessageCenter().subscribe(({ name, action, data }) =>{
if(!Object.is(name,"${ctrl.getPSAppDataEntity().getCodeName()}")){
return;
}
if(Object.is(action,'appRefresh')){
this.refresh();
}
})
}
<#if view.getViewType()?? && view.getViewType()=='DEMOBPICKUPMDVIEW'>
if (!this.isMutli) {
if (this.selectedData && this.selectedData.length > 0) {
this.radio = this.selectedData[0].srfkey;
}
} else {
if (this.selectedData && this.selectedData.length > 0) {
this.checkboxList = [];
this.selectedData.forEach((item: any) => {
this.checkboxList.push(item.srfkey);
})
}
}
</#if>
}
/**
* 数据加载
*
* @private
* @param {*} [data={}]
* @param {string} [type=""]
* @returns {Promise<any>}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
private async load(data: any = {}, type: string = "",isloadding = this.showBusyIndicator): Promise<any> {
if (!data.page) {
Object.assign(data, { page: this.pageNumber });
}
if (!data.size) {
Object.assign(data, { size: this.pageSize });
}
const parentdata: any = {};
this.$emit('beforeload', parentdata);
Object.assign(data, parentdata);
let tempViewParams:any = parentdata.viewparams?parentdata.viewparams:{};
Object.assign(tempViewParams,JSON.parse(JSON.stringify(this.viewparams)));
Object.assign(data,{viewparams:tempViewParams});
const response: any = await this.service.search(this.fetchAction, this.context, data, isloadding);
if (!response || response.status !== 200) {
this.$notify({ type: 'danger', message: response.error.message });
return response;
}
this.$emit('load', (response.data && response.data.records) ? response.data.records : []);
this.items = [];
this.items = response.data.records;
return response;
}
/**
* 刷新数据
*
* @returns {Promise<any>}
* @memberof ${srfclassname('${ctrl.name}')}
*/
public refresh(): Promise<any> {
return new Promise((resolve: any, reject: any) => {
this.load().then((res) => {
resolve(res);
}).catch((error: any) => {
reject(error);
})
})
}
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl
</#ibizinclude>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册