VIEW-BASE.vue.ftl 7.7 KB
Newer Older
1 2 3 4 5 6 7 8
<#assign self_content>
    /**
     * 工具栏模型数据
     * 
     * @memberof ${srfclassname('${view.codeName}')}Base
     */
    public linkModel:Array<any> = [];

9 10 11 12 13 14 15
    /**
     * 激活表单
     * 
     * @memberof ${srfclassname('${view.codeName}')}Base
     */
    public activeForm:any = {};

16 17 18 19 20 21 22 23 24
    /**
     * 所有表单数据
     * 
     * @memberof ${srfclassname('${view.codeName}')}Base
     */
    public allForm: any = {
    <#if view.getAllPSControls?? && view.getAllPSControls()??>
    <#list view.getAllPSControls() as singleControl>
    <#if singleControl.getControlType?? && singleControl.getControlType()?? && singleControl.getControlType() != "TOOLBAR">
25
        "${singleControl.getName()}":{name:"view_${singleControl.getName()}",autosave:"${singleControl.isEnableAutoSave()?c}",showBusyIndicator:"${singleControl.isShowBusyIndicator()?c}",updateAction:"<#if singleControl.getUpdatePSControlAction()?? && singleControl.getUpdatePSControlAction().getPSAppDEMethod()??>${singleControl.getUpdatePSControlAction().getPSAppDEMethod().getCodeName()}</#if>",removeAction:"<#if singleControl.getRemovePSControlAction()?? && singleControl.getRemovePSControlAction().getPSAppDEMethod()??>${singleControl.getRemovePSControlAction().getPSAppDEMethod().getCodeName()}</#if>",loaddraftAction:"<#if singleControl.getGetDraftPSControlAction()?? && singleControl.getGetDraftPSControlAction().getPSAppDEMethod()??>${singleControl.getGetDraftPSControlAction().getPSAppDEMethod().getCodeName()}</#if>",loadAction:"<#if singleControl.getGetPSControlAction()?? && singleControl.getGetPSControlAction().getPSAppDEMethod()??>${singleControl.getGetPSControlAction().getPSAppDEMethod().getCodeName()}</#if>",createAction:"<#if singleControl.getCreatePSControlAction()?? && singleControl.getCreatePSControlAction().getPSAppDEMethod()??>${singleControl.getCreatePSControlAction().getPSAppDEMethod().getCodeName()}</#if>",WFSubmitAction:"<#if singleControl.getWFSubmitPSControlAction()?? && singleControl.getWFSubmitPSControlAction().getPSAppDEMethod()??>${singleControl.getWFSubmitPSControlAction().getPSAppDEMethod().getCodeName()}</#if>",WFStartAction:"<#if singleControl.getWFStartPSControlAction()?? && singleControl.getWFStartPSControlAction().getPSAppDEMethod()??>${singleControl.getWFStartPSControlAction().getPSAppDEMethod().getCodeName()}</#if>"}<#if singleControl_has_next>,</#if>
26 27 28 29 30
    </#if>
    </#list>
    </#if>
    };

