import { Vue, Component, Prop } from 'vue-property-decorator'; import { CreateElement } from 'vue'; import { IDesignContext } from '../../interface'; import './design-default-content.less'; /** * 表单设计区容器 * * @export * @class DesignDefaultContent * @extends {Vue} */ @Component({}) export class DesignDefaultContent extends Vue { /** * 表单设计上下文 * * @type {IFromDesignContext} * @memberof DesignDefaultContent */ @Prop() ctx!: IDesignContext; /** * 默认子组件 * * @type {string} * @memberof DesignDefaultContent */ @Prop() childComponent!: string; /** * 表单数据 * * @type {*} * @memberof DesignDefaultContent */ data: any = null; created(): void { this.load(); } async load(): Promise { const loading = (this as any).$loading({ lock: true, text: '加载中...', background: '#ffffffe6', }); const { ctrl } = this.ctx; const data = await ctrl.load(); if (data) { this.data = data; this.$emit('ctrl',data) if (this.data?.mobflag === 1) { Object.assign(this.ctx.context, { mobflag: this.data.mobflag }); } this.ctx.context.formtype = this.data.formtype; if (!this.ctx.context.pssysapp) { this.ctx.context.pssysapp = this.data.pssysappid; } } this.ctx.loaded = true; loading.close(); } /** * 激活主数据 * * @memberof DesignDefaultContent */ activeMasterData(): void { this.ctx.ctrl.select.set(this.data); } /** * 设置mobflag标识 * * @param {number} mobflag * @memberof DesignDefaultContent */ setMobflag(mobflag: number) { this.data.mobflag = mobflag; } renderActions(h: CreateElement) { return (
e.stopPropagation()}>
{ this.setMobflag(0); }} > { this.setMobflag(1); }} >
this.activeMasterData()} >
{ this.ctx.state.setHiddenState(bol); this.$forceUpdate(); }} > 显示 隐藏
); } render(h: CreateElement) { const { select } = this.ctx.ctrl; return (
this.activeMasterData()} > {this.renderActions(h)} {this.data ? (
{this.ctx.loaded ? h(this.childComponent, { props: { ctx: this.ctx } }) : null}
) : null}
); } }