Commit 6f6b2e04 authored by Bill's avatar Bill

Merge branch 'fix-material-links' into 'v2-220418'

fix: 修改物料物料组穿梭框父子联动逻辑 See merge request linkseeks-design/pro-platform!262
parents 3529ed15 9bd8090f
......@@ -26,7 +26,7 @@ import ProcurementRoute from './procurementRoute'; // todo wuting
// import contracRoute from './contracRoute';
// export const routes = [CommodityRoute, MemberRoute, ShopRoute, ChannelRoute, TranactionRoute, AfterService, PayandSettleRoute, LogisticsRoute, AuthConfigRoute, HandlingRoute, BalaceRoute]
const isDev = process.env.NODE_ENV === "development";
const isDev = false;
const homeRoute = {
path: `/memberCenter/home`,
name: 'home',
......
......@@ -85,7 +85,7 @@ export default {
'material.belong.materialGroup': '所属物料组',
'material.remark': '备注',
'material.goodsPic.validate.format': '仅支持JPG/PNG/JPEG格式',
'material.goodsPic.validate.size': '图片大小小于600KB',
'material.goodsPic.validate.size': '图片大小需要小于600KB',
'material.columns.file': '文件',
'material.columns.description': '备注',
'material.sourceList.column.memberId': '会员id',
......
......@@ -85,7 +85,7 @@ const FormilyTransfer: React.FC<Iprops> & { isFieldComponent: boolean } = (props
const onChecked = (checkedKeys, info) => {
const { checked, node } = info;
const newCheckedKeys = [...checkedKeys, node.id];
const newCheckedKeys = checked ? [...checkedKeys, node.id] : [node.id];
// 从上到下, 联动勾选
for(let i = 0; i < levelSet.maxLevel; i++) {
......@@ -103,38 +103,58 @@ const FormilyTransfer: React.FC<Iprops> & { isFieldComponent: boolean } = (props
})
}
// 从下而上,联动勾选
const visitedKeys = new Set();
for (let level = levelSet.maxLevel; level >= 0; level -= 1) {
const entities = levelSet.levelMap.get(level) || new Set();
entities.forEach(entity => {
const { parent, node } = entity;
if (!entity.parent || visitedKeys.has(entity.parent.id)) {
return;
if(checked) {
// 从下而上,联动勾选
const visitedKeys = new Set();
for (let level = levelSet.maxLevel; level >= 0; level -= 1) {
const entities = levelSet.levelMap.get(level) || new Set();
entities.forEach(entity => {
const { parent, node } = entity;
if (!entity.parent || visitedKeys.has(entity.parent.id)) {
return;
}
let allChecked = true;
(parent.children || [])
.forEach(({ id }) => {
const checked = newCheckedKeys.includes(id);
if (allChecked && !checked) {
allChecked = false;
}
});
if (allChecked) {
newCheckedKeys.push(parent.id);
}
visitedKeys.add(parent.key);
});
}
} else {
// 有向图, 维护队列一直向上找他的父亲节点
const queue = [...newCheckedKeys];
const parentSet = new Set();
while(queue.length > 0) {
const item = queue.pop();
if (parentSet.has(item)) {
continue;
}
let allChecked = true;
(parent.children || [])
.forEach(({ id }) => {
const checked = newCheckedKeys.includes(id);
if (allChecked && !checked) {
allChecked = false;
}
});
const current = treeNodes[item];
if (current) {
if (allChecked) {
newCheckedKeys.push(parent.id);
parentSet.add(current.id);
queue.push(current.parentId);
newCheckedKeys.push(current.parentId);
}
visitedKeys.add(parent.key);
});
}
}
console.log("newCheckedKeys", newCheckedKeys);
return newCheckedKeys
return Array.from(new Set(newCheckedKeys))
}
......@@ -151,7 +171,6 @@ const FormilyTransfer: React.FC<Iprops> & { isFieldComponent: boolean } = (props
{({ direction, onItemSelect, selectedKeys, onItemSelectAll }) => {
if (direction === 'left') {
const checkedKeys = [...selectedKeys, ...value];
console.log("selectedKeys", selectedKeys, checkedKeys)
const treeData = generateTree(dataSource, value || [])
return (
<Tree
......@@ -163,6 +182,7 @@ const FormilyTransfer: React.FC<Iprops> & { isFieldComponent: boolean } = (props
onCheck={(checkedKeysValue, e) => {
const isChecked = e.checked;
const newData = onChecked(checkedKeys, e)
onItemSelectAll(newData, isChecked);
}}
/>
......
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