tony001's avatar
tony001 committed
31 32 33 34 35 36 37 38 39 40
    /**
     * 视图引用数据
     * 
     * @memberof ${srfclassname('${view.codeName}')}Base
     */
    public viewRefData:any = {
    <#if view.getPSAppViewRefs?? && view.getPSAppViewRefs()??>
    <#list view.getPSAppViewRefs() as viewRef>
    <#if viewRef.getName?? && viewRef.getName()?? && viewRef.getRefPSAppView?? && viewRef.getRefPSAppView()??>
    <#assign refAppView = viewRef.getRefPSAppView() />
tony001's avatar
tony001 committed
41
        "${viewRef.getName()}":{viewname:"${srffilepath2(refAppView.getCodeName())}",title:"<#if refAppView.getPSAppDataEntity()??>entities.${refAppView.getPSAppDataEntity().getCodeName()?lower_case}.views.${refAppView.getPSDEViewCodeName()?lower_case}.caption<#else>app.views.${refAppView.getCodeName()?lower_case}.caption</#if>", width: <#if refAppView.getWidth?? && refAppView.getWidth() gt 0>${refAppView.getWidth()?c}<#else>800</#if>, height: <#if refAppView.getHeight?? && refAppView.getHeight() gt 0>${refAppView.getHeight()?c}<#else>500</#if>}<#if viewRef_has_next>,</#if>
tony001's avatar
tony001 committed
42 43 44 45
    </#if>
    </#list>
    </#if>
    };
46

47 48 49 50 51 52 53 54
    /**
     * 获取工具栏按钮
     * 
     * @memberof ${srfclassname('${view.codeName}')}Base
     */
    public getWFLinkModel():Promise<any>{
        return new Promise((resolve:any, reject:any) =>{
            let datas: any[] = [];
Mosher's avatar
Mosher committed
55 56
            if (Object.keys(this.viewparams).length > 0) {
                Object.assign(datas, { 'processDefinitionKey': this.viewparams.processDefinitionKey });
57
                Object.assign(datas, { 'taskDefinitionKey': this.viewparams.taskDefinitionKey || this.viewparams.userTaskId });
58
            }
59 60 61
            this.appEntityService.GetWFLink(JSON.parse(JSON.stringify(this.context)),datas,true).then((response:any) =>{
                if (response && response.status === 200) {
                    this.linkModel = response.data;
62 63 64 65 66
                    if(response.headers && response.headers['process-form']){
                        this.computeActivedForm(response.headers['process-form']);
                    }else{
                        this.computeActivedForm(null);
                    }
67 68 69 70 71 72 73 74 75 76 77 78 79 80
                    resolve(response.data);
                }
            }).catch((response: any) => {
                if (response && response.status) {
                    this.$Notice.error({ title: '错误', desc: response.message });
                    return;
                }
                if (!response || !response.status || !response.data) {
                    this.$Notice.error({ title: '错误', desc: '系统异常' });
                    return;
                }
            });
        });
    }
81

82 83 84 85 86 87 88
    /**
     * 计算激活表单
     * 
     * @memberof ${srfclassname('${view.codeName}')}Base
     */
    public computeActivedForm(inputForm:any){
        if(!inputForm){
89 90
            this.activeForm = this.allForm && Object.values(this.allForm)[0];
            return;
91 92 93
        }
        if(this.allForm && Object.keys(this.allForm).length >0){
            Object.keys(this.allForm).forEach((name:string) =>{
94
                <#noparse>if(Object.is(name,`wfform_${inputForm.toLowerCase()}`)){</#noparse>
95 96 97 98 99 100
                    this.activeForm = this.allForm[name];
                }
            })
        }
    }

101 102 103 104 105 106
    /**
     * 动态工具栏点击
     * 
     * @memberof ${srfclassname('${view.codeName}')}Base
     */
    public dynamic_toolbar_click(linkItem:any, $event:any){
107 108
        let datas: any[] = [];
        let xData: any = this.$refs.form;
Mosher's avatar
Mosher committed
109
        if (xData.getDatas && xData.getDatas instanceof Function) {
110
            datas = [...xData.getDatas()];
111
        }
112 113 114 115 116 117
        const submit:Function = (submitData:any,linkItem:any) =>{
            xData.wfsubmit(submitData,linkItem).then((response: any) => {
                if (!response || response.status !== 200) {
                    return;
                }
                const { data: _data } = response;
118

119 120 121 122 123 124 125 126 127 128
                if (this.viewdata) {
                    this.$emit('viewdataschange', [{ ..._data }]);
                    this.$emit('close');
                } else if (this.$tabPageExp) {
                    this.$tabPageExp.onClose(this.$route.fullPath);
                }
            });
        }
        if(linkItem && linkItem.sequenceflowview && <#noparse>this.viewRefData[`WFACTION@${linkItem.sequenceflowview}`]</#noparse>){
            let tempContext:any = Util.deepCopy(this.context);
129
            Object.assign(tempContext,{${appde.getCodeName()?lower_case}:datas && datas[0].srfkey});
130 131
            let tempViewParam:any = {actionView:linkItem.sequenceflowview,actionForm:linkItem.sequenceflowform};
            let targetView:any = <#noparse>this.viewRefData[`WFACTION@${linkItem.sequenceflowview}`];</#noparse>
132
            const appmodal = this.$appmodal.openModal({viewname:targetView.viewname, title:(this.$t(targetView.title) as string), height: targetView.height, width: targetView.width}, tempContext,tempViewParam);
133 134 135 136 137 138 139 140 141 142 143 144 145
            appmodal.subscribe((result: any) => {
                if (!result || !Object.is(result.ret, 'OK')) {
                    return;
                }
                let tempSubmitData:any = Util.deepCopy(datas);
                tempSubmitData.forEach((element:any) => {
                    Object.assign(element,result.datas && result.datas[0]);
                });
                submit(tempSubmitData,linkItem);
            });
        }else{
            submit(datas,linkItem);
        }  
146
    }
147

148
</#assign>
149 150 151
<#ibizinclude>
../@MACRO/VIEW-BASE.vue.ftl
</#ibizinclude>