提交 74e5086e 编写于 作者: Mosher's avatar Mosher

update:更新支持树导航视图

上级 e907bef8
......@@ -23,9 +23,9 @@ export class TreeExpView extends ExpView {
* @memberof TreeExpView
*/
public useLoad(props: TreeExpViewProps) {
const { viewSubject } = this.viewState;
const { viewSubject, treeExpBarName } = this.viewState;
onMounted(() => {
viewSubject.next({ tag: 'grid', action: "load", data: {} })
viewSubject.next({ tag: treeExpBarName, action: "load", data: {} });
})
}
......@@ -37,13 +37,9 @@ export class TreeExpView extends ExpView {
* @memberof TreeExpView
*/
public moduleInstall(props: TreeExpViewProps, emit?: Function) {
this.emit = emit;
const superParams = super.moduleInstall(props, emit);
this.useLoad(props);
return {
...superParams,
handleCtrlEvent: this.handleCtrlEvent.bind(this),
state: this.viewState,
...superParams
};
}
}
\ No newline at end of file
import { MainControlState } from "@core";
import { IParam, MainControlState } from "@core";
/**
* @description 导航栏部件通讯对象
......@@ -6,4 +6,12 @@ import { MainControlState } from "@core";
* @interface ExpBarControlState
* @extends {MainControlState}
*/
export interface ExpBarControlState extends MainControlState { }
\ No newline at end of file
export interface ExpBarControlState extends MainControlState {
/**
* @description 选中数据
* @type {IParam}
* @memberof ExpBarControlState
*/
selection: IParam;
}
\ No newline at end of file
import { MainControl } from "@core";
import { IActionParam, MainControl } from "@core";
import { ExpBarControlProps } from "./exp-bar-control-prop";
import { ExpBarControlState } from "./exp-bar-control-state";
......@@ -17,11 +17,51 @@ export class ExpBarControl extends MainControl {
public declare controlState: ExpBarControlState;
/**
* @description 使用加载功能模块
* @param {ExpBarControlProps} props 传入的props
* @description 处理部件事件
* @param {IActionParam} actionParam
* @memberof ExpBarControl
*/
public useLoad(props: ExpBarControlProps) {
public handleCtrlEvent(actionParam: IActionParam) {
const { tag, action, data } = actionParam;
const { selection } = this.controlState;
switch (action) {
case 'selectionchange':
this.onSelectionChange(data);
break;
}
}
protected onSelectionChange(data: any[]) {
console.log("处理选中事件", data);
}
public calcToolbarItemState(state: boolean) {
// TODO 计算工具栏权限
// let _this: any = this;
// const models: any = _this.toolbarModels;
// if (models && models.length > 0) {
// for (const key in models) {
// if (!models.hasOwnProperty(key)) {
// return;
// }
// const _item = models[key];
// if (_item.uiaction && (Object.is(_item.uiaction.actionTarget, 'SINGLEKEY') || Object.is(_item.uiaction.actionTarget, 'MULTIKEY'))) {
// _item.disabled = state;
// }
// _item.visabled = true;
// if (_item.noprivdisplaymode && _item.noprivdisplaymode === 6) {
// _item.visabled = false;
// }
// }
// this.calcNavigationToolbarState();
// }
}
public calcNavigationToolbarState() {
let _this: any = this;
if (_this.toolbarModels) {
// ViewTool.calcActionItemAuthState({}, this.toolbarModels, this.appUIService);
}
}
/**
......@@ -36,6 +76,7 @@ export class ExpBarControl extends MainControl {
return {
...superParams,
state: this.controlState,
handleCtrlEvent: this.handleCtrlEvent.bind(this)
};
}
}
\ No newline at end of file
import { MainControlProps } from "@core";
import { IParam, MainControlProps } from "@core";
/**
* @description 树部件props
......@@ -6,4 +6,32 @@ import { MainControlProps } from "@core";
* @interface TreeControlProps
* @extends {MainControlProps}
*/
export interface TreeControlProps extends MainControlProps {}
\ No newline at end of file
export interface TreeControlProps extends MainControlProps {
/**
* @description 是否只处理子节点
* @type {boolean}
* @memberof TreeControlProps
*/
isBranchAvailable: boolean;
/**
* @description 是否多选
* @type {boolean}
* @memberof TreeControlProps
*/
multiple: boolean;
/**
* @description 选中数据
* @type {IParam[]}
* @memberof TreeControlProps
*/
selectedData: IParam[];
/**
* @description 是否默认选中第一项数据
* @type {boolean}
* @memberof TreeControlProps
*/
selectFirstDefault: boolean;
}
\ No newline at end of file
import { MainControl } from "@core";
import { toRef } from "vue";
import { deepCopy, deepObjectMerge, IActionParam, MainControl } from "@core";
import { TreeControlProps } from "./tree-control-prop";
import { TreeControlState } from "./tree-control-state";
......@@ -16,6 +17,59 @@ export class TreeControl extends MainControl {
*/
public declare controlState: TreeControlState;
/**
* @description 根据props调整设置部件state
* @param {TreeControlProps} props 传入的props
* @memberof TreeControl
*/
public setState(props: TreeControlProps): void {
super.setState(props);
this.controlState.isBranchAvailable = toRef(props, 'isBranchAvailable') as any;
}
/**
* @description 树节点选中
* @param {string} nodeId
* @param \{{ nativeEvent: MouseEvent, node: any, selected: boolean }} e
* @memberof TreeControl
*/
public treeNodeSelect(nodeId: string, e: { nativeEvent: MouseEvent, node: any, selected: boolean }) {
if (e.node.disabled) {
e.node.isCurrent = false;
return;
}
const { isBranchAvailable, currentselectedNode, multiple, selectedNodes, controlName } = this.controlState;
if (isBranchAvailable && e.node.leaf) {
if (currentselectedNode && Object.keys(currentselectedNode).length > 0) {
currentselectedNode.value.srfchecked = 0;
}
e.node.srfchecked = 1;
currentselectedNode.value = e.node;
if (!multiple) {
selectedNodes.push(currentselectedNode.value);
this.emit("ctrlEvent",{ tag: controlName, action: 'selectionchange', data: deepCopy(selectedNodes) });
}
}
}
/**
* @description 计算节点上下文
* @private
* @param {*} curNode
* @return {*}
* @memberof TreeControl
*/
private computecurNodeContext(curNode: any) {
const { context } = this.controlState;
let tempContext: any = {};
if (curNode && curNode.data && curNode.data.srfappctx) {
tempContext = deepCopy(curNode.data.srfappctx);
} else {
tempContext = deepCopy(context);
}
return tempContext;
}
/**
* @description 使用加载功能模块
* @param {TreeControlProps} props 传入的props
......@@ -24,7 +78,72 @@ export class TreeControl extends MainControl {
*/
public useLoad(props: TreeControlProps) {
const { viewSubject, controlName } = this.controlState;
const load = async (opt: any = {}) => {
const load = async (node: any, isFirst: boolean = false) => {
if (node?.dataRef?.children) {
return null;
}
const {
controlService, data, viewParams, srfnodefilter
} = this.controlState;
let tempViewParams: any = deepCopy(viewParams);
let curNode: any = {};
curNode = deepObjectMerge(curNode, node);
const params: any = {
srfnodeid: node.dataRef && node.dataRef.id ? node.dataRef.id : '#',
srfnodefilter: srfnodefilter,
parentData: curNode.dataRef?.curData
}
let tempContext: any = this.computecurNodeContext(curNode);
if (curNode.dataRef && curNode.dataRef.sefparentdename) {
Object.assign(tempContext, { srfparentdename: curNode.dataRef.srfparentdename });
Object.assign(tempViewParams, { srfparentdename: curNode.dataRef.srfparentdename });
}
if (curNode.dataRef && curNode.dataRef.srfparentdemapname) {
Object.assign(tempContext, { srfparentdemapname: curNode.dataRef.srfparentdemapname });
Object.assign(tempViewParams, { srfparentdemapname: curNode.dataRef.srfparentdemapname });
}
if (curNode.dataRef && curNode.dataRef.srfparentkey) {
Object.assign(tempContext, { srfparentkey: curNode.dataRef.srfparentkey });
Object.assign(tempViewParams, { srfparentkey: curNode.dataRef.srfparentkey });
}
Object.assign(params, { viewParams: tempViewParams });
try {
const response = await controlService.getNodes(tempContext, params);
if (!response || response.status !== 200) {
return null;
}
const items = response.data;
// TODO 展开
// this.formatExpanded(items);
// this.formatAppendCaption(items);
const isRoot = Object.is(node.level, 0);
if (isFirst) {
data.splice(0, data.length);
items.forEach((item: any) => {
data.push(item);
});
} else {
node.dataRef.children = items;
}
const isSelectedAll = node.checked;
// TODO 默认选中
// this.setDefaultSelection(items, isRoot, isSelectedAll);
this.emit("ctrlEvent",{ tag: controlName, action: "load", data: items });
} catch (error) {
console.error(error);
}
}
// 订阅viewSubject,监听load行为
if (viewSubject) {
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
if (Object.is(controlName, tag) && Object.is("load", action)) {
load(data, true);
}
})
// 部件卸载时退订viewSubject
onUnmounted(() => {
subscription.unsubscribe();
})
}
return {
load
......@@ -44,6 +163,7 @@ export class TreeControl extends MainControl {
return {
...superParams,
state: this.controlState,
treeNodeSelect: this.treeNodeSelect.bind(this),
load
};
}
......
import { deepCopy, deepObjectMerge, ExpBarControl, IParam } from "@core";
import { deepCopy, ExpBarControl, IActionParam, IParam, UIUtil } from "@core";
import { TreeExpBarControlProps } from "./tree-exp-bar-control-prop";
import { TreeExpBarControlState } from "./tree-exp-bar-control-state";
......@@ -16,23 +16,90 @@ export class TreeExpBarControl extends ExpBarControl {
*/
public declare controlState: TreeExpBarControlState;
/**
* @description 选中数据
* @private
* @type {IParam}
* @memberof TreeExpBarControl
*/
private selection: IParam = {};
protected onSelectionChange(args: any[]) {
if (args.length == 0) {
this.calcToolbarItemState(true);
return;
}
const arg: any = args[0];
if (!arg.id) {
this.calcToolbarItemState(true);
return;
}
const nodeType = arg.id.split(';')[0];
// const refView: any = this.get
const refView = this.getExpItemView({ nodeType: nodeType });
// TODO 选择视图面板支持
if (refView) {
const { selection } = this.controlState;
const { tempContext, tempViewParams } = this.computeNavParams(arg);
// 置空
Object.assign(selection, {});
Object.assign(selection, {
viewName: refView.viewName,
context: tempContext,
viewParams: tempViewParams
});
this.calcToolbarItemState(false);
} else {
this.calcToolbarItemState(true);
}
}
private computecurNodeContext(curNode: any) {
const { context } = this.controlState;
let tempContext: any = {};
if (curNode && curNode.data && curNode.data.srfappctx) {
tempContext = deepCopy(curNode.data.srfappctx);
protected getExpItemView(arg: any = {}): IParam | null {
const expMode: string = `EXPITEM:${arg.nodeType}`;
const { viewRefs } = this.controlState;
if (viewRefs && viewRefs.length > 0) {
const viewRef = viewRefs.find((_viewRef: any) => _viewRef.name == expMode);
return viewRef ? deepCopy(viewRef) : null;
} else {
tempContext = deepCopy(context);
return null;
}
}
protected computeNavParams(arg: any): { tempContext: any, tempViewParams: any } {
const tempContext: any = {};
const tempViewParams: any = {};
const { counter, context } = this.controlState;
if (arg && arg.navfilter) {
Object.defineProperty(tempViewParams, arg.navfilter, {
value: arg.srfkey,
writable: true,
enumerable: true,
configurable: true
})
Object.assign(tempContext, { srfcounter: counter });
}
Object.assign(tempContext, deepCopy(context));
if (arg.srfappctx) {
Object.assign(tempContext, deepCopy(arg.srfappctx));
}
if (arg.srfparentdename) {
Object.assign(tempContext, { srfparentdename: arg.srfparentdename });
}
if (arg.srfparentdemapname) {
Object.assign(tempContext, { srfparentdemapname: arg.srfparentdemapname });
}
if (arg.srfparentkey) {
Object.assign(tempContext, { srfparentkey: arg.srfparentkey });
}
// 计算导航上下文
if (arg && arg.navigateContext && Object.keys(arg.navigateContext).length > 0) {
let tempData: any = arg.curData ? arg.curData : {};
Object.assign(tempData, arg);
let _context = UIUtil.computedNavData(tempData, tempContext, tempViewParams, arg.navigateContext);
Object.assign(tempContext, _context);
}
return tempContext;
// 计算导航参数
if (arg && arg.navigateParams && Object.keys(arg.navigateParams).length > 0) {
let tempData: any = arg.curData ? arg.curData : {};
Object.assign(tempData, arg);
let _params = UIUtil.computedNavData(tempData, tempContext, tempViewParams, arg.navigateParams);
Object.assign(tempViewParams, _params);
counter.value += 1;
Object.assign(tempContext, { srfcounter: counter.value });
}
return { tempContext, tempViewParams };
}
/**
......@@ -41,26 +108,17 @@ export class TreeExpBarControl extends ExpBarControl {
* @memberof TreeExpBarControl
*/
public useLoad(props: TreeExpBarControlProps) {
const load = async (node: IParam) => {
console.log(1111, node);
if (node.dataRef.children) {
return null;
}
const {
controlService, context, viewParams, srfnodefilter
} = this.controlState;
let tempViewParams: any = deepCopy(viewParams);
let curNode: any = {};
curNode = deepObjectMerge(curNode, node);
const params: any = {
srfnodeid: node.data && node.data.id ? node.data.id : '#',
srfnodefilter: srfnodefilter,
parentData: curNode.data?.curData
const { viewSubject, controlName, xDataControlName } = this.controlState;
if (viewSubject) {
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
if (Object.is(controlName, tag)) {
viewSubject.next({ tag: xDataControlName, action: action, data: data })
}
let tempContext: any = this.computecurNodeContext(curNode);
}
return {
load
})
// 部件卸载时退订viewSubject
onUnmounted(() => {
subscription.unsubscribe();
})
}
}
......@@ -73,11 +131,9 @@ export class TreeExpBarControl extends ExpBarControl {
*/
public moduleInstall(props: TreeExpBarControlProps, emit?: Function) {
const superParams = super.moduleInstall(props, emit);
const { load } = this.useLoad(props);
this.useLoad(props);
return {
...superParams,
selection: this.selection,
load
};
}
}
\ No newline at end of file
export * from './control-vo-base'
export * from './tree-control-vo'
\ No newline at end of file
export * from './tree-control-vo';
export * from './tree-node-rs-vo';
export * from './tree-node-vo';
\ No newline at end of file
import { TreeNodeRSVO } from ".";
import { TreeNodeVO } from "./tree-node-vo";
export interface TreeControlVO {
/**
* @description 显示根
* @type {boolean}
* @memberof TreeControlVO
*/
rootVisible: boolean;
/**
* @description 树节点
* @type {TreeNodeVO[]}
* @memberof TreeControlVO
*/
treeNodes: TreeNodeVO[];
/**
* @description
* @type {TreeNodeRSVO[]}
* @memberof TreeControlVO
*/
treeNodeRSs: TreeNodeRSVO[];
}
\ No newline at end of file
import { IParam } from "@core";
export interface TreeNodeRSVO {
/**
* @description 下级节点对象
* @type {IParam}
* @memberof TreeNodeRSVO
*/
childDeTreeNode?: IParam;
/**
* @description 父值过滤项
* @type {string}
* @memberof TreeNodeRSVO
*/
parentFilter?: string;
/**
* @description 父值关系
* @type {IParam}
* @memberof TreeNodeRSVO
*/
parentPSDER1N?: IParam;
/**
* @description 父关系连接属性
* @type {IParam}
* @memberof TreeNodeRSVO
*/
parentPSAppDEField?: IParam;
/**
* @description 上级节点对象
* @type {IParam}
* @memberof TreeNodeRSVO
*/
parentPSDETreeNode?: IParam;
/**
* @description 父值级别 {1:上一级、 2:上两级、 3:上三级 }
* @type {(number | 1 | 2 | 3)}
* @memberof TreeNodeRSVO
*/
parentValueLevel: number | 1 | 2 | 3;
/**
* @description 搜索模式 {1:有搜索时启用、 2:无搜索时启用、 3:全部启用 }
* @type {(number | 1 | 2 | 3)}
* @memberof TreeNodeRSVO
*/
searchMode: number | 1 | 2 | 3;
}
\ No newline at end of file
import { IParam } from "@core"
export interface TreeNodeVO {
/**
* @description 允许拖到节点
* @type {boolean}
* @memberof TreeNodeVO
*/
allowDrag: boolean,
/**
* @description 允许拖入节点
* @type {boolean}
* @memberof TreeNodeVO
*/
allowDrop: boolean,
/**
* @description 允许编辑节点文本
* @type {boolean}
* @memberof TreeNodeVO
*/
allowEditText: boolean,
/**
* @description 允许节点排序
* @type {boolean}
* @memberof TreeNodeVO
*/
allowOrder: boolean,
/**
* @description 应用实体标识
* @type {string}
* @memberof TreeNodeVO
*/
appDataEntity?: IParam,
/**
* @description 应用实体结果集对象
* @type {IParam}
* @memberof TreeNodeVO
*/
appDeDataSet?: IParam;
/**
* @description 附加父节点标识
* @type {boolean}
* @memberof TreeNodeVO
*/
appendPNodeId: boolean,
/**
* @description 代码表
* @type {IParam}
* @memberof TreeNodeVO
*/
codeList?: IParam,
/**
* @description 计数器标识
* @type {string}
* @memberof TreeNodeVO
*/
counterId: string,
/**
* @description 计数器模式 {0:默认、 1:0 值时隐藏 }
* @type {number}
* @memberof TreeNodeVO
*/
counterMode: number,
/**
* @description 节点样式表
* @type {string}
* @memberof TreeNodeVO
*/
cssName?: string,
/**
* @description 树节点数据项集合
* @type {*}
* @memberof TreeNodeVO
*/
deTreeNodeDataItems?: any[] | null;
/**
* @description 禁止选择
* @type {boolean}
* @memberof TreeNodeVO
*/
disableSelect: boolean,
/**
* @description 支持选中
* @type {boolean}
* @memberof TreeNodeVO
*/
enableCheck: boolean,
/**
* @description 支持快速搜索
* @type {boolean}
* @memberof TreeNodeVO
*/
enableQuickSearch: boolean,
/**
* @description 仅展开首节点
* @type {boolean}
* @memberof TreeNodeVO
*/
expandFirstOnly: boolean,
/**
* @description 默认展开
* @type {boolean}
* @memberof TreeNodeVO
*/
expanded: boolean,
/**
* @description 是否有子节点
* @type {(boolean | null)}
* @memberof TreeNodeVO
*/
hasPSDETreeNodeRSs: boolean | null;
/**
* @description 叶节点标识值应用实体属性
* @type {IParam}
* @memberof TreeNodeVO
*/
leafFlagPSAppDEField?: IParam;
/**
* @description 节点标识值应用实体属性(DE 节点)
* @type {IParam}
* @memberof TreeNodeVO
*/
idPSAppDEField?: IParam;
/**
* @description 节点标识
* @type {string}
* @memberof TreeNodeVO
*/
id: string;
/**
* @description 节点图标值应用实体属性
* @type {IParam}
* @memberof TreeNodeVO
*/
iconPSAppDEField?: IParam;
/**
* @description 图片样式
* @type {string}
* @memberof TreeNodeVO
*/
iconcls?: string,
/**
* @description 图片路径
* @type {string}
* @memberof TreeNodeVO
*/
icon?: string,
/**
* @description 节点过滤属性
* @type {string}
* @memberof TreeNodeVO
*/
navFilter: string,
/**
* @description 导航视图
* @type {IParam}
* @memberof TreeNodeVO
*/
navView?: IParam,
/**
* @description 节点标识
* @type {string}
* @memberof TreeNodeVO
*/
nodeType: string,
/**
* @description 节点值(STATIC 节点)
* @type {rootNode}
* @memberof TreeNodeVO
*/
nodeValue?: string,
/**
* @description 根节点
* @type {boolean}
* @memberof TreeNodeVO
*/
rootNode: boolean,
/**
* @description 仅选择首节点
* @type {boolean}
* @memberof TreeNodeVO
*/
selectFirstOnly: boolean,
/**
* @description 默认选择
* @type {boolean}
* @memberof TreeNodeVO
*/
selected: boolean,
/**
* @description 排序方向
* @type {string}
* @memberof TreeNodeVO
*/
sortDir?: string;
/**
* @description 节点排序值应用实体属性
* @type {IParam}
* @memberof TreeNodeVO
*/
sortPSAppDEField?: IParam;
/**
* @description 节点文本格式化
* @type {string}
* @memberof TreeNodeVO
*/
textFormat?: string;
/**
* @description 节点文本值属性对象
* @type {IParam}
* @memberof TreeNodeVO
*/
textPSAppDEField?: IParam;
/**
* @description 文本
* @type {string}
* @memberof TreeNodeVO
*/
text?: string,
/**
* @description 提示信息
* @type {string}
* @memberof TreeNodeVO
*/
tooltip?: string,
/**
* @description 节点类型
* @type {string}
* @memberof TreeNodeVO
*/
treeNodeType: 'STATIC' | 'DE' | 'CODELIST' | string,
}
\ No newline at end of file
export * from './control-service-base'
export * from './edit-form-service'
export * from './grid-service'
export * from './tree-service'
\ No newline at end of file
......@@ -67,6 +67,16 @@ export function isExist(arg: any): boolean{
return arg !== undefined && arg !== null && arg === arg;
}
/**
* @description 是否为空
* @export
* @param {*} value
* @return {*} {boolean}
*/
export function isEmpty(value: any): boolean {
return typeof value === 'undefined' || value === '' || value === null || value !== value;
}
/**
* @description 除undefined,null,NaN,空字符串以外都为true
* @export
......
export const ViewConfig = {
{{#each page.ctrls as | ctrl |}}
{{#if (eq ctrl.controlType "TREEEXPBAR")}}
treeExpBarName: '{{ctrl.name}}',
{{/if}}
{{/each}}
{{> @macro/front-end/views/config/view-base-config.hbs}}
};
\ No newline at end of file
......@@ -25,7 +25,7 @@ interface ViewEmit {
const emit = defineEmits<ViewEmit>();
// 安装功能模块
const { state } = new TreeExpView(ViewConfig).moduleInstall(props, emit);
const { state, handleCtrlEvent, handleToolbarEvent } = new TreeExpView(ViewConfig).moduleInstall(props, emit);
</script>
<template>
......@@ -48,7 +48,6 @@ const { state } = new TreeExpView(ViewConfig).moduleInstall(props, emit);
:context="state.context"
:showBusyIndicator="true"
:viewParams="state.viewParams"
:controlAction="state.controlsAction.{{name}}"
:viewSubject="state.viewSubject"
@ctrlEvent="handleCtrlEvent"
></{{codeName}}TreeExpBar>
......
export const CtrlConfig = {
controlCodeName: '{{ctrl.codeName}}',
controlName: '{{ctrl.name}}',
counter: 0,
xDataControlName: '{{ctrl.xDataControlName}}',
selection: {},
viewRefs: [
{{#each ctrl.psAppViewRefs as | viewRef |}}
{
name: '{{viewRef.name}}',
{{#if viewRef.refPSAppView}}
viewName: '{{viewRef.refPSAppView.name}}',
{{#if viewRef.refPSAppView.psAppDataEntity}}
deKeyField: '{{viewRef.refPSAppView.psAppDataEntity.codeName}}',
{{/if}}
{{/if}}
},
{{/each}}
]
};
......@@ -7,6 +7,11 @@ import { CtrlConfig } from './{{spinalCase ctrl.codeName}}-tree-exp-bar-config';
import { {{codeName}}Tree} from '@widgets/{{spinalCase appEntity.codeName}}/{{spinalCase codeName}}-tree';
{{/eq}}
{{/ctrl.ctrls}}
{{#each ctrl.psAppViewRefs as | viewRef |}}
{{#if viewRef.refPSAppView}}
import {{viewRef.refPSAppView.name}} from '@views/{{spinalCase viewRef.refPSAppView.psAppModule.codeName}}/{{spinalCase viewRef.refPSAppView.codeName}}';
{{/if}}
{{/each}}
interface Props {
context: IContext;
......@@ -30,7 +35,7 @@ interface CtrlEmit {
const emit = defineEmits < CtrlEmit > ();
// 安装功能模块,提供状态和能力方法
const { state, selection } = new TreeExpBarControl(CtrlConfig).moduleInstall(props, emit);
const { state, handleCtrlEvent } = new TreeExpBarControl(CtrlConfig).moduleInstall(props, emit);
</script>
<template>
......@@ -40,19 +45,27 @@ const { state, selection } = new TreeExpBarControl(CtrlConfig).moduleInstall(pro
<a-layout-sider>
{{#ctrl.ctrls}}
{{#eq controlType "TREEVIEW"}}
<{{codeName}}Tree>
</{{codeName}}Tree>
<{{codeName}}Tree
:context="state.context"
:viewParams="state.viewParams"
:viewSubject="state.viewSubject"
:isBranchAvailable="true"
@ctrlEvent="handleCtrlEvent"
></{{codeName}}Tree>
{{/eq}}
{{/ctrl.ctrls}}
</a-layout-sider>
<a-layout>
<component
v-if="selection.view && !Object.is(this.selection.view.viewname, '')"
:is="selection.view.viewname"
{{#each ctrl.psAppViewRefs as | viewRef |}}
{{#if viewRef.refPSAppView}}
<{{viewRef.refPSAppView.name}}
v-if="state.selection.viewName && state.selection.viewName === '{{viewRef.refPSAppView.name}}'"
:viewDefaultUsage="false"
:viewdata="JSON.stringify(selection.context)"
:viewParam="JSON.stringify(selection.viewParam)">
</component>
:viewdata="JSON.stringify(state.selection.context)"
:viewParams="JSON.stringify(state.selection.viewParams)">
</{{viewRef.refPSAppView.name}}>
{{/if}}
{{/each}}
</a-layout>
</a-layout>
</template>
\ No newline at end of file
import { ControlVOBase, TreeControlVO, TreeNodeVO, 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.navPSAppView}}
navView: {
viewName: '{{treeNode.navPSAppView.codeName}}'
},
{{/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() {
return [
{{#each ctrl.psDETreeNodeRSs as | treeNodeRS |}}
{
{{#if treeNodeRS.childPSDETreeNode}}
childDeTreeNode: {
id: '{{treeNodeRS.childPSDETreeNode.id}}'
},
{{/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 CtrlConfig = {
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
......@@ -8,6 +8,7 @@ interface Props {
multiple: boolean;
selectedData: IParam[];
selectFirstDefault: boolean;
isBranchAvailable: boolean;
viewParams?: IParam;
controlAction: ControlAction;
showBusyIndicator?: boolean;
......@@ -18,6 +19,7 @@ const props = withDefaults(defineProps<Props>(), {
viewSubject: () => new Subject<IActionParam>(),
showBusyIndicator: true,
selectFirstDefault: false,
isBranchAvailable: false
})
// emit声明
......@@ -26,11 +28,21 @@ interface CtrlEmit {
}
const emit = defineEmits<CtrlEmit>();
// 安装功能模块,提供状态和能力方法
const { state, load } = new TreeControl(CtrlConfig).moduleInstall(props, emit);
const { state, load, treeNodeSelect } = new TreeControl(CtrlConfig).moduleInstall(props, emit);
</script>
// TODO 树节点待支持图标和自定义绘制
<template>
<a-tree
class="ibiz-tree{{#if ctrl.psSysCss}} {{ctrl.psSysCss.cssName}}{{/if}}"
:tree-data="state.data">
:tree-data="state.data"
:load-data="load"
:fieldNames="{ title: 'text', key: 'id' }"
@select="treeNodeSelect">
<template #title="{ text, id }">
<div class="ibiz-tree-node">
<span class="tree-node__title">\{{ text }}</span>
</div>
</template>
</a-tree>
</template>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册