前端 快速查询并替换默认组件

可以借助vue的调试工具快速找到对应的组件,请参考这篇文章 使用vue调试工具快速找到对应的组件

Mask默认组件

前端 快速查询并替换默认组件

重写Mask组件

重写AppSwitcherWidget
import Com from './com.vue'
/**
* SPI注册条件保持根 AppSwitcherWidget 一致,即可覆盖
*/
@SPI.ClassFactory(
  MaskWidget.Token({
    widget: 'app-switcher'
  })
)
export class CustomAppSwitcherWidget extends AppSwitcherWidget {
  /**
  * 如果需要重写vue组件,那么可以通过重写initialize方法来实现,如果是修改数据或者逻辑,那么可以删除这个函数
  */
  public initialize(props: any) {
    super.initialize(props);
    this.setComponent(Com)
    return this
  }
}
重写 MenuWidget
import Com from './com.vue'

/**
* SPI注册条件保持根 MenuWidget 一致,即可覆盖
*/
@SPI.ClassFactory(MaskWidget.Token({ widget: 'nav-menu' }))
export class CustomMenuWidget extends MenuWidget {
  /**
  * 如果需要重写vue组件,那么可以通过重写initialize方法来实现,如果是修改数据或者逻辑,那么可以删除这个函数
  */
  public initialize(props: any) {
    super.initialize(props);
    this.setComponent(Com)
    return this
  }
}
重写 NotificationWidget
import Com from './com.vue'

/**
* SPI注册条件保持根 NotificationWidget 一致,即可覆盖
*/
@SPI.ClassFactory(MaskWidget.Token({ widget: 'notification' }))
export class CustomNotificationWidget extends NotificationWidget {
  /**
  * 如果需要重写vue组件,那么可以通过重写initialize方法来实现,如果是修改数据或者逻辑,那么可以删除这个函数
  */
  public initialize(props: any) {
    super.initialize(props);
    this.setComponent(Com)
    return this
  }
}
重写 LanguageWidget
import Com from './com.vue'

/**
* SPI注册条件保持根 LanguageWidget 一致,即可覆盖
*/
@SPI.ClassFactory(MaskWidget.Token({ widget: 'language' }))
export class CustomLanguageWidget extends LanguageWidget {
  /**
  * 如果需要重写vue组件,那么可以通过重写initialize方法来实现,如果是修改数据或者逻辑,那么可以删除这个函数
  */
  public initialize(props: any) {
    super.initialize(props);
    this.setComponent(Com)
    return this
  }
}
重写 UserWidget
import Com from './com.vue'

/**
* SPI注册条件保持根 UserWidget 一致,即可覆盖
*/
@SPI.ClassFactory(MaskWidget.Token({ widget: 'user' }))
export class CustomUserWidget extends UserWidget {
  /**
  * 如果需要重写vue组件,那么可以通过重写initialize方法来实现,如果是修改数据或者逻辑,那么可以删除这个函数
  */
  public initialize(props: any) {
    super.initialize(props);
    this.setComponent(Com)
    return this
  }
}
重写 BreadcrumbWidget
import Com from './com.vue'

