mob-wf-dyna-edit-view-base.tsx 3.4 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 129 130 131 132 133 134 135
import { AppModelService, GetModelService, LogUtil, MobWFDynaEditViewEngine, MobWFDynaEditViewInterface, ModelTool, Util, } from 'ibiz-core';
import { MainViewBase } from './main-view-base';
import { IPSAppDEMobWFDynaEditView, IPSAppView, IPSDEForm } from '@ibiz/dynamic-model-api';
import { AppCenterService } from '../app-service';

/**
 * 工作流动态编辑视图基类
 *
 * @export
 * @class MobWFDynaEditViewBase
 * @extends {MainViewBase}
 */
export class MobWFDynaEditViewBase extends MainViewBase implements MobWFDynaEditViewInterface {

    /**
     * 视图实例
     *
     * @memberof MobWFDynaEditViewBase
     */
    public declare viewInstance: IPSAppDEMobWFDynaEditView;

    /**
     * 编辑表单实例
     *
     * @public
     * @type {IBizFormModel}
     * @memberof MobWFDynaEditViewBase
     */
    public editFormInstance!: IPSDEForm;

    /**
     * 工具栏模型数据
     *
     * @memberof MobWFDynaEditViewBase
     */
    public linkModel: Array<any> = [];

    /**
     * 视图引用数据
     *
     * @memberof MobWFDynaEditViewBase
     */
    public viewRefData: any = {};

    /**
     * 工作流按钮显示状态
     *
     * @memberof MobWFDynaEditViewBase
     */
    public toolBarVisible = false;

    /**
     * 工作流附加功能类型映射关系对象
     *
     * @memberof MobWFDynaEditViewBase
     */
    public wfAddiFeatureRef: any = {
        reassign: { featureTag: 'REASSIGN', action: 'TransFerTask' },
        addstepbefore: { featureTag: 'ADDSTEPBEFORE', action: 'BeforeSign' },
        sendback: { featureTag: 'SENDBACK', action: 'SendBack' },
        sendcopy: { featureTag: 'SENDCOPY', action: 'sendCopy' },
    };


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

    /**
     * 设置已经绘制完成状态
     *
     * @memberof MobWFDynaEditViewBase
     */
    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()],
                },
            });
        }
    }

    /**
     * 引擎初始化
     *
     * @public
     * @memberof MobWFDynaEditViewBase
     */
    public engineInit(opts: any = {}): void {
        if (this.Environment?.isPreviewMode) {
            return;
        }
        this.engine.init({
            view: this,
            keyPSDEField: this.appDeCodeName.toLowerCase(),
            majorPSDEField: this.appDeMajorFieldName.toLowerCase(),
            isLoadDefault: this.viewInstance.loadDefault,
        });
    }

    /**
     * 初始化编辑视图实例
     *
     * @memberof MobWFDynaEditViewBase
     */
    public async viewModelInit() {
        this.viewRefData = await ModelTool.loadedAppViewRef(this.viewInstance);
        await super.viewModelInit();
    }

    /**
     * 视图事件
     *
     * @param {*} $event
     * @return {*} 
     * @memberof MobWFDynaEditViewBase
     */
    public WFViewEvent($event: any) {
        const { tag, value } = $event;
        if (!tag) {
            console.log('视图事件tag 异常');
            return;
        }
        this.engine.onViewEvent(tag, value);
    }
}