diff --git a/examples/components/Form/Transfer.jsx b/examples/components/Form/Transfer.jsx index a70feed8..c6177730 100644 --- a/examples/components/Form/Transfer.jsx +++ b/examples/components/Form/Transfer.jsx @@ -386,6 +386,46 @@ export default { ] } ] + }, + + { + label: '延时加载', + type: 'transfer', + name: 'transfer7', + selectMode: 'tree', + deferApi: '/api/mock2/form/deferOptions?label=${label}', + options: [ + { + label: '法师', + children: [ + { + label: '诸葛亮', + value: 'zhugeliang' + } + ] + }, + { + label: '战士', + defer: true + }, + { + label: '打野', + children: [ + { + label: '李白', + value: 'libai' + }, + { + label: '韩信', + value: 'hanxin' + }, + { + label: '云中君', + value: 'yunzhongjun' + } + ] + } + ] } ] } diff --git a/mock/form/deferOptions.js b/mock/form/deferOptions.js new file mode 100644 index 00000000..064ea377 --- /dev/null +++ b/mock/form/deferOptions.js @@ -0,0 +1,23 @@ +module.exports = function (req, res) { + let repeat = 2 + Math.round(Math.random() * 5); + const options = []; + + while (repeat--) { + const value = Math.round(Math.random() * 1000000); + const label = value + ''; + + options.push({ + label: label, + value: value, + defer: Math.random() > 0.7 + }); + } + + res.json({ + status: 0, + msg: '', + data: { + options: options + } + }); +}; diff --git a/scss/components/form/_checks.scss b/scss/components/form/_checks.scss index f85c4c68..bbc0689f 100644 --- a/scss/components/form/_checks.scss +++ b/scss/components/form/_checks.scss @@ -404,6 +404,7 @@ &-sublist { position: relative; margin: 0 0 0 px2rem(35px); + display: none; &:before { width: 1px; @@ -420,8 +421,8 @@ &-item { position: relative; - &.is-collapsed > .#{$ns}TreeCheckboxes-sublist { - display: none; + &.is-expanded > .#{$ns}TreeCheckboxes-sublist { + display: block; } } @@ -442,6 +443,7 @@ &-itemInner { display: flex; + align-items: center; height: $Form-input-height; line-height: $Form-input-lineHeight; font-size: $Form-input-fontSize; @@ -452,6 +454,7 @@ > .#{$ns}Checkbox { margin-right: 0; + margin-left: $gap-sm; } cursor: pointer; user-select: none; @@ -481,7 +484,7 @@ &-col { flex-grow: 1; - min-width: 120px; + min-width: 150px; } &-col:not(:last-child) { diff --git a/src/components/ChainedCheckboxes.tsx b/src/components/ChainedCheckboxes.tsx index 17d1d8f3..4725d16a 100644 --- a/src/components/ChainedCheckboxes.tsx +++ b/src/components/ChainedCheckboxes.tsx @@ -6,9 +6,10 @@ import Checkbox from './Checkbox'; import {Option} from './Select'; import {getTreeDepth} from '../utils/helper'; import times from 'lodash/times'; +import Spinner from './Spinner'; export interface ChainedCheckboxesState { - selected: Array