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

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

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