/**
* SPI注册条件保持根 BreadcrumbWidget 一致,即可覆盖
*/
@SPI.ClassFactory(MaskWidget.Token({ widget: 'breadcrumb' }))
export class CustomBreadcrumbWidget extends BreadcrumbWidget {
  /**
  * 如果需要重写vue组件,那么可以通过重写initialize方法来实现,如果是修改数据或者逻辑,那么可以删除这个函数
  */
  public initialize(props: any) {
    super.initialize(props);
    this.setComponent(Com)
    return this
  }

视图默认组件

重写 TableWidget(表格视图)

参考文章https://doc.oinone.top/frontend/18386.html

重写 FormWidget(表单视图)

参考文章https://doc.oinone.top/frontend/18386.html

重写 DetailWidget(详情视图)

参考文章https://doc.oinone.top/frontend/18386.html

重写 SearchWidget(搜索区域视图)

参考文章https://doc.oinone.top/frontend/18386.html

重写 GalleryWidget(画廊视图)

参考文章https://doc.oinone.top/frontend/18386.html

字段默认组件

重写字段组件

参考文章https://doc.oinone.top/frontend/18386.html

动作默认组件

前端 快速查询并替换默认组件

重写 RouterViewActionWidget(路由跳转新视图)
@SPI.ClassFactory(
  ActionWidget.Token({
    actionType: ActionType.View,
    target: ViewActionTarget.Router,
    model: '当前模型编码', // 改成当前动作对应的模型编码(action.model)
    name: '名称' // 当前动作的名称 (action.name)
  })
)
export class CustomRouterViewActionWidget extends RouterViewActionWidget {
  protected async clickAction() {
    return super.clickAction()
  }
}
重写 DialogViewActionWidget(弹窗打开视图)
@SPI.ClassFactory(
  ActionWidget.Token({
    actionType: ActionType.View,
    target: ViewActionTarget.Dialog,
    model: '当前模型编码', // 改成当前动作对应的模型编码(action.model)
    name: '名称' // 当前动作的名称 (action.name)
  })
)
export class CustomDialogViewActionWidget extends DialogViewActionWidget {
  protected async clickAction() {
    return super.clickAction()
  }
}
重写 ServerActionWidget (服务端动作)
@SPI.ClassFactory(
  ActionWidget.Token({
    actionType: ActionType.Server,
    model: '当前模型编码', // 改成当前动作对应的模型编码(action.model)
    name: '名称' // 当前动作的名称 (action.name)
  })
)
export class CustomServerActionWidget extends ServerActionWidget {
  protected async clickAction() {
    return super.clickAction()
  }
}
重写 UrlActionWidget (链接动作)
@SPI.ClassFactory(
  ActionWidget.Token({
    actionType: ActionType.URL,
    model: '当前模型编码', // 改成当前动作对应的模型编码(action.model)
    name: '名称' // 当前动作的名称 (action.name)
  })
)
export class CustomUrlActionWidget extends UrlActionWidget {
  protected async clickAction() {
    return super.clickAction()
  }
重写 客户端动作
@SPI.ClassFactory(
  ActionWidget.Token({
    model: 'resource.k2.Model0000011045', // 改成当前动作对应的模型编码(action.model)
    name: ModelDefaultActionName.$$internal_GotoListTableRouter // name需要取当前动作里面的 fun 属性(action.fun)
  })
)
export class CustomBackActionWidget extends BackActionWidget {
  protected async clickAction() {
    return super.clickAction();
  }
}

Oinone社区 作者:汤乾华原创文章,如若转载,请注明出处:https://doc.oinone.top/other/21531.html

访问Oinone官网:https://www.oinone.top获取数式Oinone低代码应用平台体验

(0)
汤乾华的头像汤乾华数式员工
上一篇 2025年8月13日 pm5:46
下一篇 2025年8月21日 pm2:13

相关推荐

  • 如何通过业务数据拿到工作流用户任务待办

    在模型里面建一个非存储字段,用来传输工作流用户任务待办ID。。 界面设计器把这个字段拖到列表页里,并在跳转动作上配置上下文参数,把任务待办id传到表单页里。 重写教师模型的queryPage,通过业务数据id查询出每条业务数据的工作流用户任务待办id返回给前端。 @Function.Advanced(displayName = "查询教师列表", type = FunctionTypeEnum.QUERY, category = FunctionCategoryEnum.QUERY_PAGE, managed = true) @Function(openLevel = {FunctionOpenEnum.LOCAL, FunctionOpenEnum.REMOTE, FunctionOpenEnum.API}) public Pagination<Teacher> queryPage(Pagination<Teacher> page, IWrapper<Teacher> queryWrapper) { Pagination<Teacher> teacherPagination = new Teacher().queryPage(page, queryWrapper); List<Teacher> content = teacherPagination.getContent(); if (CollectionUtils.isEmpty(content)) { return teacherPagination; } List<Long> teacherIds = content.stream().map(Teacher::getId).collect(Collectors.toList()); List<WorkflowUserTask> workflowUserTasks = Models.data().queryListByWrapper(Pops.<WorkflowUserTask>lambdaQuery() .from(WorkflowUserTask.MODEL_MODEL) .in(WorkflowUserTask::getNodeDataBizId, teacherIds) .orderByDesc(WorkflowUserTask::getCreateDate) ); if (CollectionUtils.isEmpty(workflowUserTasks)) { return teacherPagination; } Map<Long/*业务id*/, WorkflowUserTask> userTaskMap = workflowUserTasks.stream().collect(Collectors.toMap( WorkflowUserTask::getNodeDataBizId, a -> a, (old, n) -> old) ); for (Teacher teacher : content) { if (userTaskMap.containsKey(teacher.getId())) { teacher.setWorkflowUserTaskId(userTaskMap.get(teacher.getId()).getId()); } } return teacherPagination; } 查看效果,任务待办id成功传到表单里面。

    2025年1月10日
    1.7K00
  • 流程和任务状态说明文档

