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

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

上级 a75364ae
......@@ -237,7 +237,7 @@ import UtilService from '@/utilservice/util-service';
public loadModel(){
if(this.isEnableCustomized){
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){
const data:any = res.data;
if(data && data.length >0){
......
......@@ -89,27 +89,27 @@ export default class ${srfclassname('${item.getCodeName()}')}UtilServiceBase ext
* @memberof ${srfclassname('${item.getCodeName()}')}UtilServiceBase
*/
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) => {
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:[]});
}
<#-- 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);
//从接口加载
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);
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
* @memberof ${srfclassname('${item.getCodeName()}')}UtilServiceBase
*/
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) => {
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);
});
});
// 存储到数据库
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));
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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册