incloud开发文档 5.1.0 Help

BtnFunDefine 权限按钮

用来生成调用表单的权限按钮。

权限按钮,用于台账需要设置权限的操作,包括不限于 新增 修改 删除。

一功能按钮和流程按钮页面展示

BtnFunDefine图标
01图

BtnFunDefine图标
02图

代码示例-->一般按钮注册

//创建文件夹funboxs,并创建add.ts 和 index.ts文件 在add.ts文件中设计添加功能脚本 import {FunBoxUtils} from '@platform-lib/base' import {missionManageAddApi} from '../api' export const add: any = { code: 'add', mode: 'drawer', formUrl: '/web-client/html/mission-manage-form.html', buttons: { 'addBtn': { position: 'right', name: '暂存', script: 'add', props: { theme: 'primary' } }, 'isIssueBtn': { position: 'right', name: '下发', script: 'isIssue', props: { theme: 'primary' } }, }, scripts: { init: { isAsync: true, // 02图页面初始化调用方法 code: async (request: any, utils: FunBoxUtils) => { // 刚进页面显示加载状态 utils.setLoading(true) // 这里可以给页面赋初始值 例如: await utils.setFormValue({ demo: 0 }) // 赋值完毕结束加载状态 utils.setLoading(false) } }, add: { isAsync: true, // 02图点击暂存触发事件 code: async (request: any, utils: FunBoxUtils) => { // 获取表单数据 const params = {...utils.getFormValue()} // 这里可以调用暂存方法 例如: await missionManageAddApi(params).then((r: any) => { // 消息提醒方法 utils.message('success', { content: '添加成功' }) }).finally(() => { utils.setLoading(false) }) // 页面回调 utils.complete() }, }, isIssue: { isAsync: true, // 02图点击下发触发事件 code: async (request: any, utils: FunBoxUtils) => { // 获取表单数据 const params = {...utils.getFormValue()} // 这里可以调用暂存方法 例如: await missionManageAddApi(params).then((r: any) => { // 消息提醒方法 utils.message('success', { content: '下发成功' }) }).finally(() => { utils.setLoading(false) }) // 页面回调 utils.complete() }, }, } } // 在index.ts 文件中注册添加按钮 import { ButtonFun } from "@platform-lib/base"; import { add } from "./add" const AddButton = ButtonFun.register({ code: 'add', name: '新增', descr: '新增任务', //表单左上角标题 funBox: add }) // 在APP.vue 文件中引用添加按钮 <template> <t-layout> <t-header> <t-space size="small"> <AddButton theme="primary" modalWidth="100%"></AddButton> </t-space> </t-header> <t-content> // 本段代码为01图表格,此处仅作展示使用,以实际代码为准 <vxe-grid v-bind="bind" ref="gridRef"></vxe-grid> </t-content> </t-layout> </template> <script setup lang="tsx"> import {AddButton } from "./funboxs/index" //回调页面方法 inject<any>('MittIns').on('fn-complete', (c: any) => { }) </script>

代码示例-->流程按钮注册

// 在funboxs文件夹下创建 add-wf.ts文件 import {FunBoxUtils} from '@platform-lib/base' export const addWf: any = { camundaDefKey: 'ceshiliucheng', //流程key scripts: { init: { isAsync: false, // 页面初始化触发 code: (request: any, utils: FunBoxUtils) => { } }, } } // 在index.ts 文件中注册添加按钮 import { ButtonFun } from "@platform-lib/base"; import { addWf } from "./addWf" export const AddWfButton = ButtonFun.register({ code: 'addWf', name: '新增', descr: '测试工作流新增', addwf:addWf }) // 在APP.vue 文件中引用流程添加按钮 <template> <t-layout> <t-header> <t-space size="small"> //params 为传给表单的参数 <AddWfButton theme="primary" modalWidth="100%" :params="['6677']"></AddWfButton> </t-space> </t-header> <t-content> // 本段代码为01图表格,此处仅作展示使用,以实际代码为准 <vxe-grid v-bind="bind" ref="gridRef"></vxe-grid> </t-content> </t-layout> </template> <script setup lang="tsx"> import { AddWfButton } from "./funboxs/index" </script>

自定义按钮页面展示

BtnFunDefine图标
03图

代码示例-->自定义按钮注册

// 在index.ts中直接注册自定义按钮 export const CustomButton = ButtonFun.register({ code: 'custom1', name: '自定义功能', }) // 在APP.vue 文件中引用流程添加按钮 <template> //isAuto 是否根据权限过滤 <CustomButton :isAuto="false"> <template #default="test"> <t-button>测试自定义{{ test }}</t-button> </template> </CustomButton> </template> <script setup lang="tsx"> import { CustomButton } from "./funboxs/index" </script>

代码说明

  • 一般按钮

    • 配置一般按钮

      • code ------> 按钮编码(必须有)

      • mode ------> 打开表单方式(drawer抽屉, dialog弹框)

      • formUrl ------> 表单地址(必须有)

      • buttons ------> 表单内的按钮集合

      • scripts ------> 表单和按钮相关脚本

    • 注册一般按钮

      • code ------> 按钮编码

      • name ------> 页面按钮的名称

      • descr ------> 表单页面标题(必须有)

      • funBox ------> 配置页面暴露出去的名称

  • 流程按钮

    • 配置流程按钮

      • camundaDefKey ------> 流程key(必须有)

    • 注册流程按钮

      • code ------> 按钮编码

      • name ------> 页面按钮的名称

      • descr ------> 表单页面标题(必须有)

      • addwf ------> 配置页面暴露出去的名称

  • 自定义按钮

    • 注册自定义按钮

      • code ------> 按钮编码

      • name ------> 按钮名称

    • 使用自定义按钮

      • isAuto ------> 是否根据权限过滤

funBox Props

参数

说明

类型

默认值

取值范围

必传

code

接口编码

string

""

Y

mode

打开方式

string

'drawer'

'drawer'

Y

formUrl

选择打开的from表单

string

""

Y

buttons

按钮footer按钮组

Object

key:0

Y

o[position]

按钮按钮定位

string

left/right

right

Y

o[name]

按钮按钮显示文字

string

Y

o[script]

按钮按钮执行脚本, scripts下属性对应的脚本

string

Y

o[props]

按钮属性, 参考tdesign Button props

Object

N

scripts

按钮对应脚本, key值与o[script] 键匹配

Object

key:0

Y

s[IsAsync]

按钮脚本属性, 是否异步执行

Bool

true/false

false

Y

s[oCode]

按钮脚本属性, 执行脚本

Function

(request: any, utils: FunBoxUtils) => {}

Y

funBox scripts code属性 详情参数 (request: any, utils: FunBoxUtils) => {}

参数

说明

类型

默认值

取值范围

必传

request

Promise 请求方式, 支持参数url, method, data 等

Function

N

utils

封装表单功能的方式, 包含setLoading, setFormValue, getFormValue, setRules, getParams, validate, complete, message, cancel 等

Object

N

AddButton Props

参数

说明

类型

默认值

取值范围

必传

params

接收参数

Array

[]

N

Last modified: 20 一月 2025