Commit 5253d360 by zhaochengxiang

bug fix

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