import { IPSAppDEPickupView, IPSDEPickupViewPanel, IPSTreeExpBar } from '@ibiz/dynamic-model-api'; import { ModelTool, throttle, MPickupView2Engine, MPickUpView2Interface, Util, IParams } from 'ibiz-core'; import { MainViewBase } from './mainview-base'; /** * 数据多项选择视图(左右关系)基类 * * @export * @class MPickUpView2Base * @extends {MainViewBase} */ export class MPickUpView2Base extends MainViewBase implements MPickUpView2Interface { /** * 视图实例 * * @memberof MPickUpView2Base */ public declare viewInstance: IPSAppDEPickupView; /** * 选择视图面板实例 * * @memberof MPickUpView2Base */ public pickupViewPanelInstance!: IPSDEPickupViewPanel; /** * 树导航部件 * * @type {IPSTreeExpBar} * @memberof MPickUpView2Base */ public treeExpBarInstance!: IPSTreeExpBar; /** * 是否显示按钮 * * @type {boolean} * @memberof MPickUpView2Base */ public isShowButton: boolean = true; /** * 选中数据的字符串 * * @type {string} * @memberof MPickUpView2Base */ public selectedData: string = ""; /** * 是否初始化已选中项 * * @type {any[]} * @memberof MPickUpView2Base */ public isInitSelected: boolean = false; /** * 视图选中数据 * * @type {any[]} * @memberof MPickUpView2Base */ public viewSelections: any[] = []; /** * 分隔值 * * @type {number} * @memberof MPickUpView2Base */ public split: number = 0.2; /** * 导航项 * * @type {*} * @memberof MPickUpView2Base */ public navItem: any; /** * 是否单选 * * @type {boolean} * @memberof MPickUpView2Base */ public isSingleSelect: boolean = false; /** * 部件模型 * * @type {IParams} * @memberof MPickUpView2Base */ public ctrlModel: IParams = {}; /** * 监听部件动态参数变化 * * @param {*} newVal * @param {*} oldVal * @memberof MPickUpView2Base */ public onDynamicPropsChange(newVal: any, oldVal: any) { super.onDynamicPropsChange(newVal, oldVal); if (this.viewparams?.selectedData) { this.selectedData = JSON.stringify(this.viewparams.selectedData); this.viewSelections = this.viewparams.selectedData; } } /** * 监听部件静态参数变化 * * @param {*} newVal * @param {*} oldVal * @memberof MPickUpView2Base */ public onStaticPropsChange(newVal: any, oldVal: any) { this.isShowButton = newVal?.isShowButton !== false; super.onStaticPropsChange(newVal, oldVal); } /** * 引擎初始化 * * @public * @memberof MPickUpView2Base */ public engineInit(): void { if (this.Environment && this.Environment.isPreviewMode) { return; } let engineOpts = ({ view: this, p2k: '0', treeExpBar: (this.$refs[this.treeExpBarInstance?.name] as any).ctrl, pickupViewPanel: (this.$refs[this.pickupViewPanelInstance?.name] as any)?.ctrl, keyPSDEField: this.appDeCodeName.toLowerCase(), majorPSDEField: this.appDeMajorFieldName.toLowerCase(), }); this.engine.init(engineOpts); } /** * 视图初始化 * * @memberof MPickUpView2Base */ public async containerMounted() { super.containerMounted(); this.initSplit(); } /** * 初始化容器模型 * * @param {*} opts * @memberof MPickUpView2Base */ public initContainerModel(opts: any) { super.initContainerModel(opts); const { modeldata } = opts; modeldata?.getPSControls().forEach((ctrl: any) => { this.ctrlModel[ctrl.name] = { name: `${ctrl.name}`, type: `${ctrl.controlType}` }; }); } /** * 初始化分页导航视图实例 * * @memberof MPickUpView2Base */ public async viewModelInit() { this.viewInstance = (this.staticProps?.modeldata) as IPSAppDEPickupView; await super.viewModelInit(); this.pickupViewPanelInstance = ModelTool.findPSControlByType("PICKUPVIEWPANEL", this.viewInstance.getPSControls()); this.treeExpBarInstance = ModelTool.findPSControlByType('TREEEXPBAR', this.viewInstance.getPSControls()); } /** * 渲染视图底部按钮 * @memberof MPickUpView2Base */ public renderFooter() { return ( this.isShowButton ?
: null ) } /** * 渲染按钮 * * @memberof MPickUpView2Base */ public renderButtons() { return [