feat(web): 增加表单数据校验

This commit is contained in:
v-zhangjc9
2025-07-11 11:07:50 +08:00
parent 863638deaa
commit ac2b6b1611
10 changed files with 131 additions and 58 deletions

View File

@@ -1,38 +1,15 @@
import {CopyFilled, DeleteFilled, EditFilled} from '@ant-design/icons'
import {type Edge, getIncomers, Handle, type Node, type NodeProps, Position} from '@xyflow/react'
import {type Edge, Handle, type Node, type NodeProps, Position} from '@xyflow/react'
import type {Schema} from 'amis'
import {Button, Card, Drawer} from 'antd'
import {find, has, isEmpty, isEqual, unique} from 'licia'
import {has, isEmpty} from 'licia'
import {type JSX, useCallback, useState} from 'react'
import styled from 'styled-components'
import Queue from 'yocto-queue'
import {amisRender, commonInfo, horizontalFormOptions} from '../../../util/amis.tsx'
import {getAllIncomerNodeById} from '../Helper.tsx'
import {useDataStore} from '../store/DataStore.ts'
import {useFlowStore} from '../store/FlowStore.ts'
export type InputFormOptions = {
label: string
value: string
}
export type InputFormOptionsGroup = {
group: string,
variables: InputFormOptions[],
}
const getAllIncomerNodeById: (id: string, nodes: Node[], edges: Edge[]) => string[] = (id, nodes, edges) => {
let queue = new Queue<Node>()
queue.enqueue(find(nodes, node => isEqual(node.id, id))!)
let result: string[] = []
while (queue.size !== 0) {
let currentNode = queue.dequeue()!
for (const incomer of getIncomers(currentNode, nodes, edges)) {
result.push(incomer.id)
queue.enqueue(incomer)
}
}
return unique(result, (a, b) => isEqual(a, b))
}
import type {InputFormOptions, InputFormOptionsGroup} from '../types.ts'
export function inputsFormColumns(
nodeId: string,
@@ -91,7 +68,7 @@ export function inputsFormColumns(
{
...horizontalFormOptions(),
type: 'select',
name: 'type',
name: 'variable',
label: '变量',
required: true,
selectMode: 'group',