Commit d56bdc53 authored by 邓超's avatar 邓超

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

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