Commit d56bdc53 authored by 邓超's avatar 邓超

fix: 优化人员选择器组件,替换地图人员选择器

parent 6be5aede
Pipeline #68924 failed with stages
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
/* eslint-disable array-callback-return */ /* eslint-disable array-callback-return */
/* eslint-disable eqeqeq */ /* eslint-disable eqeqeq */
/* eslint-disable no-plusplus */ /* eslint-disable no-plusplus */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect, useRef } from 'react';
import { Modal, Checkbox, Tabs, Input, Button, Pagination, Empty, Tag, Divider } from 'antd'; import { Modal, Checkbox, Tabs, Input, Button, Pagination, Empty, Tag, Divider } from 'antd';
import { CM_Event_LoadDepartmentAndRoles } from '@/services/standingBook/api'; import { CM_Event_LoadDepartmentAndRoles } from '@/services/standingBook/api';
...@@ -30,7 +30,7 @@ const RMSComponents = props => { ...@@ -30,7 +30,7 @@ const RMSComponents = props => {
newCheckedList, newCheckedList,
groupName, groupName,
chooseGroupName, chooseGroupName,
keepFiled, dataType,
} = props; } = props;
const [checkedList, setCheckedList] = useState([]); // 选中复选框内容 const [checkedList, setCheckedList] = useState([]); // 选中复选框内容
const [searchWord, setSearchWord] = useState(''); // 关键字 const [searchWord, setSearchWord] = useState(''); // 关键字
...@@ -53,16 +53,21 @@ const RMSComponents = props => { ...@@ -53,16 +53,21 @@ const RMSComponents = props => {
const [checkAll1, setCheckAll1] = useState(false); const [checkAll1, setCheckAll1] = useState(false);
const [indeterminate2, setIndeterminate2] = useState(false); const [indeterminate2, setIndeterminate2] = useState(false);
const [checkAll2, setCheckAll2] = useState(false); const [checkAll2, setCheckAll2] = useState(false);
const keepFiled = useRef({});
const onSubmit = () => { const onSubmit = () => {
let selectData = []; let selectData = [];
let ids = [];
selected.forEach((val, key) => { selected.forEach((val, key) => {
selectData.push(val.value); selectData.push(val.value);
ids.push(key);
}); });
console.log(ids, 'selected');
callBackSubmit({ callBackSubmit({
str: selectData.join(','), str: selectData.join(','),
pickItem, pickItem,
stt: selectData, stt: selectData,
ids,
}); });
setKeyValue('0'); setKeyValue('0');
setSearchWord(''); setSearchWord('');
...@@ -70,86 +75,97 @@ const RMSComponents = props => { ...@@ -70,86 +75,97 @@ const RMSComponents = props => {
useEffect(() => { useEffect(() => {
if (visible) { if (visible) {
if (groupName == '角色') { CM_Event_LoadDepartmentAndRoles().then(res => {
setKeyValue('0'); if (res.msg === 'Ok') {
setKeepTabKey(0); // setFiled1(formateArrDataA1(res.data, 'groupType'));
} else if (groupName == '部门') {
setKeyValue('1'); keepFiled.current = groupArr(res.data, 'groupType');
setKeepTabKey(1); if (groupName == '角色') {
} else if (groupName == '站点') { setKeyValue('0');
setKeyValue('2'); setKeepTabKey(0);
setKeepTabKey(2); } else if (groupName == '部门') {
} setKeyValue('1');
getRoles(groupName, '', pageSize, 1, 0); setKeepTabKey(1);
let checkArr = []; } else if (groupName == '站点') {
// 角色 setKeyValue('2');
let listdata = []; setKeepTabKey(2);
let listId = [];
newCheckedList.map(checkItem => {
keepFiled['角色'].map(i => {
if (i.label == checkItem) {
listdata.push(i);
listId.push(i.value.toString());
}
});
});
let cs = selected;
listdata.map(i => {
cs.set(i.value, {
value: i.label,
type: 0,
});
});
setSelected(cs);
let dataId = Array.from(new Set(listId));
setCheckDataRole(dataId); // 用于设置首次展示已选列表角色数据
checkArr[0] = dataId;
// 部门
let pmdata = [];
let pmId = [];
newCheckedList.map(checkItem => {
keepFiled['部门'].map(i => {
if (i.label == checkItem) {
pmdata.push(i);
pmId.push(i.value.toString());
}
});
});
let cs1 = selected;
pmdata.map(i => {
cs1.set(i.value, {
value: i.label,
type: 1,
});
});
setSelected(cs1);
let datapmId = Array.from(new Set(pmId));
setCheckDataPm(datapmId);
checkArr[1] = datapmId;
// 站点
let sitedata = [];
let siteId = [];
newCheckedList.map(checkItem => {
keepFiled['站点'].map(i => {
if (i.label == checkItem) {
sitedata.push(i);
siteId.push(i.value.toString());
} }
}); getRoles(groupName, '', pageSize, 1, 0);
}); let checkArr = [];
let cs2 = selected; // 角色
sitedata.map(i => { let listdata = [];
cs2.set(i.value, { let listId = [];
value: i.label, newCheckedList.map(checkItem => {
type: 2, keepFiled.current['角色'].map(i => {
}); let canSave = dataType === 'name' ? i.label == checkItem : i.value == checkItem;
if (canSave) {
listdata.push(i);
listId.push(i.value.toString());
}
});
});
let cs = selected;
listdata.map(i => {
cs.set(i.value, {
value: i.label,
type: 0,
});
});
setSelected(cs);
let dataId = Array.from(new Set(listId));
setCheckDataRole(dataId); // 用于设置首次展示已选列表角色数据
checkArr[0] = dataId;
// 部门
let pmdata = [];
let pmId = [];
newCheckedList.map(checkItem => {
keepFiled.current['部门'].map(i => {
let canSave = dataType === 'name' ? i.label == checkItem : i.value == checkItem;
if (canSave) {
pmdata.push(i);
pmId.push(i.value.toString());
}
});
});
let cs1 = selected;
pmdata.map(i => {
cs1.set(i.value, {
value: i.label,
type: 1,
});
});
setSelected(cs1);
let datapmId = Array.from(new Set(pmId));
setCheckDataPm(datapmId);
checkArr[1] = datapmId;
// 站点
let sitedata = [];
let siteId = [];
newCheckedList.map(checkItem => {
keepFiled.current['站点'].map(i => {
let canSave = dataType === 'name' ? i.label == checkItem : i.value == checkItem;
if (canSave) {
sitedata.push(i);
siteId.push(i.value.toString());
}
});
});
let cs2 = selected;
sitedata.map(i => {
cs2.set(i.value, {
value: i.label,
type: 2,
});
});
setSelected(cs2);
let datasiteId = Array.from(new Set(siteId));
setCheckDataSite(datasiteId);
checkArr[2] = datasiteId;
setSaveCheckValue(checkArr);
console.log(checkArr, 'checkArr');
setCheckedList(checkArr);
}
}); });
setSelected(cs2);
let datasiteId = Array.from(new Set(siteId));
setCheckDataSite(datasiteId);
checkArr[2] = datasiteId;
setSaveCheckValue(checkArr);
setCheckedList(checkArr);
} else { } else {
setSelected(new Map()); setSelected(new Map());
setPageSize(45); setPageSize(45);
...@@ -277,6 +293,7 @@ const RMSComponents = props => { ...@@ -277,6 +293,7 @@ const RMSComponents = props => {
}).then(res => { }).then(res => {
if (res.msg === 'Ok') { if (res.msg === 'Ok') {
setTotal(res.data.count); setTotal(res.data.count);
console.log(groupArr(res.data, 'groupType'), 'groupType');
setOptionValue(groupArr(res.data, 'groupType')); setOptionValue(groupArr(res.data, 'groupType'));
let aa = groupArr(res.data, 'groupType'); let aa = groupArr(res.data, 'groupType');
let list = []; let list = [];
...@@ -292,8 +309,9 @@ const RMSComponents = props => { ...@@ -292,8 +309,9 @@ const RMSComponents = props => {
if (flag != undefined) { if (flag != undefined) {
let listId = []; let listId = [];
newCheckedList.map(checkItem => { newCheckedList.map(checkItem => {
keepFiled[groupName].map(i => { keepFiled.current[groupName].map(i => {
if (i.label == checkItem) { let canSave = dataType === 'name' ? i.label == checkItem : i.value == checkItem;
if (canSave) {
listId.push(i.value.toString()); listId.push(i.value.toString());
} }
}); });
...@@ -416,8 +434,8 @@ const RMSComponents = props => { ...@@ -416,8 +434,8 @@ const RMSComponents = props => {
} }
}); });
let arrList = []; let arrList = [];
keepFiled['角色'] && keepFiled.current['角色'] &&
keepFiled['角色'].map(k => { keepFiled.current['角色'].map(k => {
if (data.indexOf(k.value) != -1) { if (data.indexOf(k.value) != -1) {
arrList.push(k); arrList.push(k);
} }
...@@ -482,8 +500,8 @@ const RMSComponents = props => { ...@@ -482,8 +500,8 @@ const RMSComponents = props => {
} }
}); });
let arrList = []; let arrList = [];
keepFiled['部门'] && keepFiled.current['部门'] &&
keepFiled['部门'].map(k => { keepFiled.current['部门'].map(k => {
if (data.indexOf(k.value) != -1) { if (data.indexOf(k.value) != -1) {
arrList.push(k); arrList.push(k);
} }
...@@ -548,8 +566,8 @@ const RMSComponents = props => { ...@@ -548,8 +566,8 @@ const RMSComponents = props => {
} }
}); });
let arrList = []; let arrList = [];
keepFiled['站点'] && keepFiled.current['站点'] &&
keepFiled['站点'].map(k => { keepFiled.current['站点'].map(k => {
if (data.indexOf(k.value) != -1) { if (data.indexOf(k.value) != -1) {
arrList.push(k); arrList.push(k);
} }
......
...@@ -766,6 +766,7 @@ const AddModal = props => { ...@@ -766,6 +766,7 @@ const AddModal = props => {
groupName={groupName} // 打开组件展示的分组名,用来首次获取数据 groupName={groupName} // 打开组件展示的分组名,用来首次获取数据
chooseGroupName={chooseGroupName} // 可选分组名 chooseGroupName={chooseGroupName} // 可选分组名
keepFiled={keepFiled} keepFiled={keepFiled}
dataType="name"
/> />
</Drawer> </Drawer>
); );
......
...@@ -974,6 +974,7 @@ const AddModal = props => { ...@@ -974,6 +974,7 @@ const AddModal = props => {
groupName={groupName} // 打开组件展示的分组名,用来首次获取数据 groupName={groupName} // 打开组件展示的分组名,用来首次获取数据
chooseGroupName={chooseGroupName} // 可选分组名 chooseGroupName={chooseGroupName} // 可选分组名
keepFiled={keepFiled} keepFiled={keepFiled}
dataType="name"
/> />
</Drawer> </Drawer>
); );
......
...@@ -443,6 +443,7 @@ const AddFlowsModal = props => { ...@@ -443,6 +443,7 @@ const AddFlowsModal = props => {
groupName={groupName} // 打开组件展示的分组名,用来首次获取数据 groupName={groupName} // 打开组件展示的分组名,用来首次获取数据
chooseGroupName={chooseGroupName} // 可选分组名 chooseGroupName={chooseGroupName} // 可选分组名
keepFiled={keepFiled} keepFiled={keepFiled}
dataType="name"
/> />
</Drawer> </Drawer>
); );
......
...@@ -1954,7 +1954,7 @@ const AddModal = props => { ...@@ -1954,7 +1954,7 @@ const AddModal = props => {
label={ label={
<div style={{ display: 'flex', alignItems: 'center' }}> <div style={{ display: 'flex', alignItems: 'center' }}>
<Tooltip <Tooltip
title = {<div>标准用法:使用标准工单系统,可通过勾选 前端/手持,来控制是否展示事件的填报入口,勾选及展示;<br/>内置用法:使用第三方完整功能,仅调用接口、表结构和流程,工单系统中无法使用</div>} title = {<div>标准使用,使用标准工单系统,可通过勾选 前端/手持,来控制是否展示事件的填报入口,勾选及展示;<br/>内置使用,使用第三方完整功能,仅调用接口、表结构和流程,工单系统中无法使用</div>}
// title="标准使用,使用标准工单系统,可通过勾选 前端/手持,来控制是否展示事件的填报入口,勾选及展示; // title="标准使用,使用标准工单系统,可通过勾选 前端/手持,来控制是否展示事件的填报入口,勾选及展示;
// 内置使用,使用第三方完整功能,仅调用接口、表结构和流程,工单系统中无法使用。" // 内置使用,使用第三方完整功能,仅调用接口、表结构和流程,工单系统中无法使用。"
> >
...@@ -2162,6 +2162,7 @@ const AddModal = props => { ...@@ -2162,6 +2162,7 @@ const AddModal = props => {
groupName={groupName} // 打开组件展示的分组名,用来首次获取数据 groupName={groupName} // 打开组件展示的分组名,用来首次获取数据
chooseGroupName={chooseGroupName} // 可选分组名 chooseGroupName={chooseGroupName} // 可选分组名
keepFiled={keepFiled} // 分组数据 keepFiled={keepFiled} // 分组数据
dataType="name"
/> />
<ChangeEdit <ChangeEdit
visible={isVisibleEdit} visible={isVisibleEdit}
......
...@@ -5,6 +5,7 @@ import VisibleRoleModal from '@/pages/platformCenter/messageManage/projectManage ...@@ -5,6 +5,7 @@ import VisibleRoleModal from '@/pages/platformCenter/messageManage/projectManage
import { PlusOutlined, UserAddOutlined } from '@ant-design/icons'; import { PlusOutlined, UserAddOutlined } from '@ant-design/icons';
import RoleModal from './RoleModal'; import RoleModal from './RoleModal';
import RMSComponents from '@/components/RolePmSite/index';
import styles from '../SchemeConfig.less'; import styles from '../SchemeConfig.less';
import { import {
deleteConfig, deleteConfig,
...@@ -155,6 +156,7 @@ const VectorData = props => { ...@@ -155,6 +156,7 @@ const VectorData = props => {
]; ];
// 获取选中的角色 // 获取选中的角色
const onPushSubmit = value => { const onPushSubmit = value => {
console.log(value, 'value');
setAddVisible(false); setAddVisible(false);
if (value.length) { if (value.length) {
let query = { let query = {
...@@ -181,16 +183,18 @@ const VectorData = props => { ...@@ -181,16 +183,18 @@ const VectorData = props => {
}; };
const rolCallBack = useCallback(list => { const rolCallBack = useCallback(list => {
let strList = []; let strList = [];
if (list.length > 0) { console.log(list, 'list');
list.forEach(item => { onPushSubmit(list.ids);
console.log(item, 'item'); // if (list.length > 0) {
Object.keys(item.last).forEach(i => { // list.forEach(item => {
strList.push(i); // console.log(item, 'item');
}); // Object.keys(item.last).forEach(i => {
}); // strList.push(i);
console.log(strList); // });
onPushSubmit(strList); // });
} // console.log(strList);
// onPushSubmit(strList);
// }
}); });
// 获取角色 // 获取角色
...@@ -716,14 +720,25 @@ const VectorData = props => { ...@@ -716,14 +720,25 @@ const VectorData = props => {
tree={tree} tree={tree}
leafs={leafs} leafs={leafs}
/> */} /> */}
<RoleModal <RMSComponents
visible={addVisible}
onCancel={() => {
setAddVisible(false);
}}
callBackSubmit={roleList => rolCallBack(roleList)}
newCheckedList={checkValue.toString().split(',')} // 单选框中的值
groupName="角色" // 打开组件展示的分组名,用来首次获取数据
chooseGroupName={['角色', '部门']} // 可选分组名
dataType="id"
/>
{/* <RoleModal
selectValue={checkValue.toString()} selectValue={checkValue.toString()}
visible={addVisible} visible={addVisible}
rolCallBack={roleList => rolCallBack(roleList)} rolCallBack={roleList => rolCallBack(roleList)}
onCancel={() => { onCancel={() => {
setAddVisible(false); 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