app-default-treegridexview-layout.tsx 3.5 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
import { Prop, Component } from 'vue-property-decorator';
import { IPSAppDETreeGridExView } from '@ibiz/dynamic-model-api';
import { ModelTool } from 'ibiz-core';
import { AppDefaultMDViewLayout } from "../app-default-mdview-layout/app-default-mdview-layout";

@Component({})
export class AppDefaultTreeGridExViewLayout extends AppDefaultMDViewLayout {

	/**
	 * 实体树表格视图模型对象
	 *
	 * @type {IPSAppDETreeGridExView}
	 * @memberof AppDefaultTreeGridExViewLayout
	 */
	@Prop() public declare viewInstance: IPSAppDETreeGridExView;

	/**
	 * 引擎初始化
	 *
	 * @param {*} [opts={}]
	 * @memberof AppDefaultTreeGridExViewLayout
	 */
	public engineInit(opts: any = {}) {
		const controls: any[] = this.containerModel.getPSControls() || [];
		const treeGridEx = ModelTool.findPSControlByType('TREEGRIDEX', controls);
		if (treeGridEx) {
			let engineOpts = Object.assign({
				view: this,
				p2k: '0',
				isLoadDefault: this.viewInstance?.loadDefault,
				keyPSDEField: this.appDeCodeName.toLowerCase(),
				majorPSDEField: this.appDeMajorFieldName.toLowerCase(),
				opendata: (args: any[], fullargs?: any[], params?: any, $event?: any, xData?: any) => {
					this.opendata(args, fullargs, params, $event, xData);
				},
				newdata: (args: any[], fullargs?: any[], params?: any, $event?: any, xData?: any) => {
					this.newdata(args, fullargs, params, $event, xData);
				},
				treegridex: (this.$refs[treeGridEx.name] as any).ctrl,
			}, opts);
			//  搜索表单
            const searchForm = ModelTool.findPSControlByType('SEARCHFORM', controls);
            if (searchForm && searchForm.name && this.$refs[searchForm.name]) {
                engineOpts.searchform = ((this.$refs[searchForm.name] as any).ctrl);
            }
            //  快速搜索表单
            const quickSearchForm = ModelTool.findPSControlByName('quicksearchform', controls);
            if (quickSearchForm && quickSearchForm.name && this.$refs[quickSearchForm.name]) {
                engineOpts.quicksearchform = ((this.$refs[quickSearchForm.name] as any).ctrl);
            }
            //  搜索栏
            const searchBar = ModelTool.findPSControlByType('SEARCHBAR', controls);
            if (searchBar && searchBar.name && this.$refs[searchBar.name]) {
                engineOpts.searchbar = ((this.$refs[searchBar.name] as any).ctrl);
            }
			this.engine.init(engineOpts);
		}
	}

	/**
	 * 计算目标部件所需参数
	 *
	 * @param {any} [controlInstance] 部件模型实例
	 * @returns
	 * @memberof AppDefaultTreeGridExViewLayout
	 */
	public computeTargetCtrlData(controlInstance: any, args?: any) {
		const { targetCtrlName, targetCtrlParam, targetCtrlEvent } = super.computeTargetCtrlData(controlInstance, args);
		// 合并视图级参数
		Object.assign(targetCtrlParam.staticProps, { viewState: this.viewState, viewtag: this.viewtag, viewIsProxyMode: this.viewProxyMode });
		Object.assign(targetCtrlEvent, {
			closeView: ($event: any) => {
				this.$emit('view-event', { viewName: this.viewInstance.codeName, action: 'viewClosed', data: $event });
			}
		})
		// 合并多数据视图级参数
		if (Object.is(controlInstance.controlType, 'SEARCHFORM') || Object.is(controlInstance.controlType, 'SEARCHBAR')) {
			Object.assign(targetCtrlParam.dynamicProps, {
				isExpandSearchForm: this.isExpandSearchForm
			});
		} else {
			Object.assign(targetCtrlParam.staticProps, {
				mDCtrlActiveMode: (this.viewInstance as any).mDCtrlActiveMode,
			});
		}
		return { targetCtrlName: targetCtrlName, targetCtrlParam: targetCtrlParam, targetCtrlEvent: targetCtrlEvent };
	}
}