|
71 | 71 | node-key="id" |
72 | 72 | :data="form.appData" |
73 | 73 | :props="defaultProps" |
74 | | - @check-change="onChangeAppData" |
| 74 | + @check="onChangeAppData" |
75 | 75 | show-checkbox |
76 | 76 | > |
77 | 77 | <template #default="{ data }"> |
|
92 | 92 | node-key="id" |
93 | 93 | :data="form.panelData" |
94 | 94 | :props="defaultProps" |
| 95 | + @check="onChangePanelData" |
95 | 96 | show-checkbox |
96 | 97 | > |
97 | 98 | <template #default="{ data }"> |
@@ -485,39 +486,67 @@ const search = async () => { |
485 | 486 | }); |
486 | 487 | }; |
487 | 488 |
|
488 | | -function onChangeAppData(data: any, isCheck: boolean) { |
489 | | - if (data.label !== 'appData' || !data.relationItemID) { |
490 | | - return; |
491 | | - } |
492 | | - data.isCheck = isCheck; |
493 | | - let isDisable = false; |
494 | | - for (const item of form.appData) { |
495 | | - if (!item.children) { |
496 | | - return; |
| 489 | +function onChangeAppData(data: any, checked: any) { |
| 490 | + let isChecked = false; |
| 491 | + let keys = checked.checkedKeys || []; |
| 492 | + for (const item of keys) { |
| 493 | + if (data.id === item) { |
| 494 | + isChecked = true; |
497 | 495 | } |
498 | | - for (const itemData of item.children) { |
499 | | - if (itemData.label === 'appData' && itemData.relationItemID === data.relationItemID && itemData.isCheck) { |
500 | | - isDisable = true; |
| 496 | + } |
| 497 | + let relationID = data.relationItemID; |
| 498 | + if (!relationID) { |
| 499 | + let list = data.children || []; |
| 500 | + for (const item of list) { |
| 501 | + if (item.label === 'appData' && item.relationItemID && !item.isDisable) { |
| 502 | + relationID = item.relationItemID; |
501 | 503 | break; |
502 | 504 | } |
503 | 505 | } |
504 | 506 | } |
| 507 | + if (!relationID) { |
| 508 | + return; |
| 509 | + } |
| 510 | + changeRelation(relationID, isChecked); |
| 511 | +} |
| 512 | +const changeRelation = (relationID: string, isChecked: boolean) => { |
505 | 513 | for (const item of form.appData) { |
506 | 514 | if (!item.children) { |
507 | 515 | return; |
508 | 516 | } |
509 | 517 | for (const relationItem of item.children) { |
510 | | - if (relationItem.id !== data.relationItemID) { |
| 518 | + if (relationItem.id !== relationID) { |
511 | 519 | continue; |
512 | 520 | } |
513 | | - relationItem.isDisable = isDisable; |
514 | | - if (isDisable) { |
515 | | - appRef.value.setChecked(relationItem.id, isDisable, isDisable); |
| 521 | + relationItem.isDisable = isChecked; |
| 522 | + if (isChecked) { |
| 523 | + appRef.value.setChecked(relationItem.id, isChecked, isChecked); |
| 524 | + } |
| 525 | + if (relationItem.relationID) { |
| 526 | + changeRelation(relationItem.relationID, isChecked); |
516 | 527 | } |
517 | 528 | break; |
518 | 529 | } |
519 | 530 | } |
520 | | -} |
| 531 | +}; |
| 532 | +
|
| 533 | +const onChangePanelData = (data: any, checked: any) => { |
| 534 | + let isChecked = false; |
| 535 | + let keys = checked.checkedKeys || []; |
| 536 | + for (const item of keys) { |
| 537 | + if (data.id === item) { |
| 538 | + isChecked = true; |
| 539 | + } |
| 540 | + } |
| 541 | + if (!isChecked && data.label === 'agent' && data.path.indexOf('1panel/agent') !== -1) { |
| 542 | + for (const item of data.children) { |
| 543 | + if (item.label !== 'package') { |
| 544 | + item.isCheck = true; |
| 545 | + panelRef.value.setChecked(item.id, true, true); |
| 546 | + } |
| 547 | + } |
| 548 | + } |
| 549 | +}; |
521 | 550 | const setAppDefaultCheck = async (list: any) => { |
522 | 551 | for (const item of list) { |
523 | 552 | if (item.isCheck) { |
|
0 commit comments