feat(web): 优化流程界面显示
This commit is contained in:
@@ -2,24 +2,30 @@ import {Handle, type NodeProps, Position} from '@xyflow/react'
|
||||
import type {Schema} from 'amis'
|
||||
import {Card, Dropdown} from 'antd'
|
||||
import {DeleteFilled, EditFilled} from '@ant-design/icons'
|
||||
import {isEqual} from 'licia'
|
||||
import {isEmpty, isEqual} from 'licia'
|
||||
import type {JSX} from 'react'
|
||||
|
||||
export type AmisNodeType = 'normal' | 'start' | 'end'
|
||||
|
||||
const AmisNode = (
|
||||
props: NodeProps,
|
||||
type: AmisNodeType,
|
||||
name: String,
|
||||
description?: String,
|
||||
defaultNodeName: String,
|
||||
defaultNodeDescription?: String,
|
||||
extraNodeDescription?: (nodeData: any) => JSX.Element,
|
||||
columnSchema?: Schema[],
|
||||
) => {
|
||||
const {id, data} = props
|
||||
const {getDataById, removeNode, editNode} = data
|
||||
// @ts-ignore
|
||||
const nodeData = getDataById(id)
|
||||
const nodeName = isEmpty(nodeData?.node?.name) ? defaultNodeName : nodeData.node.name
|
||||
const nodeDescription = isEmpty(nodeData?.node?.description) ? defaultNodeDescription : nodeData.node?.description
|
||||
return (
|
||||
<div className="p-1 w-64">
|
||||
<Card
|
||||
className="node-card"
|
||||
title={name}
|
||||
title={nodeName}
|
||||
size="small"
|
||||
hoverable
|
||||
>
|
||||
@@ -43,7 +49,29 @@ const AmisNode = (
|
||||
switch (menu.key) {
|
||||
case 'edit':
|
||||
// @ts-ignore
|
||||
editNode(id, name, description, columnSchema)
|
||||
editNode(
|
||||
id,
|
||||
defaultNodeName,
|
||||
defaultNodeDescription,
|
||||
[
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'node.name',
|
||||
label: '节点名称',
|
||||
placeholder: nodeName,
|
||||
},
|
||||
{
|
||||
type: 'textarea',
|
||||
name: 'node.description',
|
||||
label: '节点描述',
|
||||
placeholder: nodeDescription,
|
||||
},
|
||||
{
|
||||
type: 'divider'
|
||||
},
|
||||
...(columnSchema ?? [])
|
||||
]
|
||||
)
|
||||
break
|
||||
case 'remove':
|
||||
// @ts-ignore
|
||||
@@ -54,7 +82,8 @@ const AmisNode = (
|
||||
}}
|
||||
>
|
||||
<div className="card-description p-2 text-secondary text-sm">
|
||||
{description}
|
||||
{nodeDescription}
|
||||
{extraNodeDescription?.(nodeData)}
|
||||
</div>
|
||||
</Dropdown>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user