mob-wf-dyna-edit-view3-base.tsx 8.6 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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
import { IPSAppDEWFDynaEditView, IPSDEDRTab, IPSDEDRTabPage, IPSDEForm } from '@ibiz/dynamic-model-api';
import { Util, ModelTool, MobWFDynaEdit3ViewInterface } from 'ibiz-core';
import { MainViewBase } from './main-view-base';

/**
 * 工作流动态编辑视图(分页关系)基类
 *
 * @export
 * @class MobWFDynaEditView3Base
 * @extends {MainViewBase}
 * @implements {MobWFDynaEdit3ViewInterface}
 */
export class MobWFDynaEditView3Base extends MainViewBase implements MobWFDynaEdit3ViewInterface {

    /**
     * 视图实例
     *
     * @memberof MobWFDynaEditView3Base
     */
    public declare viewInstance: IPSAppDEWFDynaEditView;

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

    /**
     * 数据关系分页部件实例
     *
     * @type {IPSDEDRTab}
     * @memberof MobWFDynaEditView3Base
     */
    public drtabInstance!: IPSDEDRTab;

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

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

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

    /**
     * 关系数据分页部件分页
     *
     * @type {IPSDEDRTabPage[] | null}
     * @memberof MobWFDynaEditView3Base
     */
    public deDRTabPages: IPSDEDRTabPage[] | null = [];

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

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

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

    /**
     * 设置已经绘制完成状态
     *
     * @memberof MobWFDynaEditView3Base
     */
    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 MobWFDynaEditView3Base
     */
    public async viewModelInit() {
        await super.viewModelInit();
        this.viewRefData = await ModelTool.loadedAppViewRef(this.viewInstance);
        this.drtabInstance = ModelTool.findPSControlByName('drtab', this.viewInstance.getPSControls()) as IPSDEDRTab;
        this.deDRTabPages = this.drtabInstance?.getPSDEDRTabPages();
    }

    /**
     * 初始化工具栏数据
     *
     * @memberof MobWFDynaEditView3Base
     */
    public renderToolBar() {
        return (
            <div class="wf-button-content">
                <div class="toolbar-container" on-click={() => { this.WFViewEvent({ tag: 'toolBarVisibleChange' }) }}>
                    <ion-fab-button>
                        <ion-icon name="chevron-back-circle-outline"></ion-icon>
                    </ion-fab-button>
                </div>
            </div>
        );
    }

    /**
     * 绘制工作流按钮
     *
     * @return {*} 
     * @memberof MobWFDynaEditView3Base
     */
    public renderToolBarInfo() {
        return (
            <van-action-sheet
                class="wf-action-sheet"
                cancel-text="取消"
                get-container="#app"
                actions={this.linkModel}
                value={this.toolBarVisible}
                on-select={(item: any) => { this.WFViewEvent({ tag: 'WFButtonClick', value: item }) }}
                on-cancel={() => { this.WFViewEvent({ tag: 'toolBarVisibleChange' }) }}
                on-click-overlay={() => { this.WFViewEvent({ tag: 'toolBarVisibleChange' }) }}>
            </van-action-sheet>
        )
    }

    /**
     * 绘制分页关系
     *
     * @return {*} 
     * @memberof MobWFDynaEditView3Base
     */
    public renderDrTabPage() {
        const tempContext = Util.deepCopy(this.context);
        const tabsName = `${this.appDeCodeName?.toLowerCase()}_${this.viewInstance.codeName.toLowerCase()}`;
        const title = this.drtabInstance.M?.editItemCaption ? this.drtabInstance.M?.editItemCaption : this.editFormInstance.logicName;
        return [
            <van-tabs
                animated={false}
                name={tabsName}
                type="card"
            >
                <van-tab
                    tab={tabsName}
                    title={title}
                >
                    {this.renderFormContent()}
                </van-tab>
                {this.deDRTabPages?.map((deDRTabPage: IPSDEDRTabPage) => {
                    const tabTitle = this.$tl(deDRTabPage.getCapPSLanguageRes()?.lanResTag, deDRTabPage.caption);
                    return (
                        <van-tab tab={tabsName} title={tabTitle}                            >
                            {this.$createElement('app-view-shell', {
                                props: {
                                    staticProps: {
                                        appDeCodeName: this.appDeCodeName,
                                    },
                                    dynamicProps: {
                                        _context: JSON.stringify(
                                            Object.assign(tempContext, {
                                                viewpath: deDRTabPage?.M?.getPSAppView?.path,
                                            })
                                        ),
                                        _viewparams: JSON.stringify(
                                            this.viewparams
                                        ),
                                    },
                                },
                                class: 'view-container2'
                            })}
                        </van-tab>
                    );
                })}
            </van-tabs>,
        ]
    }

    /**
     * 渲染流程表单内容区
     *
     * @memberof MobWFDynaEditView3Base
     */
    public renderFormContent() {
        if (!this.editFormInstance) {
            return;
        }
        let {
            targetCtrlName,
            targetCtrlParam,
            targetCtrlEvent,
        } = this.computeTargetCtrlData(this.editFormInstance);
        Object.assign(targetCtrlParam.staticProps, { isautoload: true, });
        return this.$createElement(targetCtrlName, {
            slot: 'default',
            props: targetCtrlParam,
            ref: this.editFormInstance.name,
            on: targetCtrlEvent,
        });
    }

    /**
     * 渲染视图主体内容区
     *
     * @memberof MobWFDynaEditView3Base
     */
    public renderMainContent() {
        if (!this.editFormInstance) {
            return;
        }
        return <div class="app-vc-form">
            {
                this.deDRTabPages && this.deDRTabPages.length > 0 ?
                    this.renderDrTabPage() :
                    this.renderFormContent()
            }
        </div>

    }

    /**
     * 渲染视图底部
     *
     * @return {*} 
     * @memberof MobWFDynaEditView3Base
     */
    renderViewFooter() {
        return <div class="view-footer__buttons">
            {this.renderToolBar()}
            {this.renderToolBarInfo()}
        </div>
    }

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