import { Component, Prop } from 'vue-property-decorator'; import { message } from 'ant-design-vue'; import { VueLifeCycleProcessing } from '../../../decorators' import { DesignContainerBase } from '../design-container-base/design-container-base'; import './design-group.less'; /** * 表单分组 * * @export * @class DesignGroup * @extends {DragDesignItemBase} */ @Component({}) @VueLifeCycleProcessing() export class DesignGroup extends DesignContainerBase { @Prop() isGridContainerItem?: boolean; /** * @description 删除当前数据 * @param {MouseEvent} e * @return {*} {Promise} * @memberof DesignGroup */ async deleteHandle(e: MouseEvent): Promise { e.stopPropagation(); if ((this.ctrl as any)?.isDefaultLayout) { this.userOperationTips(e); } else { const event: any = (this.ctrl as any).evt; if (event) { event.emit('removePanel', this.data); } const res = await this.service.RemoveTemp(this.ctx.context, this.data); if (res.ok === false) { message.error(res.statusText || ''); return; } this.setSelect(this.parentData); } } /** * @description 绘制子项 * @param {*} item * @return {*} * @memberof DesignGroup */ renderChildItem(item: any) { if (item.isDefaultLayout || item.isCtrls) { return null; } return this.ctx.ctrl.renderChildItem(this.$createElement, this.ctx, item, this.data); } /** * @description 绘制拖拽区 * @param {any[]} list * @param {*} [content] * @return {*} {*} * @memberof DesignGroup */ renderDraggable(list: any[], content?: any): any { const h = this.$createElement; return h( 'draggable', { attrs: { handle: this.options.handle, group: this.options.group, animation: this.options.animation, list: list, }, class: 'draggable-container', on: { change: (e: any) => this.change(e, list), }, }, [ h( 'transition-group', { attrs: { type: 'transition', name: 'flip-list', }, class: this.getDraggableClass(), ...this.getDraggableOtherParams(), }, content, ), ], ); } renderContent(): any { const { text, showcaption, showtitlebar } = this.data; const contentStyle = this.getContentStyle(this.data); const hiddenHeader = showcaption == 0 || showtitlebar == 0; return (
{ this.isGridContainerItem ? (
{`配比-${this.data.flexgrow?this.data.flexgrow:"自适应"}`}
) : hiddenHeader ? (
{text}
) : (
{text}
) } < div class='content' style={contentStyle}> {this.renderDraggable(this.list, this.renderChild())}
); } }