前端低无一体使用教程

介绍

客户在使用oinone平台的时候,有一些个性化的前端展示或交互需求,oinone作为开发平台,不可能提前预置好一个跟客户需求一模一样的组件,这个时候我们提供了一个“低无一体”模块,可以反向生成API代码,生成对应的扩展工程和API依赖包,再由专业前端研发人员基于扩展工程(kunlun-sdk),利用API包进行开发并上传至平台,这样就可以在界面设计器的组件里切换为我们通过低无一体自定义的新组件。

低无一体的具体体现
  • “低”--- 指低代码,在sdk扩展工程内编写的组件代码
  • “无”--- 指无代码,在页面设计器的组件功能处新建的组件定义
低无一体的组件跟直接在自有工程内写组件的区别?

低无一体的组件复用性更高,可以在本工程其他页面和其他业务工程中再次使用。

组件、元件介绍

元件 --- 指定视图类型(viewType) + 指定业务类型(ttype)字段的个性化交互展示。
组件 --- 同一类个性化交互展示的元件的集合。
组件是一个大一点的概念,比如常用的 Input 组件,他的元件在表单视图有字符串输入元件密码输入元件,在详情和表格展示的时候就是只读的,页面最终使用的其实是元件。通过组件+ttype+视图类型+是否多值+组件名可以找到符合条件的元件,组件下有多个元件会根据最优匹配规则找到最合适的具体元件。

如何使用低无一体

界面设计器组件管理页面添加组件

数式Oinone低代码-前端低无一体使用教程
数式Oinone低代码-前端低无一体使用教程

进入组件的元件管理页面

数式Oinone低代码-前端低无一体使用教程

点击“添加元件”

数式Oinone低代码-前端低无一体使用教程
数式Oinone低代码-前端低无一体使用教程

设计元件的属性

数式Oinone低代码-前端低无一体使用教程

这里以是否“显示清除按钮”作为自定义属性从左侧拖入到中间设计区域,然后发布

数式Oinone低代码-前端低无一体使用教程

点击“返回组件”

数式Oinone低代码-前端低无一体使用教程

鼠标悬浮到卡片的更多按钮的图标,弹出下拉弹出“低无一体”的按钮

数式Oinone低代码-前端低无一体使用教程

在弹窗内点击“生成SDK”的按钮

数式Oinone低代码-前端低无一体使用教程

生成完成后,点击“下载模板工程”

数式Oinone低代码-前端低无一体使用教程

解压模板工程kunlun-sdk.zip

数式Oinone低代码-前端低无一体使用教程

解压后先查看README.MD,了解一下工程运行要点,可以先运行 npm i 安装依赖

数式Oinone低代码-前端低无一体使用教程

再看kunlun-plugin目录下已经有生成好的组件对应的ts和vue文件

数式Oinone低代码-前端低无一体使用教程
数式Oinone低代码-前端低无一体使用教程
数式Oinone低代码-前端低无一体使用教程

下面在vue文件内增加自定义代码,可以运行 npm run dev 在开发模式下调试看效果

<template>
   <div class="my-form-string-input">
    <oio-input
    :value="realValue"
      @update:value="change"
    >
      <template #prepend>MyPrepend</template>
    </oio-input>
  </div>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
import { OioInput } from '@kunlun/vue-ui-antd';

export default defineComponent({
  name: 'customField1',
  components: { OioInput },
  props: {
    value: {
      type: String
    },
    change: {
    type: Function
  },
  },
  setup(props) {
    const realValue = ref<string | null | undefined>(props.value);

    return { realValue };
  }
});
</script>
<style lang="scss">
.my-form-string-input {
  border: 1px solid red;
}
</style>

确定改好代码后运行 npm run build,生成上传所需的js和css文件

数式Oinone低代码-前端低无一体使用教程

可以看到 kunlun-plugin目录下多出了dist目录,我们需要的是 kunlun-plugin.umd.js 和 kunlun-plugin.css 这2个文件

数式Oinone低代码-前端低无一体使用教程

再次回到组件的“低无一体”管理弹窗页面,上传上面生成的js和css文件,并点击“确定”保存,到这里我们的组件就新增完成了。

数式Oinone低代码-前端低无一体使用教程

下面我们再到页面设计器的页面中使用上面设计的组件(这里的表单页面是提前准备好的,这里就不介绍如何新建表单页面了)

数式Oinone低代码-前端低无一体使用教程

将左侧组件库拉直最底部,可以看到刚刚新建的组件,将其拖至中间设计区域,我们可以看到自定义组件的展示结果跟刚刚的代码是对应上的(ps: 如果样式未生效,请刷新页面查看,因为刚刚上传的js和css文件在页面初始加载的时候才会导入进来,刚刚上传的动作未导入新上传的代码文件),再次点击设计区域中的自定义组件,可以看到右侧属性设置面板也出现了元件设计时拖入的属性。

数式Oinone低代码-前端低无一体使用教程

最后再去运行时的页面查看效果,与代码逻辑一致!

数式Oinone低代码-前端低无一体使用教程

注意事项

为什么我上传了组件后页面未生效?

检查前端启动工程的低无一体是否配置正确

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

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

(1)
汤乾华的头像汤乾华数式员工
上一篇 2023年11月6日 pm2:31
下一篇 2023年11月6日 pm2:34

