import { CodeListServiceBase, throttle, LogUtil, ModelTool, Util, ViewTool } from '@ibizstudio/runtime';
import { AppViewLogicService } from '../app-service';
import { MainControlBase } from './main-control-base';
import elementResizeDetectorMaker from 'element-resize-detector';
/**
 * 导航栏部件基类
 *
 * @export
 * @class ExpBarControlBase
 * @extends {MainControlBase}
 */
export class ExpBarControlBase extends MainControlBase {
    constructor() {
        super(...arguments);
        /**
         * 视图唯一标识
         *
         * @type {boolean}
         * @memberof ExpBarControlBase
         */
        this.viewUID = '';
        /**
         * 搜素值
         *
         * @type {(string)}
         * @memberof ExpBarControlBase
         */
        this.searchText = '';
        /**
         * 呈现模式，可选值：horizontal或者vertical
         *
         * @public
         * @type {(string)}
         * @memberof ExpBarControlBase
         */
        this.showMode = '';
        /**
         * 控件宽度
         *
         * @type {number}
         * @memberof ExpBarControlBase
         */
        this.ctrlWidth = 0;
        /**
         * 控件高度
         *
         * @type {number}
         * @memberof ExpBarControlBase
         */
        this.ctrlHeight = 0;
        /**
         * 分割宽度
         *
         * @type {number}
         * @memberof ExpBarControlBase
         */
        this.split = 0.3;
        /**
         * 导航视图名称
         *
         * @type {*}
         * @memberof ExpBarControlBase
         */
        this.navViewName = {};
        /**
         * 导航参数
         *
         * @type {*}
         * @memberof ExpBarControlBase
         */
        this.navParam = {};
        /**
         * 导航上下文参数
         *
         * @type {*}
         * @memberof ExpBarControlBase
         */
        this.navigateContext = {};
        /**
         * 导航视图参数
         *
         * @type {*}
         * @memberof ExpBarControlBase
         */
        this.navigateParams = {};
        /**
         * 导航过滤项
         *
         * @type {string}
         * @memberof ExpBarControlBase
         */
        this.navFilter = '';
        /**
         * 导航关系
         *
         * @type {string}
         * @memberof ExpBarControlBase
         */
        this.navPSDer = '';
        /**
         * 选中数据
         *
         * @type {*}
         * @memberof ExpBarControlBase
         */
        this.selection = {};
        /**
         * 快速分组是否有抛值
         *
         * @memberof ExpBarControlBase
         */
        this.isEmitQuickGroupValue = false;
        /**
         * 快速分组模型
         *
         * @memberof ExpBarControlBase
         */
        this.quickGroupModel = [];
        /**
         * 备份当前分割宽度
         *
         * @memberof ExpBarControlBase
         */
        this.copySplit = 0;
    }
    /**
     * 监听静态参数变化
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof ExpBarControlBase
     */
    onStaticPropsChange(newVal, oldVal) {
        this.viewUID = newVal.viewUID;
        this.sideBarlayout = newVal.sideBarLayout ? newVal.sideBarLayout : 'LEFT';
        super.onStaticPropsChange(newVal, oldVal);
    }
    /**
     * 部件模型数据初始化实例
     *
     * @memberof ExpBarControlBase
     */
    async ctrlModelInit(args) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
        await super.ctrlModelInit();
        this.xDataControlName = this.controlInstance.xDataControlName;
        this.$xDataControl = ModelTool.findPSControlByName(this.xDataControlName, this.controlInstance.getPSControls());
        this.showMode = this.sideBarlayout && this.sideBarlayout == 'LEFT' ? 'horizontal' : 'vertical';
        this.showBusyIndicator = (_a = this.controlInstance) === null || _a === void 0 ? void 0 : _a.showBusyIndicator;
        this.ctrlWidth = (_b = this.controlInstance) === null || _b === void 0 ? void 0 : _b.width;
        if (((_d = (_c = this.$xDataControl) === null || _c === void 0 ? void 0 : _c.getPSNavigateContexts) === null || _d === void 0 ? void 0 : _d.call(_c)) && ((_g = (_f = (_e = this.$xDataControl) === null || _e === void 0 ? void 0 : _e.getPSNavigateContexts) === null || _f === void 0 ? void 0 : _f.call(_e)) === null || _g === void 0 ? void 0 : _g.length) > 0) {
            this.navigateContext = Util.formatNavParam(this.$xDataControl.getPSNavigateContexts());
        }
        if (((_j = (_h = this.$xDataControl) === null || _h === void 0 ? void 0 : _h.getPSNavigateParams) === null || _j === void 0 ? void 0 : _j.call(_h)) && ((_m = (_l = (_k = this.$xDataControl).getPSNavigateParams) === null || _l === void 0 ? void 0 : _l.call(_k)) === null || _m === void 0 ? void 0 : _m.length) > 0) {
            this.navigateParams = Util.formatNavParam(this.$xDataControl.getPSNavigateParams());
        }
        await this.handleXDataCtrlOptions();
    }
    /**
     * 处理数据部件参数
     *
     * @memberof ExpBarControlBase
     */
    async handleXDataCtrlOptions() {
        this.parentModel = this.controlInstance.getParentPSModelObject();
        if (this.parentModel && this.parentModel.enableQuickGroup) {
            await this.loadQuickGroupModel();
        }
    }
    /**
     * 部件初始化
     *
     * @param {*} [args]
     * @memberof ExpBarControlBase
     */
    ctrlInit(args) {
        super.ctrlInit(args);
        this.initCtrlToolBar();
    }
    viewStateAction(tag, action, data) {
        if (!Object.is(tag, this.name)) {
            return;
        }
        super.viewStateAction(tag, action, data);
        if (this.$xDataControl) {
            this.viewState.next({ tag: this.xDataControlName, action: action, data: data });
        }
    }
    /**
     * 设置导航区工具栏禁用状态
     *
     * @param {boolean} state
     * @return {*}
     * @memberof ExpBarControlBase
     */
    calcToolbarItemState(state) {
        let _this = this;
        const models = _this.toolbarModels;
        if (models && models.length > 0) {
            for (const key in models) {
                if (!models.hasOwnProperty(key)) {
                    return;
                }
                const _item = models[key];
                if (_item.uiaction && (Object.is(_item.uiaction.actionTarget, 'SINGLEKEY') || Object.is(_item.uiaction.actionTarget, 'MULTIKEY'))) {
                    _item.disabled = state;
                }
                _item.visabled = true;
                if (_item.noprivdisplaymode && _item.noprivdisplaymode === 6) {
                    _item.visabled = false;
                }
            }
            this.calcNavigationToolbarState();
        }
    }
    /**
     * 加载快速分组模型
     *
     * @memberof ExpBarControlBase
     */
    async loadQuickGroupModel() {
        var _a;
        let quickGroupCodeList = this.parentModel.getQuickGroupPSCodeList();
        await ((_a = quickGroupCodeList === null || quickGroupCodeList === void 0 ? void 0 : quickGroupCodeList.fill) === null || _a === void 0 ? void 0 : _a.call(quickGroupCodeList));
        let codeListService = new CodeListServiceBase({ $store: this.$store });
        if (!(quickGroupCodeList && quickGroupCodeList.codeName)) {
            return;
        }
        try {
            let res = await codeListService.getDataItems({ tag: quickGroupCodeList.codeName, type: quickGroupCodeList.codeListType, codeList: quickGroupCodeList, context: this.context });
            this.quickGroupModel = [...this.handleDynamicData(Util.deepCopy(res))];
        }
        catch (error) {
            LogUtil.log(`----${quickGroupCodeList.codeName}----${this.$t('app.commonwords.codenotexist')}`);
        }
    }
    /**
     * 处理快速分组模型动态数据部分(%xxx%)
     *
     * @param {Array<any>} inputArray 代码表数组
     * @return {*}
     * @memberof ExpBarControlBase
     */
    handleDynamicData(inputArray) {
        if (inputArray.length > 0) {
            const defaultSelect = this.getQuickGroupDefaultSelect();
            if (defaultSelect) {
                let select = inputArray.find((item) => {
                    return item.value === defaultSelect.value;
                });
                if (select)
                    select.default = true;
            }
            inputArray.forEach((item) => {
                if (item.data && Object.keys(item.data).length > 0) {
                    Object.keys(item.data).forEach((name) => {
                        let value = item.data[name];
                        if (value && typeof value == 'string' && value.startsWith('%') && value.endsWith('%')) {
                            const key = value.substring(1, value.length - 1).toLowerCase();
                            if (this.context[key]) {
                                value = this.context[key];
                            }
                            else if (this.viewparams[key]) {
                                value = this.viewparams[key];
                            }
                        }
                        item.data[name] = value;
                    });
                }
            });
        }
        return inputArray;
    }
    /**
     * 获取快速分组默认选中项
     *
     * @memberof ExpBarControlBase
     */
    getQuickGroupDefaultSelect() {
        var _a, _b;
        const codeListItems = ((_b = (_a = this.parentModel) === null || _a === void 0 ? void 0 : _a.getQuickGroupPSCodeList()) === null || _b === void 0 ? void 0 : _b.getPSCodeItems()) || [];
        let defaultSelect = null;
        if (codeListItems.length > 0) {
            for (const item of codeListItems) {
                const childItems = item.getPSCodeItems() || [];
                if (childItems.length > 0) {
                    defaultSelect = childItems.find((_item) => {
                        return _item.default;
                    });
                }
                if (item.default || defaultSelect) {
                    defaultSelect = item;
                    break;
                }
            }
        }
        return defaultSelect;
    }
    /**
     * 初始化工具栏数据
     *
     * @memberof ExpBarControlBase
     */
    initCtrlToolBar() {
        let targetViewToolbarItems = [];
        const toolbar = ModelTool.findPSControlByType('TOOLBAR', this.controlInstance.getPSControls() || []);
        if (toolbar) {
            const toolbarItems = toolbar.getPSDEToolbarItems() || [];
            toolbarItems.forEach((item) => {
                var _a, _b, _c, _d;
                const img = item.getPSSysImage();
                const css = item.getPSSysCss();
                let itemModel = {
                    name: item.name,
                    showCaption: item.showCaption,
                    showIcon: item.showIcon,
                    tooltip: this.$tl((_a = item.getTooltipPSLanguageRes()) === null || _a === void 0 ? void 0 : _a.lanResTag, item.tooltip),
                    iconcls: (_b = item.getPSSysImage()) === null || _b === void 0 ? void 0 : _b.cssClass,
                    icon: (_c = item.getPSSysImage()) === null || _c === void 0 ? void 0 : _c.glyph,
                    caption: this.$tl((_d = item.getCapPSLanguageRes()) === null || _d === void 0 ? void 0 : _d.lanResTag, item.caption),
                    disabled: false,
                    itemType: item.itemType,
                    visabled: true,
                    getPSSysImage: img ? { cssClass: img.cssClass, imagePath: img.imagePath } : '',
                };
                if (item.itemType && item.itemType == 'DEUIACTION') {
                    const uiAction = item.getPSUIAction();
                    Object.assign(itemModel, {
                        actiontarget: item.uIActionTarget,
                        noprivdisplaymode: item.data,
                        dataaccaction: uiAction === null || uiAction === void 0 ? void 0 : uiAction.dataAccessAction,
                        uiaction: {
                            tag: uiAction === null || uiAction === void 0 ? void 0 : uiAction.uIActionTag,
                            target: uiAction === null || uiAction === void 0 ? void 0 : uiAction.actionTarget,
                        },
                    });
                    //TODO YY 表格工具栏
                }
                targetViewToolbarItems.push(itemModel);
            });
        }
        this.toolbarModels = targetViewToolbarItems;
    }
    /**
     * split值变化事件
     *
     * @memberof ExpBarControlBase
     */
    onSplitChange() {
        var _a, _b;
        if (this.split) {
            this.$store.commit('setViewSplit', { viewUID: `${(_a = this.parentModel) === null || _a === void 0 ? void 0 : _a.codeName}_${(_b = this.controlInstance) === null || _b === void 0 ? void 0 : _b.codeName}`, viewSplit: this.split });
        }
    }
    /**
     * 初始化导航参数
     *
     * @param params 初始化参数
     * @memberof ExpBarControlBase
     */
    initNavParam(params) {
        if (params && params.length > 0) {
            let navParams = {};
            params.forEach((param) => {
                const navParam = {
                    [param.key]: param.rawValue ? param.value : '%' + param.value + '%',
                };
                Object.assign(navParams, navParam);
            });
            return navParams;
        }
        else {
            return null;
        }
    }
    /**
     * 部件挂载
     *
     * @param args 额外参数
     * @memberof ExpBarControlBase
     */
    ctrlMounted(args) {
        var _a, _b;
        super.ctrlMounted(args);
        const tempSplit = this.$store.getters.getViewSplit(`${(_a = this.parentModel) === null || _a === void 0 ? void 0 : _a.codeName}_${(_b = this.controlInstance) === null || _b === void 0 ? void 0 : _b.codeName}`);
        let expBarContainer = this.$refs['exp-bar-container'];
        if (expBarContainer) {
            const erd = elementResizeDetectorMaker();
            this.resizeSplit = this.resizeSplit.bind(this);
            erd.listenTo(expBarContainer, this.resizeSplit);
        }
        if (tempSplit) {
            this.split = Number(tempSplit);
        }
        else {
            this.calcSplit();
        }
    }
    /**
     * @description 计算split值
     * @memberof ExpBarControlBase
     */
    calcSplit() {
        var _a, _b, _c, _d, _e, _f;
        let splitDom = this.$refs[`${this.appDeCodeName}-${(_b = (_a = this.controlInstance) === null || _a === void 0 ? void 0 : _a.codeName) === null || _b === void 0 ? void 0 : _b.toLowerCase()}`];
        let containerWidth = (_c = splitDom === null || splitDom === void 0 ? void 0 : splitDom.$el) === null || _c === void 0 ? void 0 : _c.offsetWidth;
        let containerHeight = (_d = splitDom === null || splitDom === void 0 ? void 0 : splitDom.$el) === null || _d === void 0 ? void 0 : _d.offsetHeight;
        if (Object.is(this.showMode, 'horizontal')) {
            if (this.ctrlWidth && containerWidth) {
                this.split = this.ctrlWidth / containerWidth;
            }
        }
        else {
            if (this.ctrlHeight && containerHeight) {
                this.split = this.ctrlHeight / containerHeight;
            }
        }
        this.$store.commit('setViewSplit', { viewUID: `${(_e = this.parentModel) === null || _e === void 0 ? void 0 : _e.codeName}_${(_f = this.controlInstance) === null || _f === void 0 ? void 0 : _f.codeName}`, viewSplit: this.split });
    }
    /**
     * @description 重新计算split值
     * @memberof ExpBarControlBase
     */
    resizeSplit() {
        this.calcSplit();
        this.$forceUpdate();
    }
    /**
     * 绘制数据部件
     *
     * @memberof ExpBarControlBase
     */
    renderXDataControl() {
        let { targetCtrlName, targetCtrlParam, targetCtrlEvent } = this.computeTargetCtrlData(this.$xDataControl);
        return this.$createElement(targetCtrlName, { props: targetCtrlParam, ref: this.xDataControlName, on: targetCtrlEvent });
    }
    /**
     * 计算目标部件所需参数
     *
     * @param {*} controlInstance 数据部件
     * @return {*}
     * @memberof ExpBarControlBase
     */
    computeTargetCtrlData(controlInstance) {
        const { targetCtrlName, targetCtrlParam, targetCtrlEvent } = super.computeTargetCtrlData(controlInstance);
        Object.assign(targetCtrlParam.staticProps, {
            isSelectFirstDefault: true,
            isSingleSelect: true,
        });
        return { targetCtrlName: targetCtrlName, targetCtrlParam: targetCtrlParam, targetCtrlEvent: targetCtrlEvent };
    }
    /**
     * 执行搜索
     *
     * @memberof ExpBarControlBase
     */
    onSearch() { }
    /**
     * 绘制快速搜索
     *
     * @memberof ExpBarControlBase
     */
    renderSearch() {
        const appDataEntity = this.controlInstance.getPSAppDataEntity();
        const getQuickSearchPlaceholader = (entity) => {
            let placeholder = '';
            const fields = entity.getQuickSearchPSAppDEFields() || [];
            fields.forEach((field, index) => {
                var _a;
                const _field = entity.findPSAppDEField(field.codeName);
                if (_field) {
                    placeholder += this.$tl((_a = _field.getLNPSLanguageRes()) === null || _a === void 0 ? void 0 : _a.lanResTag, _field.logicName) + (index === fields.length - 1 ? '' : ', ');
                }
            });
            return placeholder;
        };
        return (<div class='search-container'>
        <i-input search={true} on-on-change={($event) => {
                this.searchText = $event.target.value;
            }} placeholder={getQuickSearchPlaceholader(appDataEntity)} on-on-search={($event) => this.onSearch()}></i-input>
      </div>);
    }
    /**
     * 绘制快速分组
     *
     * @memberof ExpBarControlBase
     */
    renderQuickGroup() {
        var _a, _b;
        const enableCounter = this.controlInstance.enableCounter;
        if (enableCounter) {
            let counterService;
            let sysCounter = (_a = this.parentModel) === null || _a === void 0 ? void 0 : _a.getPSAppCounterRef();
            if (sysCounter === null || sysCounter === void 0 ? void 0 : sysCounter.id) {
                counterService = (_b = Util.findElementByField(this.counterServiceArray, 'id', sysCounter.id)) === null || _b === void 0 ? void 0 : _b.service;
            }
            return <app-quick-group items={this.quickGroupModel} counterService={counterService} on-valuechange={(value) => this.quickGroupValueChange(value)}></app-quick-group>;
        }
        else {
            return <app-quick-group items={this.quickGroupModel} on-valuechange={(value) => this.quickGroupValueChange(value)}></app-quick-group>;
        }
    }
    /**
     * 绘制工具栏
     *
     * @memberof ExpBarControlBase
     */
    renderToolbar() {
        return (<view-toolbar slot='toolbar' toolbarModels={this.toolbarModels} counterServiceArray={this.counterServiceArray} on-item-click={(data, $event) => {
                throttle(this.handleItemClick, [data, $event], this);
            }}></view-toolbar>);
    }
    /**
     * 工具栏点击
     *
     * @param {*} data 事件数据
     * @param {*} $event 事件对象
     * @return {*}
     * @memberof ExpBarControlBase
     */
    handleItemClick(data, $event) {
        var _a;
        if (this.Environment && this.Environment.isPreviewMode) {
            return;
        }
        AppViewLogicService.getInstance().executeViewLogic(`${(_a = this.controlInstance.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()}_toolbar_${data.tag}_click`, $event, this, undefined, this.controlInstance.getPSAppViewLogics() || []);
    }
    /**
     * 快速分组值变化
     *
     * @param {*} $event 分组事件源
     * @return {*}
     * @memberof ExpBarControlBase
     */
    quickGroupValueChange($event) {
        if (this.Environment && this.Environment.isPreviewMode) {
            return;
        }
        if ($event && $event.data) {
            if (this.quickGroupData) {
                for (let key in this.quickGroupData) {
                    delete this.viewparams[key];
                }
            }
            this.quickGroupData = $event.data;
            Object.assign(this.viewparams, $event.data);
        }
        else {
            if (this.quickGroupData) {
                for (let key in this.quickGroupData) {
                    delete this.viewparams[key];
                }
            }
        }
        if (this.isEmitQuickGroupValue) {
            this.onSearch();
        }
        this.isEmitQuickGroupValue = true;
    }
    /**
     * 计算导航工具栏权限状态
     *
     * @memberof ExpBarControlBase
     */
    calcNavigationToolbarState() {
        let _this = this;
        if (_this.toolbarModels) {
            ViewTool.calcActionItemAuthState({}, this.toolbarModels, this.appUIService);
        }
    }
    /**
     * 刷新
     *
     * @memberof ExpBarControlBase
     */
    refresh() {
        var _a;
        if (this.$xDataControl) {
            const xDataControl = this.$refs[`${(_a = this.xDataControlName) === null || _a === void 0 ? void 0 : _a.toLowerCase()}`].ctrl;
            if (xDataControl && xDataControl.refresh && xDataControl.refresh instanceof Function) {
                xDataControl.refresh();
            }
        }
    }
    /**
     * 选中数据事件
     *
     *
     * @param {any[]} args 选中数据
     * @return {*}  {void}
     * @memberof ExpBarControlBase
     */
    onSelectionChange(args) {
        var _a, _b, _c, _d, _e, _f;
        let tempContext = {};
        let tempViewParam = {};
        if (args.length === 0) {
            this.calcToolbarItemState(true);
            return;
        }
        const arg = args[0];
        if (this.context) {
            Object.assign(tempContext, Util.deepCopy(this.context));
        }
        if (this.$xDataControl) {
            const appDataEntity = (_a = this.$xDataControl) === null || _a === void 0 ? void 0 : _a.getPSAppDataEntity();
            if (appDataEntity) {
                Object.assign(tempContext, { [`${(_b = appDataEntity.codeName) === null || _b === void 0 ? void 0 : _b.toLowerCase()}`]: arg[(_c = appDataEntity.codeName) === null || _c === void 0 ? void 0 : _c.toLowerCase()] });
                Object.assign(tempContext, { srfparentdename: appDataEntity.codeName, srfparentdemapname: appDataEntity === null || appDataEntity === void 0 ? void 0 : appDataEntity.getPSDEName(), srfparentkey: arg[(_d = appDataEntity.codeName) === null || _d === void 0 ? void 0 : _d.toLowerCase()] });
                if (this.navFilter && !Object.is(this.navFilter, '')) {
                    Object.assign(tempViewParam, { [this.navFilter]: arg[(_e = appDataEntity.codeName) === null || _e === void 0 ? void 0 : _e.toLowerCase()] });
                }
                if (this.navPSDer && !Object.is(this.navPSDer, '')) {
                    Object.assign(tempViewParam, { [this.navPSDer]: arg[(_f = appDataEntity.codeName) === null || _f === void 0 ? void 0 : _f.toLowerCase()] });
                }
            }
            if (this.navigateContext && Object.keys(this.navigateContext).length > 0) {
                let _context = this.$util.computedNavData(arg, tempContext, tempViewParam, this.navigateContext);
                Object.assign(tempContext, _context);
            }
            if (this.navigateParams && Object.keys(this.navigateParams).length > 0) {
                let _params = this.$util.computedNavData(arg, tempContext, tempViewParam, this.navigateParams);
                Object.assign(tempViewParam, _params);
            }
            this.selection = {};
            Object.assign(tempContext, { viewpath: this.navViewName });
            Object.assign(this.selection, { view: { viewname: 'app-view-shell' }, context: tempContext, viewparam: tempViewParam });
            this.calcToolbarItemState(false);
            if (this.expDom && this.selection) {
                this.expDom.className = 'ivu-split-horizontal openedit';
                this.split = this.copySplit;
            }
            this.$forceUpdate();
            this.$emit('ctrl-event', { controlname: this.controlInstance.name, action: 'selectionchange', data: args });
        }
    }
    /**
     * load完成事件
     *
     * @param {*} args 加载数据
     * @param {string} [tag]
     * @param {*} [$event2]
     * @memberof ExpBarControlBase
     */
    onLoad(args, tag, $event2) {
        this.calcToolbarItemState(true);
        if (this.$xDataControl) {
            this.$emit('ctrl-event', { controlname: this.xDataControlName, action: 'load', data: args });
        }
    }
    /**
     * 部件事件
     * @param ctrl 部件
     * @param action  行为
     * @param data 数据
     *
     * @memberof ExpBarControlBase
     */
    onCtrlEvent(controlname, action, data) {
        if (controlname && Object.is(controlname, this.xDataControlName)) {
            switch (action) {
                case 'selectionchange':
                    this.onSelectionChange(data);
                    return;
                case 'load':
                    this.onLoad(data, action);
                    return;
            }
        }
        super.onCtrlEvent(controlname, action, data);
    }
    /**
     * 关闭编辑视图
     *
     * @memberof ExpBarControlBase
     */
    close() {
        this.expDom = document.getElementsByClassName('ivu-split-horizontal')[1];
        if (this.expDom) {
            this.expDom.className = 'ivu-split-horizontal closeedit';
        }
        this.selection = {};
        this.copySplit = this.split;
        this.split = 1;
    }
    /**
     * 绘制导航标题栏
     *
     * @memberof ExpBarControlBase
     */
    renderTitleBar() {
        var _a, _b, _c;
        const classStr = `${(_a = this.$xDataControl.controlType) === null || _a === void 0 ? void 0 : _a.toLowerCase()}-exp-bar`;
        const title = this.$tl((_b = this.controlInstance.getTitlePSLanguageRes()) === null || _b === void 0 ? void 0 : _b.lanResTag, (_c = this.controlInstance) === null || _c === void 0 ? void 0 : _c.title);
        return (<div class={`${classStr}-header`}>
        <div class={`${classStr}-title`}>
          <icon type='ios-home-outline'/>
          <span>{title}</span>
        </div>
      </div>);
    }
    /**
     * 绘制右侧导航组件
     *
     * @memberof ExpBarControlBase
     */
    renderNavView() {
        var _a;
        if (((_a = this.selection) === null || _a === void 0 ? void 0 : _a.view) && !Object.is(this.selection.view.viewname, '')) {
            if (!this.cacheUUID || this.cacheUUID.indexOf(this.selection.context.viewpath) == -1) {
                this.cacheUUID = this.selection.context.viewpath + Util.createUUID();
            }
            let targetCtrlParam = {
                staticProps: {
                    viewDefaultUsage: false,
                },
                dynamicProps: {
                    viewparam: JSON.stringify(this.selection.viewparam),
                    viewdata: JSON.stringify(this.selection.context),
                },
            };
            return this.$createElement('app-view-shell', {
                key: this.cacheUUID,
                class: 'viewcontainer2',
                props: targetCtrlParam,
                on: {
                    close: (data) => {
                        this.close();
                    },
                },
            });
        }
    }
    /**
     * 绘制内容
     *
     * @param {*} [otherClassNames] 额外类名
     * @return {*}
     * @memberof ExpBarControlBase
     */
    renderContent(otherClassNames) {
        var _a, _b, _c, _d, _e, _f;
        const { showTitleBar, enableSearch } = this.controlInstance;
        let enableQuickGroup = (_a = this.parentModel) === null || _a === void 0 ? void 0 : _a.enableQuickGroup;
        const controlType = (_b = this.$xDataControl) === null || _b === void 0 ? void 0 : _b.controlType;
        let classNames = {
            [`${controlType === null || controlType === void 0 ? void 0 : controlType.toLowerCase()}-exp-bar-content`]: showTitleBar ? true : false,
            [`${controlType === null || controlType === void 0 ? void 0 : controlType.toLowerCase()}-exp-bar-content2`]: !showTitleBar ? true : false,
            'has-search': enableSearch ? true : false,
        };
        if (otherClassNames) {
            Object.assign(classNames, otherClassNames);
        }
        let viewStyle = (_e = (_d = (_c = this.controlInstance) === null || _c === void 0 ? void 0 : _c.getParentPSModelObject) === null || _d === void 0 ? void 0 : _d.call(_c)) === null || _e === void 0 ? void 0 : _e.viewStyle;
        return [
            viewStyle == 'DEFAULT' && this.sideBarlayout == 'LEFT' ? (<div slot='trigger' class='trigger'>
          <div class='user-trigger'>
            <i class='el-icon-arrow-left'></i>
          </div>
        </div>) : null,
            <div slot={this.sideBarlayout == 'LEFT' ? 'left' : 'top'}>
        {showTitleBar ? this.renderTitleBar() : null}
        <div class={{ 'container-header': true, 'no-title': !showTitleBar ? true : false }}>
          {enableQuickGroup && ((_f = this.quickGroupModel) === null || _f === void 0 ? void 0 : _f.length) > 0 ? this.renderQuickGroup() : null}
          {enableSearch ? this.renderSearch() : null}
          {ModelTool.findPSControlByType('TOOLBAR', this.controlInstance.getPSControls() || []) ? this.renderToolbar() : null}
        </div>
        <div class={classNames}>{this.$xDataControl ? this.renderXDataControl() : null}</div>
      </div>,
            <div slot={this.sideBarlayout == 'LEFT' ? 'right' : 'bottom'}>{this.renderNavView()}</div>,
        ];
    }
    /**
     * 绘制导航栏主体内容
     *
     * @memberof ExpBarControlBase
     */
    renderMainContent() {
        var _a, _b, _c, _d;
        if (!this.controlIsLoaded) {
            return null;
        }
        return (<div ref='exp-bar-container' style='width: 100%; height: 100%' class='exp-bar-container'>
        <split ref={`${this.appDeCodeName}-${(_a = this.controlInstance.codeName) === null || _a === void 0 ? void 0 : _a.toLowerCase()}`} id={(_b = this.controlInstance.codeName) === null || _b === void 0 ? void 0 : _b.toLowerCase()} class={['expbarcontrol', `app-${(_c = this.$xDataControl.controlType) === null || _c === void 0 ? void 0 : _c.toLowerCase()}-exp-bar`, (_d = this.renderOptions) === null || _d === void 0 ? void 0 : _d.controlClassNames]} v-model={this.split} mode={this.sideBarlayout == 'LEFT' ? 'horizontal' : 'vertical'} on-on-move-end={this.onSplitChange.bind(this)}>
          {this.renderContent()}
        </split>
      </div>);
    }
    /**
     * 绘制导航栏主内容
     * @returns {*}
     * @memberof ExpBarControlBase
     */
    render() {
        if (!this.controlIsLoaded) {
            return null;
        }
        return this.renderMainContent();
    }
}
