CONTROL.tsx.ftl 2.7 KB
Newer Older
yanshaowei's avatar
yanshaowei committed
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_HEADER.tsx.ftl
</#ibizinclude>

    /**
     * 获取多项数据
     *
     * @returns {any[]}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    public getDatas(): any[] {
        return [];
    }

    /**
     * 获取单项树
     *
     * @returns {*}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    public getData(): any {
        return null;
    }

    /**
     * 父参数
     *
     * @type {*}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    public viewdata: any = { srfparentdata: {} };

    /**
     * 是否被激活
     *
     * @type {boolean}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    public isActivied: boolean = false;

    /**
     * 关系视图参数
     *
     * @private
     * @type {*}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    private parentdata: any = <#if ctrl.getParentDataJO?? && ctrl.getParentDataJO()??>${ctrl.getParentDataJO()}<#else>{}</#if>;
             
    /**
     * vue 生命周期
     *
     * @returns
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    public created() {
        if (this.viewState) {
            this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
                if (!Object.is(tag, this.name)) {
                    return;
                }
                this.viewdata = { srfparentdata: {} };
                if (data.srfparentdata) {
                    Object.assign(this.viewdata.srfparentdata, data.srfparentdata);
                }
                Object.assign(this.viewdata.srfparentdata, this.parentdata);
                if (!this.isActivied) {
                    this.$nextTick(() => {
                        this.isActivied = true;
                    });
                }
            });
        }
    }

    /**
     * vue 生命周期
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    public destroyed() {
        if (this.viewStateEvent) {
            this.viewStateEvent.unsubscribe();
        }
        <#if destroyed_block??>
        ${destroyed_block}
        </#if>
    }

    /**
     * 绘制内容
     *
     * @returns
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    public render() {
        return (
            <span>
                {
                    this.isActivied ?
                        <#if ctrl.getEmbeddedPSAppDEView()??><#assign embedddevedview = ctrl.getEmbeddedPSAppDEView()><${srffilepath2(embedddevedview.getCodeName())} class='viewcontainer2' viewdata={JSON.stringify(this.viewdata)}></${srffilepath2(embedddevedview.getCodeName())}></#if>
                        :
                        ''
                }
            </span>
        );
    }
}