wfdynastartview-base.tsx 3.7 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 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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
import { IPSAppDEWFDynaStartView, IPSDEForm } from '@ibiz/dynamic-model-api';
import { ModelTool, WFDynaStartViewInterface } from 'ibiz-core';
import { MainViewBase } from './mainview-base';

/**
 * 工作流启动视图
 *
 * @export
 * @class WFDynaStartViewBase
 * @extends {MainViewBase}
 * @implements {WFDynaStartViewInterface}
 */
export class WFDynaStartViewBase extends MainViewBase implements WFDynaStartViewInterface {

    /**
     * 视图实例
     * 
     * @memberof WFDynaStartViewBase
     */
    public declare viewInstance: IPSAppDEWFDynaStartView;

    /**
     * 表单实例
     * 
     * @memberof WFDynaStartViewBase
     */
    protected editFormInstance!: IPSDEForm;

    /**
     * 初始化挂载状态集合
     *
     * @memberof WFDynaStartViewBase
     */
    public initUIContainerMountedMap() {
        this.mountedMap.set('self', false);
    }

    /**
     * 设置已经绘制完成状态
     *
     * @memberof WFDynaStartViewBase
     */
    public setContainerIsMounted(name: string = 'self') {
        super.setContainerIsMounted(name);
        if (this.editFormInstance?.name == name) {
            this.viewState.next({ tag: this.editFormInstance.name, action: 'autoload', data: { srfkey: this.context[this.appDeCodeName.toLowerCase()] } });
        }
    }

    /**
     *  视图挂载
     *
     * @memberof WFDynaStartViewBase
     */
    public containerMounted() {
        super.containerMounted();
        if (this.viewparams && this.viewparams.actionForm) {
            this.computeActivedForm(this.viewparams.actionForm);
        } else {
            this.computeActivedForm(null);
        }
    }

    /**
     * 计算激活表单
     * 
     * @memberof WFDynaStartViewBase
     */
    public computeActivedForm(inputForm: any) {
        if (!inputForm) {
            this.editFormInstance = ModelTool.findPSControlByName('form', this.viewInstance.getPSControls()) as IPSDEForm;
        } else {
            this.editFormInstance = ModelTool.findPSControlByName(`wfform_${inputForm.toLowerCase()}`, this.viewInstance.getPSControls()) as IPSDEForm;
        }
        this.mountedMap.set(this.editFormInstance.name, false);
        this.$forceUpdate();
    }

    /**
     * 确认
     * 
     * @memberof WFDynaStartViewBase
     */
    public onClickOk() {
        let xData: any = (this.$refs.form as any).ctrl;
        if (xData && xData.formValidateStatus()) {
            let preFormData: any = xData.getData();
            let nextFormData: any = xData.transformData(preFormData);
            Object.assign(preFormData, nextFormData);
            this.$store.commit('viewAction/setViewDataChange', { viewTag: this.viewtag, viewDataChange: false });
            this.$emit("view-event", { action: "viewdataschange", data: [preFormData] });
            this.$emit("view-event", { action: "close", data: null });
        }
    }

    /**
     * 取消
     * 
     * @memberof WFDynaStartViewBase
     */
    public onClickCancel() {
        this.$store.commit('viewAction/setViewDataChange', { viewTag: this.viewtag, viewDataChange: false });
        this.$emit("view-event", { action: "close", data: null });
    }

    /**
     * 初始化编辑视图实例
     * 
     * @memberof WFDynaStartViewBase
     */
    public async viewModelInit() {
        await super.viewModelInit();
    }

    /**
     * 渲染视图主体内容区
     * 
     * @memberof WFDynaStartViewBase
     */
    public renderMainContent() {
        if (!this.editFormInstance) {
            return;
        }
        let { targetCtrlName, targetCtrlParam, targetCtrlEvent } = this.computeTargetCtrlData(this.editFormInstance);
        return this.$createElement(targetCtrlName, { slot: 'default', props: targetCtrlParam, ref: "form", on: targetCtrlEvent });
    }

}