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

fix: '表字段关联表单字段映射支持下拉选择,机构管理不允许删除和冻结panda和admin'

parent 1e9cbff9
Pipeline #63506 passed with stages
...@@ -22,6 +22,7 @@ import { ...@@ -22,6 +22,7 @@ import {
SortDescendingOutlined, SortDescendingOutlined,
PlusSquareOutlined, PlusSquareOutlined,
RollbackOutlined, RollbackOutlined,
ConsoleSqlOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import { import {
reloadTableFields, reloadTableFields,
...@@ -64,6 +65,7 @@ const AddModal = props => { ...@@ -64,6 +65,7 @@ const AddModal = props => {
const [selectGroup, setSelectGroup] = useState([]); const [selectGroup, setSelectGroup] = useState([]);
const [keepStandingBook, setKeepStandingBook] = useState([]); const [keepStandingBook, setKeepStandingBook] = useState([]);
const [keepTreeData, setKeepTreeData] = useState([]); const [keepTreeData, setKeepTreeData] = useState([]);
const [keepTree, setKeepTree] = useState([]); // 保存树字段名称
const editor = record => { const editor = record => {
console.log(record); console.log(record);
...@@ -310,7 +312,7 @@ const AddModal = props => { ...@@ -310,7 +312,7 @@ const AddModal = props => {
res.data.root.map(i => { res.data.root.map(i => {
data.push(i.name); data.push(i.name);
}); });
setKeepStandingBook(data); setKeepStandingBook(res.data.root);
} }
}); });
}, []); }, []);
...@@ -335,6 +337,8 @@ const AddModal = props => { ...@@ -335,6 +337,8 @@ const AddModal = props => {
res.data.root.map(i => { res.data.root.map(i => {
arrlist.push(i.name); arrlist.push(i.name);
}); });
console.log(arrlist);
setKeepTree(arrlist);
data.TableFieldNames = arrlist; data.TableFieldNames = arrlist;
data.TableName = treeSelectValue.substring(0, treeSelectValue.lastIndexOf('@')); data.TableName = treeSelectValue.substring(0, treeSelectValue.lastIndexOf('@'));
listArr.push(data); listArr.push(data);
...@@ -374,6 +378,8 @@ const AddModal = props => { ...@@ -374,6 +378,8 @@ const AddModal = props => {
res.data.root.map(i => { res.data.root.map(i => {
arrlist.push(i.name); arrlist.push(i.name);
}); });
console.log(arrlist);
setKeepTree(arrlist);
data.TableFieldNames = arrlist; data.TableFieldNames = arrlist;
data.TableName = props.location.state.id; data.TableName = props.location.state.id;
listArr.push(data); listArr.push(data);
...@@ -590,6 +596,8 @@ const AddModal = props => { ...@@ -590,6 +596,8 @@ const AddModal = props => {
res.data.root.map(i => { res.data.root.map(i => {
arrlist.push(i.name); arrlist.push(i.name);
}); });
console.log(arrlist);
setKeepTree(arrlist);
data.TableFieldNames = arrlist; data.TableFieldNames = arrlist;
data.TableName = e.substring(0, e.lastIndexOf('@')); data.TableName = e.substring(0, e.lastIndexOf('@'));
listArr.push(data); listArr.push(data);
...@@ -761,6 +769,7 @@ const AddModal = props => { ...@@ -761,6 +769,7 @@ const AddModal = props => {
</Modal> </Modal>
<FieldEditor <FieldEditor
isVisible={isVisible} isVisible={isVisible}
keepTree={keepTree}
keepTreeData={keepTreeData} keepTreeData={keepTreeData}
isType={isType} isType={isType}
itemData={itemData} itemData={itemData}
......
/* eslint-disable no-unused-expressions */
/* eslint-disable eqeqeq */ /* eslint-disable eqeqeq */
import React, { useState, useEffect, useRef } from 'react'; import React, { useState, useEffect, useRef } from 'react';
import { import {
...@@ -169,6 +170,7 @@ const UserManage = () => { ...@@ -169,6 +170,7 @@ const UserManage = () => {
const flagRef = useRef(1); const flagRef = useRef(1);
const [searchWordOrg, setSearchWordOrg] = useState(''); const [searchWordOrg, setSearchWordOrg] = useState('');
const [keepDataList, setKeepDataList] = useState([]);
const setRowClassName = record => const setRowClassName = record =>
record.userID === selectColor.userID ? styles.clickRowStyle : ''; record.userID === selectColor.userID ? styles.clickRowStyle : '';
// 用户表列名 // 用户表列名
...@@ -274,24 +276,27 @@ const UserManage = () => { ...@@ -274,24 +276,27 @@ const UserManage = () => {
</Tooltip> </Tooltip>
{(record.state == 0 || record.state == null) && ( {(record.state == 0 || record.state == null) && (
<> <>
{/* { console.log(record.state,'record.state')} */} {record.loginName == 'panda' || record.loginName == 'admin' ? (
<Tooltip title="冻结用户"> <StopOutlined style={{ fontSize: '16px' }} />
<Popconfirm ) : (
placement="bottomRight" <Tooltip title="冻结用户">
title={ <Popconfirm
<p> placement="bottomRight"
即将冻结用户{' '} title={
<span className={styles.redText}>{voca.stripTags(record.loginName)}</span> <p>
,是否确认冻结? 即将冻结用户{' '}
</p> <span className={styles.redText}>{voca.stripTags(record.loginName)}</span>
} ,是否确认冻结?
okText="确认" </p>
cancelText="取消" }
onConfirm={() => freezeUser(record)} okText="确认"
> cancelText="取消"
<StopOutlined style={{ fontSize: '16px', color: '#e86060' }} /> onConfirm={() => freezeUser(record)}
</Popconfirm> >
</Tooltip> <StopOutlined style={{ fontSize: '16px', color: '#e86060' }} />
</Popconfirm>
</Tooltip>
)}
</> </>
)} )}
{record.state == 1 && ( {record.state == 1 && (
...@@ -345,24 +350,28 @@ const UserManage = () => { ...@@ -345,24 +350,28 @@ const UserManage = () => {
/> />
</Popconfirm> </Popconfirm>
</Tooltip> */} </Tooltip> */}
<Tooltip title="删除用户"> {record.loginName == 'panda' || record.loginName == 'admin' ? (
<Popconfirm <DeleteOutlined style={{ fontSize: '16px' }} />
placement="bottomRight" ) : (
title={ <Tooltip title="删除用户">
<p> <Popconfirm
即将删除用户{' '} placement="bottomRight"
<span className={styles.redText}>{voca.stripTags(record.loginName)}</span> title={
,是否确认删除? <p>
</p> 即将删除用户{' '}
} <span className={styles.redText}>{voca.stripTags(record.loginName)}</span>
// title={`确认删除用户${currentUser}`} ,是否确认删除?
okText="确认" </p>
cancelText="取消" }
onConfirm={() => deleteUser(record)} // title={`确认删除用户${currentUser}`}
> okText="确认"
<DeleteOutlined style={{ fontSize: '16px', color: '#e86060' }} /> cancelText="取消"
</Popconfirm> onConfirm={() => deleteUser(record)}
</Tooltip> >
<DeleteOutlined style={{ fontSize: '16px', color: '#e86060' }} />
</Popconfirm>
</Tooltip>
)}
</Space> </Space>
), ),
}, },
...@@ -706,16 +715,27 @@ const UserManage = () => { ...@@ -706,16 +715,27 @@ const UserManage = () => {
setOrgTitle(res.data.GroupName); setOrgTitle(res.data.GroupName);
setDescription(res.data.Description); setDescription(res.data.Description);
// 返回用户表数据结构处理,扁平化 // 返回用户表数据结构处理,扁平化
console.log(res.data);
const temp = flatten(getUsers(res.data)); const temp = flatten(getUsers(res.data));
console.log(temp);
// 设置过滤字段 // 设置过滤字段
let arr = temp.map(item => item.OUName); let arr = temp.map(item => item.OUName);
console.log(arr);
arr = arr.filter((value, index) => arr.indexOf(value) === index); arr = arr.filter((value, index) => arr.indexOf(value) === index);
console.log(arr);
setOrgFilters(arr.map(item => ({ text: item, value: item }))); setOrgFilters(arr.map(item => ({ text: item, value: item })));
setTableLength(temp.length); setTableLength(temp.length);
let datalist = [];
const table = temp.map((item, index) => { const table = temp.map((item, index) => {
console.log(item);
if (item.loginName == 'panda' || item.loginName == 'admin') {
datalist.push(item.userID);
}
item.key = index; item.key = index;
return item; return item;
}); });
console.log(datalist);
setKeepDataList(datalist);
setShowSearchStyle(false); setShowSearchStyle(false);
setTableData(table); setTableData(table);
} else { } else {
...@@ -901,6 +921,7 @@ const UserManage = () => { ...@@ -901,6 +921,7 @@ const UserManage = () => {
}; };
// 冻结用户 // 冻结用户
const freezeUser = record => { const freezeUser = record => {
console.log(currentUser);
// setFreezeUserVisible(true); // setFreezeUserVisible(true);
setCurrentUser(record); setCurrentUser(record);
setSelectColor(record); setSelectColor(record);
...@@ -1265,28 +1286,48 @@ const UserManage = () => { ...@@ -1265,28 +1286,48 @@ const UserManage = () => {
}; };
// 提交-批量删除用户 // 提交-批量删除用户
const submitDeleteUsers = () => { const submitDeleteUsers = () => {
multiDeleteUsers(userIDs) console.log(userIDs);
.then(res => { console.log(keepDataList);
if (res.code === 0) { console.log(userIDs.split(','));
setDeleteUserVisible(false); let data = [];
notification.success({ keepDataList.length > 0 &&
message: '提交成功', keepDataList.map(i => {
duration: 2, let aa = userIDs.split(',').indexOf(i);
}); console.log(aa);
// 重新获取用户表,查找用户时currentSelectOrg为'-1',无需跳转 if (aa !== -1) {
// eslint-disable-next-line no-unused-expressions data.push(aa);
currentSelectOrg === '-1' ? submitSearchUser() : onSelect([currentSelectOrg]);
} else {
notification.error({
message: '提交失败',
description: res.msg,
});
} }
})
.catch(err => {
setTableLoading(false);
message.error(err);
}); });
console.log(data);
if (data.length > 0) {
notification.error({
message: '操作失败',
description: '选中项包含不可删除的用户panda或admin',
});
} else {
multiDeleteUsers(userIDs)
.then(res => {
if (res.code === 0) {
setDeleteUserVisible(false);
notification.success({
message: '提交成功',
duration: 2,
});
// 重新获取用户表,查找用户时currentSelectOrg为'-1',无需跳转
// eslint-disable-next-line no-unused-expressions
currentSelectOrg === '-1' ? submitSearchUser() : onSelect([currentSelectOrg]);
} else {
notification.error({
message: '提交失败',
description: res.msg,
});
}
})
.catch(err => {
setTableLoading(false);
message.error(err);
});
}
}; };
// 重置默认第一个 // 重置默认第一个
const handleReset = () => { const handleReset = () => {
......
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