API
使用
ts
import { useCommonCommentApi } from '@yusui/flow-pages'
import { request } from '@/api/request'
// 获取常用意见列表
const { useList } = useCommonCommentApi(request)
const { data: commentList } = useList()
常用意见
ts
import type { Ref } from 'vue'
import type { ResRecords } from '@yusui/types'
import type { RequestInstance } from '../types'
import { useRes } from '@yusui/composables'
/** 常用意见 */
export interface CommonComment {
id?: string
content?: string
type?: string
sort?: number
}
export function useCommonCommentApi(request: RequestInstance) {
const url = {
/** 常用意见列表 */
list: '/sapier-flow/flow-user-common/list',
/** 新增意见 */
save: '/sapier-flow/flow-user-common/save',
/** 更新意见 */
update: '/sapier-flow/flow-user-common/update',
/** 删除意见 */
remove: '/sapier-flow/flow-user-common/remove',
/** 批量更新意见 */
batchUpdate: '/sapier-flow/flow-user-common/batchUpdate',
}
const getList = (type?: string) => request.get<ResRecords<CommonComment[]>>(url.list, { params: { type, ascs: 'sort' } })
const useList = (type: Ref<string | undefined>) => useRes(() => getList(type.value), { res: 'data.records', modify: false, refreshDeps: [type] })
const create = (data: CommonComment) => request.post(url.save, data)
const update = (data: CommonComment) => request.post(url.update, data)
const remove = (ids: string) => request.post(url.remove, {}, { params: { ids } })
const batchUpdate = (data: CommonComment[]) => request.post(url.batchUpdate, data)
return {
url,
getList,
useList,
create,
update,
remove,
batchUpdate,
}
}
流程按钮
ts
import type { ButtonType } from 'element-plus'
import type { Page, ResRecords } from '@yusui/types'
import type { RequestInstance } from '../types'
import { useRes } from '@yusui/composables'
export enum FlowButtonType {
'默认' = 'default',
'主要' = 'primary',
'成功' = 'success',
'警告' = 'warning',
'危险' = 'danger',
'信息' = 'info',
'文字' = 'text',
}
export enum FlowButtonKey {
'保存草稿' = 'flow_draft',
'发送' = 'flow_pass',
'退回' = 'flow_reject',
'终止' = 'flow_terminate',
'撤销' = 'flow_revoke',
'撤回到发起' = 'flow_withdraw',
'打印' = 'flow_print',
'转办' = 'flow_transfer',
'加签' = 'flow_add_instance',
'减签' = 'flow_del_instance',
'指定回退' = 'flow_rollback',
'绿色通道' = 'flow_green',
}
export enum FlowButtonDisplay {
'显示' = 'true',
'隐藏' = 'false',
'发起人' = 'startUser',
'处理人' = 'assignee',
'已办' = 'done',
'待办' = 'todo',
'已办结' = 'finished',
'未办结' = 'unfinished',
'已发起' = 'started',
'未发起' = 'notstarted',
}
export enum FlowButtonApproval {
'不显示' = 'false',
'指定节点' = 'specifyNode',
'审批人' = 'assignee',
'传阅人' = 'circulate',
'意见' = 'comment',
}
export enum FlowButtonStatus {
'禁用' = 0,
'正常' = 1,
}
/** 按钮配置 */
export interface FlowButton {
id?: string
/** 按钮的key */
buttonKey?: FlowButtonKey
/** element的按钮类型 */
buttonType?: ButtonType
/** 显示类型 */
display?: FlowButtonDisplay
/** 审批弹窗显示 */
approval?: FlowButtonApproval
/** 点击按钮是否先执行校验 0否 1是 */
validate?: number
/** 按钮图标 */
icon?: string
/** 按钮名称 */
name?: string
/** 排序 */
sort?: number
/** 0 正常 | 1 禁用 */
status?: FlowButtonStatus
/** 按钮备注 */
remarks?: string
}
export function useFlowButtonApi(request: RequestInstance) {
const url = {
/** 按钮列表 */
list: '/sapier-flow/dev-button/list',
/** 新增按钮 */
save: '/sapier-flow/dev-button/save',
/** 更新按钮 */
update: '/sapier-flow/dev-button/update',
/** 删除按钮 */
remove: '/sapier-flow/dev-button/remove',
}
const getList = (params: Page & FlowButton) => request.get<ResRecords<FlowButton[]>>(url.list, { params })
const useList = useRes(getList, { res: 'data.records', defaultParams: [{ size: -1, ascs: 'sort', status: 1 }] })
const create = (data: FlowButton) => request.post(url.save, data)
const update = (data: FlowButton) => request.post(url.update, data)
const remove = (ids: string) => request.post(url.remove, {}, { params: { ids } })
return {
url,
getList,
useList,
create,
update,
remove,
}
}
流程分类
ts
import type { Page, ResData } from '@yusui/types'
import type { RequestInstance } from '../types'
import { useRes } from '@yusui/composables'
/** 流程分类 */
export interface FlowCategory {
/** 主键id */
id?: string
/** 分类名称 */
name?: string
/** 上级id */
parentId?: number
/** 分类备注 */
remark?: string
/** 排序 */
sort?: number
}
export function useFlowCategoryApi(request: RequestInstance) {
const url = {
/** 分类列表 */
list: '/sapier-flow/flow-category/list',
/** 新增分类 */
save: '/sapier-flow/flow-category/save',
/** 更新分类 */
update: '/sapier-flow/flow-category/update',
/** 删除分类 */
remove: '/sapier-flow/flow-category/remove',
/** 分类树 */
tree: '/sapier-flow/flow-category/tree',
}
const getList = (params: Page & FlowCategory) => request.get<ResData<FlowCategory[]>>(url.list, { params })
const useList = useRes(getList, { res: 'data', defaultParams: [{ size: -1, ascs: 'sort' }] })
const getTree = (params: Page & FlowCategory) => request.get<ResData<FlowCategory[]>>(url.tree, { params })
const create = (data: FlowCategory) => request.post(url.save, data)
const update = (data: FlowCategory) => request.post(url.update, data)
const remove = (ids: string) => request.post(url.remove, {}, { params: { ids } })
return {
getList,
useList,
getTree,
create,
update,
remove,
}
}
流程定义
ts
import type { Page, ResData, ResRecords } from '@yusui/types'
import type { RequestInstance } from '../types'
import { useRes } from '@yusui/composables'
/** 流程定义 */
export interface FlowDefinition {
/** 流程定义数据 */
flowData?: string
/** 流程KEY */
flowKey?: string
/** 流程定义ID */
flowModuleId?: string
/** 流程名称 */
flowName?: string
/** 表单配置数据 */
formOption?: string
/** 自定义表单路径 */
formPath?: string
/** 关联表 */
formDataTable?: string
/** 分类ID */
categoryId?: string
/** 图标 */
flowIcon?: string
/** 流程备注 */
remarks?: string
/** 排序 */
sort?: number
status?: number
/** 版本号 */
version?: number
/** 主版本 */
mainVersion?: number
}
export function useFlowDefinitionApi(request: RequestInstance) {
const url = {
/** 流程定义列表 */
list: '/sapier-flow/flow-definition/list',
/** 新增流程 */
save: '/sapier-flow/flow-definition/save',
/** 更新流程 */
update: '/sapier-flow/flow-definition/update',
/** 删除流程 */
remove: '/sapier-flow/flow-definition/remove',
/** 流程定义详情 */
detail: '/sapier-flow/flow-definition/detail',
/** 部署流程 */
deploy: '/sapier-flow/flow-definition/deployFlow',
}
const getList = (params: Page & FlowDefinition) => request.get<ResRecords<FlowDefinition[]>>(url.list, { params })
const useList = useRes(getList, { res: 'data.records', defaultParams: [{ size: -1, ascs: 'sort' }] })
const getDetail = (params: { flowModuleId?: string, flowDeployId?: string }) => request.get<ResData<FlowDefinition>>(url.detail, { params })
const create = (data: Pick<FlowDefinition, 'flowKey' | 'flowName' | 'remarks'>) => request.post<ResData<{ flowModuleId?: string }>>(url.save, data)
const update = (data: FlowDefinition) => request.post(url.update, data)
const remove = (ids: string) => request.post(url.remove, {}, { params: { ids } })
const deploy = (data: Pick<FlowDefinition, 'flowModuleId'>) => request.post(url.deploy, data)
return {
url,
getList,
useList,
create,
update,
remove,
deploy,
getDetail,
}
}
流程部署
ts
import type { Page, ResData } from '@yusui/types'
import type { FlowDefinition } from './flow-definition'
import type { RequestInstance } from '../types'
import { useRes } from '@yusui/composables'
export enum IsMainVersion {
'否' = 0,
'是' = 1,
}
/** 已部署流程 */
export interface FlowDeploy extends FlowDefinition {
/** 部署id */
flowDeployId?: string
/** 是否主版本 */
mainVersion?: IsMainVersion
}
export function useFlowDeployApi(request: RequestInstance) {
const url = {
/** 流程部署列表 */
list: '/sapier-flow/flow-deploy/list',
/** 更新流程 */
update: '/sapier-flow/flow-deploy/update',
/** 删除流程 */
remove: '/sapier-flow/flow-deploy/remove',
/** 流程部署详情 */
detail: '/sapier-flow/flow-deploy/detail',
}
const getList = (params: Page & FlowDeploy) => request.get<ResData<FlowDeploy[]>>(url.list, { params })
const useList = useRes(getList, { res: 'data' })
const getDetail = (params: { flowModuleId?: string, flowDeployId?: string }) => request.get<ResData<FlowDeploy>>(url.detail, { params })
const update = (data: FlowDeploy) => request.post(url.update, data)
const remove = (ids: string) => request.post(url.remove, {}, { params: { ids } })
return {
url,
getList,
useList,
getDetail,
update,
remove,
}
}
流程附件
ts
import type { Page, ResData } from '@yusui/types'
import type { RequestInstance } from '../types'
import { useRes } from '@yusui/composables'
/** 流程文件 */
export interface FlowFile {
id?: string
/** 附件目录 */
categoryId?: string
/** 实例ID */
flowInstanceId?: string
/** 任务ID */
taskId?: string
/** 任务节点名称 */
taskNodeName?: string
/** 附件名称 */
fileName?: string
/** 附件类型 */
fileType?: string
/** 附件大小 */
fileSize?: number
/** 附件地址 */
fileUrl?: string
/** 附件描述 */
description?: string
/** 初始附件标识 */
rootMark?: string
/** 附件版本 */
version?: number
/** 最后版本 */
isLatest?: number
createTime?: string
}
export function useFlowFileApi(request: RequestInstance) {
const url = {
/** 文件列表 */
list: '/sapier-flow/flow-file/list',
/** 保存文件 */
save: '/sapier-flow/flow-file/save',
/** 删除文件 */
remove: '/sapier-flow/flow-file/remove',
}
const getList = (params: Page & FlowFile) => request.get<ResData<FlowFile[]>>(url.list, { params })
const useList = useRes(getList, { res: 'data' })
const create = (data: FlowFile) => request.post(url.save, data)
const remove = (ids: string) => request.post(url.remove, {}, { params: { ids } })
return {
getList,
useList,
create,
remove,
}
}
流程运维
ts
import type { Page, ResRecords } from '@yusui/types'
import type { FlowTask } from './flow-task'
import type { RequestInstance } from '../types'
import { useRes } from '@yusui/composables'
/** 流程运维 */
export interface FlowOps extends FlowTask {
/** 申请人 */
applyUserId?: string
applyUserName?: string
flowKey?: string
flowName?: string
categoryId?: string
processStartTime?: string
processStatus?: number
processTitle?: string
serialNumber?: string
version?: number
}
export function useFlowOpsApi(request: RequestInstance) {
const url = {
/** 流程运维列表 */
list: '/sapier-flow/flow-ops/list',
}
const getTaskOpsList = (params: Page & FlowOps) => request.get<ResRecords<FlowOps[]>>(url.list, { params })
const useTaskOpsList = useRes(getTaskOpsList, { res: 'data.records', defaultParams: [{ size: -1 }] })
return {
url,
getTaskOpsList,
useTaskOpsList,
}
}
流程参数
ts
import type { Page, ResData, ResRecords } from '@yusui/types'
import type { DicItem } from '@smallwei/avue'
import type { Whether } from '../constants'
import type { FlowStatus, HandleType, TaskStatus } from './flow-task'
import type { TableField } from './table-template'
import type { RequestInstance } from '../types'
import { useRes } from '@yusui/composables'
/** 流程参数 */
export interface FlowParam {
id?: string
/** 配置Key */
paramKey?: string
/** 配置名称 */
paramName?: string
/** 配置值 */
paramValue?: string
/** 是否系统内置 */
paramType?: Whether
/** 备注 */
remark?: string
}
export interface FlowParamTaskStatus {
label?: TaskStatus
value?: TaskStatus
style?: { fill?: string, stroke?: string, strokeWidth?: number }
}
export interface FlowParamHandleType {
label?: HandleType
value?: HandleType
}
export interface FlowParamFlowStatus {
label?: FlowStatus
value?: FlowStatus
}
export interface FlowParamMap {
/** 流程办理状态 */
'flow.task.status': FlowParamTaskStatus[]
/** 流程操作类型 */
'flow.handle.type': FlowParamHandleType[]
/** 流程状态 */
'flow.status': FlowParamFlowStatus[]
/** 自动建表设计默认字段 */
'table.default.fields': TableField[]
/** 只有一个节点时自动选择 */
'flow.approval.autocheck': boolean
/** 自动填入意见 */
'flow.approval.autocomment': boolean
/** 流程动态审批人 */
'flow.trends.user': DicItem[]
/** 审批树人名的排列方向 */
'flow.approval.tree.horizontal': boolean
}
export type FlowParamValue<K> = K extends keyof FlowParamMap ? FlowParamMap[K] : any
export function useFlowParamApi(request: RequestInstance) {
const url = {
/** 流程参数列表 */
list: '/sapier-flow/flow-param/list',
/** 新增流程参数 */
save: '/sapier-flow/flow-param/save',
/** 更新流程参数 */
update: '/sapier-flow/flow-param/update',
/** 删除流程参数 */
remove: '/sapier-flow/flow-param/remove',
/** 获取所有流程参数键值对 */
all: '/sapier-flow/flow-param/getAllParam',
/** 根据key获取流程参数 */
key: '/sapier-flow/flow-param/getParam',
}
const getList = (params: Page & FlowParam) => request.get<ResRecords<FlowParam[]>>(url.list, { params })
/** 获取所有流程参数键值对 */
const getParams = () => request.get<ResData<FlowParamMap>>(url.all)
const useParams = useRes(getParams, { res: 'data' })
/** 根据key获取流程参数 */
const getParam = <K extends keyof FlowParamMap>(key: K) => request.get<ResData<FlowParamValue<K>>>(url.key, { params: { paramKey: key } })
const useParam = <K extends keyof FlowParamMap>(key: K) => useRes(getParam, { res: 'data', modify: false, defaultParams: [key] })
const create = (data: FlowParam) => request.post(url.save, data)
const update = (data: FlowParam) => request.post(url.update, data)
const remove = (ids: string) => request.post(url.remove, {}, { params: { ids } })
return {
url,
getList,
getParams,
useParams,
getParam,
useParam,
create,
update,
remove,
}
}
流程运行相关
ts
import type { Page, ResData, ResRecords } from '@yusui/types'
import type { FlowFormData } from '@yusui/flow-design'
import type { FlowDeploy } from './flow-deploy'
import type { FlowOps } from './flow-ops'
import type { RequestInstance } from '../types'
import { useRes } from '@yusui/composables'
/** 任务状态 */
export enum TaskStatus {
'已办' = 1,
'待办' = 2,
'失败' = 3,
'撤销' = 4,
'终止' = 5,
'退回' = 6,
}
/** 流程状态 */
export enum FlowStatus {
'已办结' = 1,
'未办结' = 2,
'已终止' = 3,
}
/** 操作类型 */
export enum HandleType {
'系统执行' = 1,
'用户办理' = 2,
'任务撤销' = 3,
'任务退回' = 4,
'流程终止' = 5,
'任务转办' = 6,
'绿色通道' = 7,
}
/** 流程详情 */
export interface FlowDetail {
/** 流转记录 */
flowHistory?: FlowHistory[]
/** 流程实例详情 */
flowInstance?: FlowInstance
/** 当前表单数据 */
formData?: Record<string, any>
/** 流程部署信息 */
process?: FlowDeploy
/** 当前节点配置 */
properties?: FlowFormData
/** 当前任务详情 */
task?: FlowTask
}
/** 流程实例详情 */
export interface FlowInstance {
/** 发起人 */
createUser?: string
flowInstanceId: string
flowDeployId: string
flowModuleId: string
/** 表单数据对应的数据表名 */
formDataTable: string
/** 优先级 */
priority: number
/** 标题 */
title: string
/** 流水号 */
serialNumber: string
/** 流程实例状态 */
status: FlowStatus
}
/** 流程任务详情 */
export interface FlowTask {
/** 审批人 */
assignee?: string
/** 审批人名 */
assigneeName?: string
/** 时长 */
duration?: number
/** 任务处理时间 */
endTime?: string
/** 流程部署id */
flowDeployId?: string
/** 流程实例id */
flowInstanceId?: string
/** 表单id */
instanceVariableId?: string
/** 来源任务id */
sourceTaskId?: string
/** 来源节点key */
sourceTaskNodeKey?: string
/** 任务接收时间 */
startTime?: string
/** 任务状态 */
status?: TaskStatus
/** 子流程id */
subProcessId?: string
/** 任务id */
taskId?: string
/** 任务节点key */
taskNodeKey?: string
/** 任务节点名称 */
taskNodeName?: string
/** 任务节点类型 */
taskNodeType?: string
/** 自定义表单 */
formPath?: string
}
/** 流程历史 */
export interface FlowHistory extends FlowTask {
id?: string
/** 操作类型 */
type?: HandleType
/** 审批意见 */
comment?: FlowComment
}
/** 意见 */
export interface FlowComment {
id?: string
status?: number
/** 任务id */
taskId?: string
/** 流程实例id */
flowInstanceId?: string
/** 操作类型 */
handleType?: HandleType
/** 审批人 */
assignee?: string
/** 意见 */
handleComment?: string
}
/** 提交任务数据 */
export interface CommitTaskData extends ApprovalFormData {
/** 流程部署id */
flowDeployId?: string
/** 流程实例ID */
flowInstanceId?: string
/** 流程任务ID */
taskId?: string
/** 是否调试模式,调试模式任务执行逻辑但不提交 */
isDebug?: boolean
/** 表单数据 */
variables?: FlowVariable[]
/** 发起时携带文件ids */
fileIds?: string
}
/** 审批窗口表单数据 */
export interface ApprovalFormData {
/** 指定节点key */
jumpTaskNodeKey?: string
/** 审批人集合 */
assignee?: Record<Required<ApprovalNode>['taskNodeKey'], Required<ApprovalNode>['userId']>
/** 传阅人集合 */
circulate?: Record<Required<ApprovalNode>['taskNodeKey'], Required<ApprovalNode>['userId']>
/** 审批意见 */
comment?: string
/** 流向 */
outgoing?: string[]
}
/** 获取审批节点的请求参数 */
export interface GetApprovalNodeParams {
flowKey?: string
/** 表单数据 */
variables?: FlowVariable[]
taskId?: string
/** 是否从流程配置加载,false则返回全部 */
loadConfig?: boolean
/** 按钮key */
buttonType?: string
/** 指定节点key */
jumpTaskNodeKey?: string
}
/** 转换的表单数据 */
export interface FlowVariable {
key?: string
value?: any
type?: string
}
/** 审批节点数据 */
export interface ApprovalNode {
id?: string
title?: string
type?: string
/** 父级id */
parentId?: string
/** 节点id,只有一级节点有 */
taskNodeKey?: string
/** 节点配置,只有一级节点有 */
taskNodeProperties?: any
/** 流进线id,只有一级节点有 */
incoming?: string
/** 是否多选,只有一级节点有 */
multiple?: boolean
/** 用户id,只有用户节点有 */
userId?: string
children?: ApprovalNode[]
}
export type GetApprovalNodeResData = ResData<{ approvalNodeList: ApprovalNode[], circulateNodeList: ApprovalNode[] }>
export function useFlowTaskApi(request: RequestInstance) {
const url = {
/** 获取已部署流程 */
publishList: '/sapier-flow/flow-run/queryPublishFlowList',
/** 待办/已办列表 */
taskList: '/sapier-flow/flow-run/userTaskList',
/** 任务详情 */
detail: '/sapier-flow/flow-run/queryPublishFlowDetail',
/** 获取审批人节点树 */
approvalNode: '/sapier-flow/flow-run/queryApprovalNode',
/** 发起任务 */
start: '/sapier-flow/flow-run/startProcess',
/** 提交任务 */
commit: '/sapier-flow/flow-run/commitTask',
/** 保存草稿 */
draft: '/sapier-flow/flow-run/saveDraft',
/** 撤销 */
revoke: '/sapier-flow/flow-run/revokeTask',
/** 终止 */
terminate: '/sapier-flow/flow-run/terminateFlow',
/** 撤回到发起 */
withdraw: '/sapier-flow/flow-run/withdrawToStart',
/** 转办 */
transfer: '/sapier-flow/flow-run/transferTask',
/** 退回 */
reject: '/sapier-flow/flow-run/rollbackTask',
/** 绿色通道 */
green: '/sapier-flow/flow-run/greenTask',
}
/** 获取流程详情 */
const getFlowDetail = (params: { flowKey?: string, taskId?: string, flowInstanceId?: string }) => request.get<ResData<FlowDetail>>(url.detail, { params })
/** 获取审批节点 */
const getApprovalNode = (data: GetApprovalNodeParams) => request.post<GetApprovalNodeResData>(url.approvalNode, data)
/** 发起 */
const startTask = (data: CommitTaskData) => request.post(url.start, data)
/** 发送 */
const commitTask = (data: CommitTaskData) => request.post(url.commit, data)
/** 保存草稿 */
const saveDraft = (data: CommitTaskData) => request.post(url.draft, data)
/** 撤销 */
const revokeTask = (data: CommitTaskData) => request.post(url.revoke, data)
/** 终止 */
const terminateTask = (data: CommitTaskData) => request.post(url.terminate, data)
/** 撤回到发起 */
const withdrawTask = (data: CommitTaskData) => request.post(url.withdraw, data)
/** 转办 */
const transferTask = (data: CommitTaskData) => request.post(url.transfer, data)
/** 退回 */
const rejectTask = (data: CommitTaskData) => request.post(url.reject, data)
/** 绿色通道 */
const greenChannel = (data: CommitTaskData) => request.post(url.green, data)
/** 已部署列表 */
const getPublishList = (params: Page & FlowDeploy) => request.get<ResData<FlowDeploy[]>>(url.publishList, { params })
const usePublishList = useRes(getPublishList, { res: 'data', defaultParams: [{ ascs: 'sort' }] })
/** 待办/已办列表 */
const getTaskList = (params: Page & FlowOps) => request.get<ResRecords<FlowOps[]>>(url.taskList, { params })
const useTaskList = useRes(getTaskList, { res: 'data.records' })
return {
url,
getFlowDetail,
getApprovalNode,
startTask,
commitTask,
saveDraft,
revokeTask,
terminateTask,
withdrawTask,
transferTask,
rejectTask,
greenChannel,
getPublishList,
usePublishList,
getTaskList,
useTaskList,
}
}
流程模板
ts
import type { Page, ResRecords } from '@yusui/types'
import type { RequestInstance } from '../types'
import { useRes } from '@yusui/composables'
/** 流程模板 */
export interface FlowTemplate {
/** 流程模型数据 */
flowData?: string
/** 流程KEY */
flowKey?: string
/** 流程名称 */
flowName?: string
/** 分类ID */
categoryId?: string
/** 主键id */
id?: string
/** 流程备注 */
remarks?: string
/** 排序 */
sort?: number
/** 业务状态 */
status?: number
/** 版本号 */
version?: number
}
export function useFlowTemplateApi(request: RequestInstance) {
const url = {
/** 流程模板列表 */
list: '/sapier-flow/dev-flow/list',
/** 新增流程模板 */
save: '/sapier-flow/dev-flow/save',
/** 更新流程模板 */
update: '/sapier-flow/dev-flow/update',
/** 删除流程模板 */
remove: '/sapier-flow/dev-flow/remove',
}
const getList = (params: Page & FlowTemplate) => request.get<ResRecords<FlowTemplate[]>>(url.list, { params })
const useList = useRes(getList, { res: 'data.records', defaultParams: [{ size: -1 }] })
const create = (data: FlowTemplate) => request.post(url.save, data)
const update = (data: FlowTemplate) => request.post(url.update, data)
const remove = (ids: string) => request.post(url.remove, {}, { params: { ids } })
return {
url,
getList,
useList,
create,
update,
remove,
}
}
流程用户
ts
import type { ResData } from '@yusui/types'
import type { RequestInstance } from '../types'
import { useRes } from '@yusui/composables'
/** 用户 */
export interface FlowUserTree {
id?: string
title?: string
type?: string
parentId?: string
/** 部门id,只有部门和用户节点有 */
deptId?: string
/** 用户id,只有用户节点有 */
userId?: string
/** 岗位id,只有岗位节点有 */
postId?: string
children?: FlowUserTree[]
}
export function useFlowUserApi(request: RequestInstance) {
const url = {
/** 用户、部门、岗位树 */
tree: '/sapier-flow/flow-user/tree',
}
const getUserTree = (filter?: string) => request.get<ResData<FlowUserTree[]>>(url.tree, { params: { filter } })
const useUserTree = useRes(getUserTree, { res: 'data' })
return {
url,
getUserTree,
useUserTree,
}
}
表单模板
ts
import type { Page, ResRecords } from '@yusui/types'
import type { RequestInstance } from '../types'
import { useRes } from '@yusui/composables'
/** 表单模板 */
export interface FormTemplate {
/** 表单KEY */
formKey?: string
/** 表单名称 */
formName?: string
/** 表单配置 */
formOption?: string
/** 分类ID */
categoryId?: string
/** 主键id */
id?: string
/** 表单备注 */
remarks?: string
/** 排序 */
sort?: number
/** 业务状态 */
status?: number
/** 版本号 */
version?: number
}
export function useFormTemplateApi(request: RequestInstance) {
const url = {
/** 表单模板列表 */
list: '/sapier-flow/dev-form/list',
/** 新增表单模板 */
save: '/sapier-flow/dev-form/save',
/** 更新表单模板 */
update: '/sapier-flow/dev-form/update',
/** 删除表单模板 */
remove: '/sapier-flow/dev-form/remove',
}
const getList = (params: Page & FormTemplate) => request.get<ResRecords<FormTemplate[]>>(url.list, { params })
const useList = useRes(getList, { res: 'data.records', defaultParams: [{ size: -1 }] })
const create = (data: FormTemplate) => request.post(url.save, data)
const update = (data: FormTemplate) => request.post(url.update, data)
const remove = (ids: string) => request.post(url.remove, {}, { params: { ids } })
return {
url,
getList,
useList,
create,
update,
remove,
}
}
建表设计
ts
import type { Page, ResData, ResRecords } from '@yusui/types'
import type { Whether } from '../constants'
import type { RequestInstance } from '../types'
import { useRes } from '@yusui/composables'
/** 建表设计 */
export interface TableTemplate {
id?: string
/** 表名 */
tableName?: string
/** 表注释 */
tableComment?: string
/** 表引擎 */
tableEngine?: string
/** 表主键策略 */
tablePrimary?: TablePrimary
/** 数据库字段 */
tableFields?: string | TableField[]
}
export enum TablePrimary {
ASSIGN_ID = 'ASSIGN_ID',
ASSIGN_UUID = 'ASSIGN_UUID',
AUTO = 'AUTO',
INPUT = 'INPUT',
NONE = 'NONE',
}
export interface TableField {
/** 字段名称 */
name?: string
/** 字段备注 */
comment?: string
/** 字段类型 */
type?: FieldType
/** 字段长度 */
size?: number
/** 小数位 */
point?: number
/** 默认值 */
default?: string
/** 是否主键 */
primary?: Whether
/** 是否允许为空 */
permitNull?: Whether
}
export enum FieldType {
bigint = 'bigint',
blob = 'blob',
char = 'char',
date = 'date',
datetime = 'datetime',
decimal = 'decimal',
double = 'double',
enum = 'enum',
float = 'float',
int = 'int',
longblob = 'longblob',
longtext = 'longtext',
mediumblob = 'mediumblob',
mediumint = 'mediumint',
mediumtext = 'mediumtext',
set = 'set',
smallint = 'smallint',
text = 'text',
time = 'time',
timestamp = 'timestamp',
tinyblob = 'tinyblob',
tinyint = 'tinyint',
tinytext = 'tinytext',
varbinary = 'varbinary',
varchar = 'varchar',
year = 'year',
}
export function useTableTemplateApi(request: RequestInstance) {
const url = {
/** 数据库表列表 */
list: '/sapier-flow/dev-table/list',
/** 新增数据库表 */
save: '/sapier-flow/dev-table/save',
/** 更新数据库表 */
update: '/sapier-flow/dev-table/update',
/** 删除数据库表 */
remove: '/sapier-flow/dev-table/remove',
/** 部署数据库表 */
deploy: '/sapier-flow/dev-table/deploy',
/** 获取已存在的表字段 */
getFields: '/sapier-flow/dev-table/getTableFields',
}
const getList = (params: Page & TableTemplate) => request.get<ResRecords<TableTemplate[]>>(url.list, { params })
const useList = useRes(getList, { res: 'data.records', defaultParams: [{ size: -1 }] })
const create = (data: TableTemplate) => request.post(url.save, data)
const update = (data: TableTemplate) => request.post(url.update, data)
const remove = (ids: string) => request.post(url.remove, {}, { params: { ids } })
const deploy = (data: { id?: string }) => request.post(url.deploy, data)
const getFields = (params: TableTemplate) => request.get<ResData<TableField[]>>(url.getFields, { params })
return {
url,
getList,
useList,
create,
update,
remove,
deploy,
getFields,
}
}