Commit cddd5c11 authored by Maofei94's avatar Maofei94

perf: perf

parent 19dd0baf
...@@ -5,7 +5,7 @@ import PicturesWall from '@/components/Upload/index'; ...@@ -5,7 +5,7 @@ import PicturesWall from '@/components/Upload/index';
const { Item } = Form; const { Item } = Form;
const AddForm = props => { const AddForm = props => {
const { submitCallback, nodeType, nodeObj, addType } = props; const { submitCallback, nodeType, nodeObj, addType, submitLoading } = props;
const [form] = Form.useForm(); const [form] = Form.useForm();
const [otherForm] = Form.useForm(); const [otherForm] = Form.useForm();
console.log(nodeObj, 'nodeObj'); console.log(nodeObj, 'nodeObj');
...@@ -99,7 +99,7 @@ const AddForm = props => { ...@@ -99,7 +99,7 @@ const AddForm = props => {
<Input /> <Input />
</Item> </Item>
<Item wrapperCol={{ offset: 5 }} style={{ marginTop: '40px' }}> <Item wrapperCol={{ offset: 5 }} style={{ marginTop: '40px' }}>
<Button type="primary" htmlType="submit"> <Button type="primary" htmlType="submit" loading={submitLoading}>
提交 提交
</Button> </Button>
</Item> </Item>
...@@ -187,7 +187,7 @@ const AddForm = props => { ...@@ -187,7 +187,7 @@ const AddForm = props => {
<Input /> <Input />
</Item> </Item>
<Item wrapperCol={{ offset: 5 }} style={{ marginTop: '40px' }}> <Item wrapperCol={{ offset: 5 }} style={{ marginTop: '40px' }}>
<Button type="primary" htmlType="submit"> <Button type="primary" htmlType="submit" loading={submitLoading}>
提交 提交
</Button> </Button>
</Item> </Item>
......
...@@ -44,11 +44,14 @@ const MiniMenu = props => { ...@@ -44,11 +44,14 @@ const MiniMenu = props => {
const [info, setInfo] = useState({}); const [info, setInfo] = useState({});
const [addVisible, setAddVisible] = useState(false); // 新增弹窗 const [addVisible, setAddVisible] = useState(false); // 新增弹窗
const [addTwoVisible, setAddTwoVisible] = useState(false); // 编辑弹窗 const [addTwoVisible, setAddTwoVisible] = useState(false); // 编辑弹窗
const [delVisible, setDelVisible] = useState(false); // 删除弹窗
const [addFlag, setAddFlag] = useState('root'); // 设置新增标志 const [addFlag, setAddFlag] = useState('root'); // 设置新增标志
const [nodeObj, setNodeObj] = useState({}); const [nodeObj, setNodeObj] = useState({});
const [addType, setAddType] = useState(''); // 添加下级类型 const [addType, setAddType] = useState(''); // 添加下级类型
const [modalTitle, setModalTitle] = useState(''); const [modalTitle, setModalTitle] = useState('');
const [roleList, setRoleList] = useState([]); // 复选框选中的值 const [roleList, setRoleList] = useState([]); // 复选框选中的值
const [modalLoading, setModalLoading] = useState(false);
const [submitLoading, setSubmitLoading] = useState(false);
// 获取菜单树 // 获取菜单树
useEffect(() => { useEffect(() => {
updateTrees(); updateTrees();
...@@ -106,17 +109,10 @@ const MiniMenu = props => { ...@@ -106,17 +109,10 @@ const MiniMenu = props => {
<FileAddTwoTone onClick={() => addMenuTip(obj)} /> <FileAddTwoTone onClick={() => addMenuTip(obj)} />
</Tooltip> </Tooltip>
)} )}
<Popconfirm
cancelText="取消" <Tooltip title="删除菜单" className={styles.fs}>
okText="确定" <DeleteTwoTone onClick={() => deleteMenuTip(obj)} />
title={`确定删除${obj.text}?`} </Tooltip>
onConfirm={() => deleteMenuTip(obj)}
placement="right"
>
<Tooltip title="删除菜单" className={styles.fs}>
<DeleteTwoTone />
</Tooltip>
</Popconfirm>
</div> </div>
</div> </div>
), ),
...@@ -201,26 +197,41 @@ const MiniMenu = props => { ...@@ -201,26 +197,41 @@ const MiniMenu = props => {
// 删除的回调 // 删除的回调
const deleteMenuTip = val => { const deleteMenuTip = val => {
console.log(val, 'val'); console.log(val, 'val');
setModalTitle(val.text);
setNodeObj(val);
setDelVisible(true);
};
const delMenu = () => {
setModalLoading(true);
deleteMenu({ deleteMenu({
menuID: val.menuID, menuID: nodeObj.menuID,
_dc: Date.now(), _dc: Date.now(),
_version: 9999, _version: 9999,
}).then(res => { })
if (res.success) { .then(res => {
setFlag(flag + 1); setModalLoading(false);
notification.success({ if (res.success) {
message: '提示', setDelVisible(false);
duration: 3, setFlag(flag + 1);
description: '删除成功', setNodeType('');
}); setNodeObj('');
} else { notification.success({
notification.error({ message: '提示',
message: '提示', duration: 3,
duration: 10, description: '删除成功',
description: res.message || '删除成功', });
}); } else {
} notification.error({
}); message: '提示',
duration: 10,
description: res.message || '删除失败',
});
}
})
.catch(err => {
setModalLoading(false);
console.log(err);
});
}; };
// 新增菜单组 // 新增菜单组
const addMenuGroupTip = val => { const addMenuGroupTip = val => {
...@@ -232,7 +243,7 @@ const MiniMenu = props => { ...@@ -232,7 +243,7 @@ const MiniMenu = props => {
const rootAddGroup = () => { const rootAddGroup = () => {
setNodeObj(''); setNodeObj('');
setNodeType(1); setNodeType(1);
setModalTitle('根目录'); setModalTitle('最上级列表');
setAddType(1); setAddType(1);
setAddVisible(true); setAddVisible(true);
}; };
...@@ -244,7 +255,7 @@ const MiniMenu = props => { ...@@ -244,7 +255,7 @@ const MiniMenu = props => {
setAddTwoVisible(true); setAddTwoVisible(true);
}; };
const rootAdd = () => { const rootAdd = () => {
setModalTitle('根目录'); setModalTitle('最上级列表');
setNodeObj(''); setNodeObj('');
setNodeType(3); setNodeType(3);
setAddType(3); setAddType(3);
...@@ -252,6 +263,7 @@ const MiniMenu = props => { ...@@ -252,6 +263,7 @@ const MiniMenu = props => {
}; };
// 新增提交的回调 // 新增提交的回调
const submitCallback = (prop, item) => { const submitCallback = (prop, item) => {
setSubmitLoading(true);
console.log(prop, item); console.log(prop, item);
let obj = { ...prop }; let obj = { ...prop };
const parentID = item.menuID ? item.menuID : -1; const parentID = item.menuID ? item.menuID : -1;
...@@ -263,6 +275,7 @@ const MiniMenu = props => { ...@@ -263,6 +275,7 @@ const MiniMenu = props => {
...obj, ...obj,
}) })
.then(res => { .then(res => {
setSubmitLoading(false);
if (res.success) { if (res.success) {
setAddVisible(false); setAddVisible(false);
setAddTwoVisible(false); setAddTwoVisible(false);
...@@ -282,6 +295,7 @@ const MiniMenu = props => { ...@@ -282,6 +295,7 @@ const MiniMenu = props => {
console.log(res, 'resadd'); console.log(res, 'resadd');
}) })
.catch(err => { .catch(err => {
setSubmitLoading(false);
console.error(err); console.error(err);
}); });
}; };
...@@ -388,7 +402,7 @@ const MiniMenu = props => { ...@@ -388,7 +402,7 @@ const MiniMenu = props => {
visible={addVisible} visible={addVisible}
title={`在${modalTitle}下新增菜单组`} title={`在${modalTitle}下新增菜单组`}
bodyStyle={{ width: '100%', minHeight: '100px' }} bodyStyle={{ width: '100%', minHeight: '100px' }}
style={{ top: 20 }} style={{ top: 80 }}
width="600px" width="600px"
destroyOnClose destroyOnClose
footer={null} footer={null}
...@@ -404,13 +418,14 @@ const MiniMenu = props => { ...@@ -404,13 +418,14 @@ const MiniMenu = props => {
nodeObj={nodeObj} nodeObj={nodeObj}
addType={addType} addType={addType}
submitCallback={submitCallback} submitCallback={submitCallback}
submitLoading={submitLoading}
/> />
</Modal> </Modal>
<Modal <Modal
visible={addTwoVisible} visible={addTwoVisible}
title={`在${modalTitle}下新增功能菜单`} title={`在${modalTitle}下新增功能菜单`}
bodyStyle={{ width: '100%', minHeight: '100px' }} bodyStyle={{ width: '100%', minHeight: '100px' }}
style={{ top: 20 }} style={{ top: 80 }}
width="600px" width="600px"
destroyOnClose destroyOnClose
footer={null} footer={null}
...@@ -419,12 +434,28 @@ const MiniMenu = props => { ...@@ -419,12 +434,28 @@ const MiniMenu = props => {
onCancel={() => setAddTwoVisible(false)} onCancel={() => setAddTwoVisible(false)}
> >
<AddForm <AddForm
submitLoading={submitLoading}
nodeType={nodeType} nodeType={nodeType}
nodeObj={nodeObj} nodeObj={nodeObj}
addType={addType} addType={addType}
submitCallback={submitCallback} submitCallback={submitCallback}
/> />
</Modal> </Modal>
<Modal
visible={delVisible}
title="请确认"
bodyStyle={{ width: '100%', minHeight: '100px' }}
style={{ top: 80 }}
width="400px"
destroyOnClose
cancelText="取消"
okText="确认"
onCancel={() => setDelVisible(false)}
onOk={() => delMenu()}
confirmLoading={modalLoading}
>
是否删除<span style={{ color: 'red' }}>{modalTitle}</span>?
</Modal>
<div <div
className={classnames({ className={classnames({
[styles.middle]: true, [styles.middle]: true,
......
...@@ -70,8 +70,9 @@ ...@@ -70,8 +70,9 @@
margin-left: 10px; margin-left: 10px;
} }
.rightBox{ .rightBox{
min-width: 600px; min-width: 200px;
// width: 600px; // width: 600px;
width: 100%;
min-height: 100%; min-height: 100%;
border: 1px solid #eee; border: 1px solid #eee;
padding: 10px; padding: 10px;
......
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