Commit 5253d360 by zhaochengxiang

bug fix

parent 38de0949
......@@ -148,9 +148,7 @@ const FC = (props) => {
{ id: 'down', title: '下移栏目' },
{ id: 'delete', title: '删除栏目' }
]
if (rightSelectedNode.resourceType !== 'custom' && rightSelectedNode.type !== 'custom') {
newMenuData = [...newMenuData, { id: 'sync', title: '同步Schema' },]
}
return newMenuData
} else if (rightSelectedNode.resourceType === 'custom' || rightSelectedNode.type === 'custom') {
return [
......
......@@ -17,6 +17,7 @@ const FC = (props) => {
const [loading, setLoading] = React.useState(false)
const [waiting, setWaiting] = React.useState(false)
const [node, setNode] = React.useState()
const [type, setType] = React.useState('root')
const [isCustomType, setIsCustomType] = React.useState(false)
const basicRef = React.useRef()
......@@ -28,6 +29,13 @@ const FC = (props) => {
}
}, [visible, id])
const showSync = React.useMemo(() => {
if (action === 'add' && type === 'root') return false
if (action === 'edit' && (node?.directory?.level===1||isCustomType)) return false
return true
}, [type, isCustomType, action, node])
const getDetail = () => {
dispatch({
type: 'assetmanage.getDirectoryWithSyncStrategy',
......@@ -47,6 +55,8 @@ const FC = (props) => {
setLoading(false)
setWaiting(false)
setNode()
setType('root')
setIsCustomType(false)
onCancel?.(refresh)
}
......@@ -59,7 +69,7 @@ const FC = (props) => {
let parentPath = ''
if (action === 'add') {
if (basicRef.current?.getType === 'child') {
if (type === 'child') {
parentPath = node?.directory?.path
rows.resourceType = node?.directory?.resourceType
}
......@@ -116,14 +126,18 @@ const FC = (props) => {
<Spin spinning={loading||waiting} >
<Basic
ref={basicRef}
type={type}
node={node?.directory}
action={action}
onTypeChange={(val) => {
setType(val)
}}
onResourceTypeChange={(val) => {
setIsCustomType(val === 'custom')
}}
/>
{
!isCustomType && <SyncBasic ref={syncBasicRef} node={node?.resourceDirectorySyncStrategy} action={action} />
showSync && <SyncBasic ref={syncBasicRef} node={node?.resourceDirectorySyncStrategy} action={action} />
}
</Spin>
</Modal>
......@@ -132,18 +146,16 @@ const FC = (props) => {
export default FC
export const Basic = React.forwardRef(function ({ node, action, onResourceTypeChange }, ref) {
const [type, setType] = React.useState('root')
export const Basic = React.forwardRef(function ({ node, action, type, onTypeChange, onResourceTypeChange }, ref) {
const [currentResourceType, setCurrentResourceType] = React.useState()
const [form] = Form.useForm()
React.useImperativeHandle(ref, () => ({
getType: type,
validate: async () => {
return await form.validateFields()
},
}), [type, form])
}), [form])
React.useEffect(() => {
if (node) {
......@@ -182,7 +194,7 @@ export const Basic = React.forwardRef(function ({ node, action, onResourceTypeCh
rules={[{ required: true, message: '请选择类型!' }]}
>
<Radio.Group value={type} onChange={(e) => {
setType(e.target.value)
onTypeChange?.(e.target.value)
}}>
<Radio value='root'>栏目</Radio>
<Radio value='child' disabled={!node?.id}>目录</Radio>
......
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