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

fix: '地图方案权限配置关联站点优化'

parent 01c660bd
Pipeline #82569 passed with stages
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
import React, { useState, useEffect, useRef } from 'react'; import React, { useState, useEffect, useRef } from 'react';
import { Modal, Checkbox, Tabs, Input, Button, Pagination, Empty, Tag, Divider, Radio } from 'antd'; import { Modal, Checkbox, Tabs, Input, Button, Pagination, Empty, Tag, Divider, Radio } from 'antd';
import { CM_Event_LoadDepartmentAndRoles } from '@/services/standingBook/api'; import { CM_Event_LoadDepartmentAndRoles } from '@/services/standingBook/api';
import { GetMapLayerStationList } from '@/services/webConfig/api';
import styles from './index.less'; import styles from './index.less';
const CheckboxGroup = Checkbox.Group; const CheckboxGroup = Checkbox.Group;
...@@ -32,6 +33,8 @@ const RMSComponents = props => { ...@@ -32,6 +33,8 @@ const RMSComponents = props => {
chooseGroupName, chooseGroupName,
dataType, dataType,
isRadio, isRadio,
mapSite,
gisType,
} = props; } = props;
const [checkedList, setCheckedList] = useState([]); // 选中复选框内容 const [checkedList, setCheckedList] = useState([]); // 选中复选框内容
const [searchWord, setSearchWord] = useState(''); // 关键字 const [searchWord, setSearchWord] = useState(''); // 关键字
...@@ -102,7 +105,7 @@ const RMSComponents = props => { ...@@ -102,7 +105,7 @@ const RMSComponents = props => {
setKeyValue('2'); setKeyValue('2');
setKeepTabKey(2); setKeepTabKey(2);
} }
getRoles(groupName, '', pageSize, 1, 0);
let checkArr = []; let checkArr = [];
// 角色 // 角色
let listdata = []; let listdata = [];
...@@ -178,6 +181,7 @@ const RMSComponents = props => { ...@@ -178,6 +181,7 @@ const RMSComponents = props => {
} }
setSaveCheckValue(checkArr); setSaveCheckValue(checkArr);
setCheckedList(checkArr); setCheckedList(checkArr);
getRoles(groupName, '', pageSize, 1, 0, checkArr);
} }
}); });
} else { } else {
...@@ -232,162 +236,349 @@ const RMSComponents = props => { ...@@ -232,162 +236,349 @@ const RMSComponents = props => {
// 搜索时获取数据 // 搜索时获取数据
const sreachRoles = (type, keywords, pageSizes, pageIndex) => { const sreachRoles = (type, keywords, pageSizes, pageIndex) => {
CM_Event_LoadDepartmentAndRoles({ if (!mapSite) {
type, CM_Event_LoadDepartmentAndRoles({
keywords, type,
pageSize: pageSizes, keywords,
pageIndex, pageSize: pageSizes,
}).then(res => { pageIndex,
if (res.msg === 'Ok') { }).then(res => {
setOptionValue(groupArr(res.data, 'groupType')); if (res.msg === 'Ok') {
let aa = groupArr(res.data, 'groupType'); setOptionValue(groupArr(res.data, 'groupType'));
let list = []; let aa = groupArr(res.data, 'groupType');
let data = ''; let list = [];
if (type == '角色') { let data = '';
data = 0;
} else if (type == '部门') {
data = 1;
} else if (type == '站点') {
data = 2;
}
aa[type] &&
aa[type].map(i => {
if (checkedList[data].indexOf(i.value) != -1) {
list.push(i.value);
}
});
if (list.length === aa[type].length) {
if (type == '角色') {
setCheckAll(true);
setIndeterminate(false);
} else if (type == '部门') {
setCheckAll1(true);
setIndeterminate1(false);
} else if (type == '站点') {
setCheckAll2(true);
setIndeterminate2(false);
}
} else if (list.length < aa[type].length && list.length !== 0) {
if (type == '角色') {
setCheckAll(false);
setIndeterminate(true);
} else if (type == '部门') {
setCheckAll1(false);
setIndeterminate1(true);
} else if (type == '站点') {
setCheckAll2(false);
setIndeterminate2(true);
}
} else if (list.length === 0) {
if (type == '角色') { if (type == '角色') {
setCheckAll(false); data = 0;
setIndeterminate(false);
} else if (type == '部门') { } else if (type == '部门') {
setCheckAll1(false); data = 1;
setIndeterminate1(false);
} else if (type == '站点') { } else if (type == '站点') {
setCheckAll2(false); data = 2;
setIndeterminate2(false);
} }
}
setCurrentPage(1);
setTotal(res.data.count);
if (res.data.count == 0) {
setEmptyValue(1);
} else {
setEmptyValue(0);
}
}
});
};
const getRoles = (type, keywords, pageSizes, pageIndex, flag) => {
CM_Event_LoadDepartmentAndRoles({
type,
keywords,
pageSize: pageSizes,
pageIndex,
}).then(res => {
if (res.msg === 'Ok') {
setTotal(res.data.count);
setOptionValue(groupArr(res.data, 'groupType'));
let aa = groupArr(res.data, 'groupType');
let list = [];
let data = '';
if (type == '角色') {
data = 0;
} else if (type == '部门') {
data = 1;
} else if (type == '站点') {
data = 2;
}
// 首次进入调用
if (flag != undefined) {
let listId = [];
newCheckedList.map(checkItem => {
keepFiled.current[groupName].map(i => {
let canSave = dataType === 'name' ? i.label == checkItem : i.value == checkItem;
if (canSave) {
listId.push(i.value.toString());
}
});
});
aa[type] && aa[type] &&
aa[type].map(i => { aa[type].map(i => {
if (listId.indexOf(i.value) != -1) { if (checkedList[data].indexOf(i.value) != -1) {
list.push(i.value); list.push(i.value);
} }
}); });
} else { if (list.length === aa[type].length) {
aa[type] && if (type == '角色') {
aa[type].map(i => { setCheckAll(true);
setIndeterminate(false);
} else if (type == '部门') {
setCheckAll1(true);
setIndeterminate1(false);
} else if (type == '站点') {
setCheckAll2(true);
setIndeterminate2(false);
}
} else if (list.length < aa[type].length && list.length !== 0) {
if (type == '角色') {
setCheckAll(false);
setIndeterminate(true);
} else if (type == '部门') {
setCheckAll1(false);
setIndeterminate1(true);
} else if (type == '站点') {
setCheckAll2(false);
setIndeterminate2(true);
}
} else if (list.length === 0) {
if (type == '角色') {
setCheckAll(false);
setIndeterminate(false);
} else if (type == '部门') {
setCheckAll1(false);
setIndeterminate1(false);
} else if (type == '站点') {
setCheckAll2(false);
setIndeterminate2(false);
}
}
setCurrentPage(1);
setTotal(res.data.count);
if (res.data.count == 0) {
setEmptyValue(1);
} else {
setEmptyValue(0);
}
}
});
} else {
GetMapLayerStationList({
keywords: keywords,
}).then(res => {
if (res.code === '0') {
let obj = {};
let arr = [];
res.data.list.forEach(i => {
let str = checkedList[2].indexOf(i.id.toString()) !== -1;
if (gisType === 'phone') {
arr.push({
label: i.name,
value: i.id.toString(),
disabled: str ? false : i.isPhone,
});
} else {
arr.push({
label: i.name,
value: i.id.toString(),
disabled: str ? false : i.isWeb,
});
}
});
obj.站点 = arr;
setOptionValue(obj);
let list = [];
let data = '';
if (type == '角色') {
data = 0;
} else if (type == '部门') {
data = 1;
} else if (type == '站点') {
data = 2;
}
obj[type] &&
obj[type].map(i => {
if (checkedList[data].indexOf(i.value) != -1) { if (checkedList[data].indexOf(i.value) != -1) {
list.push(i.value); list.push(i.value);
} }
}); });
if (list.length === obj[type].length) {
if (type == '角色') {
setCheckAll(true);
setIndeterminate(false);
} else if (type == '部门') {
setCheckAll1(true);
setIndeterminate1(false);
} else if (type == '站点') {
setCheckAll2(true);
setIndeterminate2(false);
}
} else if (list.length < obj[type].length && list.length !== 0) {
if (type == '角色') {
setCheckAll(false);
setIndeterminate(true);
} else if (type == '部门') {
setCheckAll1(false);
setIndeterminate1(true);
} else if (type == '站点') {
setCheckAll2(false);
setIndeterminate2(true);
}
} else if (list.length === 0) {
if (type == '角色') {
setCheckAll(false);
setIndeterminate(false);
} else if (type == '部门') {
setCheckAll1(false);
setIndeterminate1(false);
} else if (type == '站点') {
setCheckAll2(false);
setIndeterminate2(false);
}
}
if (res.data.count == 0) {
setEmptyValue(1);
} else {
setEmptyValue(0);
}
} }
});
}
};
if (list.length === aa[type].length) { const getRoles = (type, keywords, pageSizes, pageIndex, flag, check) => {
if (!mapSite) {
CM_Event_LoadDepartmentAndRoles({
type,
keywords,
pageSize: pageSizes,
pageIndex,
}).then(res => {
if (res.msg === 'Ok') {
setTotal(res.data.count);
setOptionValue(groupArr(res.data, 'groupType'));
let aa = groupArr(res.data, 'groupType');
let list = [];
let data = '';
if (type == '角色') { if (type == '角色') {
setCheckAll(true); data = 0;
setIndeterminate(false);
} else if (type == '部门') { } else if (type == '部门') {
setCheckAll1(true); data = 1;
setIndeterminate1(false);
} else if (type == '站点') { } else if (type == '站点') {
setCheckAll2(true); data = 2;
setIndeterminate2(false);
} }
} else if (list.length < aa[type].length && list.length !== 0) { // 首次进入调用
if (type == '角色') { if (flag != undefined) {
setCheckAll(false); let listId = [];
setIndeterminate(true); newCheckedList.map(checkItem => {
} else if (type == '部门') { keepFiled.current[groupName].map(i => {
setCheckAll1(false); let canSave = dataType === 'name' ? i.label == checkItem : i.value == checkItem;
setIndeterminate1(true); if (canSave) {
} else if (type == '站点') { listId.push(i.value.toString());
setCheckAll2(false); }
setIndeterminate2(true); });
});
aa[type] &&
aa[type].map(i => {
if (listId.indexOf(i.value) != -1) {
list.push(i.value);
}
});
} else {
aa[type] &&
aa[type].map(i => {
if (checkedList[data].indexOf(i.value) != -1) {
list.push(i.value);
}
});
}
if (list.length === aa[type].length) {
if (type == '角色') {
setCheckAll(true);
setIndeterminate(false);
} else if (type == '部门') {
setCheckAll1(true);
setIndeterminate1(false);
} else if (type == '站点') {
setCheckAll2(true);
setIndeterminate2(false);
}
} else if (list.length < aa[type].length && list.length !== 0) {
if (type == '角色') {
setCheckAll(false);
setIndeterminate(true);
} else if (type == '部门') {
setCheckAll1(false);
setIndeterminate1(true);
} else if (type == '站点') {
setCheckAll2(false);
setIndeterminate2(true);
}
} else if (list.length === 0) {
if (type == '角色') {
setCheckAll(false);
setIndeterminate(false);
} else if (type == '部门') {
setCheckAll1(false);
setIndeterminate1(false);
} else if (type == '站点') {
setCheckAll2(false);
setIndeterminate2(false);
}
}
if (res.data.count == 0) {
setEmptyValue(1);
} else {
setEmptyValue(0);
} }
} else if (list.length === 0) { }
});
} else {
GetMapLayerStationList({
keywords: '',
}).then(res => {
if (res.code === '0') {
let obj = {};
let arr = [];
res.data.list.forEach(i => {
let newCheck = check ? check : checkedList;
let str = newCheck[2].indexOf(i.id.toString()) !== -1;
if (gisType === 'phone') {
arr.push({
label: i.name,
value: i.id.toString(),
disabled: str ? false : i.isPhone,
});
} else {
arr.push({
label: i.name,
value: i.id.toString(),
disabled: str ? false : i.isWeb,
});
}
});
obj.站点 = arr;
setOptionValue(obj);
let list = [];
let data = '';
if (type == '角色') { if (type == '角色') {
setCheckAll(false); data = 0;
setIndeterminate(false);
} else if (type == '部门') { } else if (type == '部门') {
setCheckAll1(false); data = 1;
setIndeterminate1(false);
} else if (type == '站点') { } else if (type == '站点') {
setCheckAll2(false); data = 2;
setIndeterminate2(false); }
// 首次进入调用
if (flag != undefined) {
let listId = [];
newCheckedList.map(checkItem => {
keepFiled.current[groupName].map(i => {
let canSave = dataType === 'name' ? i.label == checkItem : i.value == checkItem;
if (canSave) {
listId.push(i.value.toString());
}
});
});
obj[type] &&
obj[type].map(i => {
if (listId.indexOf(i.value) != -1) {
list.push(i.value);
}
});
} else {
obj[type] &&
obj[type].map(i => {
if (checkedList[data].indexOf(i.value) != -1) {
list.push(i.value);
}
});
}
if (list.length === obj[type].length) {
if (type == '角色') {
setCheckAll(true);
setIndeterminate(false);
} else if (type == '部门') {
setCheckAll1(true);
setIndeterminate1(false);
} else if (type == '站点') {
setCheckAll2(true);
setIndeterminate2(false);
}
} else if (list.length < obj[type].length && list.length !== 0) {
if (type == '角色') {
setCheckAll(false);
setIndeterminate(true);
} else if (type == '部门') {
setCheckAll1(false);
setIndeterminate1(true);
} else if (type == '站点') {
setCheckAll2(false);
setIndeterminate2(true);
}
} else if (list.length === 0) {
if (type == '角色') {
setCheckAll(false);
setIndeterminate(false);
} else if (type == '部门') {
setCheckAll1(false);
setIndeterminate1(false);
} else if (type == '站点') {
setCheckAll2(false);
setIndeterminate2(false);
}
}
if (res.data.count == 0) {
setEmptyValue(1);
} else {
setEmptyValue(0);
} }
} }
if (res.data.count == 0) { });
setEmptyValue(1); }
} else {
setEmptyValue(0);
}
}
});
}; };
const groupArr = (initialArr, name) => { const groupArr = (initialArr, name) => {
...@@ -928,14 +1119,19 @@ const RMSComponents = props => { ...@@ -928,14 +1119,19 @@ const RMSComponents = props => {
</Radio.Group> </Radio.Group>
) : ( ) : (
<> <>
<Checkbox {!mapSite && (
indeterminate={indeterminate2} <>
onChange={onCheckAllChange2} <Checkbox
checked={checkAll2} indeterminate={indeterminate2}
> onChange={onCheckAllChange2}
全选 checked={checkAll2}
</Checkbox> >
<Divider /> 全选
</Checkbox>
<Divider />
</>
)}
<CheckboxGroup <CheckboxGroup
options={optionValue['站点']} options={optionValue['站点']}
value={checkedList[2]} value={checkedList[2]}
...@@ -957,17 +1153,19 @@ const RMSComponents = props => { ...@@ -957,17 +1153,19 @@ const RMSComponents = props => {
</div> </div>
{/* 分页 */} {/* 分页 */}
<div className={styles.footer}> <div className={styles.footer}>
<Pagination {!mapSite && (
size="small" <Pagination
total={total} size="small"
showSizeChanger total={total}
defaultPageSize={pageSize} showSizeChanger
defaultCurrent={1} defaultPageSize={pageSize}
pageSizeOptions={[10, 20, 45, 100]} defaultCurrent={1}
current={currentPage} pageSizeOptions={[10, 20, 45, 100]}
onChange={paginationChange} current={currentPage}
style={{ marginBottom: '10px' }} onChange={paginationChange}
/> style={{ marginBottom: '10px' }}
/>
)}
</div> </div>
</div> </div>
{/* 已选列表 */} {/* 已选列表 */}
......
...@@ -35,6 +35,7 @@ const VectorData = props => { ...@@ -35,6 +35,7 @@ const VectorData = props => {
const [leafs, setLeafs] = 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 columns = [ const columns = [
{ {
...@@ -65,7 +66,10 @@ const VectorData = props => { ...@@ -65,7 +66,10 @@ const VectorData = props => {
render: record => ( render: record => (
<Space size="middle"> <Space size="middle">
<UserAddOutlined <UserAddOutlined
onClick={() => pickRole(record)} onClick={() => {
pickRole(record);
setGisType('web');
}}
style={{ fontSize: '18px', color: '#1890FF' }} style={{ fontSize: '18px', color: '#1890FF' }}
/> />
</Space> </Space>
...@@ -124,7 +128,10 @@ const VectorData = props => { ...@@ -124,7 +128,10 @@ const VectorData = props => {
render: record => ( render: record => (
<Space size="middle"> <Space size="middle">
<UserAddOutlined <UserAddOutlined
onClick={() => pickRole(record)} onClick={() => {
pickRole(record);
setGisType('phone');
}}
style={{ fontSize: '18px', color: '#1890FF' }} style={{ fontSize: '18px', color: '#1890FF' }}
/> />
</Space> </Space>
...@@ -779,6 +786,8 @@ const VectorData = props => { ...@@ -779,6 +786,8 @@ const VectorData = props => {
groupName="站点" // 打开组件展示的分组名,用来首次获取数据 groupName="站点" // 打开组件展示的分组名,用来首次获取数据
chooseGroupName={['站点']} // 可选分组名 chooseGroupName={['站点']} // 可选分组名
dataType="id" dataType="id"
mapSite={true}
gisType={gisType}
// isRadio={true} // 站点单选 // isRadio={true} // 站点单选
/> />
{/* <RoleModal {/* <RoleModal
......
...@@ -349,3 +349,6 @@ export const SortSchemePost = param => post(`${PANDA_GIS}/MapLayer/SortSchemePos ...@@ -349,3 +349,6 @@ export const SortSchemePost = param => post(`${PANDA_GIS}/MapLayer/SortSchemePos
export const GetUserName = param => get(`${PUBLISH_SERVICE}/UserCenter/GetUserName`, param); export const GetUserName = param => get(`${PUBLISH_SERVICE}/UserCenter/GetUserName`, param);
export const ProductRepair = param => get(`${PUBLISH_SERVICE}/DBManager/ProductRepair`, param); export const ProductRepair = param => get(`${PUBLISH_SERVICE}/DBManager/ProductRepair`, param);
export const GetMapLayerStationList = param =>
get(`${PANDA_GIS}/MapLayer/GetMapLayerStationList`, 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