Commit 979ebb08 authored by 涂伟's avatar 涂伟

feat: '1.关联角色权限新增搜索'

parent 81b8fe3f
Pipeline #93553 passed with stages
import React, { useState, useCallback, useEffect } from 'react'; import React, { useState, useCallback, useEffect } from 'react';
import { Modal, Spin, Tabs, notification, message, Checkbox, Divider } from 'antd'; import { Modal, Spin, Tabs, notification, message, Checkbox, Divider, Input } from 'antd';
import { SetUserRelationList, setUserRelation, setUserRelations } from '@/services/userManage/api'; import { SetUserRelationList, setUserRelation, setUserRelations } from '@/services/userManage/api';
import ListCardItem from './components/listCardItem'; import ListCardItem from './components/listCardItem';
const CheckboxGroup = Checkbox.Group; const CheckboxGroup = Checkbox.Group;
const { Search } = Input;
const RelateRoleModal = props => { const RelateRoleModal = props => {
const { const {
...@@ -26,6 +27,9 @@ const RelateRoleModal = props => { ...@@ -26,6 +27,9 @@ const RelateRoleModal = props => {
const [stationValueList, setStationValueList] = useState({}); // 勾选的站点列表 const [stationValueList, setStationValueList] = useState({}); // 勾选的站点列表
const authority = localStorage.getItem('panda-oms-authority'); const authority = localStorage.getItem('panda-oms-authority');
const [activeKey, setActiveKey] = useState('1'); const [activeKey, setActiveKey] = useState('1');
const [searchWord, setSearchWord] = useState(''); // 关键字
const [keyWord, setKeyWord] = useState(''); // 保存关键字
const [filterRoleList, setFilterRoleList] = useState(rolelist); // 过滤人员
const getRoleValueCallback = useCallback((value, index) => { const getRoleValueCallback = useCallback((value, index) => {
console.log(value); console.log(value);
...@@ -123,7 +127,32 @@ const RelateRoleModal = props => { ...@@ -123,7 +127,32 @@ const RelateRoleModal = props => {
message.error(err); message.error(err);
}); });
}; };
const onChangeList = () => {}; // 获取搜索框的值
const handleSearch = e => {
setSearchWord(e.target.value);
};
// 过滤人员
const searchUser = (e) => {
setKeyWord(searchWord);
console.log(searchWord, filterRoleList, 'filterRoleList');
// setFilterRoleList(rolelist.map(item => {
// // 使用filter来创建一个新数组,只包含符合条件的元素
// return {
// ...item, // 保留item的其他属性
// roleList: item.roleList.filter(ele => ele.roleName.includes(searchWord))
// };
// }).filter(item => item.roleList.length > 0)); // 过滤掉那些roleList为空的项目
// console.log(rolelist.map(item => {
// // 使用filter来创建一个新数组,只包含符合条件的元素
// return {
// ...item, // 保留item的其他属性
// roleList: item.roleList.filter(ele => ele.roleName.includes(searchWord))
// };
// }).filter(item => item.roleList.length > 0),'8888888888888888');
}
const onChangeList = () => { };
const title = ( const title = (
<span> <span>
<span style={{ marginRight: '20px' }}>批量关联角色</span> <span style={{ marginRight: '20px' }}>批量关联角色</span>
...@@ -155,12 +184,20 @@ const RelateRoleModal = props => { ...@@ -155,12 +184,20 @@ const RelateRoleModal = props => {
onCancel={onCancel} onCancel={onCancel}
okText="确认" okText="确认"
cancelText="取消" cancelText="取消"
width="600px" width="650px"
> >
<Spin spinning={loading} tip="loading"> <Spin spinning={loading} tip="loading">
<Tabs activeKey={activeKey} onChange={onChange} style={{ marginTop: '-16px' }}> <Tabs activeKey={activeKey} onChange={onChange} style={{ marginTop: '-16px' }}>
<TabPane tab="角色" key="1"> <TabPane tab="角色" key="1">
<div style={{ height: '500px', overflowY: 'scroll' }}> <div style={{ height: '500px', overflowY: 'scroll' }}>
<Search
style={{ width: 260, marginRight: '15px' }}
placeholder="搜索角色名"
onSearch={e => searchUser(e)}
onChange={e => handleSearch(e)}
enterButton
value={searchWord}
/>
{visible && {visible &&
rolelist.map((role, index) => ( rolelist.map((role, index) => (
<ListCardItem <ListCardItem
...@@ -170,6 +207,7 @@ const RelateRoleModal = props => { ...@@ -170,6 +207,7 @@ const RelateRoleModal = props => {
userList={role.roleList} userList={role.roleList}
multiRoleList={multiRoleList} multiRoleList={multiRoleList}
mult={mult} mult={mult}
searchWord={searchWord}
OUName={role.visibleTitle} OUName={role.visibleTitle}
getValueCallback={getRoleValueCallback} getValueCallback={getRoleValueCallback}
/> />
...@@ -206,11 +244,19 @@ const RelateRoleModal = props => { ...@@ -206,11 +244,19 @@ const RelateRoleModal = props => {
maskClosable={false} maskClosable={false}
okText="确认" okText="确认"
cancelText="取消" cancelText="取消"
width="600px" width="650px"
> >
<Spin spinning={loading} tip="loading"> <Spin spinning={loading} tip="loading">
<Tabs activeKey={activeKey} onChange={onChange} style={{ marginTop: '-16px' }}> <Tabs activeKey={activeKey} onChange={onChange} style={{ marginTop: '-16px' }}>
<TabPane tab="角色" key="1"> <TabPane tab="角色" key="1">
<Search
style={{ width: 260, marginRight: '15px' }}
placeholder="搜索角色名"
onSearch={e => searchUser(e)}
onChange={e => handleSearch(e)}
enterButton
value={searchWord}
/>
<div style={{ height: '500px', overflowY: 'scroll' }}> <div style={{ height: '500px', overflowY: 'scroll' }}>
{visible && {visible &&
rolelist.map((role, index) => ( rolelist.map((role, index) => (
...@@ -219,6 +265,7 @@ const RelateRoleModal = props => { ...@@ -219,6 +265,7 @@ const RelateRoleModal = props => {
key={`item${index}key`} key={`item${index}key`}
userList={role.roleList} userList={role.roleList}
mult={mult} mult={mult}
searchWord={searchWord}
OUName={role.visibleTitle} OUName={role.visibleTitle}
getValueCallback={getRoleValueCallback} getValueCallback={getRoleValueCallback}
tab="roles" tab="roles"
......
...@@ -30,8 +30,8 @@ const ListCardItem = props => { ...@@ -30,8 +30,8 @@ const ListCardItem = props => {
userList.map((item, index) => { userList.map((item, index) => {
let obj = { ...item }; let obj = { ...item };
obj.label = ( obj.label = (
<span className={searchWord && obj.userName.includes(searchWord) ? styles.isSearch : ''}> <span className={searchWord && obj.roleName.includes(searchWord) ? styles.isSearch : ''}>
{obj.userName || obj.roleName || obj.stationName} {obj.roleName || obj.roleName || obj.stationName}
</span> </span>
); );
obj.value = obj.userID || obj.roleID || obj.stationID; obj.value = obj.userID || obj.roleID || obj.stationID;
......
...@@ -374,7 +374,7 @@ export default { ...@@ -374,7 +374,7 @@ export default {
}, },
{ {
path: '/biz/patrolMaintenance', path: '/biz/patrolMaintenance',
name: '巡检维保', name: '巡检配置',
component: BlankLayout, component: BlankLayout,
routes: [ routes: [
{ {
......
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