    一、工作流实例状态说明 INIT:新的流程创建时,执行工作流实例前的状态。 PROCESSING:发起的新的流程之后,结束之前的状态。 FINISHED:整个流程结束后的状态。 ERROR:流程异常时的状态。 RECALL: 撤销流程实例时的状态 CLOSE:关闭流程实例时(流程撤销)的状态。 一、工作流实例通过状态说明 FILLED:流程走到填写节点,填写人填写过后的状态。 PASS:审批同意操作后的状态。 REJECT:审批结果被拒绝(审批节点结束后)的状态。 ING:新的流程创建时,执行工作流实例前的状态。 ERROR:流程异常时的状态。 RECALL:撤销流程实例时的状态。 RECALL_PASS:无 RECALL_REJECT:无 RECALL_FILLED:无 FALLBACK:已退回时标识抄送/工作流实例为已退回时的状态。 FALLBACK_PASS:无 FALLBACK_REJECT:无 FALLBACK_FILLED:无 TRANSFER:无 CLOSE:关闭流程实例时((流程撤销))的状态。

    2025年6月24日
    27900
  • 模版名称如何翻译

    导出翻译项: mutation { excelExportTaskMutation { createExportTask( data: { workbookDefinition: { model: "file.ExcelWorkbookDefinition" name: "excelLocationTemplate" } } ) { name } } } { "path": "/file", "lang": "en-US" } 导入翻译项: mutation { excelImportTaskMutation { createImportTask( data: { workbookDefinition: { model: "file.ExcelWorkbookDefinition" name: "excelLocationTemplate" } file: { url: "https://minio.oinone.top/pamirs/upload/zbh/test/2024/06/03/导出国际化配置模板_1717390304285_1717391684633.xlsx" } } ) { name } } } PS:导入自行修改url进行导入

    2025年2月7日
    45400
  • 前端自定义组件之锚点分组

    本文将讲解如何通过自定义,实现锚点组件。这个锚点组件会根据界面设计器拖入的分组,动态解析出锚点。 实现路径 整体的实现思路是界面设计器拖个容器类的组件(这里以选项卡为例),自定义这个选项卡,往选项卡里拖拽的每个分组,每个锚点的名称是分组的标题。 1. 界面设计器拖出页面 我们界面设计器拖个选项卡组件,然后在选项页里拖拽任意多个分组。完成后点击右上角九宫格,选中选项卡,填入组件 api 名称,作用是把选项卡切换成我们自定义的锚点分组组件,这里的 api 名称和自定义组件的 widget 对应。最后发布页面,并绑定菜单。 2. 组件实现 widget 组件重写了选项卡,核心函数 renderGroups,通过 DslRender.render 方法渲染界面设计器拖拽的分组。 import { BasePackWidget, DslDefinition, DslRender, SPI, Widget } from '@oinone/kunlun-dependencies'; import TabsParseGroup from './TabsParseGroup.vue'; function fetchGroupChildren(widgets?: DslDefinition[], level = 1): DslDefinition[] { if (!widgets) { return []; } const children: DslDefinition[] = []; for (const widget of widgets) { if (widget.widget === 'group') { children.push(widget); } else if (level >= 1) { fetchGroupChildren(widget.widgets, level – 1).forEach((child) => children.push(child)); } } return children; } @SPI.ClassFactory( BasePackWidget.Token({ widget: 'TabsParseGroup' }) ) export class TabsParseGroupWidget extends BasePackWidget { public initialize(props) { super.initialize(props); this.setComponent(TabsParseGroup); return this; } // 获取分组的子元素 public get groupChildren(): DslDefinition[] { return fetchGroupChildren(this.template?.widgets); } @Widget.Reactive() public get groupTitles() { return this.groupChildren.map((group) => group.title); } // 根据容器子元素渲染左侧 @Widget.Method() public renderGroups() { if (this.groupChildren && this.groupChildren.length) { return this.groupChildren.map((group) => DslRender.render(group)); } } } vue组件核心内容是用component :is属性,渲染出配置的分组组件 <template> <div class="TabsParseGroup"> <a-anchor :affix="false"> <a-anchor-link v-for="(item, index) in groupTitles" :href="`#default-group-${index}`" :title="item" /> </a-anchor> <div v-for="(item, index) in groupComponents" :id="`default-group-${index}`"> <component :is="item" /> </div> </div> </template> <script lang="ts"> import { computed, defineComponent, PropType } from 'vue'; export default…

    2025年7月8日
    20500

Leave a Reply

登录后才能评论