Commit ca6f37cf by zhaochengxiang

bug fix

parent c1d6e9f3
...@@ -443,6 +443,11 @@ const AssetManageTree = (props) => { ...@@ -443,6 +443,11 @@ const AssetManageTree = (props) => {
setUpdateDirectoryModalVisible(true); setUpdateDirectoryModalVisible(true);
} }
const onDetailClick = () => {
setUpdateDirectoryAction('detail');
setUpdateDirectoryModalVisible(true);
}
const editDir = () => { const editDir = () => {
if ((currentDirType||'') === '') { if ((currentDirType||'') === '') {
...@@ -793,7 +798,7 @@ const AssetManageTree = (props) => { ...@@ -793,7 +798,7 @@ const AssetManageTree = (props) => {
getAllDirectoryAsTree(false) getAllDirectoryAsTree(false)
}, 100) }, 100)
}} }}
style={{ width: 65 }} style={{ width: 80 }}
> >
{ {
(templates??[]).map((item, index) => <Select.Option key={index} value={item.type}>{item.name}</Select.Option>) (templates??[]).map((item, index) => <Select.Option key={index} value={item.type}>{item.name}</Select.Option>)
...@@ -892,6 +897,11 @@ const AssetManageTree = (props) => { ...@@ -892,6 +897,11 @@ const AssetManageTree = (props) => {
{ {
(reference!==AssetMountReference) && <RcMenu id={MENU_ID}> (reference!==AssetMountReference) && <RcMenu id={MENU_ID}>
{ {
currentRightClickDir && (currentRightClickDir.type!=='custom') && <RcItem id="detail" onClick={onDetailClick}>
{ (currentRightClickDir.level===1)?'栏目详情':'目录详情' }
</RcItem>
}
{
currentRightClickDir && (currentRightClickDir.type!=='custom') && <RcItem id="edit" onClick={editDir}> currentRightClickDir && (currentRightClickDir.type!=='custom') && <RcItem id="edit" onClick={editDir}>
{ (currentRightClickDir.level===1)?'修改栏目':'修改目录' } { (currentRightClickDir.level===1)?'修改栏目':'修改目录' }
</RcItem> </RcItem>
......
...@@ -1056,7 +1056,7 @@ const AssetTable = (props) => { ...@@ -1056,7 +1056,7 @@ const AssetTable = (props) => {
LocalStorage.set(`templateType-${appId}`, val); LocalStorage.set(`templateType-${appId}`, val);
setPagination({ ...pagination, pageNum: 1 }); setPagination({ ...pagination, pageNum: 1 });
}} }}
style={{ width: 80 }} style={{ width: 85 }}
> >
{ {
(templates??[]).map((item, index) => <Select.Option key={index} value={item.type}>{item.name}</Select.Option>) (templates??[]).map((item, index) => <Select.Option key={index} value={item.type}>{item.name}</Select.Option>)
......
...@@ -9,6 +9,7 @@ import CustomDirectoryModal from './CustomDirectoryModal'; ...@@ -9,6 +9,7 @@ import CustomDirectoryModal from './CustomDirectoryModal';
import { showMessage, getQueryParam } from '../../../../util'; import { showMessage, getQueryParam } from '../../../../util';
import { AnchorTimestamp, AnchorId, AssetBrowseReference, ResourceBrowseReference, AnchorDirId } from '../../../../util/constant'; import { AnchorTimestamp, AnchorId, AssetBrowseReference, ResourceBrowseReference, AnchorDirId } from '../../../../util/constant';
import { highlightSearchContentByTerms } from '../../../../util'; import { highlightSearchContentByTerms } from '../../../../util';
import UpdateDirectoryModal from './UpdateDirectoryModal';
import './AssetTree.less'; import './AssetTree.less';
import 'react-contexify/dist/ReactContexify.css'; import 'react-contexify/dist/ReactContexify.css';
...@@ -58,6 +59,8 @@ const AssetTree = (props) => { ...@@ -58,6 +59,8 @@ const AssetTree = (props) => {
const [loadingTemplates, setLoadingTemplates] = useState(false) const [loadingTemplates, setLoadingTemplates] = useState(false)
const [templates, setTemplates] = useState() const [templates, setTemplates] = useState()
const [currentTemplateType, setTemplateType] = useState() const [currentTemplateType, setTemplateType] = useState()
const [ updateDirectoryAction, setUpdateDirectoryAction ] = useState('');
const [ updateDirectoryModalVisible, setUpdateDirectoryModalVisible ] = useState(false);
const [modal, contextHolder] = Modal.useModal(); const [modal, contextHolder] = Modal.useModal();
...@@ -482,8 +485,14 @@ const AssetTree = (props) => { ...@@ -482,8 +485,14 @@ const AssetTree = (props) => {
} }
} }
const onDetailClick = () => {
setUpdateDirectoryAction('detail');
setUpdateDirectoryModalVisible(true);
}
const displayMenu = (e) => { const displayMenu = (e) => {
show(e, { show({
event: e,
position: { position: {
x: e.clientX + 30, x: e.clientX + 30,
y: e.clientY - 10 y: e.clientY - 10
...@@ -591,7 +600,7 @@ const AssetTree = (props) => { ...@@ -591,7 +600,7 @@ const AssetTree = (props) => {
getAllDirectoryAsTree(false) getAllDirectoryAsTree(false)
}, 100) }, 100)
}} }}
style={{ width: 65 }} style={{ width: 80 }}
> >
{ {
(templates??[]).map((item, index) => <Select.Option key={index} value={item.type}>{item.name}</Select.Option>) (templates??[]).map((item, index) => <Select.Option key={index} value={item.type}>{item.name}</Select.Option>)
...@@ -647,14 +656,22 @@ const AssetTree = (props) => { ...@@ -647,14 +656,22 @@ const AssetTree = (props) => {
onSelect={onTreeSelect} onSelect={onTreeSelect}
checkStrictly checkStrictly
onRightClick={({event, node}) => { onRightClick={({event, node}) => {
if (node.level>1 && node.type==='custom') { setCurrentRightClickDir(node);
setCurrentRightClickDir(node); displayMenu(event);
displayMenu(event);
}
}} }}
/> />
</Spin> </Spin>
<UpdateDirectoryModal
visible={ updateDirectoryModalVisible }
onCancel={() => {
setUpdateDirectoryAction()
setUpdateDirectoryModalVisible(false)
}}
action={ updateDirectoryAction }
dirId={ currentRightClickDir?.nodeId }
/>
<CustomDirectoryModal <CustomDirectoryModal
visible={ customDirectoryModalVisible } visible={ customDirectoryModalVisible }
onCancel={ onCustomDirectoryCancel } onCancel={ onCustomDirectoryCancel }
...@@ -665,19 +682,9 @@ const AssetTree = (props) => { ...@@ -665,19 +682,9 @@ const AssetTree = (props) => {
{ {
<RcMenu id={MENU_ID}> <RcMenu id={MENU_ID}>
{ {
currentRightClickDir && currentRightClickDir.level>1 && currentRightClickDir.type==='custom' && <RcItem id="up" onClick={() => { moveNode(1); }}> currentRightClickDir && (currentRightClickDir.type!=='custom') && <RcItem id="detail" onClick={onDetailClick}>
上移目录 { (currentRightClickDir.level===1)?'栏目详情':'目录详情' }
</RcItem> </RcItem>
}
{
currentRightClickDir && currentRightClickDir.level>1 && currentRightClickDir.type==='custom' && <RcItem id="up" onClick={() => { moveNode(-1); }}>
下移目录
</RcItem>
}
{
currentRightClickDir && currentRightClickDir.level===2 && currentRightClickDir.type==='custom' && !currentRightClickDir.adminCreate && <RcItem id="up" onClick={deleteDir}>
删除目录
</RcItem>
} }
</RcMenu> </RcMenu>
} }
......
import React, { useEffect, useState, useMemo } from 'react'; import React, { useEffect, useState, useMemo } from 'react';
import { Modal, Form, Input, Space, Button, Radio, Select } from 'antd'; import { Modal, Form, Input, Space, Button, Radio, Select, Spin } from 'antd';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
import { showMessage } from '../../../../util'; import { showMessage } from '../../../../util';
...@@ -34,26 +34,16 @@ const UpdateDirectoryModal = (props) => { ...@@ -34,26 +34,16 @@ const UpdateDirectoryModal = (props) => {
const { visible, onCancel, dirId, action } = props; const { visible, onCancel, dirId, action } = props;
const [loading, setLoading] = useState(false);
const [ form ] = Form.useForm(); const [ form ] = Form.useForm();
const [ dir, setDir ] = useState(null); const [ dir, setDir ] = useState(null);
const [ confirmLoading, setConfirmLoading ] = useState(false); const [ confirmLoading, setConfirmLoading ] = useState(false);
const [ isThemeAdd, setIsThemeAdd ] = useState(false); const [ isThemeAdd, setIsThemeAdd ] = useState(false);
useEffect(() => { useEffect(() => {
if (visible && dirId) {
if (visible) { getDirectory();
setDir(null);
form.resetFields();
if (action === 'add') {
form.setFieldsValue({ resourceType: 'dataAsset' });
}
if ((dirId||'')!=='') {
getDirectory();
}
} }
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [ visible ]) }, [ visible ])
...@@ -69,19 +59,27 @@ const UpdateDirectoryModal = (props) => { ...@@ -69,19 +59,27 @@ const UpdateDirectoryModal = (props) => {
return false; return false;
}, [action, dir, isThemeAdd]) }, [action, dir, isThemeAdd])
const marginBottom = useMemo(() => {
return (action === 'detail') ? 5 : 15
}, [action])
const getDirectory = () => { const getDirectory = () => {
setDir(null); setLoading(true);
dispatch({ dispatch({
type: 'assetmanage.getDirectoryById', type: 'assetmanage.getDirectoryById',
payload: { payload: {
dirId dirId
}, },
callback: data => { callback: data => {
setLoading(false);
setDir(data); setDir(data);
if (action !== 'add') { if (action !== 'add') {
form.setFieldsValue({ code: data?.code, name: data?.name||'', desc: data?.desc||'', remarks: data?.remarks||'' }); form.setFieldsValue({ code: data?.code, name: data?.name||'', desc: data?.desc||'', remarks: data?.remarks||'' });
} }
},
error: () => {
setLoading(false);
} }
}) })
} }
...@@ -154,8 +152,9 @@ const UpdateDirectoryModal = (props) => { ...@@ -154,8 +152,9 @@ const UpdateDirectoryModal = (props) => {
const reset = () => { const reset = () => {
setIsThemeAdd(false); setIsThemeAdd(false);
setDir(undefined); setLoading(false);
form.resetFields(); setConfirmLoading(false);
setDir();
} }
const onReset = () => { const onReset = () => {
...@@ -198,8 +197,8 @@ const UpdateDirectoryModal = (props) => { ...@@ -198,8 +197,8 @@ const UpdateDirectoryModal = (props) => {
return ( return (
<Modal <Modal
forceRender destroyOnClose
title={'资产目录的目录信息'} title='资产目录的目录信息'
visible={visible} visible={visible}
width={600} width={600}
onCancel={() => { onCancel={() => {
...@@ -207,7 +206,7 @@ const UpdateDirectoryModal = (props) => { ...@@ -207,7 +206,7 @@ const UpdateDirectoryModal = (props) => {
onCancel && onCancel(); onCancel && onCancel();
}} }}
footer={ footer={
<Space> (action==='detail') ? null : <Space>
<Button type="primary" onClick={onOk} loading={confirmLoading}>提交</Button> <Button type="primary" onClick={onOk} loading={confirmLoading}>提交</Button>
<Button onClick={onReset} >重置</Button> <Button onClick={onReset} >重置</Button>
<Button onClick={() => { <Button onClick={() => {
...@@ -217,58 +216,74 @@ const UpdateDirectoryModal = (props) => { ...@@ -217,58 +216,74 @@ const UpdateDirectoryModal = (props) => {
</Space> </Space>
} }
> >
<Form {...formItemLayout} form={form} onValuesChange={onValuesChange}> <Spin spinning={loading}>
{ <Form {...formItemLayout} form={form} onValuesChange={onValuesChange}>
action==='add' && <Form.Item {
label="类型" action==='add' && <Form.Item
name="type" label="类型"
name="type"
rules={[{ required: true, message: '必填项' }]}
style={{ marginBottom }}
>
<Radio.Group>
<Radio value='theme'>栏目</Radio>
<Radio value='directory' disabled={ !dirId }>目录</Radio>
</Radio.Group>
</Form.Item>
}
{
codeRestrict && <Form.Item
label="编号"
name="code"
rules={[{ required: true, message: '必填项' }]}
style={{ marginBottom }}
>
{
(action==='detail') ? <span>{dir?.code}</span> : <CodeInput restrict={codeRestrict} action={action} />
}
</Form.Item>
}
<Form.Item
label="名称"
name="name"
rules={[{ required: true, message: '必填项' }]} rules={[{ required: true, message: '必填项' }]}
style={{ marginBottom }}
> >
<Radio.Group> {
<Radio value='theme'>栏目</Radio> (action==='detail') ? <span>{dir?.name}</span> : <Input placeholder="请输入名称" />
<Radio value='directory' disabled={ !dirId }>目录</Radio> }
</Radio.Group>
</Form.Item> </Form.Item>
} {
{ action !== 'add' && (
codeRestrict && <Form.Item <Form.Item
label="编号" label="路径"
name="code" name="path"
rules={[{ required: true, message: '必填项' }]} style={{ marginBottom }}
>
<span>{dir?.path}</span>
</Form.Item>
)
}
<Form.Item
label="描述"
name="desc"
style={{ marginBottom }}
> >
<CodeInput restrict={codeRestrict} action={action} /> {
(action==='detail') ? <span>{dir?.desc}</span> : <Input.TextArea placeholder="请输入描述" autoSize={{ minRows: 4, maxRows: 4 }} />
}
</Form.Item> </Form.Item>
} <Form.Item
<Form.Item label="备注"
label="名称" name="remarks"
name="name" style={{ marginBottom }}
rules={[{ required: true, message: '必填项' }]} >
> {
<Input placeholder="请输入名称" /> (action==='detail') ? <span>{dir?.remarks}</span> : <Input.TextArea placeholder="请输入备注" autoSize={{ minRows: 4, maxRows: 4 }} />
</Form.Item> }
{ </Form.Item>
action !== 'add' && ( </Form>
<Form.Item </Spin>
label="路径"
name="path"
>
<span>{ dir ? (dir.path||''):'' }</span>
</Form.Item>
)
}
<Form.Item
label="描述"
name="desc"
>
<Input.TextArea placeholder="请输入描述" autoSize={{ minRows: 4, maxRows: 4 }} />
</Form.Item>
<Form.Item
label="备注"
name="remarks"
>
<Input.TextArea placeholder="请输入备注" autoSize={{ minRows: 4, maxRows: 4 }} />
</Form.Item>
</Form>
</Modal> </Modal>
); );
} }
......
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