Commit 790b67d1 authored by 皮倩雯's avatar 皮倩雯

fix: 'web配置关联角色增加多选,角色管理新增默认分组'

parent c1facb6f
Pipeline #44182 skipped with stages
......@@ -85,8 +85,10 @@ const RoalChoose = props => {
};
// 复选框监听事件
const selectChange = (e, index, value) => {
console.log(plainOptions);
let list = JSON.parse(JSON.stringify(plainOptions));
list[index].isChecked = e.target.checked;
console.log(list);
// 存储勾选角色或站点信息
if (e.target.checked) {
// 存储已选角色或站点的默认承办人
......@@ -106,6 +108,9 @@ const RoalChoose = props => {
delArr.set(value.id, selected.get(value.id));
selected.delete(value.id);
}
console.log(list);
console.log(selected);
console.log(list);
setDelArr(delArr);
setSelected(selected);
setPlainOptions(list);
......
......@@ -42,7 +42,7 @@ const VectorData = props => {
return (
<>
<Spin tip="loading..." spinning={treeLoading}>
<div style={{ height: '780px', overflow: 'scroll' }}>
<div>
<div className={styles.tileBtn}>
<Button
type="primary"
......@@ -53,22 +53,24 @@ const VectorData = props => {
新增
</Button>
</div>
<div className={styles.cardsList}>
{tileData && tileData.length
? tileData.map((item, index) => {
return (
<div
className={styles.cardItem}
key={index}
span={5}
offset={2}
style={{ marginBottom: '1rem' }}
>
<Cards item={item} deletebaseMaps={onDeletebaseMap} />
</div>
);
})
: ''}
<div style={{ height: '700px', overflow: 'scroll' }}>
<div className={styles.cardsList}>
{tileData && tileData.length
? tileData.map((item, index) => {
return (
<div
className={styles.cardItem}
key={index}
span={5}
offset={2}
style={{ marginBottom: '1rem' }}
>
<Cards item={item} deletebaseMaps={onDeletebaseMap} />
</div>
);
})
: ''}
</div>
</div>
<AddModal
visible={visible}
......
......@@ -17,11 +17,11 @@ import AddModal from './AddModal';
const VectorData = props => {
const [treeLoading, setTreeLoading] = useState(false); // 弹窗显示
const [schemename, setSchemename] = useState([]);
const [record, setRecord] = useState({}); //选中关联角色的方案名
const [record, setRecord] = useState({}); // 选中关联角色的方案名
const [webCurrent, setWebCurrent] = useState(0); // web列表下标
const [handCurrent, setHandCurrent] = useState(0); // hand列表下标
const [webData, setWebData] = useState([]); // web数据
const [handData, setHandData] = useState([]); //手持数据
const [handData, setHandData] = useState([]); // 手持数据
const [visible, setVisible] = useState(false); // 弹窗
const [flag, setFlag] = useState(0); // 更新list
const [handStatus, setHandStatus] = useState([]); // 更新状态
......@@ -416,6 +416,7 @@ const VectorData = props => {
columns={columns}
dataSource={webData}
bordered
style={{ height: 'calc(100vh - 230px)' }}
pagination={{
showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条`,
defaultPageSize: 8,
......@@ -424,7 +425,7 @@ const VectorData = props => {
},
}}
rowKey={(record, index) => record.scheme.schemename}
scroll={{ y: 600 }}
scroll={{ y: 300 }}
/>
</div>
{/* <Divider orientation="left"><div className={styles.divider}>手持 <PlusOutlined
......
......@@ -46,7 +46,7 @@ const VectorData = props => {
return (
<>
<Spin tip="loading..." spinning={treeLoading}>
<div>
<div style={{ height: '780px', overflow: 'scroll' }}>
<div className={styles.tileBtn}>
<Button
type="primary"
......
......@@ -250,7 +250,7 @@ const ProjectManage = props => {
};
const onTypeChange = value => {
if (value == '全部') {
setCurrentType('');
setCurrentType('全部');
GetMessageList({ pageIndex, pageSize: 10 });
} else {
GetMessageList({
......@@ -264,7 +264,7 @@ const ProjectManage = props => {
};
const onNameChange = value => {
if (value == '全部') {
setCurrentName('');
setCurrentName('全部');
GetMessageList({ pageIndex, pageSize: 10 });
} else {
GetMessageList({
......
......@@ -253,7 +253,11 @@ const TemplateManage = () => {
const placeholder = '请输入模板名称';
const handleSearch = value => {
setValue(value);
getTemplateList({ queryInfo: value });
if (currentType == '全部') {
getTemplateList({ queryInfo: value });
} else {
getTemplateList({ queryInfo: value, tempType: currentType });
}
setShowSearchStyle(true);
};
const handleReset = () => {
......@@ -267,7 +271,7 @@ const TemplateManage = () => {
};
const handleSelectType = value => {
if (value === '全部') {
setCurrentType('');
setCurrentType('全部');
getTemplateList();
} else {
getTemplateList({ tempType: value });
......
.formStyle{
.formStyle {
margin-bottom: 40px;
padding-bottom: 30px;
}
.rolebox{
.rolebox {
display: flex;
justify-content: space-between;
flex-wrap: nowrap;
}
\ No newline at end of file
}
.cardItemData {
display: flex;
justify-content: space-around;
width: 100%;
padding: 1rem;
border: 1px solid #b5b8c8;
margin-bottom: 1rem;
overflow-x: scroll;
}
.divBox {
// display: flex;
width: 100%;
flex-wrap: wrap;
border: 1px solid #c2cdfd;
border-radius: 5px;
margin-top: 20px;
min-height: 50px;
padding: 0 10px 10px 20px;
.ant-checkbox-wrapper {
background-color: #fff;
}
.topCheckbox {
height: 20px;
margin: -10px 0 0 0px;
line-height: 20px;
}
.topCheckbox > label :hover {
font-weight: 600;
}
.checkdiv {
display: flex;
flex-wrap: wrap;
// margin-left: 20px;
// justify-content: space-between;
}
}
.boe {
border: 1px solid #d9d9d9;
width: 93%;
margin-left: 3%;
}
......@@ -8,10 +8,12 @@ import {
Select,
Radio,
Checkbox,
checkedValue,
message,
notification,
} from 'antd';
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
import classnames from 'classnames';
import styles from './addForm.less';
import PicturesWall from '@/components/Upload/index';
import EditeConfigWrapper from './editConfigFileWrapper';
......@@ -25,6 +27,8 @@ const EditForm = props => {
submitCallback,
nodeType,
info,
infoAll,
checkList,
configFiles,
valueCallback = () => {},
productList,
......@@ -32,6 +36,10 @@ const EditForm = props => {
const [form] = Form.useForm();
const [otherForm] = Form.useForm();
const [showParmarModal, setShowParmarModal] = useState(false);
const [plainOptions, setPlainOptions] = useState([]); // 存储一级数据
const [indeterminate, setIndeterminate] = useState([]);
const [indeterminateAll, setIndeterminateAll] = useState(false);
const [choo, setChoo] = useState(false); // 最外层复选框状态
const layout = {
layout: 'horizontal',
labelCol: { span: 2 },
......@@ -41,20 +49,71 @@ const EditForm = props => {
useEffect(() => {
form.resetFields();
otherForm.resetFields();
}, [info]);
setPlainOptions(info);
}, [infoAll]);
useEffect(() => {
const targetForm = nodeType === 1 ? form : otherForm;
let arr = Object.keys(targetForm.getFieldsValue());
let obj = {};
arr.map(i => {
obj[i] = info[i];
obj[i] = infoAll[i];
});
targetForm.setFieldsValue({ ...obj, shortName: info.menuShortName });
}, [info]);
targetForm.setFieldsValue({ ...obj, shortName: infoAll.menuShortName });
if (info.length > 0) {
let list = [];
info.map(item => {
list.push(item);
});
let chooseData = [];
let listData = [];
list.forEach((item, index) => {
chooseData.push(
!!list[index].checkedList.size && list[index].checkedList.size < list[index].list.length,
);
item.list.map(i => {
listData.push(i.related);
});
});
let data = new Set();
info.map(item => {
if (item.isChecked == true) {
data.add(item.groupName);
}
});
if (data.size == info.length) {
setChoo(true);
setIndeterminateAll(false);
} else {
setChoo(false);
if (listData.indexOf(true) != -1) {
setIndeterminateAll(true);
}
}
if (data.size == 0) {
setIndeterminateAll(false);
}
setIndeterminate(chooseData);
}
}, [infoAll]);
const submit = () => {
const targetForm = nodeType === 1 ? form : otherForm;
let obj = targetForm.getFieldsValue();
console.log(obj);
console.log(plainOptions);
let data = [];
if (nodeType == 1) {
plainOptions.map(item => {
item.checkedList.forEach(i => {
data.push(i);
});
});
if (data.length > 0) {
obj.relatedRoleList = data.toString();
} else {
obj.relatedRoleList = '';
}
}
submitCallback(obj);
};
......@@ -71,6 +130,138 @@ const EditForm = props => {
setShowParmarModal(true);
};
const radioChange = e => {};
// 一级复选框改变事件
const selectChange = (e, index, value) => {
let list = [];
plainOptions.map(item => {
list.push(item);
});
list[index].isChecked = e.target.checked;
if (e.target.checked) {
checkList.add(list[index].groupName);
list[index].list.map(i => {
i.related = true;
list[index].checkedList.add(i.relatedRoleCode);
});
} else {
checkList.delete(list[index].groupName);
list[index].list.map(i => {
i.related = false;
list[index].checkedList.delete(i.relatedRoleCode);
});
}
const indeterminateArr = [...indeterminate];
indeterminateArr[index] = false;
setIndeterminate(indeterminateArr);
let flag = [];
let data = [];
list.map(item => {
if (item.isChecked == false) {
flag.push(item);
}
});
list.map((k, i) => {
data.push(list[i].isChecked);
});
if (data.indexOf(true) == -1) {
setIndeterminateAll(false);
} else if (data.indexOf(false) == -1) {
setIndeterminateAll(false);
} else {
setIndeterminateAll(true);
}
if (flag.length > 0) {
setChoo(false);
} else {
setChoo(true);
}
setPlainOptions(list);
};
// 二级复选框改变事件
const handleChecked = (e, index, value, i) => {
let list = [];
plainOptions.map(item => {
list.push(item);
});
list[index].list[i].related = e.target.checked;
if (e.target.checked) {
list[index].checkedList.add(list[index].list[i].relatedRoleCode);
} else {
list[index].checkedList.delete(list[index].list[i].relatedRoleCode);
}
const indeterminateArr = [...indeterminate];
indeterminateArr[index] =
!!list[index].checkedList.size && list[index].checkedList.size < list[index].list.length;
setIndeterminate(indeterminateArr);
if (
list[index].checkedList.size == 0 ||
list[index].checkedList.size < list[index].list.length
) {
list[index].isChecked = false;
}
if (list[index].checkedList.size == list[index].list.length) {
list[index].isChecked = true;
}
let flag = [];
let data = [];
list.map(item => {
if (item.isChecked == false) {
flag.push(item);
}
});
list.map((k, i) => {
k.list.map(p => {
data.push(p.related);
});
// data.push(list[i].isChecked);
});
if (data.indexOf(true) == -1) {
setIndeterminateAll(false);
} else if (data.indexOf(false) == -1) {
setIndeterminateAll(false);
} else {
setIndeterminateAll(true);
}
if (flag.length > 0) {
setChoo(false);
} else {
setChoo(true);
}
setPlainOptions(list);
};
// 全选复选框改变事件
const checkAll = () => {
let list = [];
plainOptions.map(item => {
list.push(item);
});
if (choo == false) {
indeterminate.forEach((i, j) => {
if (i == true) {
indeterminate[j] = false;
}
});
setChoo(true);
list.map((item, index) => {
item.isChecked = true;
item.list.map(i => {
i.related = true;
list[index].checkedList.add(i.relatedRoleCode);
});
});
} else {
setChoo(false);
list.map((item, index) => {
item.isChecked = false;
item.list.map(i => {
i.related = false;
list[index].checkedList.delete(i.relatedRoleCode);
});
});
}
setIndeterminateAll(false);
setPlainOptions(list);
};
return (
<div style={{ marginTop: '10px' }}>
{nodeType === 1 && (
......@@ -153,7 +344,95 @@ const EditForm = props => {
</Select>
</EditeConfigWrapper>
</Item>
<CheckList info={info} nodeType={nodeType} valueCallback={valueCallback} />
<div className={styles.boe}>
{/* <div style={{ marginTop: '-16px', fontSize: '16px', marginLeft: '21px' }}>关联角色</div> */}
<div
style={{ width: '95%', marginLeft: '2%', marginTop: '10px', marginBottom: '20px' }}
>
<div style={{ marginTop: '-23px', backgroundColor: 'white', width: '92px' }}>
<Checkbox
onChange={checkAll}
checked={choo}
nodeType={nodeType}
indeterminate={indeterminateAll}
>
<span style={{ fontWeight: 'bold', fontSize: '15px' }}>关联角色</span>
</Checkbox>
</div>
{plainOptions && plainOptions.length > 0 ? (
plainOptions.map((item, index) => {
return (
<div
className={classnames({
[styles.divBox]: item.groupName.length > 0,
})}
>
<div style={{ marginTop: '-12px' }}>
{item.groupName.length == 0 ? (
<span style={{ marginLeft: '15px', marginTop: '0px' }} />
) : (
<Checkbox
onChange={e => {
selectChange(e, index, item);
}}
checked={item.isChecked}
indeterminate={indeterminate[index]}
>
<span style={{ fontWeight: 'bold', fontSize: '15px' }}>
{item.groupName}
</span>
</Checkbox>
)}
</div>
<div style={{ marginLeft: '0px', marginTop: '5px' }}>
{item.groupName.length == 0 ? (
<>
<Row>
{item.list.map((val, i) => {
return (
<Col span={4} style={{ marginBottom: '10px' }}>
<Checkbox
onChange={e => {
handleChecked(e, index, item, i);
}}
checked={val.related}
>
{val.relatedRoleName}
</Checkbox>
</Col>
);
})}
</Row>
</>
) : (
<>
<Row>
{item.list.map((val, i) => {
return (
<Col span={4}>
<Checkbox
onChange={e => {
handleChecked(e, index, item, i);
}}
checked={val.related}
>
{val.relatedRoleName}
</Checkbox>
</Col>
);
})}
</Row>
</>
)}
</div>
</div>
);
})
) : (
<span />
)}
</div>
</div>
<Item wrapperCol={{ offset: 10 }} style={{ marginTop: '20px' }}>
<Button type="primary" htmlType="submit">
提交
......
......@@ -35,6 +35,7 @@ const MiniMenu = props => {
const [menuID, setMenuID] = useState(''); // 选中的树ID
const [nodeType, setNodeType] = useState(''); // 选中的节点类型
const [info, setInfo] = useState({});
const [infoAll, setInfoAll] = useState({});
const [importOrExportVisible, setImportOrExportVisible] = useState(false); // 导入导出弹窗
const [addVisible, setAddVisible] = useState(false); // 新增弹窗
const [addTwoVisible, setAddTwoVisible] = useState(false); // 编辑弹窗
......@@ -46,6 +47,8 @@ const MiniMenu = props => {
const [modalLoading, setModalLoading] = useState(false);
const [submitLoading, setSubmitLoading] = useState(false);
const [newTreeList, setNewTreeList] = useState([]);
const [checkList, setCheckList] = useState([]);
const [flagg, setFlagg] = useState(0);
const [menuList, setMenuList] = useState([]); // 菜单树
......@@ -141,7 +144,26 @@ const MiniMenu = props => {
.then(res => {
setLoading(false);
if (res.code === 0) {
setInfo({ ...res.data });
let infoList = res.data.relatedRoleList.map(item => ({
groupName: item.groupName,
isChecked: item.isChecked,
list: item.list,
checkedList: new Set([]),
}));
setInfo(infoList);
setInfoAll({ ...res.data });
let data = new Set();
infoList.map(item => {
if (item.isChecked == true) {
data.add(item.groupName);
}
item.list.map(i => {
if (i.related) {
item.checkedList.add(i.relatedRoleCode);
}
});
});
setCheckList(data);
} else {
notification.error({
message: '提示',
......@@ -285,8 +307,9 @@ const MiniMenu = props => {
setLoading(true);
let baseUrl = handleGeturl(prop.imageUrl);
let obj = { ...prop, baseUrl };
console.log(obj);
if (nodeType === 1) {
obj.relatedRoleList = String(roleList) || '';
// obj.relatedRoleList = roleList || '';
editWebMenu({
_dc: Date.now(),
menuID: Number(menuID),
......@@ -295,7 +318,6 @@ const MiniMenu = props => {
})
.then(res => {
setLoading(false);
if (res.code === 0) {
// setFlag(flag + 1);
getTree();
......@@ -331,7 +353,6 @@ const MiniMenu = props => {
})
.then(res => {
setLoading(false);
if (res.code === 0) {
// setFlag(flag + 1);
getTree();
......@@ -357,14 +378,15 @@ const MiniMenu = props => {
}
};
const valueCallback = val => {
let arr = [...val];
let arr2 = [];
arr.map(item => {
if (item.related) {
arr2.push(item.relatedRoleCode);
}
});
setRoleList(arr2);
console.log(val);
// let arr = [...val];
// let arr2 = [];
// arr.map(item => {
// if (item.related) {
// arr2.push(item.relatedRoleCode);
// }
// });
setRoleList(val.toString());
};
// 返回拖拽完毕后的信息
const loop = (data, key, parentID, callback) => {
......@@ -612,6 +634,8 @@ const MiniMenu = props => {
<EditForm
nodeType={nodeType}
info={info}
infoAll={infoAll}
checkList={checkList}
configFiles={configFiles}
productList={productList}
submitCallback={editSubmitCallback}
......
......@@ -65,6 +65,7 @@ const SiteManage = () => {
const [mulu, setMulu] = useState(true); // 展示目录
const [siteList, setSiteList] = useState([]);
const [disFlag, setDisFlag] = useState(false);
// const [childData, setChildData] = useState({visibleValue:''})
// 点击树的回调
const handleTreeSelect = (e, treenode) => {
......@@ -114,10 +115,34 @@ const SiteManage = () => {
getRoleGroupList({ userID: '1' }).then(res => {
setSpinLoading(false);
if (res.code === 0) {
console.log(res.data.roleList);
res.data.roleList.map((i, j) => {
console.log(i);
if (i.child.length == 0) {
let childData = { visibleTitle: '默认分组', roleList: [] };
childData.visibleValue = i.visibleValue;
i.child.push(childData);
} else {
let arr = [];
i.child.map(k => {
arr.push(k.visibleTitle);
// if (k.visibleTitle != '默认分组') {
// console.log(11);
// let childData = { visibleTitle: '默认分组', roleList: [] };
// childData.visibleValue = i.visibleValue;
// i.child.push(childData);
// }
});
if (arr.indexOf('默认分组') == -1) {
let childData = { visibleTitle: '默认分组', roleList: [] };
childData.visibleValue = i.visibleValue;
i.child.push(childData);
}
}
});
console.log(res.data.roleList);
const { roleList } = res.data;
let arr = transTree(roleList);
console.log(roleList);
console.log(arr);
setTreeData(arr);
}
});
......@@ -198,6 +223,7 @@ const SiteManage = () => {
// 树形数据转换;
const transTree = val => {
let arr = val;
console.log(arr);
let newArr = [];
// 提取child里面的数组
let arr2 = arr.filter(item => {
......@@ -273,7 +299,7 @@ const SiteManage = () => {
/>
</Tooltip>
)}
{i.groupflag && (
{i.groupflag && i.groupflag != '默认分组' && (
<Tooltip title="编辑分组" className={styles.fs}>
<EditOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
......@@ -338,7 +364,7 @@ const SiteManage = () => {
/>
</Tooltip>
)}
{itemRole.groupflag && (
{itemRole.groupflag && itemRole.groupflag != '默认分组' && (
<Tooltip title="编辑分组" className={styles.fs}>
<EditOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
......@@ -387,7 +413,7 @@ const SiteManage = () => {
/>
</Tooltip>
)}
{item.groupflag && (
{item.groupflag && item.groupflag != '默认分组' && (
<Tooltip title="编辑分组" className={styles.fs}>
<EditOutlined
style={{ fontSize: '16px', color: '#1890FF' }}
......
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