Commit 7d9070cb authored by 武广's avatar 武广

feat: 添加初始化tree

parent 0d105a36
...@@ -8,7 +8,7 @@ const CustomTree = forwardRef(props => { ...@@ -8,7 +8,7 @@ const CustomTree = forwardRef(props => {
const { treeData } = props; const { treeData } = props;
const onChange = () => { const onChange = () => {
props.onChange(treeData.key, !treeData.checked); props.onChange(treeData.key, !treeData.checked, treeData.level);
}; };
const onVisible = debounce(e => { const onVisible = debounce(e => {
......
This diff is collapsed.
...@@ -48,15 +48,22 @@ const AddAreaModal = props => { ...@@ -48,15 +48,22 @@ const AddAreaModal = props => {
const handleOk = () => { const handleOk = () => {
validateFields(async (error, fieldsValue) => { validateFields(async (error, fieldsValue) => {
const newData = []; const newData = [];
console.log('fieldsValue :>> ', fieldsValue); const getValues = list => {
fieldsValue.list.map(itemData => list.forEach(itemData => {
if (itemData.checked) {
newData.push({ newData.push({
addressId: itemData.key, addressId: itemData.key,
addressLevel: itemData.level, addressLevel: itemData.level,
addressName: itemData.label, addressName: itemData.label,
}), });
); } else if (itemData.children && itemData.children.length) {
getValues(itemData.children);
}
});
};
if (!error) { if (!error) {
console.log('fieldsValue :>> ', fieldsValue);
getValues(fieldsValue.list);
if (props.templateData.status) { if (props.templateData.status) {
const data = await forbiddenAddress({ const data = await forbiddenAddress({
templateId: props.templateData.id, templateId: props.templateData.id,
...@@ -91,6 +98,9 @@ const AddAreaModal = props => { ...@@ -91,6 +98,9 @@ const AddAreaModal = props => {
let arr = []; let arr = [];
const dealData = list => const dealData = list =>
list.map(item => { list.map(item => {
item.key = +item.addressId;
item.label = item.addressName;
item.indeterminate = !item.isForbidden;
item.checked = item.isForbidden; item.checked = item.isForbidden;
item.children && item.children.length && dealData(item.children); item.children && item.children.length && dealData(item.children);
return item; return item;
......
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