Commit 2bdca006 authored by 皮倩雯's avatar 皮倩雯

修改数据字典搜索状态编辑删除未保存搜索状态问题

parent 3cd24a36
Pipeline #38903 skipped with stages
/* eslint-disable react-hooks/rules-of-hooks */
/*
* @Description:
* @Description:
* @Author: leizhe
* @Date: 2021-05-27 16:31:05
* @LastEditTime: 2021-11-02 11:41:28
* @LastEditTime: 2021-11-26 16:43:17
* @LastEditors: leizhe
*/
import React, { useState, useEffect } from 'react';
......@@ -20,7 +21,6 @@ import {
Button,
Upload,
Search,
} from 'antd';
import PageContainer from '@/components/BasePageContainer';
import {
......@@ -31,21 +31,23 @@ import {
import {
SearchDataDictionaryList,
EditDataDictionary,
DeleteDataDictionary
DeleteDataDictionary,
} from '@/services/dataCenter/api';
import styles from './index.less';
import { useHistory } from 'react-router-dom';
import styles from './index.less';
const dictionary = () => {
const [searchData, setSearchData] = useState([]); // 搜索框表格数据
// eslint-disable-next-line react-hooks/rules-of-hooks
const [treeLoading, setTreeLoading] = useState(false);
const [searchWord, setSearchWord] = useState(''); // 关键字
const [editVisible, setEditVisible] = useState(false);//编辑二级条目
const [editVisible1, setEditVisible1] = useState(false);//编辑一级条目
const [editVisible, setEditVisible] = useState(false); // 编辑二级条目
const [editVisible1, setEditVisible1] = useState(false); // 编辑一级条目
const [select, setSelect] = useState({}); // 当前选中条目,可以是一级/二级,修改/删除时设置
const history = useHistory();
const [editForm] = Form.useForm();
const [title, setTitle] = useState('')
const [title, setTitle] = useState('');
// eslint-disable-next-line no-shadow
const { Search } = Input;
const columns2 = [
......@@ -104,12 +106,13 @@ const dictionary = () => {
onClick={() => {
setSelect(record);
if (record.parentID === '-1' || record.parentID === null) {
setTitle('确认删除一级目录数据,删除一级目录数据会将其二级目录子数据一起删除');
setTitle(
'确认删除一级目录数据,删除一级目录数据会将其二级目录子数据一起删除',
);
} else {
setTitle('确认删除二级条目数据');
}
}
}
}}
style={{
fontSize: '16px',
margin: '0px 10px',
......@@ -124,19 +127,19 @@ const dictionary = () => {
},
];
//修改
// 修改
const submitEdit = () => {
const nodeName = editForm.getFieldValue('nodeName');
const nodeValue = editForm.getFieldValue('nodeValue');
if (nodeName) {
EditDataDictionary({
nodeID: select.nodeID,
nodeName: nodeName,
nodeValue: nodeValue
nodeName,
nodeValue,
}).then(res => {
if (res.code === 0) {
setEditVisible(false);
sumbitSearch()
sumbitSearch();
// getData(select.parentID === '-1' ? null : select.parentID);
notification.success({
message: '提交成功',
......@@ -144,8 +147,6 @@ const dictionary = () => {
// if (flag1 === 1) {
// sumbitSearch()
// }
} else {
notification.error({
message: '提交失败',
......@@ -159,20 +160,20 @@ const dictionary = () => {
description: '名称不能为空',
});
}
}
};
const submitEdit1 = () => {
const nodeName = editForm.getFieldValue('nodeName');
if (nodeName) {
EditDataDictionary({
nodeID: select.nodeID,
nodeName: nodeName,
nodeValue: '-'
nodeName,
nodeValue: '-',
}).then(res => {
if (res.code === 0) {
setEditVisible1(false);
sumbitSearch()
sumbitSearch();
// getData(select.parentID === '-1' ? null : select.parentID);
notification.success({
message: '提交成功',
});
......@@ -192,7 +193,7 @@ const dictionary = () => {
description: '名称不能为空',
});
}
}
};
const sumbitSearch = () => {
SearchDataDictionaryList({ key: searchWord }).then(res => {
......@@ -209,29 +210,30 @@ const dictionary = () => {
};
const submitDelete = () => {
console.log(select)
console.log(select);
DeleteDataDictionary({
nodeID: select.nodeID,
}).then(res => {
nodeID: select.nodeID,
})
.then(res => {
if (res.code === 0) {
// if (flag1 === 1) {
// sumbitSearch()
// }
sumbitSearch()
notification.success({
message: '删除成功',
});
// if (flag1 === 1) {
// sumbitSearch()
// }
sumbitSearch();
notification.success({
message: '删除成功',
});
} else {
notification.error({
message: '删除失败',
description: res.message,
});
notification.error({
message: '删除失败',
description: res.message,
});
}
})
.catch(err => {
message.error(err);
})
}
})
.catch(err => {
message.error(err);
});
};
// 获取搜索框的值
const handleSearch = e => {
setSearchWord(e.target.value);
......@@ -246,7 +248,7 @@ const dictionary = () => {
};
const back = () => {
history.push({
pathname: '/dataCenter/dictionary1'
pathname: '/dataCenter/dictionary1',
});
};
......@@ -265,13 +267,17 @@ const dictionary = () => {
/>
</div>
<div className={styles.btn}>
<Button type="primary" icon={<RollbackOutlined />} onClick={() => back()}>
<Button
type="primary"
icon={<RollbackOutlined />}
onClick={() => back()}
>
返回
</Button>
</div>
</div>
<Table
size='small'
size="small"
bordered
key=""
columns={columns2}
......@@ -280,15 +286,14 @@ const dictionary = () => {
pagination={pagenation}
onRow={record => ({
onClick: () => {
setSelect(record);
setSelect(record);
},
})}
})}
/>
</div>
{/*修改一级条目 */}
{/* 修改一级条目 */}
<Modal
title={'修改一级条目'}
title="修改一级条目"
visible={editVisible1}
onOk={submitEdit1}
onCancel={() => {
......@@ -307,10 +312,10 @@ const dictionary = () => {
</Form.Item>
</Form>
</Modal>
{/*修改二级条目 */}
{/* 修改二级条目 */}
<Modal
title={'修改二级条目'}
title="修改二级条目"
visible={editVisible}
onOk={submitEdit}
onCancel={() => {
......
......@@ -140,7 +140,7 @@ const AppDic = () => {
// message.error(err);
// });
GetKeyValue({}).then(resnew => {
if (resnew.code == 0) {
if (resnew.code === 0) {
let res = resnew.data;
if (res.length > 0) {
res.map(item => {
......@@ -152,6 +152,7 @@ const AppDic = () => {
} else {
notification.error({
message: '获取失败',
// eslint-disable-next-line no-undef
description: res.msg,
});
}
......@@ -196,7 +197,7 @@ const AppDic = () => {
value,
desc: description,
}).then(res => {
if (res.code == 0) {
if (res.code === 0) {
setAddVisible(false);
getData();
notification.success({
......@@ -276,7 +277,7 @@ const AppDic = () => {
value,
desc: description,
}).then(res => {
if (res.code == 0) {
if (res.code === 0) {
setEditVisible(false);
getData();
notification.success({
......@@ -354,45 +355,42 @@ const AppDic = () => {
height: 'calc(100vh-200px)',
display: 'flex',
alignItems: 'center',
justifyContent:'space-between'
justifyContent: 'space-between',
}}
>
<span>数据字典</span>
<div>
<Tooltip title="添加">
<PlusSquareOutlined
onClick={() => {
setAddVisible(true);
addForm.resetFields();
}}
style={{
color: '#1890FF',
fontSize: '20px',
marginRight: '22px',
}}
/>
</Tooltip>
<Popconfirm
title="是否重置默认配置?"
okText="确认"
cancelText="取消"
onConfirm={submitReset}
>
<Tooltip title="还原">
<SyncOutlined
<Tooltip title="添加">
<PlusSquareOutlined
onClick={() => {
setAddVisible(true);
addForm.resetFields();
}}
style={{
color: '#1890FF',
fontSize: '20px',
marginRight: '30px',
marginRight: '22px',
}}
/>
</Tooltip>
</Popconfirm>
<Popconfirm
title="是否重置默认配置?"
okText="确认"
cancelText="取消"
onConfirm={submitReset}
>
<Tooltip title="还原">
<SyncOutlined
style={{
color: '#1890FF',
fontSize: '20px',
marginRight: '30px',
}}
/>
</Tooltip>
</Popconfirm>
</div>
</div>
<Table
size="small"
......
This diff is collapsed.
/*
* @Description:
* @Description:
* @Author: leizhe
* @Date: 2021-07-08 16:18:14
* @LastEditTime: 2021-11-26 15:53:25
* @LastEditTime: 2021-11-26 16:28:39
* @LastEditors: leizhe
*/
import { post, postForm, get, PUBLISH_SERVICE } from '../index';
......@@ -16,6 +16,6 @@ export const getSysConfigurate = params =>
);
export const gateWayConfig = params =>
get(`/PandaCore/GCK/Basis/GateWayConfig`, params);
//获取网关配置
// 获取网关配置
export const GetGateWay = param =>
get(`${PUBLISH_SERVICE}/HostManager/GetGateWay`, param);
get(`${PUBLISH_SERVICE}/HostManager/GetGateWay`, param);
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