相关推荐

  • 打开弹窗的action,传入默认的查询条件不生效

    场景 form视图中的action,点击后打开table的弹窗的,xml中配置的filter,但是table查询的时候没有带上查询条件: <action name=”action_name” label=”打开tabel弹窗视图” filter=”id==${activeRecord.id}” /> 解决方案 将xml中的activeRecord修改成openerRecord即可。 <action name=”action_name” label=”打开tabel弹窗视图” filter=”id==${openerRecord.id}” />

    2023年11月1日
    1.2K00
  • OioNotification 通知提醒框

    全局展示通知提醒信息。 何时使用 在系统四个角显示通知提醒信息。经常用于以下情况: 较为复杂的通知内容。 带有交互的通知,给出用户下一步的行动点。 系统主动推送。 API OioNotification.success(title,message, config) OioNotification.error(title,message, config) OioNotification.info(title,message, config) OioNotification.warning(title,message, config) config 参数如下: 参数 说明 类型 默认值 版本 duration 默认 3 秒后自动关闭 number 3 class 自定义 CSS class string –

    2023年12月18日
    80000
  • oio-input 输入框

    代码演示 <oio-input v-model:value="value"></oio-input> API Input 参数 说明 类型 默认值 版本 addonAfter 带标签的 input,设置后置标签 string|slot addonBefore 带标签的 input,设置前置标签 string|slot allowClear 可以点击清除图标删除内容 boolean defaultValue 输入框默认内容 string disabled 是否禁用状态,默认为 false boolean false maxlength 最大长度 number prefix 带有前缀图标的 input slot showCount 是否展示字数 boolean false suffix 带有后缀图标的 input slot type 声明 input 类型,同原生 input 标签的 type 属性,见:MDN(请直接使用 <a-textarea /> 代替 type="textarea")。 string text value(v-model:value) 输入框内容 string Input 事件 事件名称 说明 回调参数 update:value 输入框内容变化时的回调 function(e) pressEnter 按下回车的回调 function(e) Input.Search 代码演示 <oio-input-search v-model:value="value"></oio-input-search> Input.Search 事件 事件名称 说明 回调参数 search 点击搜索或按下回车键时的回调 function(value, event) 其余属性和 Input 一致。

    2023年12月18日
    2.0K00
  • 如何在表格的字段内添加动作

    介绍 在日常的业务中,我们经常需要在表格内直接点击动作完成一些操作,而不是只能在操作栏中,例如:订单的表格内点击商品名称或者里面的按钮跳转到商品详情页面,这里我们将带来大家来通过自定义表格字段来实现这个功能。 1.编写表格字段组件 组件ts文件TableBtnFieldWidget.ts import { ActionWidget, ActiveRecordExtendKeys, BaseFieldWidget, BaseListView, ModelFieldType, queryDslWidget, queryRowActionBar, RowContext, SPI, TableStringFieldWidget, BaseElementListViewWidget, ViewType, Widget } from '@kunlun/dependencies'; import { createVNode, VNode } from 'vue'; import { toString } from 'lodash-es'; import TableBtnField from './TableBtnField.vue'; @SPI.ClassFactory( BaseFieldWidget.Token({ viewType: ViewType.Table, ttype: [ModelFieldType.String, ModelFieldType.Text], // widget: 'StringLink', // 以下3行配置代码测试用,生产建议在界面设计器自定义组件,widget填自定义组件的api名称 model: 'resource.k2.Model0000000109', name: 'name' }) ) export class TableBtnFieldWidget extends TableStringFieldWidget { @Widget.Reactive() private get triggerActionLabel() { // 界面设计器组件内设计该属性 return this.getDsl().triggerActionLabel || '更新'; } private getTriggerAction() { return this.model.modelActions.find((a) => a.label === this.triggerActionLabel); } private getTriggerActionWidget(widgetHandle: string, draftId: string, triggerActionLabel: string): ActionWidget | undefined { const listView = Widget.select(widgetHandle) as unknown as BaseListView; const listWidget = queryDslWidget(listView?.getChildrenInstance(), BaseElementListViewWidget); if (!listWidget) { return undefined; } const rowActionBar = queryRowActionBar(listWidget.getChildrenInstance(), draftId); const actionWidget = rowActionBar?.getChildrenInstance().find((a) => (a as ActionWidget).action.label === triggerActionLabel); return actionWidget as ActionWidget; } protected clickAction(context: RowContext) { const draftId = context.data[ActiveRecordExtendKeys.DRAFT_ID] as unknown as string; const actionWidget = this.getTriggerActionWidget(this.getRootHandle()!, draftId, this.triggerActionLabel); if (!actionWidget) { console.error('未找到action', this.triggerActionLabel); return; } actionWidget.click(); } @Widget.Method() public renderDefaultSlot(context: RowContext): VNode[] | string { const value = toString(this.compute(context)); if (value) { return [ createVNode(TableBtnField,…

    2024年5月16日
    1.1K00
  • 文件上传组件前端校验超128长度大小,不清楚怎么配置

    原因是拼上后端返回的文件全路径后超出了字段的存储长度,后端通过注解@Field.String(size=1024)修改字段的存储长度后重新运行一遍服务。

    2023年11月1日
    84800

Leave a Reply

登录后才能评论