app-treegridex-model.ts 2.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
import { IPSDETreeGridEx, IPSDETreeNode, IPSDETreeNodeDataItem, IPSDETreeDataSetNode, IPSAppDataEntity, IPSAppDEField, IPSAppDERS } from '@ibiz/dynamic-model-api';

export class AppTreeGridExModel {

    public treeGridExInstance!: IPSDETreeGridEx;

    /**
	 * 日历项类型
	 *
	 * @returns {any[]}
	 * @memberof AppTreeGridExModel
	 */
    public itemType: string = "";

    /**
    * Creates an instance of AppTreeGridExModel.
    * 
    * @param {*} [opts={}]
    * @memberof AppGridModel
    */
    constructor(opts: any) {
        this.treeGridExInstance = opts;
    }

    
    public getDataItems() {
        let dataItems: any[] = [{
            name: 'srffrontuf',
            prop: 'srffrontuf',
            dataType: 'TEXT',
        }, {
            name: 'style',
        }, {
            name: 'textColor',
        }, {
             name: 'itemType',
        }, {
            name: 'parentId'
        }, {
            name: 'query',
            prop: 'query',
        }];
        const allTreeNodes = this.treeGridExInstance.getPSDETreeNodes() || [];
        if(allTreeNodes?.length>0) {
            let tempModel: Array<any> = [];
            allTreeNodes.forEach((node: IPSDETreeNode) => {
                if(node.treeNodeType == 'DE') {
                    if((node as IPSDETreeDataSetNode)?.getIdPSAppDEField()) {
                        tempModel.push({
                            name: 'id',
                            prop: (node as IPSDETreeDataSetNode)?.getIdPSAppDEField()?.codeName.toLowerCase()
                        })
                    }
                    let nodeDataItems:any = node.getPSDETreeNodeDataItems();
                    if(nodeDataItems?.length>0) {
                        nodeDataItems.forEach((dataItem: IPSDETreeNodeDataItem) => {
                            tempModel.push({
                                name: dataItem.name == 'begin' ? "start" : node.name.toLowerCase(),
                                prop: dataItem.getPSAppDEField()?.codeName.toLowerCase()
                            })
                        })
                    }
                }
            })
            dataItems = [...dataItems, ...tempModel];
        }
        return dataItems;
    }
}