Commit 11992942 authored by 皮倩雯's avatar 皮倩雯

fix: '权限配置界面报错修复,修复删除默认方案数据不刷新bug'

parent 241d1ae8
Pipeline #82889 passed with stages
/* eslint-disable no-unneeded-ternary */
/* eslint-disable no-return-assign */ /* eslint-disable no-return-assign */
import { Space, Table, Button, Popconfirm, notification, Divider, Checkbox, Spin } from 'antd'; import { Space, Table, Button, Popconfirm, notification, Divider, Checkbox, Spin } from 'antd';
import React, { useState, useEffect, useCallback } from 'react'; import React, { useState, useEffect, useCallback } from 'react';
import VisibleRoleModal from '@/pages/platformCenter/messageManage/projectManage/components/RolseSelect/VisibleRoleModal';
import { PlusOutlined, UserAddOutlined } from '@ant-design/icons'; import { PlusOutlined, UserAddOutlined } from '@ant-design/icons';
import RoleModal from './RoleModal';
import RMSComponents from '@/components/RolePmSite/index'; import RMSComponents from '@/components/RolePmSite/index';
import styles from '../SchemeConfig.less'; import styles from '../SchemeConfig.less';
import { import {
deleteConfig, deleteConfig,
setServiceType,
SetServiceConfig, SetServiceConfig,
GetMaplayerByTerminalType, GetMaplayerByTerminalType,
SetDefaultsSchemeName, SetDefaultsSchemeName,
} from '@/services/webConfig/api'; } from '@/services/webConfig/api';
import { RoleGroupList } from '@/services/messagemanage/messagemanage';
import AddModal from './AddModal'; import AddModal from './AddModal';
const VectorData = props => { const VectorData = props => {
const [treeLoading, setTreeLoading] = useState(false); // 弹窗显示
const [schemename, setSchemename] = useState([]); const [schemename, setSchemename] = useState([]);
const [record, setRecord] = useState({}); // 选中关联角色的方案名 const [record, setRecord] = useState({}); // 选中关联角色的方案名
const [webCurrent, setWebCurrent] = useState(0); // web列表下标 const [webCurrent, setWebCurrent] = useState(0); // web列表下标
...@@ -31,8 +26,6 @@ const VectorData = props => { ...@@ -31,8 +26,6 @@ const VectorData = props => {
const [type, setType] = useState(''); // 弹窗类型 const [type, setType] = useState(''); // 弹窗类型
const [checkLoading, setCheckLoading] = useState(false); const [checkLoading, setCheckLoading] = useState(false);
const [formObj, setFormObj] = useState({ user: 'admin', password: 'geoserver' }); const [formObj, setFormObj] = useState({ user: 'admin', password: 'geoserver' });
const [tree, setTree] = useState([]);
const [leafs, setLeafs] = useState([]);
const [addVisible, setAddVisible] = useState(false); const [addVisible, setAddVisible] = useState(false);
const [checkValue, setCheckValue] = useState([]); const [checkValue, setCheckValue] = useState([]);
const [gisType, setGisType] = useState(''); const [gisType, setGisType] = useState('');
...@@ -47,7 +40,7 @@ const VectorData = props => { ...@@ -47,7 +40,7 @@ const VectorData = props => {
<Checkbox <Checkbox
checked={webStatus[index + webCurrent * 5]} checked={webStatus[index + webCurrent * 5]}
onChange={e => { onChange={e => {
onChangeCheck(e, record, index + webCurrent * 5); onChangeCheck(record, index + webCurrent * 5);
}} }}
/> />
</Space> </Space>
...@@ -109,7 +102,7 @@ const VectorData = props => { ...@@ -109,7 +102,7 @@ const VectorData = props => {
<Checkbox <Checkbox
checked={handStatus[index + handCurrent * 5]} checked={handStatus[index + handCurrent * 5]}
onChange={e => { onChange={e => {
onChangeHand(e, record, index + handCurrent * 5); onChangeHand(record, index + handCurrent * 5);
}} }}
/> />
</Space> </Space>
...@@ -161,9 +154,9 @@ const VectorData = props => { ...@@ -161,9 +154,9 @@ const VectorData = props => {
), ),
}, },
]; ];
// 获取选中的角色 // 获取选中的角色
const onPushSubmit = value => { const onPushSubmit = value => {
console.log(value, 'value');
setAddVisible(false); setAddVisible(false);
let query = { let query = {
...@@ -187,293 +180,113 @@ const VectorData = props => { ...@@ -187,293 +180,113 @@ const VectorData = props => {
prompt('fail', '网络请求失败'); prompt('fail', '网络请求失败');
}); });
}; };
const rolCallBack = useCallback(list => { const rolCallBack = useCallback(list => {
let strList = [];
console.log(list, 'list');
onPushSubmit(list.ids); onPushSubmit(list.ids);
// if (list.length > 0) {
// list.forEach(item => {
// console.log(item, 'item');
// Object.keys(item.last).forEach(i => {
// strList.push(i);
// });
// });
// console.log(strList);
// onPushSubmit(strList);
// }
}); });
// 获取角色 // 获取站点
const pickRole = e => { const pickRole = e => {
setRecord(e); setRecord(e);
setAddVisible(true); setAddVisible(true);
console.log(tree);
console.log(leafs);
let arr = e.roles != null ? e.roles.split(',') : []; let arr = e.roles != null ? e.roles.split(',') : [];
console.log(arr);
setCheckValue(arr); setCheckValue(arr);
}; };
// 设置web方案 // 设置web方案
const onChangeCheck = (e, record, index) => { const onChangeCheck = (record, index, aa, newData) => {
console.log(e);
console.log(record);
console.log(index);
setCheckLoading(true); setCheckLoading(true);
console.log(webStatus); const newLoadings = aa ? [...aa] : [...webStatus];
const newLoadings = [...webStatus]; if (!aa) {
newLoadings.map((item, loadIndex) => newLoadings.map((item, loadIndex) =>
loadIndex == index loadIndex == index
? (newLoadings[loadIndex] = !newLoadings[loadIndex]) ? (newLoadings[loadIndex] = !newLoadings[loadIndex])
: (newLoadings[loadIndex] = false), : (newLoadings[loadIndex] = false),
); );
console.log(newLoadings); setWebStatus(newLoadings);
setWebStatus(newLoadings); }
let query = { let query = {
schemename: record.schemename, schemename: record.schemename,
type: 'web', type: 'web',
uncheck: true, uncheck: !newLoadings[index] ? true : false,
}; };
// 取消默认 // 取消默认
if (!newLoadings[index]) { SetDefaultsSchemeName(query)
SetDefaultsSchemeName(query).then(res => { .then(res => {
setCheckLoading(false); setCheckLoading(false);
if (res.code == '0') { if (res.code == '0') {
const changehandData = [...webData]; const changehandData = newData ? [...newData] : [...webData];
changehandData[index].type = 'dynamic'; changehandData[index].type = !newLoadings[index] ? 'dynamic' : 'pipenet';
console.log(changehandData);
setWebData(changehandData); setWebData(changehandData);
prompt('success', '设置成功'); prompt('success', '设置成功');
} else { } else {
prompt('fail', `${record.schemename}默认设置时遇到错误:${res.message}`); prompt('fail', `${record.schemename}默认设置时遇到错误:${res.message}`);
} }
}); })
return; .catch(err => {
}
// 设置默认
let beforeDefault = webData.findIndex(item => item.type == 'pipenet');
SetDefaultsSchemeName({
schemename: record.schemename,
type: 'web',
uncheck: false,
}).then(res => {
setCheckLoading(false);
if (res.code == '0') {
const changehandData = [...webData];
changehandData[index].type = 'pipenet';
console.log(changehandData);
setWebData(changehandData);
// 设置默认的同时取消另一个默认
// if (beforeDefault != -1) {
// SetDefaultsSchemeName({
// schemename: changehandData[beforeDefault].schemename,
// type: 'web',
// uncheck: true,
// }).then(resdata => {
// setCheckLoading(false);
// if (resdata.code == 0) {
// const changehandData1 = [...webData];
// changehandData1[beforeDefault].type = 'dynamic';
// console.log(changehandData1);
// setWebData(changehandData1);
// prompt('success', '设置成功');
// // return;
// } else {
// prompt('fail', `${record.schemename}默认设置时遇到错误:${res.message}`);
// }
// });
// } else {
// prompt('success', '设置成功');
// }
prompt('success', '设置成功');
}
});
};
// 无选中值时的默认值
const onChangeCheck1 = (e, record, index, aa) => {
console.log(aa);
console.log(webStatus);
setCheckLoading(true);
const newLoadings = [...aa];
let query = {
schemename: record.schemename,
type: 'web',
uncheck: true,
};
if (!newLoadings[index]) {
SetDefaultsSchemeName(query).then(res => {
setCheckLoading(false); setCheckLoading(false);
if (res.code == '0') { if (err.message.indexOf('timeout') !== -1) {
const changehandData = [...webData]; notification.error({
changehandData[index].type = 'dynamic'; message: '提示',
// setWebData(changehandData); duration: 3,
prompt('success', '设置成功'); description: '请求超时',
});
} else { } else {
prompt('fail', `${record.schemename}默认设置时遇到错误:${res.message}`); notification.error({
message: '提示',
duration: 3,
description: err.message,
});
} }
}); });
return;
}
let beforeDefault = webData.findIndex(item => item.type == 'pipenet');
SetDefaultsSchemeName({
schemename: record.schemename,
type: 'web',
uncheck: false,
}).then(res => {
setCheckLoading(false);
if (res.code == '0') {
const changehandData = [...webData];
changehandData[index].type = 'pipenet';
// setWebData(changehandData);
// if (beforeDefault != -1) {
// SetDefaultsSchemeName({
// schemename: changehandData[beforeDefault].schemename,
// type: 'web',
// uncheck: true,
// }).then(resdata => {
// setCheckLoading(false);
// if (resdata.code == 0) {
// const changehandData1 = [...webData];
// changehandData1[beforeDefault].type = 'dynamic';
// // setWebData(changehandData1);
// prompt('success', '设置成功');
// } else {
// prompt('fail', `${record.schemename}默认设置时遇到错误:${res.message}`);
// }
// });
// } else {
// prompt('success', '设置成功');
// }
prompt('success', '设置成功');
}
});
}; };
// 选择手持方案 // 选择手持方案
const onChangeHand = (e, record, index) => { const onChangeHand = (record, index, aa, newData) => {
setCheckLoading(true); setCheckLoading(true);
const newLoadings = [...handStatus]; const newLoadings = aa ? [...aa] : [...handStatus];
newLoadings.map((item, loadIndex) => if (!aa) {
loadIndex == index newLoadings.map((item, loadIndex) =>
? (newLoadings[loadIndex] = !newLoadings[loadIndex]) loadIndex == index
: (newLoadings[loadIndex] = false), ? (newLoadings[loadIndex] = !newLoadings[loadIndex])
); : (newLoadings[loadIndex] = false),
setHandStatus(newLoadings); );
setHandStatus(newLoadings);
}
let query = { let query = {
schemename: record.schemename, schemename: record.schemename,
type: 'phone', type: 'phone',
uncheck: true, uncheck: !newLoadings[index] ? true : false,
}; };
if (!newLoadings[index]) { SetDefaultsSchemeName(query)
SetDefaultsSchemeName(query).then(res => { .then(res => {
setCheckLoading(false); setCheckLoading(false);
if (res.code == '0') { if (res.code == '0') {
const changehandData = [...handData]; const changehandData = newData ? [...newData] : [...handData];
changehandData[index].isDefault = false; changehandData[index].isDefault = !newLoadings[index] ? false : true;
setHandData(changehandData); setHandData(changehandData);
prompt('success', '设置成功'); prompt('success', '设置成功');
} else { } else {
prompt('fail', `${record.schemename}默认设置时遇到错误:${res.message}`); prompt('fail', `${record.schemename}默认设置时遇到错误:${res.message}`);
} }
}); })
return; .catch(err => {
}
let beforeDefault = handData.findIndex(item => item.isDefault);
SetDefaultsSchemeName({
schemename: record.schemename,
type: 'phone',
uncheck: false,
}).then(res => {
setCheckLoading(false);
if (res.code == '0') {
const changehandData = [...handData];
changehandData[index].isDefault = true;
setHandData(changehandData);
// if (beforeDefault != -1) {
// SetDefaultsSchemeName({
// schemename: changehandData[beforeDefault].schemename,
// type: 'phone',
// uncheck: true,
// }).then(resdata => {
// setCheckLoading(false);
// if (resdata.code == 0) {
// const changehandData1 = [...handData];
// changehandData1[beforeDefault].isDefault = false;
// setHandData(changehandData1);
// prompt('success', '设置成功');
// // return;
// } else {
// prompt('fail', `${record.schemename}默认设置时遇到错误:${res.message}`);
// }
// });
// } else {
// prompt('success', '设置成功');
// }
prompt('success', '设置成功');
}
});
};
// 选择手持方案
const onChangeHand1 = (e, record, index, aa) => {
setCheckLoading(true);
const newLoadings = [...aa];
let query = {
schemename: record.schemename,
type: 'phone',
uncheck: true,
};
if (!newLoadings[index]) {
SetDefaultsSchemeName(query).then(res => {
setCheckLoading(false); setCheckLoading(false);
if (res.code == '0') { if (err.message.indexOf('timeout') !== -1) {
const changehandData = [...handData]; notification.error({
changehandData[index].isDefault = false; message: '提示',
// setHandData(changehandData); duration: 3,
prompt('success', '设置成功'); description: '请求超时',
});
} else { } else {
prompt('fail', `${record.schemename}默认设置时遇到错误:${res.message}`); notification.error({
message: '提示',
duration: 3,
description: err.message,
});
} }
}); });
return;
}
let beforeDefault = handData.findIndex(item => item.isDefault);
SetDefaultsSchemeName({
schemename: record.schemename,
type: 'phone',
uncheck: false,
}).then(res => {
setCheckLoading(false);
if (res.code == '0') {
const changehandData = [...handData];
changehandData[index].isDefault = true;
// setHandData(changehandData);
// if (beforeDefault != -1) {
// SetDefaultsSchemeName({
// schemename: changehandData[beforeDefault].schemename,
// type: 'phone',
// uncheck: true,
// }).then(resdata => {
// setCheckLoading(false);
// if (resdata.code == 0) {
// const changehandData1 = [...handData];
// changehandData1[beforeDefault].isDefault = false;
// // setHandData(changehandData1);
// prompt('success', '设置成功');
// // return;
// } else {
// prompt('fail', `${record.schemename}默认设置时遇到错误:${res.message}`);
// }
// });
// } else {
// prompt('success', '设置成功');
// }
prompt('success', '设置成功');
}
});
}; };
const prompt = (type, content) => { const prompt = (type, content) => {
if (type == 'success') { if (type == 'success') {
notification.success({ notification.success({
...@@ -489,6 +302,7 @@ const VectorData = props => { ...@@ -489,6 +302,7 @@ const VectorData = props => {
}); });
} }
}; };
const onSubmit = prop => { const onSubmit = prop => {
setVisible(false); setVisible(false);
if (type == 'add') { if (type == 'add') {
...@@ -498,6 +312,7 @@ const VectorData = props => { ...@@ -498,6 +312,7 @@ const VectorData = props => {
} }
// setFlag(flag + 1); // setFlag(flag + 1);
}; };
// 删除web配置方案 // 删除web配置方案
const delWebConfirm = record => { const delWebConfirm = record => {
deleteConfig({ deleteConfig({
...@@ -513,6 +328,7 @@ const VectorData = props => { ...@@ -513,6 +328,7 @@ const VectorData = props => {
} }
}); });
}; };
// 删除手持配置方案 // 删除手持配置方案
const delhandConfirm = e => { const delhandConfirm = e => {
setCheckLoading(true); setCheckLoading(true);
...@@ -530,6 +346,7 @@ const VectorData = props => { ...@@ -530,6 +346,7 @@ const VectorData = props => {
} }
}); });
}; };
// 添加方案 // 添加方案
const addType = type => { const addType = type => {
setType(type); setType(type);
...@@ -537,14 +354,12 @@ const VectorData = props => { ...@@ -537,14 +354,12 @@ const VectorData = props => {
type == 'add' ? (listData = webData) : (listData = handData); type == 'add' ? (listData = webData) : (listData = handData);
let webSchemenameArr = []; let webSchemenameArr = [];
let schemeArr = []; let schemeArr = [];
setTreeLoading(true);
GetMaplayerByTerminalType({ GetMaplayerByTerminalType({
terminalType: 'scheme', terminalType: 'scheme',
isBaseMap: false, isBaseMap: false,
}) })
.then(res => { .then(res => {
if (res.data && res.data.length > 0) { if (res.data && res.data.length > 0) {
setTreeLoading(false);
listData.map(item => { listData.map(item => {
webSchemenameArr.push(item.schemename); webSchemenameArr.push(item.schemename);
}); });
...@@ -555,7 +370,6 @@ const VectorData = props => { ...@@ -555,7 +370,6 @@ const VectorData = props => {
if (schemeArr.length) { if (schemeArr.length) {
setVisible(true); setVisible(true);
} else { } else {
console.log(12);
notification.warning({ notification.warning({
message: '提示', message: '提示',
duration: 3, duration: 3,
...@@ -563,8 +377,6 @@ const VectorData = props => { ...@@ -563,8 +377,6 @@ const VectorData = props => {
}); });
} }
} else { } else {
console.log(34);
setTreeLoading(false);
notification.warning({ notification.warning({
message: '提示', message: '提示',
duration: 3, duration: 3,
...@@ -586,14 +398,14 @@ const VectorData = props => { ...@@ -586,14 +398,14 @@ const VectorData = props => {
description: err.message, description: err.message,
}); });
} }
setTreeLoading(false);
}); });
}; };
useEffect(() => { useEffect(() => {
console.log(flag);
renderTile(); renderTile();
renderTileWeb(); renderTileWeb();
}, [flag]); }, [flag]);
// 获取瓦片数据配置数据 // 获取瓦片数据配置数据
const renderTile = () => { const renderTile = () => {
setCheckLoading(true); setCheckLoading(true);
...@@ -604,6 +416,7 @@ const VectorData = props => { ...@@ -604,6 +416,7 @@ const VectorData = props => {
}); });
Promise.all([schemeConfigQueryRequest]) Promise.all([schemeConfigQueryRequest])
.then(res => { .then(res => {
setCheckLoading(false);
if (res[0].code == '0') { if (res[0].code == '0') {
let arr = []; let arr = [];
res[0].data.optionalLayer.layers.map((item, index) => { res[0].data.optionalLayer.layers.map((item, index) => {
...@@ -616,22 +429,22 @@ const VectorData = props => { ...@@ -616,22 +429,22 @@ const VectorData = props => {
return item; return item;
}); });
setHandData(res[0].data.optionalLayer.layers); setHandData(res[0].data.optionalLayer.layers);
if (arr.indexOf(true) == -1) { if (arr.indexOf(true) == -1 && arr.length > 0) {
arr[arr.length - 1] = true; arr[arr.length - 1] = true;
setHandStatus(arr); setHandStatus(arr);
onChangeHand1( onChangeHand(
'',
res[0].data.optionalLayer.layers[arr.length - 1], res[0].data.optionalLayer.layers[arr.length - 1],
arr.length - 1, arr.length - 1,
arr, arr,
res[0].data.optionalLayer.layers,
); );
} else { } else {
setHandStatus(arr); setHandStatus(arr);
} }
} }
setCheckLoading(false);
}) })
.catch(err => { .catch(err => {
setCheckLoading(false);
if (err.message.indexOf('timeout') !== -1) { if (err.message.indexOf('timeout') !== -1) {
notification.error({ notification.error({
message: '提示', message: '提示',
...@@ -645,7 +458,6 @@ const VectorData = props => { ...@@ -645,7 +458,6 @@ const VectorData = props => {
description: err.message, description: err.message,
}); });
} }
setTreeLoading(false);
}); });
}; };
...@@ -659,6 +471,7 @@ const VectorData = props => { ...@@ -659,6 +471,7 @@ const VectorData = props => {
}); });
Promise.all([webSchemeQueryRequest]) Promise.all([webSchemeQueryRequest])
.then(res => { .then(res => {
setCheckLoading(false);
if (res[0].code == '0') { if (res[0].code == '0') {
let arr = []; let arr = [];
res[0].data.optionalLayer.layers.map((item, index) => { res[0].data.optionalLayer.layers.map((item, index) => {
...@@ -671,22 +484,22 @@ const VectorData = props => { ...@@ -671,22 +484,22 @@ const VectorData = props => {
return item; return item;
}); });
setWebData(res[0].data.optionalLayer.layers); setWebData(res[0].data.optionalLayer.layers);
if (arr.indexOf(true) == -1) { if (arr.indexOf(true) == -1 && arr.length > 0) {
arr[arr.length - 1] = true; arr[arr.length - 1] = true;
setWebStatus(arr); setWebStatus(arr);
onChangeCheck1( onChangeCheck(
'',
res[0].data.optionalLayer.layers[arr.length - 1], res[0].data.optionalLayer.layers[arr.length - 1],
arr.length - 1, arr.length - 1,
arr, arr,
res[0].data.optionalLayer.layers,
); );
} else { } else {
setWebStatus(arr); setWebStatus(arr);
} }
} }
setCheckLoading(false);
}) })
.catch(err => { .catch(err => {
setCheckLoading(false);
if (err.message.indexOf('timeout') !== -1) { if (err.message.indexOf('timeout') !== -1) {
notification.error({ notification.error({
message: '提示', message: '提示',
...@@ -700,7 +513,6 @@ const VectorData = props => { ...@@ -700,7 +513,6 @@ const VectorData = props => {
description: err.message, description: err.message,
}); });
} }
setTreeLoading(false);
}); });
}; };
...@@ -714,8 +526,7 @@ const VectorData = props => { ...@@ -714,8 +526,7 @@ const VectorData = props => {
<div className={styles.tableContent}> <div className={styles.tableContent}>
<Divider orientation="left"> <Divider orientation="left">
<div className={styles.divider}> <div className={styles.divider}>
{' '} Web
Web{' '}
<PlusOutlined <PlusOutlined
onClick={() => { onClick={() => {
addType('add'); addType('add');
...@@ -728,7 +539,6 @@ const VectorData = props => { ...@@ -728,7 +539,6 @@ const VectorData = props => {
columns={columns} columns={columns}
dataSource={webData} dataSource={webData}
bordered bordered
// style={{ height: 'calc(100vh - 610px)' }}
pagination={false} pagination={false}
rowKey="schemename" rowKey="schemename"
scroll={{ y: 600 }} scroll={{ y: 600 }}
...@@ -737,7 +547,7 @@ const VectorData = props => { ...@@ -737,7 +547,7 @@ const VectorData = props => {
<div className={styles.tableContent}> <div className={styles.tableContent}>
<Divider orientation="left"> <Divider orientation="left">
<div className={styles.divider}> <div className={styles.divider}>
Moblie{' '} Moblie
<PlusOutlined <PlusOutlined
onClick={() => { onClick={() => {
addType('addHand'); addType('addHand');
...@@ -752,7 +562,6 @@ const VectorData = props => { ...@@ -752,7 +562,6 @@ const VectorData = props => {
bordered bordered
rowKey="schemename" rowKey="schemename"
scroll={{ y: 600 }} scroll={{ y: 600 }}
// style={{ height: 'calc(100vh - 610px)' }}
pagination={false} pagination={false}
/> />
</div> </div>
...@@ -766,15 +575,6 @@ const VectorData = props => { ...@@ -766,15 +575,6 @@ const VectorData = props => {
formObj={formObj} formObj={formObj}
listData={schemename} listData={schemename}
/> />
{/* <VisibleRoleModal
visible={addVisible}
onCancel={() => setAddVisible(false)}
onSubmit={onPushSubmit}
title="关联角色"
initValues={checkValue}
tree={tree}
leafs={leafs}
/> */}
<RMSComponents <RMSComponents
visible={addVisible} visible={addVisible}
onCancel={() => { onCancel={() => {
...@@ -789,14 +589,6 @@ const VectorData = props => { ...@@ -789,14 +589,6 @@ const VectorData = props => {
gisType={gisType} gisType={gisType}
// isRadio={true} // 站点单选 // isRadio={true} // 站点单选
/> />
{/* <RoleModal
selectValue={checkValue.toString()}
visible={addVisible}
rolCallBack={roleList => rolCallBack(roleList)}
onCancel={() => {
setAddVisible(false);
}}
/> */}
</div> </div>
); );
}; };
......
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