import { __decorate } from "tslib";
import Vue from 'vue';
import { Prop } from 'vue-property-decorator';
import { Subject } from 'rxjs';
import { Util, ViewTool, AppServiceBase, ModelTool, GetModelService, LogUtil, SandboxInstance, throttle, AppCtrlEventEngine, AppTimerEngine, AppViewEventEngine, CounterService, } from '@ibizstudio/runtime';
import { ViewMessageService } from '@ibizstudio/runtime';
import { AppMessageBoxService, NavDataService, ViewLoadingService } from '../app-service';
import { createUUID, isNilOrEmpty } from 'qx-util';
import { Watch } from '../decorators';
/**
 * 视图基类
 *
 * @export
 * @class ViewBase
 * @extends {Vue}
 * @implements {ViewInterface}
 */
export class ViewBase extends Vue {
    constructor() {
        super(...arguments);
        /**
         * 环境文件
         *
         * @type {any}
         * @protected
         * @memberof ViewBase
         */
        this.Environment = AppServiceBase.getInstance().getAppEnvironment();
        /**
         * 注册事件逻辑分隔符
         *
         * @memberof ViewBase
         */
        this.registerEventSeparator = 'ibiz__';
        /**
         * 视图操作参数集合
         *
         * @type {*}
         * @memberof ViewBase
         */
        this.viewCtx = {};
        /**
         * 视图loading服务
         *
         * @type {ViewLoadingService}
         * @memberof ViewBase
         */
        this.viewLoadingService = new ViewLoadingService();
        /**
         * 是否禁用视图标题（不显示标题：true）
         *
         * @memberof ViewBase
         */
        this.noViewCaption = false;
        /**
         * 视图传递对象
         *
         * @type {Subject}
         * @memberof ViewBase
         */
        this.viewState = new Subject();
        /**
         * 应用导航服务
         *
         * @type {*}
         * @memberof ViewBase
         */
        this.navDataService = NavDataService.getInstance(this.$store);
        /**
         * 视图标识
         *
         * @type {string}
         * @memberof ViewBase
         */
        this.viewtag = '';
        /**
         * 自定义视图导航上下文集合
         *
         * @type {*}
         * @memberof ViewBase
         */
        this.customViewNavContexts = {};
        /**
         * 自定义视图导航参数集合
         *
         * @type {*}
         * @memberof ViewBase
         */
        this.customViewParams = {};
        /**
         * 视图模型数据
         *
         * @type {*}
         * @memberof ViewBase
         */
        this.model = {};
        /**
         * 容器模型
         *
         * @type {*}
         * @memberof ViewBase
         */
        this.containerModel = {};
        this.viewMessageService = new ViewMessageService();
        /**
         * 应用上下文
         *
         * @type {*}
         * @memberof ViewBase
         */
        this.context = {};
        /**
         * 视图参数
         *
         * @type {*}
         * @memberof ViewBase
         */
        this.viewparams = {};
        /**
         * 计数器服务对象集合
         *
         * @type {Array<*>}
         * @memberof ViewBase
         */
        this.counterServiceArray = [];
        /**
         * 模型数据是否加载完成
         *
         * @memberof ViewBase
         */
        this.viewIsLoaded = false;
        /**
         * 界面触发逻辑Map
         *
         * @memberof ViewBase
         */
        this.viewTriggerLogicMap = new Map();
        /**
         * 挂载状态集合
         *
         * @type {Map<string,boolean>}
         * @memberof ControlBase
         */
        this.mountedMap = new Map();
        /**
         * 是否视图已经完成viewMounted
         *
         * @type {boolean}
         * @memberof ControlBase
         */
        this.hasViewMounted = false;
    }
    /**
     * 监听视图动态参数变化
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof AppCalendarExpViewBase
     */
    watchDynamicPropsChange(newVal, oldVal) {
        if (newVal && !Util.isFieldsSame(newVal, oldVal)) {
            this.onDynamicPropsChange(newVal, oldVal);
        }
    }
    /**
     * 监听视图静态参数变化
     *
     * @memberof AppCalendarExpViewBase
     */
    watchStaticPropsChange(newVal, oldVal) {
        if (newVal && !Util.isFieldsSame(newVal, oldVal)) {
            this.onStaticPropsChange(newVal, oldVal);
        }
    }
    /**
     * 获取顶层视图
     *
     * @memberof ViewBase
     */
    getTopView() {
        return this.viewCtx.topview;
    }
    /**
     * 获取父级视图
     *
     * @memberof ViewBase
     */
    getParentView() {
        return this.viewCtx.parentview;
    }
    /**
     * 获取指定名称部件
     *
     * @memberof ViewBase
     */
    getCtrlByName(name) {
        return this.$refs[name].ctrl;
    }
    loadModel() { }
    engineInit() { }
    /**
     * 监听动态参数变化
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof ViewBase
     */
    onDynamicPropsChange(newVal, oldVal) {
        var _a;
        // 处理viewparam
        if (newVal.viewparam && newVal.viewparam !== (oldVal === null || oldVal === void 0 ? void 0 : oldVal.viewparam)) {
            this.viewparam = newVal.viewparam;
            if (typeof this.viewparam == 'string') {
                this.viewparams = JSON.parse(this.viewparam);
            }
            else {
                this.viewparams = Util.deepCopy(this.viewparam);
            }
        }
        // 处理viewdata
        if (newVal.viewdata && newVal.viewdata !== (oldVal === null || oldVal === void 0 ? void 0 : oldVal.viewdata)) {
            const _this = this;
            this.viewDefaultUsage = (_a = this.staticProps) === null || _a === void 0 ? void 0 : _a.viewDefaultUsage;
            this.viewdata = newVal.viewdata;
            if (this.viewIsLoaded) {
                setTimeout(() => {
                    if (this.engine && this.engine.view) {
                        this.engine.load();
                    }
                    else if (this.refresh && this.refresh instanceof Function) {
                        this.refresh();
                    }
                }, 0);
            }
        }
        this.parseViewParam();
        // 处理navdatas
        if (newVal.navdatas && newVal.navdatas !== (oldVal === null || oldVal === void 0 ? void 0 : oldVal.navdatas)) {
            this.navdatas = newVal.navdatas;
        }
        this.initViewCtx();
    }
    /**
     * 视图销毁
     *
     * @author chitanda
     * @date 2022-06-20 16:06:44
     */
    destroyed() {
        this.viewDestroyed();
    }
    /**
     * 初始化挂载状态集合
     *
     * @memberof ControlBase
     */
    initMountedMap() {
        var _a, _b;
        let controls = (_b = (_a = this.viewInstance) === null || _a === void 0 ? void 0 : _a.getPSControls) === null || _b === void 0 ? void 0 : _b.call(_a);
        controls === null || controls === void 0 ? void 0 : controls.forEach((item) => {
            if (item.controlType == 'TOOLBAR' || item.controlType == 'SEARCHBAR' || item.controlType == 'CAPTIONBAR' || item.controlType == 'DATAINFOBAR') {
                this.mountedMap.set(item.name, true);
            }
            else {
                this.mountedMap.set(item.name, false);
            }
        });
        this.mountedMap.set('self', false);
    }
    /**
     * 设置已经绘制完成状态
     *
     * @memberof ViewBase
     */
    setIsMounted(name = 'self') {
        this.mountedMap.set(name, true);
        if ([...this.mountedMap.values()].indexOf(false) == -1) {
            // 执行viewMounted
            if (!this.hasViewMounted) {
                this.$nextTick(() => {
                    this.viewMounted();
                });
            }
        }
    }
    /**
     * 监听静态参数变化
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof ViewBase
     */
    onStaticPropsChange(newVal, oldVal) {
        if (!(newVal === null || newVal === void 0 ? void 0 : newVal.modeldata)) {
            return;
        }
        this.beforeViewModelInit(newVal);
        this.viewModelInit().then((res) => {
            this.viewInit();
            this.viewIsLoaded = true;
            setTimeout(() => {
                this.setIsMounted();
            }, 0);
        });
    }
    /**
     * 执行初始化视图模型实例前逻辑
     *
     * @param data 静态数据
     * @memberof ViewBase
     */
    beforeViewModelInit(data) {
        var _a;
        this.viewDefaultUsage = data.viewDefaultUsage !== false;
        this.noViewCaption = data.noViewCaption == true;
        this.portletState = data.portletState;
        this.viewtag = data.viewtag;
        this.formDruipartState = data.formDruipartState;
        this.viewInstance = data === null || data === void 0 ? void 0 : data.modeldata;
        this.customViewNavContexts = this.viewInstance.getPSAppViewNavContexts() ? this.viewInstance.getPSAppViewNavContexts() : [];
        this.customViewParams = this.viewInstance.getPSAppViewNavParams() ? this.viewInstance.getPSAppViewNavParams() : [];
        this.viewCodeName = (_a = this.viewInstance) === null || _a === void 0 ? void 0 : _a.codeName;
        this.context = data.viewcontainer;
    }
    /**
     * 视图模型数据加载
     *
     * @memberof ViewBase
     */
    async viewModelLoad() {
        var _a, _b, _c;
        // 视图部件数据加载
        if (this.viewInstance.getPSControls()) {
            for (const control of this.viewInstance.getPSControls()) {
                await control.fill();
            }
        }
        // 视图应用实体加载
        await ((_c = (_b = (_a = this.viewInstance) === null || _a === void 0 ? void 0 : _a.getPSAppDataEntity) === null || _b === void 0 ? void 0 : _b.call(_a)) === null || _c === void 0 ? void 0 : _c.fill());
    }
    /**
     * 初始化模型服务
     *
     * @memberof ViewBase
     */
    async initModelService() {
        var _a;
        let tempContext = {};
        if (AppServiceBase.getInstance()) {
            this.mergeAppData(AppServiceBase.getInstance()
                .getAppStore()
                .getters.getAppData());
        }
        if (!this.viewDefaultUsage && this.viewdata && !Object.is(this.viewdata, '')) {
            if (typeof this.viewdata == 'string') {
                Object.assign(tempContext, JSON.parse(this.viewdata));
            }
            else {
                tempContext = Util.deepCopy(this.viewdata);
            }
        }
        else {
            const keys = [];
            let matchArray = [];
            if ((_a = this.$route) === null || _a === void 0 ? void 0 : _a.matched) {
                const path = this.$route.matched[this.$route.matched.length - 1].path;
                const curReg = this.$pathToRegExp.pathToRegexp(path, keys);
                matchArray = curReg.exec(this.$route.path);
            }
            let tempValue = {};
            keys.forEach((item, index) => {
                if (matchArray[index + 1]) {
                    Object.defineProperty(tempValue, item.name, {
                        enumerable: true,
                        value: decodeURIComponent(matchArray[index + 1]),
                    });
                }
            });
            ViewTool.formatRouteParams(tempValue, this.$route, tempContext, this.viewparams);
            if (this.viewparams && this.viewparams.srfdynainstid) {
                Object.assign(tempContext, { srfdynainstid: this.viewparams.srfdynainstid });
            }
            if (this.viewparams.srfinsttag && this.viewparams.srfinsttag2) {
                Object.assign(tempContext, { instTag: this.viewparams.srfinsttag, instTag2: this.viewparams.srfinsttag2 });
            }
            // 补充沙箱实例参数（路由）
            if (this.viewparams && this.viewparams.hasOwnProperty('srfsandboxtag')) {
                Object.assign(tempContext, { srfsandboxtag: this.viewparams.srfsandboxtag });
            }
        }
        try {
            this.modelService = await GetModelService(tempContext);
        }
        catch (error) {
            await this.initSandBoxInst(tempContext);
            this.modelService = await GetModelService(tempContext);
        }
    }
    /**
     * 初始化沙箱实例
     *
     * @memberof ViewBase
     */
    async initSandBoxInst(args) {
        if (args && args.srfsandboxtag) {
            const tempSandboxInst = new SandboxInstance(args);
            await tempSandboxInst.initSandBox();
        }
    }
    /**
     * 视图模型数据初始化实例
     *
     * @memberof ViewBase
     */
    async viewModelInit() {
        try {
            await this.initModelService();
            await this.viewModelLoad();
            this.initMountedMap();
            // 初始化时需要计算context和viewparams
            this.parseViewParam();
            // 初始化viewCtx
            this.initViewCtx();
            if (this.staticProps && this.staticProps.modeldata) {
                this.initContainerModel(this.staticProps);
                await this.initViewMessageService(this.staticProps.modeldata);
                await this.initCounterService(this.staticProps.modeldata);
                await this.initAppUIService();
                await this.initViewLogic(this.viewInstance);
            }
        }
        catch (error) {
            LogUtil.warn(error);
        }
    }
    /**
     * 绘制视图部件集合
     *
     * @memberof ViewBase
     */
    renderViewControls() {
        const viewLayoutPanel = this.viewInstance.getPSViewLayoutPanel();
        if (viewLayoutPanel && viewLayoutPanel.useDefaultLayout) {
            return [];
        }
        else {
            const controlArray = [];
            if (this.viewInstance.getPSControls() && this.viewInstance.getPSControls().length > 0) {
                this.viewInstance.getPSControls().forEach((control) => {
                    const targetCtrl = this.renderTargetControl(control);
                    controlArray.push(targetCtrl);
                });
            }
            controlArray.push(this.renderCaptionBar());
            controlArray.push(this.renderDataInfoBar());
            return controlArray;
        }
    }
    /**
     * 绘制目标部件
     *
     * @memberof ViewBase
     */
    renderTargetControl(control) {
        var _a, _b, _c;
        if (Object.is(control.controlType, 'TOOLBAR')) {
            const viewToolBar = control;
            const targetViewToolbarItems = [];
            if (viewToolBar && viewToolBar.getPSDEToolbarItems()) {
                (_a = viewToolBar.getPSDEToolbarItems()) === null || _a === void 0 ? void 0 : _a.forEach((toolbarItem) => {
                    targetViewToolbarItems.push(this.initToolBarItems(toolbarItem));
                });
            }
            return (<view-toolbar slot={`layout-${control.name}`} mode={((_b = this.viewInstance) === null || _b === void 0 ? void 0 : _b.viewStyle) || 'DEFAULT'} counterServiceArray={this.counterServiceArray} isViewLoading={(_c = this.viewLoadingService) === null || _c === void 0 ? void 0 : _c.isLoading} toolbarModels={targetViewToolbarItems} on-item-click={(data, $event) => {
                    throttle(this.handleItemClick, [data, $event], this);
                }}></view-toolbar>);
        }
        else {
            let { targetCtrlName, targetCtrlParam, targetCtrlEvent } = this.computeTargetCtrlData(control);
            Object.assign(targetCtrlParam, {
                dynamicProps: {
                    viewparams: Util.deepCopy(this.viewparams),
                    context: Util.deepCopy(this.context),
                    viewCtx: this.viewCtx,
                },
            });
            return this.$createElement(targetCtrlName, { slot: `layout-${control.name}`, props: targetCtrlParam, ref: control === null || control === void 0 ? void 0 : control.name, on: targetCtrlEvent });
        }
    }
    /**
     * 初始化containerModel
     *
     * @memberof ViewBase
     */
    initContainerModel(opts) {
        const { modeldata } = opts;
        if (!modeldata) {
            return;
        }
        if (Object.is(modeldata.viewType, 'DEPICKUPVIEW') ||
            Object.is(modeldata.viewType, 'DEPICKUPVIEW2') ||
            Object.is(modeldata.viewType, 'DEPICKUPVIEW3') ||
            Object.is(modeldata.viewType, 'DEMPICKUPVIEW') ||
            Object.is(modeldata.viewType, 'DEMPICKUPVIEW2') ||
            Object.is(modeldata.viewType, 'DEOPTVIEW') ||
            Object.is(modeldata.viewType, 'DEWFSTARTVIEW') ||
            Object.is(modeldata.viewType, 'DEWFACTIONVIEW')) {
            this.containerModel = {
                view_okbtn: { name: 'okbtn', type: 'button', text: this.$t('app.commonwords.ok'), disabled: true },
                view_cancelbtn: { name: 'cancelbtn', type: 'button', text: this.$t('app.commonwords.cancel'), disabled: false },
                view_leftbtn: { name: 'leftbtn', type: 'button', text: this.$t('app.button.leftbtn'), disabled: true },
                view_rightbtn: { name: 'rightbtn', type: 'button', text: this.$t('app.button.rightbtn'), disabled: true },
                view_allleftbtn: { name: 'allleftbtn', type: 'button', text: this.$t('app.button.allleftbtn'), disabled: true },
                view_allrightbtn: { name: 'allrightbtn', type: 'button', text: this.$t('app.button.allrightbtn'), disabled: true },
            };
        }
    }
    /**
     * 初始化应用界面服务
     *
     * @memberof ViewBase
     */
    async initAppUIService() { }
    /**
     * 初始化工具栏项
     *
     * @param {IPSDEToolbarItem} item
     *
     * @@memberof ViewBase
     */
    initToolBarItems(item) {
        var _a, _b, _c, _d, _e;
        if (item.itemType === 'ITEMS') {
            const items = item.getPSDEToolbarItems();
            if (items && items.length != 0) {
                const models = [];
                const tempModel = {
                    name: item.name,
                    showCaption: item.showCaption,
                    caption: this.$tl((_a = item.getCapPSLanguageRes()) === null || _a === void 0 ? void 0 : _a.lanResTag, item.caption),
                    tooltip: this.$tl((_b = item.getTooltipPSLanguageRes()) === null || _b === void 0 ? void 0 : _b.lanResTag, item.tooltip),
                    disabled: false,
                    visabled: true,
                    itemType: item.itemType,
                    dataaccaction: '',
                    actionLevel: item.actionLevel,
                };
                items.forEach((_item) => {
                    models.push(this.initToolBarItems(_item));
                });
                Object.assign(tempModel, {
                    model: models,
                });
                return tempModel;
            }
        }
        const img = item.getPSSysImage();
        const css = item.getPSSysCss();
        const uiAction = (_c = item === null || item === void 0 ? void 0 : item.getPSUIAction) === null || _c === void 0 ? void 0 : _c.call(item);
        const tempModel = {
            name: item.name,
            showCaption: item.showCaption,
            caption: this.$tl((_d = item.getCapPSLanguageRes()) === null || _d === void 0 ? void 0 : _d.lanResTag, item.caption),
            tooltip: this.$tl((_e = item.getTooltipPSLanguageRes()) === null || _e === void 0 ? void 0 : _e.lanResTag, item.tooltip),
            disabled: false,
            visabled: (uiAction === null || uiAction === void 0 ? void 0 : uiAction.dataAccessAction) && this.Environment.enablePermissionValid ? false : true,
            itemType: item.itemType,
            dataaccaction: uiAction === null || uiAction === void 0 ? void 0 : uiAction.dataAccessAction,
            noprivdisplaymode: uiAction === null || uiAction === void 0 ? void 0 : uiAction.noPrivDisplayMode,
            uiaction: uiAction,
            showIcon: item.showIcon,
            class: css ? css.cssName : '',
            getPSSysImage: img ? { cssClass: img.cssClass, imagePath: img.imagePath } : '',
            actionLevel: item.actionLevel,
        };
        if (item.itemType == 'RAWITEM') {
            Object.assign(tempModel, {
                rawType: item.contentType,
                rawContent: item.rawContent,
                htmlContent: item.htmlContent,
                style: {},
            });
            if (item.height) {
                Object.assign(tempModel.style, { height: item.height + 'px' });
            }
            if (item.width) {
                Object.assign(tempModel.style, { width: item.width + 'px' });
            }
        }
        return tempModel;
    }
    /**
     * 初始化计数器服务
     *
     * @param {*} param 视图实例
     * @memberof ViewBase
     */
    async initCounterService(param) {
        var _a;
        const appCounterRef = param.getPSAppCounterRefs() || [];
        if (appCounterRef && appCounterRef.length > 0) {
            for (const counterRef of appCounterRef) {
                const counter = (_a = counterRef.getPSAppCounter) === null || _a === void 0 ? void 0 : _a.call(counterRef);
                if (counter) {
                    await counter.fill(true);
                    const counterService = new CounterService();
                    await counterService.loaded(counter, { context: this.context, viewparams: this.viewparams });
                    const tempData = { id: counterRef.id, path: counter.modelPath, service: counterService };
                    this.counterServiceArray.push(tempData);
                }
            }
        }
    }
    /**
     * 初始化视图消息服务
     *
     * @memberof ViewBase
     */
    async initViewMessageService(param) {
        var _a, _b;
        const viewMsgGroup = (_b = (_a = param).getPSAppViewMsgGroup) === null || _b === void 0 ? void 0 : _b.call(_a);
        await this.viewMessageService.initBasicParam(viewMsgGroup, this.context, this.viewparams);
    }
    /**
     * 初始化视图标题数据
     *
     * @param {*} view 视图实例
     * @memberof ViewBase
     */
    initModel(view) {
        if (!view) {
            return;
        }
        this.model = { dataInfo: '' };
        Object.assign(this.model, {
            srfCaption: this.viewInstance.getCapPSLanguageRes() ? this.$tl(this.viewInstance.getCapPSLanguageRes().lanResTag, this.viewInstance.caption) : this.viewInstance.caption,
        });
        Object.assign(this.model, {
            srfTitle: this.viewInstance.getTitlePSLanguageRes() ? this.$tl(this.viewInstance.getTitlePSLanguageRes().lanResTag, this.viewInstance.title) : this.viewInstance.title,
        });
        Object.assign(this.model, {
            srfSubTitle: this.viewInstance.getSubCapPSLanguageRes()
                ? this.$tl(this.viewInstance.getSubCapPSLanguageRes().lanResTag, this.viewInstance.subCaption)
                : this.viewInstance.subCaption,
        });
    }
    /**
     *  视图初始化
     *
     * @memberof ViewBase
     */
    viewInit() {
        this.initModel(this.viewInstance);
        this.viewtag = Util.createUUID();
        if (this.viewDefaultUsage) {
            const navHistory = AppServiceBase.getInstance().getAppNavDataService();
            if (navHistory) {
                navHistory.setViewTag(this.viewtag, this.$route);
                navHistory.setCaption({ tag: this.viewtag, caption: this.model.srfCaption, info: '' });
            }
        }
        if (this.navDataService) {
            this.serviceStateEvent = this.navDataService.serviceState.subscribe(({ action, name, data }) => {
                if (!Object.is(name, this.viewCodeName)) {
                    return;
                }
                if (Object.is(action, 'viewrefresh')) {
                    this.parseViewParam(data);
                    setTimeout(() => {
                        if (this.engine) {
                            this.engine.load();
                        }
                        this.$forceUpdate();
                    }, 0);
                }
            });
        }
        if (this.portletState) {
            this.portletStateEvent = this.portletState.subscribe((res) => {
                if (!Object.is(res.tag, this.viewInstance.name)) {
                    return;
                }
                if (Object.is(res.action, 'refresh') && this.refresh && this.refresh instanceof Function) {
                    this.refresh();
                }
            });
        }
        if (this.formDruipartState) {
            this.formDruipartStateEvent = this.formDruipartState.subscribe(({ action }) => {
                if (Object.is(action, 'save')) {
                    if (this.viewInstance) {
                        const inst = this.viewInstance;
                        if (inst.xDataControlName &&
                            this.$refs &&
                            this.$refs[inst.xDataControlName] &&
                            this.$refs[inst.xDataControlName].ctrl &&
                            this.$refs[inst.xDataControlName].ctrl.save &&
                            this.$refs[inst.xDataControlName].ctrl.save instanceof Function) {
                            this.viewState.next({ tag: inst.xDataControlName, action: action, data: Object.assign(this.viewparams, { showResultInfo: false }) });
                        }
                        else {
                            this.$emit('view-event', { viewName: this.viewCodeName, action: 'drdatasaved', data: {} });
                        }
                    }
                }
                if (Object.is(action, 'load')) {
                    if (this.engine) {
                        this.engine.load();
                    }
                }
            });
        }
        // 视图加载服务初始化操作
        this.viewLoadingService.srfsessionid = this.context.srfsessionid;
        this.$store.commit('loadingService/addViewLoadingService', this.viewLoadingService);
        // 视图初始化向导航栈里面加数据
        this.$nextTick(() => {
            var _a;
            this.navDataService.addNavData({
                title: this.model.srfCaption,
                viewType: this.viewInstance.viewType,
                path: (_a = this.$route) === null || _a === void 0 ? void 0 : _a.fullPath,
                viewmode: this.viewDefaultUsage,
                tag: this.viewInstance.codeName,
                key: null,
                data: {},
            });
        });
        // 处理视图定时器逻辑
        this.handleTimerLogic();
    }
    /**
     *  视图挂载
     *
     * @memberof ViewBase
     */
    viewMounted() {
        // 设置挂载状态
        this.hasViewMounted = true;
        this.$emit('view-event', { viewname: this.viewInstance.name, action: 'viewIsMounted', data: true });
        if (this.engine) {
            this.engineInit();
        }
        if (this.loadModel && this.loadModel instanceof Function) {
            this.loadModel();
        }
        this.$emit('view-event', { viewName: this.viewCodeName, action: 'viewLoaded', data: null });
    }
    /**
     *  视图销毁
     *
     * @memberof ViewBase
     */
    viewDestroyed() {
        if (this.viewDefaultUsage) {
            let localStoreLength = Object.keys(localStorage);
            if (localStoreLength.length > 0) {
                localStoreLength.forEach((item) => {
                    if (item.startsWith(this.context.srfsessionid)) {
                        localStorage.removeItem(item);
                    }
                });
            }
            if (this.serviceStateEvent) {
                this.serviceStateEvent.unsubscribe();
            }
            if (AppServiceBase.getInstance() && AppServiceBase.getInstance().getAppStore()) {
                // 清除顶层路由参数
                AppServiceBase.getInstance()
                    .getAppStore()
                    .commit('removeRouteViewGlobal', this.context.srfsessionid);
                // 清除顶层视图
                AppServiceBase.getInstance()
                    .getAppStore()
                    .commit('removeView', this.context.srfsessionid);
            }
        }
        // 清除当前视图
        if (AppServiceBase.getInstance() && AppServiceBase.getInstance().getAppStore()) {
            if (this.viewInstance && this.viewInstance.modelPath) {
                AppServiceBase.getInstance()
                    .getAppStore()
                    .commit('removeView', this.viewInstance.modelPath);
            }
        }
        // 销毁计数器定时器
        if (this.counterServiceArray && this.counterServiceArray.length > 0) {
            this.counterServiceArray.forEach((item) => {
                let counterService = item.service;
                if (counterService && counterService.destroyCounter && counterService.destroyCounter instanceof Function) {
                    counterService.destroyCounter();
                }
            });
        }
        if (this.portletStateEvent) {
            this.portletStateEvent.unsubscribe();
        }
        if (this.formDruipartStateEvent) {
            this.formDruipartStateEvent.unsubscribe();
        }
        // 视图销毁从导航栈里面删除数据
        this.navDataService.removeNavData(this.viewInstance.codeName);
        // 销毁逻辑定时器
        this.destroyLogicTimer();
        this.viewState.complete();
    }
    /**
     * 初始化视图操作参数
     *
     * @public
     * @memberof ViewBase
     */
    initViewCtx(args) {
        this.viewCtx = { viewNavContext: this.context, viewNavParam: this.viewparams };
        if (AppServiceBase.getInstance() && AppServiceBase.getInstance().getAppStore()) {
            this.viewCtx['appGlobal'] = AppServiceBase.getInstance()
                .getAppStore()
                .getters.getAppGlobal();
        }
        if (AppServiceBase.getInstance()
            .getAppStore()
            .getters.getRouteViewGlobal(this.context.srfsessionid)) {
            this.viewCtx['routeViewGlobal'] = AppServiceBase.getInstance()
                .getAppStore()
                .getters.getRouteViewGlobal(this.context.srfsessionid);
        }
        else {
            AppServiceBase.getInstance()
                .getAppStore()
                .commit('addRouteViewGlobal', { tag: this.context.srfsessionid, param: {} });
            this.viewCtx['routeViewGlobal'] = AppServiceBase.getInstance()
                .getAppStore()
                .getters.getRouteViewGlobal(this.context.srfsessionid);
        }
        this.viewCtx['viewGlobal'] = {};
        this.viewCtx['viewNavData'] = {};
        this.viewCtx['messagebox'] = AppMessageBoxService.getInstance();
        this.viewCtx['app'] = AppServiceBase.getInstance();
        this.viewCtx['view'] = this;
        // 处理顶层视图
        if (!this.viewDefaultUsage && this.viewdata && !Object.is(this.viewdata, '')) {
            // 嵌入视图
            if (AppServiceBase.getInstance() && AppServiceBase.getInstance().getAppStore()) {
                this.viewCtx['topview'] = AppServiceBase.getInstance()
                    .getAppStore()
                    .getters.getView(this.context.srfsessionid);
            }
        }
        else {
            // 顶层路由视图
            if (AppServiceBase.getInstance() && AppServiceBase.getInstance().getAppStore()) {
                AppServiceBase.getInstance()
                    .getAppStore()
                    .commit('addView', { tag: this.context.srfsessionid, param: this });
            }
            this.viewCtx['topview'] = this;
        }
        // 处理父层视图
        this.handleParentView();
    }
    /**
     * 处理父级视图数据
     *
     * @memberof ViewBase
     */
    handleParentView() {
        if (this.context && this.context.parentviewpath) {
            if (AppServiceBase.getInstance() && AppServiceBase.getInstance().getAppStore()) {
                this.viewCtx['parentview'] = AppServiceBase.getInstance()
                    .getAppStore()
                    .getters.getView(this.context.parentviewpath);
            }
            else {
                this.viewCtx['parentview'] = null;
            }
        }
        else {
            this.viewCtx['parentview'] = null;
        }
        if (this.viewInstance && this.viewInstance.modelPath) {
            if (AppServiceBase.getInstance() && AppServiceBase.getInstance().getAppStore()) {
                AppServiceBase.getInstance()
                    .getAppStore()
                    .commit('addView', { tag: this.viewInstance.modelPath, param: this });
            }
            Object.assign(this.context, { parentviewpath: this.viewInstance.modelPath });
        }
    }
    /**
     *  合入应用数据到当前视图的导航参数中
     *
     * @param 应用数据
     * @memberof ViewBase
     */
    mergeAppData(appData) {
        for (let key in this.context) {
            delete this.context[key];
        }
        if (appData && appData.context) {
            Object.assign(this.context, appData.context);
        }
    }
    /**
     * 解析视图参数
     *
     * @public
     * @memberof ViewBase
     */
    parseViewParam(inputvalue = null) {
        var _a, _b;
        this.context = {};
        if (AppServiceBase.getInstance() && AppServiceBase.getInstance().getAppStore()) {
            this.mergeAppData(AppServiceBase.getInstance()
                .getAppStore()
                .getters.getAppData());
        }
        if (!this.viewDefaultUsage && this.viewdata && !Object.is(this.viewdata, '')) {
            if (typeof this.viewdata == 'string') {
                Object.assign(this.context, JSON.parse(this.viewdata));
            }
            if (isNilOrEmpty(this.context.srfsessionid) && isNilOrEmpty(this.context.srfsessionkey)) {
                this.context.srfsessionid = createUUID();
            }
            // 补充逻辑，当视图是临时模式主数据时，重新创建srfsessionid;
            if (((_a = this.viewInstance) === null || _a === void 0 ? void 0 : _a.tempMode) == 1) {
                this.context.srfsessionid = createUUID();
            }
            if (this.context && this.context.srfparentdename) {
                Object.assign(this.viewparams, { srfparentdename: this.context.srfparentdename });
            }
            if (this.context && this.context.srfparentdemapname) {
                Object.assign(this.viewparams, { srfparentdemapname: this.context.srfparentdemapname });
            }
            if (this.context && this.context.srfparentkey) {
                Object.assign(this.viewparams, { srfparentkey: this.context.srfparentkey });
            }
            this.handleCustomViewData();
            this.handleOtherViewData();
            return;
        }
        const keys = [];
        let matchArray = [];
        if ((_b = this.$route) === null || _b === void 0 ? void 0 : _b.matched) {
            const path = this.$route.matched[this.$route.matched.length - 1].path;
            const curReg = this.$pathToRegExp.pathToRegexp(path, keys);
            matchArray = curReg.exec(this.$route.path);
        }
        let tempValue = {};
        keys.forEach((item, index) => {
            if (matchArray[index + 1]) {
                Object.defineProperty(tempValue, item.name, {
                    enumerable: true,
                    value: decodeURIComponent(matchArray[index + 1]),
                });
            }
        });
        ViewTool.formatRouteParams(tempValue, this.$route, this.context, this.viewparams);
        if (inputvalue && ModelTool.getViewAppEntityCodeName(this.viewInstance)) {
            Object.assign(this.context, { [ModelTool.getViewAppEntityCodeName(this.viewInstance).toLowerCase()]: inputvalue });
        }
        if (this.viewInstance && ModelTool.getViewAppEntityCodeName(this.viewInstance)) {
            Object.assign(this.context, { srfsessionid: Util.createUUID() });
        }
        if (this.viewparams.srfinsttag && this.viewparams.srfinsttag2 && this.modelService) {
            let dynainstParam = this.modelService.getDynaInsConfig();
            Object.assign(this.context, { srfdynainstid: dynainstParam.id });
        }
        if (this.viewparams && this.viewparams.srfdynainstid) {
            Object.assign(this.context, { srfdynainstid: this.viewparams.srfdynainstid });
        }
        // 补充沙箱实例参数（路由）
        if (this.viewparams && this.viewparams.hasOwnProperty('srfsandboxtag')) {
            Object.assign(this.context, { srfsandboxtag: this.viewparams.srfsandboxtag });
        }
        this.handleCustomViewData();
        this.handleOtherViewData();
    }
    /**
     * 处理自定义视图数据
     *
     * @memberof ViewBase
     */
    handleCustomViewData() {
        this.handleviewRes();
        if (this.customViewNavContexts.length > 0) {
            this.customViewNavContexts.forEach((item) => {
                let tempContext = {};
                let curNavContext = item;
                this.handleCustomDataLogic(curNavContext, tempContext, item.key);
                Object.assign(this.context, tempContext);
            });
        }
        if (this.customViewParams.length > 0) {
            this.customViewParams.forEach((item) => {
                let tempParam = {};
                let curNavParam = item;
                this.handleCustomDataLogic(curNavParam, tempParam, item.key);
                Object.assign(this.viewparams, tempParam);
            });
        }
    }
    /**
     * 处理其他数据(多实例)
     *
     * @memberof ViewBase
     */
    handleOtherViewData() {
        let appEnvironment = AppServiceBase.getInstance().getAppEnvironment();
        if (appEnvironment.bDynamic && this.modelService) {
            let dynainstParam = this.modelService.getDynaInsConfig();
            if (dynainstParam) {
                Object.assign(this.viewparams, { srfinsttag: dynainstParam.instTag, srfinsttag2: dynainstParam.instTag2 });
            }
        }
    }
    /**
     * 处理指定视图控制关系将父键转为父实体上下文
     *
     * @memberof ViewBase
     */
    async handleviewRes() { }
    /**
     * 处理自定义视图数据逻辑
     *
     * @memberof ViewBase
     */
    handleCustomDataLogic(curNavData, tempData, item) {
        // 直接值直接赋值
        if (curNavData.rawValue) {
            if (Object.is(curNavData.value, 'null') || Object.is(curNavData.value, '')) {
                Object.defineProperty(tempData, item.toLowerCase(), {
                    value: null,
                    writable: true,
                    enumerable: true,
                    configurable: true,
                });
            }
            else {
                Object.defineProperty(tempData, item.toLowerCase(), {
                    value: curNavData.value,
                    writable: true,
                    enumerable: true,
                    configurable: true,
                });
            }
        }
        else {
            // 先从导航上下文取数，没有再从导航参数（URL）取数，如果导航上下文和导航参数都没有则为null
            if (this.context[curNavData.value.toLowerCase()] != null) {
                Object.defineProperty(tempData, item.toLowerCase(), {
                    value: this.context[curNavData.value.toLowerCase()],
                    writable: true,
                    enumerable: true,
                    configurable: true,
                });
            }
            else {
                if (this.viewparams[curNavData.value.toLowerCase()] != null) {
                    Object.defineProperty(tempData, item.toLowerCase(), {
                        value: this.viewparams[curNavData.value.toLowerCase()],
                        writable: true,
                        enumerable: true,
                        configurable: true,
                    });
                }
                else {
                    Object.defineProperty(tempData, item.toLowerCase(), {
                        value: null,
                        writable: true,
                        enumerable: true,
                        configurable: true,
                    });
                }
            }
        }
    }
    /**
     *  计数器刷新
     *
     * @memberof ViewBase
     */
    counterRefresh(arg) {
        if (this.counterServiceArray && this.counterServiceArray.length > 0) {
            this.counterServiceArray.forEach((item) => {
                let counterService = item.service;
                if (counterService && counterService.refreshCounterData && counterService.refreshCounterData instanceof Function) {
                    const tempParams = Util.deepCopy(this.viewparams);
                    if (arg && Object.keys(arg).length > 0) {
                        Object.assign(tempParams, arg);
                    }
                    counterService.refreshCounterData(this.context, tempParams);
                }
            });
        }
    }
    /**
     * 视图刷新
     *
     * @param {*} args
     * @memberof ViewBase
     */
    refresh(args) {
        var _a, _b, _c;
        const refs = this.$refs;
        const modelData = (_a = this.staticProps) === null || _a === void 0 ? void 0 : _a.modeldata;
        try {
            if (refs && modelData && modelData.xDataControlName && refs[modelData.xDataControlName]) {
                (_c = (_b = refs[modelData.xDataControlName]) === null || _b === void 0 ? void 0 : _b.ctrl) === null || _c === void 0 ? void 0 : _c.refresh(args);
            }
        }
        catch (error) {
            LogUtil.log(refs, modelData);
        }
    }
    /**
     *  关闭视图
     *
     * @memberof ViewBase
     */
    closeView(args) {
        let view = this;
        // if (window.opener && Boolean(this.$store.getters['getCustomParamByTag']('srffullscreen'))) {
        //     window.opener.postMessage({ type: 'CLOSE', data: args }, '*');
        //     window.close();
        //     return;
        // }
        if (view.viewdata) {
            view.$emit('view-event', { action: 'viewdataschange', data: Array.isArray(args) ? args : [args] });
            view.$emit('view-event', { action: 'close', data: Array.isArray(args) ? args : [args] });
        }
        else {
            if (this.viewInstance && this.viewInstance.viewStyle && Object.is(this.viewInstance.viewStyle, 'STYLE2')) {
                this.closeViewWithStyle2(view);
            }
            else {
                this.closeViewWithDefault(view);
            }
        }
        // 视图关闭从导航栈里面删除数据
        this.navDataService.removeNavDataLast();
    }
    /**
     * 关闭视图(视图样式为style2样式)
     *
     * @view {*} 当前视图
     * @memberof ViewBase
     */
    closeViewWithStyle2(view) {
        var _a;
        const navHistory = AppServiceBase.getInstance().getAppNavDataService();
        const item = navHistory.historyList[navHistory.findHistoryIndex(view.$route)];
        navHistory.remove(item);
        if (navHistory.historyList.length > 0) {
            if (navHistory.isRouteSame(item.to, this.$route)) {
                let go = navHistory.historyList[navHistory.historyList.length - 1].to;
                this.$router.push({ path: go.path, params: go.params, query: go.query });
            }
        }
        else {
            const path = window.sessionStorage.getItem(AppServiceBase.getInstance().getAppEnvironment().AppName);
            if (path) {
                this.$router.push({ path: path });
            }
            else {
                const name = (_a = this.$route) === null || _a === void 0 ? void 0 : _a.matched[0].name;
                const param = this.$route.params[name];
                const path = `/${name}${param ? `/${param}` : ''}`;
                this.$router.push({ path });
            }
        }
    }
    /**
     * 关闭视图(视图样式为默认样式)
     *
     * @view {*} 当前视图
     * @memberof ViewBase
     */
    closeViewWithDefault(view) {
        view.$store.commit('deletePage', view.$route.fullPath);
        const length = view.$store.state.historyPathList.length;
        if (length > 0) {
            const path = view.$store.state.historyPathList[length - 1];
            if (Object.is(path, view.$route.fullPath)) {
                return;
            }
            const index = view.$store.state.pageTagList.findIndex((page) => Object.is(page.fullPath, path));
            if (index >= 0) {
                const page = view.$store.state.pageTagList[index];
                view.$router.push({
                    path: page.path,
                    params: page.params,
                    query: page.query,
                });
            }
        }
        else {
            let path = window.sessionStorage.getItem(AppServiceBase.getInstance().getAppEnvironment().AppName);
            if (path) {
                this.$router.push({ path: path });
            }
            else {
                this.$router.push('/');
            }
        }
    }
    /**
     * 初始化工具栏数据
     *
     * @memberof ViewBase
     */
    initViewToolBar() { }
    /**
     * 渲染视图头部视图消息
     *
     * @memberof ViewBase
     */
    renderTopMessage() {
        var _a, _b;
        const msgDetails = this.viewMessageService.getViewMsgDetails('TOP');
        if (msgDetails.length == 0) {
            return null;
        }
        const topStyle = (_a = this.viewInstance.getPSAppViewMsgGroup()) === null || _a === void 0 ? void 0 : _a.topStyle;
        return (<div slot='topMessage' class='view-top-message'>
        <app-alert position='TOP' showStyle={topStyle} messageDetails={msgDetails} context={Util.deepCopy(this.context)} viewparam={Util.deepCopy(this.viewparam)} infoGroup={(_b = this.viewInstance.getPSAppViewMsgGroup()) === null || _b === void 0 ? void 0 : _b.codeName} viewname={this.viewInstance.codeName.toLowerCase()}></app-alert>
      </div>);
    }
    /**
     * 渲染视图Body视图消息
     *
     * @memberof ViewBase
     */
    renderBodyMessage() {
        var _a, _b;
        const msgDetails = this.viewMessageService.getViewMsgDetails('BODY');
        if (msgDetails.length == 0) {
            return null;
        }
        const bodyStyle = (_a = this.viewInstance.getPSAppViewMsgGroup()) === null || _a === void 0 ? void 0 : _a.bodyStyle;
        return (<div slot='bodyMessage' class='view-body-message'>
        <app-alert position='BODY' showStyle={bodyStyle} messageDetails={msgDetails} context={Util.deepCopy(this.context)} viewparam={Util.deepCopy(this.viewparam)} infoGroup={(_b = this.viewInstance.getPSAppViewMsgGroup()) === null || _b === void 0 ? void 0 : _b.codeName} viewname={this.viewInstance.codeName.toLowerCase()}></app-alert>
      </div>);
    }
    /**
     * 渲染视图底部视图消息
     *
     * @memberof ViewBase
     */
    renderBottomMessage() {
        var _a, _b;
        const msgDetails = this.viewMessageService.getViewMsgDetails('BOTTOM');
        if (msgDetails.length == 0) {
            return null;
        }
        const bottomStyle = (_a = this.viewInstance.getPSAppViewMsgGroup()) === null || _a === void 0 ? void 0 : _a.bottomStyle;
        return (<div slot='bottomMessage' class='view-bottom-message'>
        <app-alert position='BOTTOM' showStyle={bottomStyle} messageDetails={msgDetails} context={Util.deepCopy(this.context)} viewparam={Util.deepCopy(this.viewparam)} infoGroup={(_b = this.viewInstance.getPSAppViewMsgGroup()) === null || _b === void 0 ? void 0 : _b.codeName} viewname={this.viewInstance.codeName.toLowerCase()}></app-alert>
      </div>);
    }
    /**
     * 渲染视图主体内容区
     *
     * @memberof ViewBase
     */
    renderMainContent() { }
    /**
     * 工具栏点击
     *
     * @param ctrl 部件
     * @param action  行为
     * @param data 数据
     * @param $event 事件源对象
     *
     * @memberof ViewBase
     */
    handleItemClick(data, $event) { }
    /**
     * 计算目标部件所需参数
     *
     * @param {string} [controlType]
     * @returns
     * @memberof ViewBase
     */
    computeTargetCtrlData(controlInstance) {
        let targetCtrlName = `app-control-shell`;
        let targetCtrlParam = {
            staticProps: {
                viewState: this.viewState,
                viewtag: this.viewtag,
                containerInstance: this.viewInstance,
                modelData: controlInstance,
                ref: controlInstance.name,
                viewLoadingService: this.viewLoadingService,
                viewDefaultUsage: this.viewDefaultUsage,
            },
            dynamicProps: {
                viewparams: this.viewparams,
                context: this.context,
                viewCtx: this.viewCtx,
            },
        };
        Object.defineProperty(targetCtrlParam.staticProps, 'containerInstance', { enumerable: false, writable: true });
        Object.defineProperty(targetCtrlParam.staticProps, 'modelData', { enumerable: false, writable: true });
        let targetCtrlEvent = {
            'ctrl-event': ({ controlname, action, data }) => {
                this.onCtrlEvent(controlname, action, data);
            },
            closeView: ($event) => {
                this.closeView($event);
            },
        };
        return { targetCtrlName: targetCtrlName, targetCtrlParam: targetCtrlParam, targetCtrlEvent: targetCtrlEvent };
    }
    /**
     *  绘制标题栏
     *
     * @memberof ViewBase
     */
    renderCaptionBar() {
        const captionBar = ModelTool.findPSControlByName('captionbar', this.viewInstance.getPSControls());
        if (this.viewInstance.showCaptionBar) {
            return (<div slot='layout-captionbar' class='app-captionbar-container'>
          <app-default-captionbar viewModelData={this.viewInstance} modelData={captionBar} context={this.context} viewparam={this.viewparam}></app-default-captionbar>
        </div>);
        }
    }
    /**
     *  绘制信息栏
     *
     * @memberof ViewBase
     */
    renderDataInfoBar() {
        const datainfoBar = ModelTool.findPSControlByName('datainfobar', this.viewInstance.getPSControls());
        return (<div slot='layout-datainfobar' class='app-datainfobar-container'>
        <app-default-datainfobar modelData={datainfoBar} viewInfo={this.model} context={this.context} viewparam={this.viewparam}></app-default-datainfobar>
      </div>);
    }
    /**
     * 部件事件
     *
     * @param controlname 部件名称
     * @param action  行为
     * @param data 数据
     *
     * @memberof ViewBase
     */
    onCtrlEvent(controlname, action, data) {
        const _this = this;
        if (action == 'controlIsMounted') {
            this.setIsMounted(controlname);
        }
        else {
            if (Object.is(action, 'authlimit')) {
                this.renderShade();
            }
            else {
                if (controlname && action && this.viewTriggerLogicMap.get(`${controlname.toLowerCase()}-${action.toLowerCase()}`)) {
                    if (this.viewTriggerLogicMap.get(`${controlname.toLowerCase()}-${action.toLowerCase()}`)) {
                        this.viewTriggerLogicMap
                            .get(`${controlname.toLowerCase()}-${action.toLowerCase()}`)
                            .executeAsyncUILogic({ arg: data, utils: this.viewCtx, app: this.viewCtx.app, view: this, ctrl: this.$refs[controlname].ctrl })
                            .then((args) => {
                            if (args && (args === null || args === void 0 ? void 0 : args.hasOwnProperty('srfret')) && !args.srfret) {
                                return;
                            }
                            if (this.engine) {
                                this.engine.onCtrlEvent(controlname, action, data);
                            }
                        });
                    }
                }
                else {
                    if (this.engine) {
                        this.engine.onCtrlEvent(controlname, action, data);
                    }
                }
            }
        }
    }
    /**
     * 渲染内容区
     *
     * @memberof ViewBase
     */
    renderContent() { }
    /**
     * 绘制遮罩
     *
     * @memberof ViewBase
     */
    renderShade() {
        const currentViewKey = `${this.viewInstance.codeName}`;
        const el = currentViewKey ? document.getElementById(currentViewKey) : null;
        if (el) {
            el.classList.add('no-authority-shade');
            const shade = document.createElement('div');
            shade.setAttribute('class', 'no-authority-shade-child');
            el.appendChild(shade);
        }
    }
    /**
     * 初始化视图逻辑
     *
     * @memberof ViewBase
     */
    async initViewLogic(opts) {
        if (opts.getPSAppViewLogics() && opts.getPSAppViewLogics().length > 0) {
            opts.getPSAppViewLogics().forEach((element) => {
                var _a, _b, _c;
                // 目标逻辑类型类型为实体界面逻辑、系统预置界面逻辑、前端扩展插件、脚本代码
                if (element &&
                    element.logicTrigger &&
                    (Object.is(element.logicType, 'DEUILOGIC') || Object.is(element.logicType, 'SYSVIEWLOGIC') || Object.is(element.logicType, 'PFPLUGIN') || Object.is(element.logicType, 'SCRIPT'))) {
                    switch (element.logicTrigger) {
                        case 'TIMER':
                            this.viewTriggerLogicMap.set(element.name.toLowerCase(), new AppTimerEngine(element));
                            break;
                        case 'CTRLEVENT':
                            if ((element === null || element === void 0 ? void 0 : element.getPSViewCtrlName()) && (element === null || element === void 0 ? void 0 : element.eventNames)) {
                                this.viewTriggerLogicMap.set(`${(_a = element.getPSViewCtrlName()) === null || _a === void 0 ? void 0 : _a.toLowerCase()}-${(_b = element.eventNames) === null || _b === void 0 ? void 0 : _b.toLowerCase()}`, new AppCtrlEventEngine(element));
                            }
                            break;
                        case 'VIEWEVENT':
                            if (element === null || element === void 0 ? void 0 : element.eventNames) {
                                this.viewTriggerLogicMap.set(`${(_c = element.eventNames) === null || _c === void 0 ? void 0 : _c.toLowerCase()}`, new AppViewEventEngine(element));
                            }
                            break;
                        default:
                            console.log(`视图${element.logicTrigger}类型暂未支持`);
                            break;
                    }
                }
                // 绑定用户自定义事件
                if (element.eventNames && element.eventNames.toLowerCase().startsWith(this.registerEventSeparator)) {
                    this.$on(element.eventNames, (...args) => {
                        var _a;
                        this.handleViewCustomEvent((_a = element.name) === null || _a === void 0 ? void 0 : _a.toLowerCase(), null, args);
                    });
                }
            });
        }
    }
    /**
     * 处理视图自定义事件
     *
     * @memberof ViewBase
     */
    handleViewCustomEvent(name, data, args) {
        if (this.viewTriggerLogicMap.get(name)) {
            this.viewTriggerLogicMap.get(name).executeAsyncUILogic({
                arg: { sender: this, navContext: this.context, navParam: this.viewparams, navData: this.navdatas, data: data, args: args },
                utils: this.viewCtx,
                app: this.viewCtx.app,
                view: this,
            });
        }
    }
    /**
     * 处理视图定时器逻辑
     *
     * @memberof ViewBase
     */
    handleTimerLogic() {
        if (this.viewTriggerLogicMap && this.viewTriggerLogicMap.size > 0) {
            for (let item of this.viewTriggerLogicMap.values()) {
                if (item && item instanceof AppTimerEngine) {
                    item.executeAsyncUILogic({
                        arg: { sender: this, navContext: this.context, navParam: this.viewparams, navData: this.navdatas, data: null },
                        utils: this.viewCtx,
                        app: this.viewCtx.app,
                        view: this,
                    });
                }
            }
        }
    }
    /**
     * 销毁视图定时器逻辑
     *
     * @memberof ViewBase
     */
    destroyLogicTimer() {
        if (this.viewTriggerLogicMap && this.viewTriggerLogicMap.size > 0) {
            for (let item of this.viewTriggerLogicMap.values()) {
                if (item && item instanceof AppTimerEngine) {
                    item.destroyTimer();
                }
            }
        }
    }
}
__decorate([
    Prop()
], ViewBase.prototype, "dynamicProps", void 0);
__decorate([
    Prop()
], ViewBase.prototype, "staticProps", void 0);
__decorate([
    Watch('dynamicProps', {
        immediate: true,
    })
], ViewBase.prototype, "watchDynamicPropsChange", null);
__decorate([
    Watch('staticProps', {
        immediate: true,
    })
], ViewBase.prototype, "watchStaticPropsChange", null);
