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

适配多项数据主键逻辑(自定义批处理)

上级 44807c1b
...@@ -81,10 +81,35 @@ ${backend_block} ...@@ -81,10 +81,35 @@ ${backend_block}
} }
context = UIActionTool.handleContextParam(actionTarget,_args,parentContext,parentViewParam,context); context = UIActionTool.handleContextParam(actionTarget,_args,parentContext,parentViewParam,context);
data = UIActionTool.handleActionParam(actionTarget,_args,parentContext,parentViewParam,params); data = UIActionTool.handleActionParam(actionTarget,_args,parentContext,parentViewParam,params);
<#-- 多项数据主键转换数据 start -->
if(Object.is(actionTarget,"MULTIKEY")){
let tempDataArray:Array<any> = [];
if((_args.length >1) && (Object.keys(data).length >0)){
for(let i =0;i<_args.length;i++){
let tempObject:any = {};
Object.keys(data).forEach((key:string) =>{
Object.assign(tempObject,{[key]:data[key].split(',')[i]});
})
tempDataArray.push(tempObject);
}
}else{
tempDataArray.push(data);
}
data = tempDataArray;
}
<#-- 多项数据主键转换数据 end -->
context = Object.assign({},actionContext.context,context); context = Object.assign({},actionContext.context,context);
<#-- 构建srfparentdename和srfparentkey start --> <#-- 构建srfparentdename和srfparentkey start -->
let parentObj:any = {srfparentdename:srfParentDeName?srfParentDeName:null,srfparentkey:srfParentDeName?context[srfParentDeName.toLowerCase()]:null}; let parentObj:any = {srfparentdename:srfParentDeName?srfParentDeName:null,srfparentkey:srfParentDeName?context[srfParentDeName.toLowerCase()]:null};
Object.assign(data,parentObj); <#-- 多项数据主键转换数据 start -->
if(Object.is(actionTarget,"MULTIKEY") && data.length >0){
data.forEach((item:any) => {
Object.assign(item,parentObj);
});
}else{
Object.assign(data,parentObj);
}
<#-- 多项数据主键转换数据 end -->
Object.assign(context,parentObj); Object.assign(context,parentObj);
<#-- 构建srfparentdename和srfparentkey end --> <#-- 构建srfparentdename和srfparentkey end -->
// 直接调实体服务需要转换的数据 // 直接调实体服务需要转换的数据
...@@ -95,7 +120,7 @@ ${backend_block} ...@@ -95,7 +120,7 @@ ${backend_block}
const backend = () => { const backend = () => {
<#if item.getPSAppDataEntity?? && item.getPSAppDataEntity()?? && item.getPSAppDEMethod?? && item.getPSAppDEMethod()??> <#if item.getPSAppDataEntity?? && item.getPSAppDataEntity()?? && item.getPSAppDEMethod?? && item.getPSAppDEMethod()??>
const curService:${srfclassname('${item.getPSAppDataEntity().getCodeName()}')}Service = new ${srfclassname('${item.getPSAppDataEntity().getCodeName()}')}Service(); const curService:${srfclassname('${item.getPSAppDataEntity().getCodeName()}')}Service = new ${srfclassname('${item.getPSAppDataEntity().getCodeName()}')}Service();
curService.${item.getPSAppDEMethod().getCodeName()}(context,data, ${item.isShowBusyIndicator()?c}).then((response: any) => { curService.${item.getPSAppDEMethod().getCodeName()}<#if item.getActionTarget() == 'MULTIKEY'>Batch</#if>(context,data, ${item.isShowBusyIndicator()?c}).then((response: any) => {
if (!response || response.status !== 200) { if (!response || response.status !== 200) {
actionContext.$Notice.error({ title: '错误', desc: response.message }); actionContext.$Notice.error({ title: '错误', desc: response.message });
return; return;
......
...@@ -729,6 +729,44 @@ export default class ${srfclassname('${item.getCodeName()}')}ServiceBase extends ...@@ -729,6 +729,44 @@ export default class ${srfclassname('${item.getCodeName()}')}ServiceBase extends
} }
</#if> </#if>
<#-- 查询数据集(post方式)end --> <#-- 查询数据集(post方式)end -->
<#-- 自定义行为Batch方法start -->
<#if singleAppMethod.getMethodType?? && singleAppMethod.getMethodType()?? && singleAppMethod.getMethodType() == "DEACTION" && singleAppMethod.getPSDEAction?? && singleAppMethod.getPSDEAction()?? && singleAppMethod.getPSDEServiceAPIMethod?? && singleAppMethod.getPSDEServiceAPIMethod()??>
<#assign deAction = singleAppMethod.getPSDEAction()>
<#assign singleServiceApi = singleAppMethod.getPSDEServiceAPIMethod()/>
/**
* ${singleAppMethod.getCodeName()}Batch接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof ${srfclassname('${item.getCodeName()}')}ServiceBase
*/
public async ${singleAppMethod.getCodeName()}Batch(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
<#if item.getPSAppDERSPathCount() gt 0 && singleServiceApi??>
<#list 1..item.getPSAppDERSPathCount() as count>
<#assign path = ''/>
<#assign condition = ''/>
<#list item.getPSAppDERSPath(count_index) as deRSPath>
<#if deRSPath.getMajorPSAppDataEntity?? && deRSPath.getMajorPSAppDataEntity()??>
<#assign _dataEntity = deRSPath.getMajorPSAppDataEntity()/>
<#assign condition>${condition}context.${_dataEntity.getCodeName()?lower_case} && </#assign>
<#assign path>${path}${srfpluralize(_dataEntity.codeName)?lower_case}/<#noparse>$</#noparse>{context.${_dataEntity.getCodeName()?lower_case}}/</#assign>
</#if>
</#list>
if(${condition}true){
let tempData:any = JSON.parse(JSON.stringify(data));
return await Http.getInstance().post(`/${path}${item.codeName?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>batch`,tempData,isloading);
}
</#list>
</#if>
<#if item.isMajor()>
let tempData:any = JSON.parse(JSON.stringify(data));
return await Http.getInstance().post(`/${item.codeName?lower_case}<#if singleServiceApi.getRequestPath()??>${singleServiceApi.getRequestPath()}</#if>batch`,tempData,isloading);
</#if>
}
</#if>
<#-- 自定义行为Batch方法end -->
<#-- 检查行为是否可以执行 start --> <#-- 检查行为是否可以执行 start -->
<#-- @author zpc --> <#-- @author zpc -->
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册