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

树部件 部件服务

上级 89323861
<#assign extendsClass>TreeViewServiceBase</#assign>
<#assign import_block>
import CodeListService from '@service/app/codelist-service';
import i18n from '@/locale';
<#if ctrl.getPSDETreeNodes()??>
<#list ctrl.getPSDETreeNodes() as node>
<#if node.getTreeNodeType() == 'DE' && node.getPSAppDataEntity()??>
<#if appde?? && appde.getId() != node.getPSAppDataEntity().getId()>
<#if !P.exists("importService", node.getPSAppDataEntity().getId(), "")>
import ${srfclassname('${node.getPSAppDataEntity().codeName}')}Service from '@service/${srffilepath2(node.getPSAppDataEntity().codeName)}/${srffilepath2(node.getPSAppDataEntity().codeName)}-service';
</#if>
</#if>
</#if>
</#list>
</#if>
</#assign>
<#ibizinclude>
../@MACRO/SERVICE/SERVICE_HEADER.ts.ftl
</#ibizinclude>
<#ibizinclude>
../@MACRO/FUNC/MACRO.ftl
</#ibizinclude>
<#-- 获取树节点关系导航上下文 -->
<#macro getNavContext nodeRs>
<#compress>
<#if nodeRs.getPSDETreeNodeRSNavContexts()??>
<#list nodeRs.getPSDETreeNodeRSNavContexts() as rsNavContext>
"${rsNavContext.getKey()}":{"isRawValue":${rsNavContext.isRawValue()?c},"value":"${rsNavContext.getValue()}"}<#if rsNavContext_has_next>,</#if>
</#list>
</#if>
</#compress>
</#macro>
<#-- 获取树节点关系导航参数 -->
<#macro getNavParams nodeRs>
<#compress>
<#if nodeRs.getPSDETreeNodeRSNavParams()??>
<#list nodeRs.getPSDETreeNodeRSNavParams() as rsNavParam>
"${rsNavParam.getKey()}":{"isRawValue":${rsNavParam.isRawValue()?c},"value":"${rsNavParam.getValue()}"}<#if rsNavParam_has_next>,</#if>
</#list>
</#if>
</#compress>
</#macro>
<#-- 获取树节点关系参数 -->
<#macro getParams nodeRs>
<#compress>
<#if nodeRs.getPSDETreeNodeRSParams()??>
<#list nodeRs.getPSDETreeNodeRSParams() as rsParam>
"${rsParam.getKey()}":{"value":"${rsParam.getValue()}"}<#if rsParam_has_next>,</#if>
</#list>
</#if>
</#compress>
</#macro>
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public codeListService:CodeListService = new CodeListService({ $store: this.getStore() });
<#if ctrl.getPSDETreeNodes()??>
<#list ctrl.getPSDETreeNodes() as node>
<#if node.getTreeNodeType() == 'DE' && node.getPSAppDataEntity()??>
<#if appde?? && appde.getId() != node.getPSAppDataEntity().getId()>
<#if !P.exists("importService2", node.getPSAppDataEntity().getId(), "")>
/**
* ${node.getName()}节点标识
* ${node.getPSAppDataEntity().getLogicName()}服务对象
*
* @protected
* @type {${srfclassname('${node.getPSAppDataEntity().codeName}')}Service}
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public ${node.getPSAppDataEntity().codeName?lower_case}Service: ${srfclassname('${node.getPSAppDataEntity().codeName}')}Service = new ${srfclassname('${node.getPSAppDataEntity().codeName}')}Service({ $store: this.getStore() });
</#if>
</#if>
</#if>
</#list>
</#if>
/**
* 节点分隔符号
*
* @public
* @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public TREENODE_SEPARATOR: string = ';';
<#if ctrl.getPSDETreeNodes()??>
<#list ctrl.getPSDETreeNodes() as node>
/**
* ${node.getName()}节点分隔符号
*
* @public
* @type {string}
* @memberof ${srfclassname(ctrl.codeName)}Service
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
protected TREENODE_${node.getNodeType()?upper_case}: string = '${node.getNodeType()?j_string}';
public TREENODE_${node.getNodeType()?upper_case}: string = '${node.getNodeType()?j_string}';
</#list>
</#if>
......@@ -23,19 +109,22 @@
* @param {string} action
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<HttpResponse>}
* @memberof ${srfclassname(ctrl.codeName)}Service
* @returns {Promise<any>}
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public async getNodes(context:any = {}, data: any = {}, isloading?: boolean): Promise<HttpResponse> {
const { srfparentkey, srfcat, srfnodeid, query }: any = data;
const srfnodefilter: any = query || data.srfnodefilter;
const list: any[] = [];
const filter: any = {};
@Errorlog
public async getNodes(context:any = {},data: any = {}, isloading?: boolean): Promise<any> {
let { srfparentkey, srfcat, srfnodeid, srfnodefilter, query }: { srfparentkey: string, srfcat: string, srfnodeid: string, srfnodefilter: string, query:string } = data;
srfnodefilter = query ? query : srfnodefilter;
let list: any[] = [];
let filter: any = {};
<#-- BEGIN:逻辑代码 -->
if (!srfnodeid || Object.is(srfnodeid, '#')) {
<#if ctrl.isRootVisible()>
await this.fill${srfclassname(ctrl.getRootPSDETreeNode().getNodeType()?lower_case)}Nodes(context, filter, list);
return new HttpResponse(200, { records: list });
return Promise.resolve({ status: 200, data: list });
<#else>
srfnodeid = this.TREENODE_${ctrl.getRootPSDETreeNode().getNodeType()?upper_case};
</#if>
......@@ -55,7 +144,7 @@
} else {
let nPos = strTreeNodeId.indexOf(this.TREENODE_SEPARATOR);
if (nPos === -1) {
return new HttpResponse(200, null, { code: 100, message: '树节点 ' + strTreeNodeId + ' 标识无效' });
return Promise.reject({ status: 500, data: { title: '失败', message: `树节点${r'${strTreeNodeId}'}标识无效` } });
}
strNodeType = strTreeNodeId.substring(0, nPos);
strRealNodeId = strTreeNodeId.substring(nPos + 1);
......@@ -68,12 +157,13 @@
srfnodefilter: srfnodefilter,
strRealNodeId: strRealNodeId,
srfnodeid: srfnodeid,
strNodeType: strNodeType
strNodeType: strNodeType,
viewparams: JSON.parse(JSON.stringify(data)).viewparams
}
);
// 分解节点标识
const nodeid: string[] = strRealNodeId.split(this.TREENODE_SEPARATOR);
let nodeid: string[] = strRealNodeId.split(this.TREENODE_SEPARATOR);
for (let i = 0; i < nodeid.length; i++) {
switch (i) {
case 0:
......@@ -92,16 +182,17 @@
break;
}
}
<#if ctrl.getPSDETreeNodes()??>
<#list ctrl.getPSDETreeNodes() as node>
if (Object.is(strNodeType, this.TREENODE_${node.getNodeType()?upper_case})) {
await this.fill${srfclassname(node.getNodeType()?lower_case)}NodeChilds(context, filter, list);
return new HttpResponse(200, { records: list });
await this.fill${srfclassname(node.getNodeType()?lower_case)}NodeChilds(context,filter, list);
return Promise.resolve({ status: 200, data: list });
}
</#list>
</#if>
<#-- END:逻辑代码 -->
return new HttpResponse(500, null, { code: 100, message: '树节点' + strTreeNodeId + ' 标识无效' });
return Promise.resolve({ status: 500, data: { title: '失败', message: `树节点${r'${strTreeNodeId}'}标识无效` } });
}
<#-- BEGIN:填充代码 -->
......@@ -112,24 +203,32 @@
/**
* 填充 树视图节点[${node.getName()}]
*
* @protected
* @public
* @param {any{}} context
* @param {*} filter
* @param {any[]} list
* @param {*} rsNavContext
* @param {*} rsNavParams
* @param {*} rsParams
* @returns {Promise<any>}
* @memberof ${srfclassname(ctrl.codeName)}Service
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
protected async fill${srfclassname(node.getNodeType()?lower_case)}Nodes(context: any = {}, filter: any, list: any[]): Promise<any> {
<#if node.getTreeNodeType() == 'STATIC'>
const treeNode: any = {};
Object.assign(treeNode, { text: '${node.getText()?j_string}' });
@Errorlog
public fill${srfclassname(node.getNodeType()?lower_case)}Nodes(context:any={},filter: any, list: any[],rsNavContext?:any,rsNavParams?:any,rsParams?:any): Promise<any> {
context = this.handleResNavContext(context,filter,rsNavContext);
filter = this.handleResNavParams(context,filter,rsNavParams,rsParams);
return new Promise((resolve:any,reject:any) =>{
<#if node.getTreeNodeType() == 'STATIC'>
let treeNode: any = {};
Object.assign(treeNode, { text: i18n.t('entities.${appde.getCodeName()?lower_case}.${ctrl.getCodeName()?lower_case}_${ctrl.getControlType()?lower_case}.nodes.${node.getNodeType()?lower_case}') });
Object.assign(treeNode, { isUseLangRes: true });
<#if node.isEnableQuickSearch()>
if (treeNode.srfnodefilter) {
if (treeNode.text().toUpperCase().indexOf(filter.srfnodefilter.toUpperCase()) === -1) {
return;
}
if(filter.srfnodefilter && !Object.is(filter.srfnodefilter,"")){
if((i18n.t(treeNode.text) as string).toUpperCase().indexOf(filter.getSrfnodefilter().toUpperCase())==-1)
return Promise.reject();
}
</#if>
Object.assign(treeNode,{srfappctx:context});
Object.assign(treeNode, { srfmajortext: treeNode.text });
let strNodeId: string = '${node.getNodeType()?j_string}';
......@@ -140,14 +239,14 @@
<#if node.isAppendPNodeId()>
strNodeId += this.TREENODE_SEPARATOR;
strNodeId += filter.realnodeid;
strNodeId += filter.strRealNodeId;
</#if>
<#else>
// 没有指定节点值,直接使用父节点值
Object.assign(treeNode, { srfkey: filter.realnodeid });
Object.assign(treeNode, { srfkey: filter.strRealNodeId });
strNodeId += this.TREENODE_SEPARATOR;
strNodeId += filter.realnodeid;
strNodeId += filter.strRealNodeId;
</#if>
Object.assign(treeNode, { id: strNodeId });
......@@ -166,7 +265,7 @@
</#if>
<#if node.isDisableSelect()>
Object.assign(treeNode, { disableselect: true });
Object.assign(treeNode, { disabled: true });
</#if>
<#if node.isExpanded()>
......@@ -179,23 +278,105 @@
<#else>
Object.assign(treeNode, { leaf: true });
</#if>
<#if node.isSelected()>
Object.assign(treeNode, { selected: true });
</#if>
<#if node.getNavFilter()??>
Object.assign(treeNode, { navfilter: "${node.getNavFilter()}" });
</#if>
<#if node.getPSNavigateContexts?? && node.getPSNavigateContexts()??>
Object.assign(treeNode, {navigateContext: <@getNavigateContext node /> });
</#if>
<#if node.getPSNavigateParams?? && node.getPSNavigateParams()??>
Object.assign(treeNode, {navigateParams: <@getNavigateParams node /> });
</#if>
<#-- 补充nodeid和nodeid2 -->
Object.assign(treeNode, { nodeid: treeNode.srfkey });
Object.assign(treeNode, { nodeid2: filter.strRealNodeId });
list.push(treeNode);
resolve(list);
});
</#if>
<#if node.getTreeNodeType() == 'CODELIST' && node.getPSCodeList()??>
<#if node.getPSCodeList().getCodeListType()?? && node.getPSCodeList().getCodeListType() == 'STATIC'>
const codeListIems: any[] = await this.codeListService.getItems('${node.getPSCodeList().codeName}');
let codeListIems:Array<any> = [];
if (this.getStore()) {
codeListIems = (this.getStore() as any).getters.getCodeListItems('${node.getPSCodeList().codeName}');
}
<#elseif node.getPSCodeList().getCodeListType()?? && node.getPSCodeList().getCodeListType() == 'DYNAMIC'>
const response: any = await this.codeListService.getItems('${node.getPSCodeList().codeName}');
if (response.status === 200) {
const codeListIems: any[] = response.data || [];
let bFirst: boolean = true;
this.codeListService.getItems('${node.getPSCodeList().codeName}',context).then((codeListIems:any)=>{
</#if>
if(codeListIems && codeListIems.length >0){
const handleChildData = (context:any,item:any,) =>{
Object.assign(item,{srfappctx:context});
<#if node.getPSCodeList().getCodeListType() == 'STATIC'>
Object.assign(item, { text: i18n.t('codelist.${node.getPSCodeList().codeName}.'+item.value) });
Object.assign(item, { isUseLangRes: true });
<#else>
Object.assign(item, { text: item.text });
</#if>
Object.assign(item, { srfmajortext: item.text });
let strNodeId: string = "${srfjavastring(node.getNodeType())}";
Object.assign(item, { srfkey: item.value });
strNodeId += this.TREENODE_SEPARATOR;
strNodeId += item.value;
<#if node.isAppendPNodeId()>
strNodeId += TREENODE_SEPARATOR;
strNodeId += filter.getRealnodeid();
</#if>
Object.assign(item, { id: strNodeId });
<#if node.getPSSysImage()??>
<#if node.getPSSysImage().getCssClass()?? && node.getPSSysImage().getCssClass()?length gt 0>
Object.assign(item, { iconcls: '${node.getPSSysImage().getCssClass()}' });
<#else>
Object.assign(item, { icon: '${node.getPSSysImage().getImagePath()}' });
</#if>
</#if>
<#if node.isEnableCheck()>
Object.assign(item, { enablecheck: true });
</#if>
<#if node.isDisableSelect()>
Object.assign(item, { disabled: true });
</#if>
<#if node.isExpanded()>
<#if node.isExpandFirstOnly()>
Object.assign(item, { expanded: bFirst });
<#else>
Object.assign(item, { expanded: true });
</#if>
<#else>
Object.assign(item, { expanded: filter.isautoexpand });
</#if>
<#if node.isSelected()>
Object.assign(item, { selected: true });
</#if>
<#if node.getNavFilter()??>
Object.assign(item, { navfilter: "${node.getNavFilter()}" });
</#if>
<#if node.getPSNavigateContexts?? && node.getPSNavigateContexts()??>
Object.assign(item, {navigateContext: <@getNavigateContext node /> });
</#if>
<#if node.getPSNavigateParams?? && node.getPSNavigateParams()??>
Object.assign(item, {navigateParams: <@getNavigateParams node /> });
</#if>
<#-- 补充nodeid和nodeid2 -->
Object.assign(item, { nodeid: item.srfkey });
Object.assign(item, { nodeid2: item.pvalue });
}
codeListIems = this.handleDataSet(JSON.parse(JSON.stringify(codeListIems)),context,handleChildData);
codeListIems.forEach((item:any) => {
const treeNode: any = {};
let treeNode: any = {};
Object.assign(treeNode,{srfappctx:context});
<#if node.getPSCodeList().getCodeListType() == 'STATIC'>
Object.assign(treeNode, { text: i18n.t('codelist.${node.getPSCodeList().codeName}.'+item.value) });
Object.assign(treeNode, { isUseLangRes: true });
<#else>
Object.assign(treeNode, { text: item.text });
</#if>
<#if node.isEnableQuickSearch()>
if(filter.srfnodefilter){
if(treeNode.getText().toUpperCase().indexOf(filter.getSrfnodefilter().toUpperCase())==-1)
continue;
if(filter.srfnodefilter && !Object.is(filter.srfnodefilter,"")){
if((i18n.t(treeNode.text) as string).toUpperCase().indexOf(filter.getSrfnodefilter().toUpperCase())==-1)
return;
}
</#if>
Object.assign(treeNode, { srfmajortext: treeNode.text });
......@@ -219,7 +400,7 @@
Object.assign(treeNode, { enablecheck: true });
</#if>
<#if node.isDisableSelect()>
Object.assign(treeNode, { disableselect: true });
Object.assign(treeNode, { disabled: true });
</#if>
<#if node.isExpanded()>
<#if node.isExpandFirstOnly()>
......@@ -235,50 +416,84 @@
<#else>
Object.assign(treeNode, { leaf: true });
</#if>
<#if node.isSelected()>
Object.assign(treeNode, { selected: true });
</#if>
<#if node.getNavFilter()??>
Object.assign(treeNode, { navfilter: "${node.getNavFilter()}" });
</#if>
<#if node.getPSNavigateContexts?? && node.getPSNavigateContexts()??>
Object.assign(treeNode, {navigateContext: <@getNavigateContext node /> });
</#if>
<#if node.getPSNavigateParams?? && node.getPSNavigateParams()??>
Object.assign(treeNode, {navigateParams: <@getNavigateParams node /> });
</#if>
if(item.children && item.children.length >0){
Object.assign(treeNode, { children: item.children });
}
<#-- 补充nodeid和nodeid2 -->
Object.assign(treeNode, { nodeid: treeNode.srfkey });
Object.assign(treeNode, { nodeid2: filter.strRealNodeId });
list.push(treeNode);
bFirst = false;
});
resolve(list);
})
}else{
resolve(list);
}
<#if node.getPSCodeList().getCodeListType()?? && node.getPSCodeList().getCodeListType() == 'DYNAMIC'>
});
</#if>
});
</#if>
<#if node.getTreeNodeType() == 'DE' && node.getPSDataEntity()??>
<#assign filtername>${node.getPSDataEntity().codeName}SearchFilter</#assign>
<#assign entityname>${node.getPSDataEntity().codeName}</#assign>
const searchFilter: any = {};
<#if node.getTreeNodeType() == 'DE' && node.getPSAppDataEntity()??>
<#assign filtername>${node.getPSAppDataEntity().codeName}SearchFilter</#assign>
<#assign entityname>${node.getPSAppDataEntity().codeName}</#assign>
let searchFilter: any = {};
<#list ctrl.getPSDETreeNodeRSs() as noders>
<#if noders.getChildPSDETreeNode().id == node.id>
<#if noders.getParentFilter()?? && noders.getParentFilter()?length gt 0>
<#assign pickupfield=noders.getParentFilter()>
if (Object.is(filter.nodetype, this.TREENODE_${noders.getParentPSDETreeNode().getNodeType()?upper_case})) {
if (Object.is(filter.strNodeType, this.TREENODE_${noders.getParentPSDETreeNode().getNodeType()?upper_case})) {
Object.assign(searchFilter, { n_${pickupfield?lower_case}_eq: filter.nodeid<#if noders.getParentValueLevel() gt 1>${noders.getParentValueLevel()?c}</#if> });
}
<#elseif noders.getParentPSDER1N()??>
<#assign pickupfield=noders.getParentPSDER1N().getPSPickupDEField()>
if (Object.is(filter.nodetype, this.TREENODE_${noders.getParentPSDETreeNode().getNodeType()?upper_case})) {
if (Object.is(filter.strNodeType, this.TREENODE_${noders.getParentPSDETreeNode().getNodeType()?upper_case})) {
Object.assign(searchFilter, { n_${pickupfield.getName()?lower_case}_eq: filter.nodeid<#if noders.getParentValueLevel() gt 1>${noders.getParentValueLevel()?c}</#if> });
}
</#if>
</#if>
</#list>
Object.assign(searchFilter, { total: false });
Object.assign(searchFilter, { nodeid: filter.nodeid });
<#if node.isEnableQuickSearch()>
Object.assign(searchFilter, { query: filter.srfnodefilter });
<#else>
// 节点不支持搜索
</#if>
let bFirst: boolean = true;
const response: any = await this.search${srfclassname(node.getNodeType()?lower_case)}(context, searchFilter, filter);
if (response.status === 200 && response.data) {
const records: any[] = response.data || [];
let records: any[] = [];
try {
this.search${srfclassname(node.getNodeType()?lower_case)}(context, searchFilter, filter).then((records:any) =>{
if(records && records.length >0){
records.forEach((entity: any) => {
const treeNode: any = {};
const strId: string = entity.${node.getPSAppDataEntity().getKeyPSAppDEField().codeName?lower_case};
let treeNode: any = {};
// 整理context
<#if node.getIdPSDEField()??>
let strId: string = entity.${node.getIdPSDEField().codeName?lower_case};
<#else>
let strId: string = entity.${node.getPSAppDataEntity().getKeyPSAppDEField().codeName?lower_case};
</#if>
<#if node.getTextPSDEField()??>
const strText: string = entity.${node.getTextPSDEField().codeName?lower_case};
let strText: string = entity.${node.getTextPSDEField().codeName?lower_case};
<#else>
const strText: string = entity.${node.getPSAppDataEntity().getMajorPSAppDEField().codeName?lower_case};
let strText: string = entity.${node.getPSAppDataEntity().getMajorPSAppDEField().codeName?lower_case};
</#if>
Object.assign(treeNode,{srfparentdename:'${node.getPSAppDataEntity().getCodeName()}',srfparentkey:<#if node.getIdPSDEField()??>entity.${node.getIdPSDEField().codeName?lower_case}<#else>entity.${node.getPSAppDataEntity().getKeyPSAppDEField().codeName?lower_case}</#if>});
let tempContext:any = JSON.parse(JSON.stringify(context));
Object.assign(tempContext,{srfparentdename:'${node.getPSAppDataEntity().getCodeName()}',srfparentkey:<#if node.getIdPSDEField()??>entity.${node.getIdPSDEField().codeName?lower_case}<#else>entity.${node.getPSAppDataEntity().getKeyPSAppDEField().codeName?lower_case}</#if>,${node.getPSAppDataEntity().getCodeName()?lower_case}:strId})
Object.assign(treeNode,{srfappctx:tempContext});
Object.assign(treeNode,{'${node.getPSAppDataEntity().getCodeName()?lower_case}':strId});
Object.assign(treeNode, { srfkey: strId });
Object.assign(treeNode, { text: strText, srfmajortext: strText });
let strNodeId: string = '${node.getNodeType()?j_string}';
......@@ -300,7 +515,7 @@
Object.assign(treeNode, { enablecheck: true });
</#if>
<#if node.isDisableSelect()>
Object.assign(treeNode, { disableselect: true });
Object.assign(treeNode, { disabled: true });
</#if>
<#if node.isExpanded()>
<#if node.isExpandFirstOnly()>
......@@ -332,67 +547,123 @@
</#if>
</#list>
</#if>
<#if node.isSelected()>
Object.assign(treeNode, { selected: true });
</#if>
<#if node.getNavFilter()??>
Object.assign(treeNode, { navfilter: "${node.getNavFilter()}" });
</#if>
Object.assign(treeNode, { curData: entity });
<#if node.getPSNavigateContexts?? && node.getPSNavigateContexts()??>
Object.assign(treeNode, {navigateContext: <@getNavigateContext node /> });
</#if>
<#if node.getPSNavigateParams?? && node.getPSNavigateParams()??>
Object.assign(treeNode, {navigateParams: <@getNavigateParams node /> });
</#if>
<#-- 补充nodeid和nodeid2 -->
Object.assign(treeNode, { nodeid: treeNode.srfkey });
Object.assign(treeNode, { nodeid2: filter.strRealNodeId });
list.push(treeNode);
resolve(list);
bFirst = false;
});
}else{
resolve(list);
}
});
} catch (error) {
console.error(error);
}
});
</#if>
return list;
}
<#if (filtername?length gt 0) && (entityname?length gt 0)>
/**
* 获取查询集合
*
* @protected
* @param {*} [context={}]
* @public
* @param {any{}} context
* @param {*} searchFilter
* @param {*} filter
* @returns {any[]}
* @memberof TestEnetityDatasService
*/
protected async search${srfclassname(node.getNodeType()?lower_case)}(context: any = {}, searchFilter: any, filter: any): Promise<any> {
await this.onBeforeAction('', context, null, false);
if (!searchFilter.page) {
Object.assign(searchFilter, { page: 0 });
@Errorlog
public search${srfclassname(node.getNodeType()?lower_case)}(context:any={}, searchFilter: any, filter: any): Promise<any> {
return new Promise((resolve:any,reject:any) =>{
if(filter.viewparams){
Object.assign(searchFilter,filter.viewparams);
}
if(!searchFilter.page){
Object.assign(searchFilter,{page:0});
}
if (!searchFilter.size) {
Object.assign(searchFilter, { size: 9999 });
if(!searchFilter.size){
Object.assign(searchFilter,{size:1000});
}
if(context && context.srfparentdename){
Object.assign(searchFilter,{srfparentdename:JSON.parse(JSON.stringify(context)).srfparentdename});
}
if(context && context.srfparentkey){
Object.assign(searchFilter,{srfparentkey:JSON.parse(JSON.stringify(context)).srfparentkey});
}
<#if node.getSortField?? && node.getSortField()?? && node.getSortField() != "" && node.getSortDir?? && node.getSortDir()?? && node.getSortDir() != "">
Object.assign(searchFilter,{sort: '${node.getSortField()?lower_case},${node.getSortDir()?lower_case}'})
</#if>
<#if appde?? && appde.getId() != node.getPSAppDataEntity().getId()>
const service: any = await this.getService('${node.getPSAppDataEntity().codeName?lower_case}');
const _appEntityService: any = this.${node.getPSAppDataEntity().codeName?lower_case}Service;
<#else>
const service: any = this.service;
</#if>
if (Util.isFunction(service['${node.getPSAppDEDataSet().getCodeName()}'])) {
const response: HttpResponse = await service['${node.getPSAppDEDataSet().getCodeName()}'](context, searchFilter, false);
if (response.status !== 200) {
return response;
const _appEntityService: any = this.appEntityService;
</#if>
let list: any[] = [];
if (_appEntityService['${node.getPSAppDEDataSet().getCodeName()}'] && _appEntityService['${node.getPSAppDEDataSet().getCodeName()}'] instanceof Function) {
const response: Promise<any> = _appEntityService['${node.getPSAppDEDataSet().getCodeName()}'](context, searchFilter, false);
response.then((response: any) => {
if (!response.status || response.status !== 200) {
resolve([]);
console.log(JSON.stringify(context));
console.error('查询${node.getPSAppDEDataSet().getCodeName()}数据集异常!');
}
return new HttpResponse(200, response.data || []);
const data: any = response.data;
if (Object.keys(data).length > 0) {
list = JSON.parse(JSON.stringify(data));
resolve(list);
} else {
resolve([]);
}
return new HttpResponse(500, null, { code: 100, message: '数据加载异常,${node.getPSAppDEDataSet().getCodeName()}行为不存在' });
}).catch((response: any) => {
resolve([]);
console.log(JSON.stringify(context));
console.error('查询${node.getPSAppDEDataSet().getCodeName()}数据集异常!');
});
}
})
}
</#if>
/**
* 填充 树视图节点[${node.getName()}]子节点
*
* @private
* @public
* @param {any{}} context
* @param {*} filter
* @param {any[]} list
* @returns {Promise<any>}
* @memberof ${srfclassname(ctrl.codeName)}Service
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
private async fill${srfclassname(node.getNodeType()?lower_case)}NodeChilds(context: any = {}, filter: any, list: any[]): Promise<any> {
@Errorlog
public async fill${srfclassname(node.getNodeType()?lower_case)}NodeChilds(context:any={}, filter: any, list: any[]): Promise<any> {
<#if ctrl.getPSDETreeNodeRSs()??>
if (!filter.srfnodefilter) {
if (filter.srfnodefilter && !Object.is(filter.srfnodefilter,"")) {
<#list ctrl.getPSDETreeNodeRSs() as noders>
<#if noders.getParentPSDETreeNode().id == node.id>
<#if noders.getSearchMode() == 1 || noders.getSearchMode() == 3>
// 填充${noders.getChildPSDETreeNode().getName()}
await this.fill${srfclassname(noders.getChildPSDETreeNode().getNodeType()?lower_case)}Nodes(context, filter, list);
let ${srfclassname(noders.getChildPSDETreeNode().getNodeType()?lower_case)}RsNavContext:any = {<@getNavContext nodeRs=noders />};
let ${srfclassname(noders.getChildPSDETreeNode().getNodeType()?lower_case)}RsNavParams:any = {<@getNavParams nodeRs=noders />};
let ${srfclassname(noders.getChildPSDETreeNode().getNodeType()?lower_case)}RsParams:any = {<@getParams nodeRs=noders />};
await this.fill${srfclassname(noders.getChildPSDETreeNode().getNodeType()?lower_case)}Nodes(context, filter, list ,${srfclassname(noders.getChildPSDETreeNode().getNodeType()?lower_case)}RsNavContext,${srfclassname(noders.getChildPSDETreeNode().getNodeType()?lower_case)}RsNavParams,${srfclassname(noders.getChildPSDETreeNode().getNodeType()?lower_case)}RsParams);
</#if>
</#if>
</#list>
......@@ -401,22 +672,206 @@
<#if noders.getParentPSDETreeNode().id == node.id>
<#if noders.getSearchMode() == 2 || noders.getSearchMode() == 3>
// 填充${noders.getChildPSDETreeNode().getName()}
await this.fill${srfclassname(noders.getChildPSDETreeNode().getNodeType()?lower_case)}Nodes(context, filter, list);
let ${srfclassname(noders.getChildPSDETreeNode().getNodeType()?lower_case)}RsNavContext:any = {<@getNavContext nodeRs=noders />};
let ${srfclassname(noders.getChildPSDETreeNode().getNodeType()?lower_case)}RsNavParams:any = {<@getNavParams nodeRs=noders />};
let ${srfclassname(noders.getChildPSDETreeNode().getNodeType()?lower_case)}RsParams:any = {<@getParams nodeRs=noders />};
await this.fill${srfclassname(noders.getChildPSDETreeNode().getNodeType()?lower_case)}Nodes(context, filter, list ,${srfclassname(noders.getChildPSDETreeNode().getNodeType()?lower_case)}RsNavContext,${srfclassname(noders.getChildPSDETreeNode().getNodeType()?lower_case)}RsNavParams,${srfclassname(noders.getChildPSDETreeNode().getNodeType()?lower_case)}RsParams);
</#if>
</#if>
</#list>
}
</#if>
<#if node.isRootNode()>
if (list.length > 0) {
Object.assign(list[0], { selected: true })
}
return list;
</#if>
}
</#list>
</#if>
/**
* 处理代码表返回数据(树状结构)
*
* @param result 返回数组
* @param context 应用上下文
* @param callBack 回调
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public handleDataSet(result:Array<any>,context:any,callBack:any){
let list:Array<any> = [];
if(result.length === 0){
return list;
}
result.forEach((codeItem:any) =>{
if(!codeItem.pvalue){
let valueField:string = codeItem.value;
this.setChildCodeItems(valueField,result,codeItem);
list.push(codeItem);
}
})
this.setNodeData(list,context,callBack);
return list;
}
/**
* 处理非根节点数据
*
* @param result 返回数组
* @param context 应用上下文
* @param callBack 回调
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public setChildCodeItems(pValue:string,result:Array<any>,codeItem:any){
result.forEach((item:any) =>{
if(item.pvalue == pValue){
let valueField:string = item.value;
this.setChildCodeItems(valueField,result,item);
if(!codeItem.children){
codeItem.children = [];
}
codeItem.children.push(item);
}
})
}
/**
* 设置节点UI数据
*
* @param result 返回数组
* @param context 应用上下文
* @param callBack 回调
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public setNodeData(result:Array<any>,context:any,callBack:any){
result.forEach((item:any) =>{
if(item.children){
item.leaf = false;
this.setNodeData(item.children,context,callBack);
}else{
item.leaf = true;
}
callBack(context,item);
})
}
/**
* 处理节点关系导航上下文
*
* @param context 应用上下文
* @param filter 参数
* @param resNavContext 节点关系导航上下文
*
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public handleResNavContext(context:any,filter:any,resNavContext:any){
if(resNavContext && Object.keys(resNavContext).length > 0){
let tempContextData:any = JSON.parse(JSON.stringify(context));
let tempViewParams:any = {};
if(filter && filter.viewparams){
tempViewParams = filter.viewparams;
}
Object.keys(resNavContext).forEach((item:any) =>{
let curDataObj:any = resNavContext[item];
this.handleCustomDataLogic(context,tempViewParams,curDataObj,tempContextData,item);
})
return tempContextData;
}else{
return context;
}
}
/**
* 处理关系导航参数
*
* @param context 应用上下文
* @param filter 参数
* @param resNavParams 节点关系导航参数
* @param resParams 节点关系参数
*
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public handleResNavParams(context:any,filter:any,resNavParams:any,resParams:any){
if((resNavParams && Object.keys(resNavParams).length >0) || (resParams && Object.keys(resParams).length >0)){
let tempViewParamData:any = {};
let tempViewParams:any = {};
if(filter && filter.viewparams){
tempViewParams = filter.viewparams;
tempViewParamData = JSON.parse(JSON.stringify(filter.viewparams));
}
if( Object.keys(resNavParams).length > 0){
Object.keys(resNavParams).forEach((item:any) =>{
let curDataObj:any = resNavParams[item];
this.handleCustomDataLogic(context,tempViewParams,curDataObj,tempViewParamData,item);
})
}
if( Object.keys(resParams).length > 0){
Object.keys(resParams).forEach((item:any) =>{
let curDataObj:any = resParams[item];
tempViewParamData[item.toLowerCase()] = curDataObj.value;
})
}
Object.assign(filter,{viewparams:tempViewParamData});
return filter;
}else{
return filter;
}
}
/**
* 处理自定义节点关系导航数据
*
* @param context 应用上下文
* @param viewparams 参数
* @param curNavData 节点关系导航参数对象
* @param tempData 返回数据
* @param item 节点关系导航参数键值
*
* @memberof ${srfclassname('${ctrl.codeName}')}Service
*/
public handleCustomDataLogic(context:any,viewparams:any,curNavData:any,tempData:any,item:string){
// 直接值直接赋值
if(curNavData.isRawValue){
if(Object.is(curNavData.value,"null") || Object.is(curNavData.value,"")){
Object.defineProperty(tempData, item.toLowerCase(), {
value: null,
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(tempData, item.toLowerCase(), {
value: curNavData.value,
writable : true,
enumerable : true,
configurable : true
});
}
}else{
// 先从导航上下文取数,没有再从导航参数(URL)取数,如果导航上下文和导航参数都没有则为null
if(context[(curNavData.value).toLowerCase()] != null){
Object.defineProperty(tempData, item.toLowerCase(), {
value: context[(curNavData.value).toLowerCase()],
writable : true,
enumerable : true,
configurable : true
});
}else{
if(viewparams[(curNavData.value).toLowerCase()] != null){
Object.defineProperty(tempData, item.toLowerCase(), {
value: viewparams[(curNavData.value).toLowerCase()],
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(tempData, item.toLowerCase(), {
value: null,
writable : true,
enumerable : true,
configurable : true
});
}
}
}
}
<#ibizinclude>
../@MACRO/SERVICE/SERVICE_BOTTOM.ts.ftl
</#ibizinclude>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册