提交 e580fbb4 编写于 作者: RedPig97's avatar RedPig97

update:树导航树部件

上级 226f2d45
import {{ctrl.codeName}}Tree from "./{{spinalCase ctrl.codeName}}-tree.vue";
export { {{ctrl.codeName}}Tree };
import { ControlVOBase, TreeControlVO, TreeNodeVO, TreeNodeRSVO, TreeService } from "@core";
import { {{pascalCase ctrl.psAppDataEntity.codeName}}Service } from '@api/{{spinalCase ctrl.psAppDataEntity.codeName}}/{{spinalCase ctrl.psAppDataEntity.codeName}}-service';
export class ControlVO extends ControlVOBase implements TreeControlVO {
get rootVisible(): boolean {
return {{ctrl.rootVisible}};
}
get treeNodes(): TreeNodeVO[] {
return [
{{#each ctrl.psDETreeNodes as | treeNode |}}
{
allowDrag: {{treeNode.allowDrag}},
allowDrop: {{treeNode.allowDrop}},
allowEditText: {{treeNode.allowEditText}},
allowOrder: {{treeNode.allowOrder}},
{{#if treeNode.psAppDataEntity}}
appDataEntity: {
codeName: '{{treeNode.psAppDataEntity.codeName}}',
{{#each treeNode.psAppDataEntity.allPSAppDEFields as | field |}}
{{#if field.keyField}}
keyField: '{{field.codeName}}',
{{/if}}
{{#if field.majorField}}
majorField: '{{field.majorField}}',
{{/if}}
{{/each}}
},
{{/if}}
{{#if treeNode.psAppDEDataSet}}
appDeDataSet: { codeName: '{{treeNode.psAppDEDataSet.codeName}}' },
{{/if}}
appendPNodeId: {{treeNode.appendPNodeId}},
{{#if treeNode.psCodeList}}
codeList: {
codeName: '{{treeNode.psCodeList.codeName}}',
type: '{{treeNode.psCodeList.codeListType}}'
},
{{/if}}
counterId: '{{treeNode.counterId}}',
counterMode: {{treeNode.counterMode}},
{{#if treeNode.psSysCss}}
cssName: '{{treeNode.psSysCss.cssName}}'
{{/if}}
{{#if treeNode.psDETreeNodeDataItems}}
deTreeNodeDataItems: [
customCode: {{dataItem.customCode}},
{{#each treeNode.psDETreeNodeDataItems as | dataItem |}}
{{#if dataItem.psAppDEField}}
fieldCodeName: '{{dataItem.psAppDEField.codeName}}',
{{/if}}
name: '{{dataItem.name}}',
scriptCode: `{{dataItem.scriptCode}}`
{{/each}}
],
{{/if}}
disableSelect: {{treeNode.disableSelect}},
enableCheck: {{treeNode.enableCheck}},
enableQuickSearch: {{treeNode.enableQuickSearch}},
expandFirstOnly: {{treeNode.expandFirstOnly}},
expanded: {{treeNode.expanded}},
hasPSDETreeNodeRSs: {{treeNode.hasPSDETreeNodeRSs}},
{{#if treeNode.leafFlagPSAppDEField}}
leafFlagPSAppDEField: { codeName: '{{treeNode.leafFlagPSAppDEField.codeName}}' },
{{/if}}
{{#if treeNode.idPSAppDEField}}
idPSAppDEField: { codeName: '{{treeNode.idPSAppDEField.codeName}}' },
{{/if}}
{{#if treeNode.iconPSAppDEField}}
iconPSAppDEField: { codeName: '{{treeNode.iconPSAppDEField.codeName}}' },
{{/if}}
{{#if treeNode.psSysImage}}
{{#if treeNode.psSysImage.cssClass}}
iconcls: '{{treeNode.psSysImage.cssClass}}',
{{else if (treeNode.psSysImage.imagePath)}}
icon: '{{treeNode.psSysImage.imagePath}}',
{{/if}}
{{/if}}
id: '{{treeNode.id}}',
navFilter: '{{treeNode.navFilter}}',
{{#if treeNode.psNavigateContexts}}
navigateContext: {
{{#each treeNode.psNavigateContexts as | navContext |}}
{{navContext.key}}: '{{#if navContext.rawValue}}{{navContext.value}}{{else}}%{{navContext.value}}%{{/if}}',
{{/each}}
},
{{/if}}
{{#if treeNode.psNavigateParams}}
navigateParams: {
{{#each treeNode.psNavigateParams as | navParam |}}
{{navParam.key}}: '{{#if navParam.rawValue}}{{navParam.value}}{{else}}%{{navParam.value}}%{{/if}}',
{{/each}}
},
{{/if}}
{{#if treeNode.navPSAppView}}
navView: {
viewName: '{{treeNode.navPSAppView.codeName}}'
},
{{/if}}
{{#if treeNode.nodeValue}}
nodeValue: '{{treeNode.nodeValue}}',
{{/if}}
nodeType: '{{treeNode.nodeType}}',
rootNode: {{treeNode.rootNode}},
selectFirstOnly: {{treeNode.selectFirstOnly}},
selected: {{treeNode.selected}},
{{#if treeNode.sortDir}}
sortDir: '{{treeNode.sortDir}}',
{{/if}}
{{#if treeNode.sortPSAppDEField}}
sortPSAppDEField: { codeName: '{{treeNode.sortPSAppDEField.codeName}}' },
{{/if}}
{{#if treeNode.textFormat}}
textFormat: '{{treeNode.textFormat}}',
{{/if}}
{{#if treeNode.textPSAppDEField}}
textPSAppDEField: { codeName: '{{treeNode.textPSAppDEField.codeName}}' },
{{/if}}
{{#if treeNode.text}}
text: '{{treeNode.text}}',
{{/if}}
{{#if treeNode.tooltip}}
tooltip: '{{treeNode.tooltip}}',
{{/if}}
treeNodeType: '{{treeNode.treeNodeType}}',
},
{{/each}}
];
}
get treeNodeRSs(): TreeNodeRSVO[] {
return [
{{#each ctrl.psDETreeNodeRSs as | treeNodeRS |}}
{
{{#if treeNodeRS.childPSDETreeNode}}
childDeTreeNode: {
id: '{{treeNodeRS.childPSDETreeNode.id}}'
},
{{/if}}
{{#if treeNodeRS.psNavigateContexts}}
navigateContext: {
{{#each treeNodeRS.psNavigateContexts as | navContext |}}
{{navContext.key}}: '{{#if navContext.rawValue}}{{navContext.value}}{{else}}%{{navContext.value}}%{{/if}}',
{{/each}}
},
{{/if}}
{{#if treeNodeRS.psNavigateParams}}
navigateParams: {
{{#each treeNodeRS.psNavigateParams as | navParam |}}
{{navParam.key}}: '{{#if navParam.rawValue}}{{navParam.value}}{{else}}%{{navParam.value}}%{{/if}}',
{{/each}}
},
{{/if}}
{{#if treeNodeRS.psDETreeNodeRSParams}}
params: {
{{#each treeNodeRS.psDETreeNodeRSParams as | param |}}
{{param.key}}: { value: '{{param.value}}' }
{{/each}}
},
{{/if}}
{{#if treeNodeRS.parentFilter}}
parentFilter: '{{treeNodeRS.parentFilter}}',
{{/if}}
{{#if treeNodeRS.parentPSDER1N}}
parentPSDER1N: { codeName: '{{treeNodeRS.parentPSDER1N.codeName}}' },
{{/if}}
{{#if treeNodeRS.parentPSAppDEField}}
parentPSAppDEField: { codeName: '{{treeNodeRS.parentPSAppDEField.codeName}}' },
{{/if}}
{{#if treeNodeRS.parentPSDETreeNode}}
parentPSDETreeNode: { id: '{{treeNodeRS.parentPSDETreeNode.id}}' },
{{/if}}
parentValueLevel: {{#if treeNodeRS.parentValueLevel}}{{treeNodeRS.parentValueLevel}}{{else}}null{{/if}},
searchMode: {{treeNodeRS.searchMode}}
},
{{/each}}
];
}
}
export const ctrlState = {
controlCodeName: '{{ctrl.codeName}}',
controlName: '{{ctrl.name}}',
controlService: new TreeService<ControlVO>(ControlVO, new {{pascalCase ctrl.psAppDataEntity.codeName}}Service() ),
currentselectedNode: {},
data: [],
selectedNodes: []
};
\ No newline at end of file
<script setup lang="ts">
import { Subject } from 'rxjs';
import { IActionParam, IParam, ControlAction, TreeControl, IContext } from '@core';
import { ctrlState } from './{{spinalCase ctrl.codeName}}-tree-state';
interface Props {
context: IContext;
multiple: boolean;
selectedData: IParam[];
selectFirstDefault: boolean;
isBranchAvailable: boolean;
viewParams?: IParam;
controlAction: ControlAction;
showBusyIndicator?: boolean;
viewSubject: Subject<IActionParam>;
}
const props = withDefaults(defineProps<Props>(), {
viewSubject: () => new Subject<IActionParam>(),
showBusyIndicator: true,
selectFirstDefault: false,
isBranchAvailable: false
})
// emit声明
interface CtrlEmit {
(name: "ctrlEvent", value: IActionParam): void;
}
const emit = defineEmits<CtrlEmit>();
// 安装功能模块,提供状态和能力方法
const { state, load, treeNodeSelect } = new TreeControl(ctrlState, props, emit).moduleInstall();
// 暴露内部状态及能力
defineExpose({ state, name: '{{ctrl.name}}' });
</script>
// TODO 树节点待支持图标和自定义绘制
<template>
<a-tree
class="app-tree{{#if ctrl.psSysCss}} {{ctrl.psSysCss.cssName}}{{/if}}"
:tree-data="state.data"
:load-data="load"
:fieldNames="{ title: 'text', key: 'id' }"
@select="treeNodeSelect">
<template #title="{ text, id }">
<div class="app-tree-node">
<span class="tree-node__title">\{{ text }}</span>
</div>
</template>
</a-tree>
</template>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册