Commit 64c113be by zhaochengxiang

右键编辑

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