import { throttle, Util } from '@ibizstudio/runtime';
import { KanbanControlBase } from '../../../widgets';
import { IPSUIAction, IPSUIActionGroup, IPSUIActionGroupDetail } from '@ibizstudio/runtime';
/**
* 实体看板部件基类
*
* @export
* @class AppKanbanBase
* @extends {KanbanControlBase}
*/
export class AppKanbanBase extends KanbanControlBase {
/**
* 绘制itemPSLayoutPanel部件
*
* @returns {*}
* @memberof AppKanbanBase
*/
renderItemPSLayoutPanel(item: any) {
let { targetCtrlName, targetCtrlParam, targetCtrlEvent }: { targetCtrlName: string; targetCtrlParam: any; targetCtrlEvent: any } = this.computeTargetCtrlData(
this.controlInstance.getItemPSLayoutPanel(),
item,
);
return this.$createElement(targetCtrlName, { props: targetCtrlParam, ref: this.controlInstance?.getItemPSLayoutPanel?.name, on: targetCtrlEvent });
}
/**
* 绘制折叠栏
*
* @param group 分组
* @param index 下标
* @memberof AppKanbanBase
*/
renderDragbar(group: any, index: any) {
return (
this.onDragChange($event, group?.value)}
>
{!group.folding ? (
throttle(this.onClick, [group, index], this)}>
{this.getGroupText(group?.value)}
{'(' + group?.items?.length + ')'}
) : null}
);
}
/**
* 绘制分组界面行为
*
* @param ActionGroup 分组界面行为组
* @param group 分组类型
* @memberof AppKanbanBase
*/
renderGroupAction(ActionGroup: IPSUIActionGroup | null, group: any) {
return (
{ActionGroup?.getPSUIActionGroupDetails()?.map((uiActionDetail: IPSUIActionGroupDetail) => {
const uiAction = uiActionDetail.getPSUIAction() as IPSUIAction;
if (uiAction) {
return (
throttle(this.uiActionClick, [uiActionDetail, $event, group], this)}>
{uiAction.getPSSysImage()?.imagePath ?
: null}
{uiAction.getPSSysImage()?.cssClass ? : null}
{this.$tl(uiAction.getCapPSLanguageRes()?.lanResTag, uiAction.caption)}
);
}
})}
);
}
renderItemContent(item: any) {
if (this.controlInstance?.getItemPSSysPFPlugin()) {
const pluginInstance: any = this.PluginFactory.getPluginInstance('CONTROLITEM', this.controlInstance?.getItemPSSysPFPlugin()?.pluginCode || '');
if (pluginInstance) {
return pluginInstance.renderCtrlItem(this.$createElement, this.controlInstance, this, item);
}
} else {
return item.srfmajortext;
}
}
/**
* 绘制分组看板
*
* @param group 分组
* @param index 下标
* @memberof AppKanbanBase
*/
renderGroup(group: any, index: any) {
const groupStyle = {
'flex-grow': this.controlInstance?.groupWidth || this.controlInstance.groupHeight ? false : '1',
};
this.controlInstance?.groupWidth ? Object.assign(groupStyle, { width: this.controlInstance?.groupWidth + 'px' }) : null;
this.controlInstance?.groupHeight ? Object.assign(groupStyle, { height: this.controlInstance?.groupHeight + 'px' }) : null;
return group.folding ? (
{group.items.length > 0 ? (
this.onDragChange($event, group.value)}
on-end={() => this.onDragEnd()}
>
{group.items.map((item: any) => {
return (
throttle(this.handleClick, [item], this)}
on-dblclick={() => throttle(this.handleDblClick, [item], this)}
>
{this.controlInstance.getItemPSLayoutPanel() ? this.renderItemPSLayoutPanel(item) : this.renderItemContent(item)}
);
})}
) : (
{this.$tl(this.controlInstance.getEmptyTextPSLanguageRes()?.lanResTag, this.$t('app.commonwords.nodata'))}
)}
) : null;
}
/**
* 绘制部件
*
* @param h
* @memberof AppKanbanBase
*/
render(h: any) {
if (!this.controlIsLoaded) {
return null;
}
const { controlClassNames } = this.renderOptions;
return (
{[
this.groups.map((item, index) => {
if (this.controlInstance?.getGroupPSSysPFPlugin()) {
const pluginInstance: any = this.PluginFactory.getPluginInstance('CONTROLITEM', this.controlInstance.getGroupPSSysPFPlugin()?.pluginCode || '');
if (pluginInstance) {
return pluginInstance.renderCtrlItem(this.$createElement, this.controlInstance, this, item);
}
} else {
return [this.renderDragbar(item, index), this.renderGroup(item, index)];
}
}),
this.renderQuickToolbar(),
]}
);
}
}