提交 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,27 +89,27 @@ export default class ${srfclassname('${item.getCodeName()}')}UtilServiceBase ext ...@@ -89,27 +89,27 @@ 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) => {
let dataStr = window.localStorage.getItem(data.modelid); //从接口加载
if(dataStr) { if(data && data.utilServiceName){
const data: any = JSON.parse(dataStr); const requestParam:any ={configType:data.utilServiceName,targetType:data.modelid};
resolve({status:200,data:data.model}); this.stoageDataService.getDynaModel(context,requestParam).then((res:any) =>{
} else { if(res && res.status === 200){
resolve({status:200,data:[]}); const data: any = res.data;
} resolve({status:200,data:data.model?data.model:[]});
<#-- let result: Promise<any>; }
const _appEntityService: any = this.stoageDataService; }).catch((error:any) =>{
if (_appEntityService[this.loadAction] && _appEntityService[this.loadAction] instanceof Function) { reject(error);
result = _appEntityService[this.loadAction](contextResult,dataResult, isloading); })
} else { }else{
result = _appEntityService.Get(contextResult,dataResult, isloading); let dataStr = window.localStorage.getItem(data.modelid);
if(dataStr) {
const data: any = JSON.parse(dataStr);
resolve({status:200,data:data.model});
} else {
resolve({status:200,data:[]});
}
} }
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) => {
window.localStorage.setItem(data.modelid, JSON.stringify(data));
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) => { return new Promise((resolve: any, reject: any) => {
let result: Promise<any>; // 存储到数据库
const _appEntityService: any = this.stoageDataService; if(data && data.utilServiceName){
result = _appEntityService[this.createAction](contextResult,dataResult, isloading); const requestParam:any ={configType:data.utilServiceName,targetType:data.modelid,model:data.model};
result.then((response) => { this.stoageDataService.setDynaModel(context,requestParam).then((res:any) =>{
resolve(response); if(res && res.status === 200){
}).catch(response => { const data: any = res.data;
reject(response); resolve({status:200,data:data.model});
}); }
}); }).catch((error:any) =>{
reject(error);
})
}else{
window.localStorage.setItem(data.modelid, JSON.stringify(data));
resolve({status:200,data:data.model});
}
});
} }
/**
* 更新模型数据
*
* @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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册