import { IPSAppDEPickupView, IPSDEPickupViewPanel } from '@ibiz/dynamic-model-api'; import { MPickupViewEngine, ModelTool, throttle, MPickUpViewInterface, Util } from 'ibiz-core'; import { MainViewBase } from './mainview-base'; /** * 数据多项选择视图基类 * * @export * @class MPickUpViewBase * @extends {MainViewBase} * @implements {MPickUpViewInterface} */ export class MPickUpViewBase extends MainViewBase implements MPickUpViewInterface { /** * 视图实例 * * @memberof MPickUpViewBase */ public declare viewInstance: IPSAppDEPickupView; /** * 引擎对象 * * @type {MPickupViewEngine} * @memberof MPickUpViewBase */ public declare engine: MPickupViewEngine; /** * 选择视图面板实例 * * @memberof MPickUpViewBase */ public pickUpViewPanelInstance!: IPSDEPickupViewPanel; /** * 是否显示按钮 * * @type {boolean} * @memberof MPickUpViewBase */ public isShowButton: boolean = true; /** * 选中数据的字符串 * * @type {string} * @memberof MPickUpViewBase */ public selectedData: string = ""; /** * 视图选中数据 * * @type {any[]} * @memberof MPickUpViewBase */ public viewSelections: any[] = []; /** * 部件模型 * * @type {*} * @memberof MPickUpViewBase */ public ctrlModel: any = {}; /** * 监听部件动态参数变化 * * @param {*} newVal * @param {*} oldVal * @memberof MPickUpViewBase */ 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 MPickUpViewBase */ public onStaticPropsChange(newVal: any, oldVal: any) { this.isShowButton = newVal?.isShowButton !== false; super.onStaticPropsChange(newVal, oldVal); } /** * 引擎初始化 * * @public * @memberof MPickUpViewBase */ public engineInit(): void { if (this.Environment && this.Environment.isPreviewMode) { return; } let engineOpts = ({ view: this, p2k: '0', pickupViewPanel: (this.$refs[this.pickUpViewPanelInstance?.name] as any).ctrl, keyPSDEField: this.appDeCodeName.toLowerCase(), majorPSDEField: this.appDeMajorFieldName.toLowerCase(), }); this.engine.init(engineOpts); } /** * 初始化分页导航视图实例 * * @memberof MPickUpViewBase */ public async viewModelInit() { this.viewInstance = (this.staticProps?.modeldata) as IPSAppDEPickupView; await super.viewModelInit(); this.pickUpViewPanelInstance = ModelTool.findPSControlByType("PICKUPVIEWPANEL", this.viewInstance.getPSControls()); } /** * 初始化容器模型 * * @param {*} opts * @memberof MPickUpViewBase */ 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 MPickUpViewBase */ public onCLickLeft(): void { if (this.engine) { this.engine.toLeft(); } } /** * 添加左侧选中数据 * * @memberof MPickUpViewBase */ public onCLickRight(): void { if (this.engine) { this.engine.toRight(); } } /** * 选中数据全部删除 * * @memberof MPickUpViewBase */ public onCLickAllLeft(): void { if (this.Environment && this.Environment.isPreviewMode) { return; } if (this.engine) { this.engine.toAllLeft(); } } /** * 添加左侧面板所有数据到右侧 * * @memberof MPickUpViewBase */ public onCLickAllRight(): void { if (this.Environment && this.Environment.isPreviewMode) { return; } if (this.engine) { this.engine.toAllRight(); } } /** * 确定 * * @memberof MPickUpViewBase */ public onClickOk(): void { if (this.engine) { this.engine.ok(this.viewSelections); } } /** * 取消 * * @memberof MPickUpViewBase */ public onClickCancel(): void { if (this.engine) { this.engine.cancel(); } } /** * 渲染视图主体内容区 * * @memberof MPickUpViewBase */ public renderMainContent() { return (