提交 ca370650 编写于 作者: tony001's avatar tony001

补充动态数据看板接口存储

上级 a75364ae
...@@ -237,7 +237,7 @@ import UtilService from '@/utilservice/util-service'; ...@@ -237,7 +237,7 @@ import UtilService from '@/utilservice/util-service';
public loadModel(){ public loadModel(){
if(this.isEnableCustomized){ if(this.isEnableCustomized){
this.utilService.getService(this.utilServiceName).then((service:any) =>{ this.utilService.getService(this.utilServiceName).then((service:any) =>{
service.loadModelData(JSON.parse(JSON.stringify(this.context)),{modelid:this.modelId}).then((res:any) =>{ service.loadModelData(JSON.parse(JSON.stringify(this.context)),{modelid:this.modelId,utilServiceName:this.utilServiceName}).then((res:any) =>{
if(res && res.status == 200){ if(res && res.status == 200){
const data:any = res.data; const data:any = res.data;
if(data && data.length >0){ if(data && data.length >0){
......
...@@ -89,8 +89,19 @@ export default class ${srfclassname('${item.getCodeName()}')}UtilServiceBase ext ...@@ -89,8 +89,19 @@ export default class ${srfclassname('${item.getCodeName()}')}UtilServiceBase ext
* @memberof ${srfclassname('${item.getCodeName()}')}UtilServiceBase * @memberof ${srfclassname('${item.getCodeName()}')}UtilServiceBase
*/ */
public loadModelData(context: any = {},data: any = {}, isloading?: boolean): Promise<any>{ public loadModelData(context: any = {},data: any = {}, isloading?: boolean): Promise<any>{
<#-- const {context:contextResult,data:dataResult} = this.handlePreParam(context,data); -->
return new Promise((resolve: any, reject: any) => { return new Promise((resolve: any, reject: any) => {
//从接口加载
if(data && data.utilServiceName){
const requestParam:any ={configType:data.utilServiceName,targetType:data.modelid};
this.stoageDataService.getDynaModel(context,requestParam).then((res:any) =>{
if(res && res.status === 200){
const data: any = res.data;
resolve({status:200,data:data.model?data.model:[]});
}
}).catch((error:any) =>{
reject(error);
})
}else{
let dataStr = window.localStorage.getItem(data.modelid); let dataStr = window.localStorage.getItem(data.modelid);
if(dataStr) { if(dataStr) {
const data: any = JSON.parse(dataStr); const data: any = JSON.parse(dataStr);
...@@ -98,18 +109,7 @@ export default class ${srfclassname('${item.getCodeName()}')}UtilServiceBase ext ...@@ -98,18 +109,7 @@ export default class ${srfclassname('${item.getCodeName()}')}UtilServiceBase ext
} else { } else {
resolve({status:200,data:[]}); resolve({status:200,data:[]});
} }
<#-- let result: Promise<any>;
const _appEntityService: any = this.stoageDataService;
if (_appEntityService[this.loadAction] && _appEntityService[this.loadAction] instanceof Function) {
result = _appEntityService[this.loadAction](contextResult,dataResult, isloading);
} else {
result = _appEntityService.Get(contextResult,dataResult, isloading);
} }
result.then((response) => {
resolve(response);
}).catch(response => {
reject(response);
}); -->
}); });
} }
...@@ -123,61 +123,24 @@ export default class ${srfclassname('${item.getCodeName()}')}UtilServiceBase ext ...@@ -123,61 +123,24 @@ export default class ${srfclassname('${item.getCodeName()}')}UtilServiceBase ext
* @memberof ${srfclassname('${item.getCodeName()}')}UtilServiceBase * @memberof ${srfclassname('${item.getCodeName()}')}UtilServiceBase
*/ */
public saveModelData(context: any = {},action:string,data: any = {}, isloading?: boolean):Promise<any>{ public saveModelData(context: any = {},action:string,data: any = {}, isloading?: boolean):Promise<any>{
<#-- const {context:contextResult,data:dataResult} = this.handlePreParam(context,data); -->
return new Promise((resolve: any, reject: any) => { return new Promise((resolve: any, reject: any) => {
// 存储到数据库
if(data && data.utilServiceName){
const requestParam:any ={configType:data.utilServiceName,targetType:data.modelid,model:data.model};
this.stoageDataService.setDynaModel(context,requestParam).then((res:any) =>{
if(res && res.status === 200){
const data: any = res.data;
resolve({status:200,data:data.model});
}
}).catch((error:any) =>{
reject(error);
})
}else{
window.localStorage.setItem(data.modelid, JSON.stringify(data)); window.localStorage.setItem(data.modelid, JSON.stringify(data));
resolve({status:200,data:data.model}); resolve({status:200,data:data.model});
<#-- let result: Promise<any> = Object.is(action,"Update") ? this.updateModelData(context,data,isloading):this.createdModelData(context,data,isloading);
result.then((response) => {
resolve(response);
}).catch(response => {
reject(response);
}); -->
});
} }
/**
* 新建模型数据
*
* @param context 应用上下文
* @param data 传入模型数据
* @param isloading 是否加载
* @memberof ${srfclassname('${item.getCodeName()}')}UtilServiceBase
*/
public createdModelData(context: any = {},data: any = {}, isloading?: boolean):Promise<any>{
const {context:contextResult,data:dataResult} = this.handlePreParam(context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.stoageDataService;
result = _appEntityService[this.createAction](contextResult,dataResult, isloading);
result.then((response) => {
resolve(response);
}).catch(response => {
reject(response);
});
}); });
} }
/**
* 更新模型数据
*
* @param context 应用上下文
* @param data 传入模型数据
* @param isloading 是否加载
* @memberof ${srfclassname('${item.getCodeName()}')}UtilServiceBase
*/
public updateModelData(context: any = {},data: any = {}, isloading?: boolean):Promise<any>{
const {context:contextResult,data:dataResult} = this.handlePreParam(context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.stoageDataService;
result = _appEntityService[this.updateAction](contextResult,dataResult, isloading);
result.then((response) => {
resolve(response);
}).catch(response => {
reject(response);
});
});
}
} }
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册