import { throttle } from '@ibizstudio/runtime'; import { StateWizardPanelControlBase } from '../../../widgets'; import { IPSDEEditForm, IPSDEWizard, IPSDEWizardEditForm, IPSDEWizardStep } from '@ibizstudio/runtime'; export class AppStateWizardPanelBase extends StateWizardPanelControlBase { /** * 绘制步骤标题 * * @memberof AppWizardPanelBase */ renderTitle(step: any, stepForm: string) { return this.$createElement( 'div', { slot: 'title', directives: [ { name: 'popover', arg: `${stepForm}_popover`, }, ], on: { click: () => throttle(this.stepTitleClick, [stepForm], this), }, }, [ {this.activeForm != stepForm && !this.historyForms.includes(stepForm) ? : null} {step.title} , ], ); } /** * 绘制向导面板步骤 * * @memberof AppWizardPanelBase */ renderViewSteps() { const wizardSteps: Array = (this.controlInstance.getPSDEWizard() as IPSDEWizard).getPSDEWizardSteps() || []; if (wizardSteps.length > 0) { return (
throttle(this.handleClick, ['PRE'], this)}>
{wizardSteps.map((step: IPSDEWizardStep) => { const stepForm = this.getStepForm(step); return {this.renderTitle(step, stepForm)}; })}
throttle(this.handleClick, ['NEXT'], this)}>
); } } /** * 绘制表单 * * @memberof AppWizardPanelBase */ renderEditForm(form: IPSDEWizardEditForm) { if (form?.controlType != 'FORM' || form.formFuncMode != 'WIZARDFORM') { return; } let { targetCtrlName, targetCtrlParam, targetCtrlEvent } = this.computeTargetCtrlData(form); Object.assign(targetCtrlParam.staticProps, { viewState: this.wizardState }); return this.$createElement(targetCtrlName, { key: form.codeName, props: targetCtrlParam, ref: form.name, on: targetCtrlEvent }); } /** * 绘制所有表单 * * @memberof AppWizardPanelBase */ renderEditForms() { const editForms: Array = this.controlInstance.getPSDEEditForms() || []; let content: any; if (editForms.length > 0) { content = editForms.map((form: IPSDEEditForm, index: number) => { return (
throttle(this.handleOpen, [form.name], this)}> throttle(this.handleClose, [form.name], this)}>
{form.logicName}
{this.renderEditForm(form as IPSDEWizardEditForm)}
{this.renderStepsFooter(form.name)}
); }); } return content; } /** * 绘制向导面板footer * * @memberof AppWizardPanelBase */ renderStepsFooter(name: string) { return (
{this.isVisiable(name, 'PREV') ? ( throttle(this.onClickPrev, params, this)} type='primary'> ) : null} {this.isVisiable(name, 'NEXT') ? ( throttle(this.onClickNext, params, this)} type='primary' long> {this.$t('app.wizardpanel.next')} ) : null} {this.isVisiable(name, 'FINISH') ? ( throttle(this.onClickFinish, params, this)} type='primary' long> {this.$t('app.wizardpanel.complete')} ) : null}
); } /** * 绘制状态向导面板 * * @memberof AppWizardPanelBase */ render() { if (!this.controlIsLoaded) { return null; } const wizard: IPSDEWizard | null = this.controlInstance.getPSDEWizard(); const controlClassNames = this.renderOptions.controlClassNames; //TODO 表单抽屉 return ( {wizard && (wizard.getPSDEWizardSteps() || []).length > 0 ? [this.renderViewSteps(), this.renderEditForms()] : null} ); } }