Commit 64c113be by zhaochengxiang

右键编辑

parent 51f420c0
......@@ -41,7 +41,7 @@ function FC<RowType extends object = any>({ width, maxHeight, pageSize, pageNum,
const MENU_ID = generateUUID()
const [tableWidth, setTableWidth] = useState(0)
const { show } = useContextMenu({
const { show, hideAll } = useContextMenu({
id: MENU_ID,
})
......@@ -154,7 +154,11 @@ function FC<RowType extends object = any>({ width, maxHeight, pageSize, pageNum,
tip={rightClickNode?.[`${item}`]?.tip}
permissions={rightClickNode?.permissions||menuPermissions}
permissionKey={item}
onClick={() => onMenuItemClick?.(item, rightClickNode)}>
onClick={({ event }) => {
event?.stopPropagation()
hideAll()
onMenuItemClick?.(item, rightClickNode)
}}>
{item}
</PermissionRcItem>)
}
......
......@@ -362,6 +362,7 @@ const Strategy = React.forwardRef(function ({ type, task }, ref) {
const [editingKey, setEditingKey] = React.useState('')
const [editingModelKey, setEditingModelKey] = React.useState('')
const [selectablePropertyTypes, setSelectablePropertyTypes] = React.useState()
const [rightRow, setRightRow] = React.useState()
const [form] = Form.useForm()
const tableRef = React.useRef()
......@@ -396,6 +397,14 @@ const Strategy = React.forwardRef(function ({ type, task }, ref) {
}
}, [type])
const menuData = React.useMemo(() => {
if (rightRow) {
return isEditing(rightRow) ? ['删除'] : ['编辑', '删除']
}
return []
}, [rightRow, isEditing])
const getPropertyTypes = () => {
setLoadingPropertyTypes(true)
dispatch({
......@@ -532,7 +541,9 @@ const Strategy = React.forwardRef(function ({ type, task }, ref) {
}
const onRightMenuItemClick = (key, record) => {
if (key === '删除') {
if (key === '编辑') {
onEditClick(record)
} else if (key === '删除') {
onRightDeleteClick(record)
}
}
......@@ -627,10 +638,11 @@ const Strategy = React.forwardRef(function ({ type, task }, ref) {
}}
pagination={false}
shouldRowContextMenu={(record) => {
setRightRow(record)
return true
}}
menuData={['删除']}
menuPermissions={['删除']}
menuData={menuData}
menuPermissions={menuData}
onMenuItemClick={onRightMenuItemClick}
/>
</Form>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment