@@ -48,13 +48,14 @@ export const RulesController = <T,>(props: IProps<T>) => {
4848
4949 // 计算每个节点的高度(height)/线条高度(lineHeight)/距离底部高度(bottom)
5050 const calculateTreeItemHeight = ( item : IFilterValue < T > , disabled : boolean ) => {
51+ const composeDisabled = disabled || ! ! item . disabled ;
5152 if ( ! item ?. children )
5253 return weakMap . set ( item , { height : ITEM_HEIGHT + MARGIN , lineHeight : ITEM_HEIGHT } ) ;
53- item . children . map ( ( child ) => calculateTreeItemHeight ( child , disabled ) ) ;
54+ item . children . map ( ( child ) => calculateTreeItemHeight ( child , composeDisabled ) ) ;
5455 const isLastCondition = ! item . children . some ( isCondition ) ;
5556 const firstNodeIsCondition = isCondition ( item . children [ 0 ] ) ;
5657 // 编辑模式下计算
57- if ( ! disabled ) {
58+ if ( ! composeDisabled ) {
5859 const height = item . children . reduce (
5960 ( prev , curr ) => prev + weakMap . get ( curr ) . height ,
6061 ITEM_HEIGHT
@@ -123,6 +124,8 @@ export const RulesController = <T,>(props: IProps<T>) => {
123124 namePath : InternalNamePath ,
124125 disabled : boolean
125126 ) => {
127+ const composeDisabled = disabled || ! ! item . disabled ;
128+
126129 // 渲染条件节点和线条
127130 if ( item ?. children ?. length ) {
128131 const childrenPath = ( index : number ) => {
@@ -140,15 +143,16 @@ export const RulesController = <T,>(props: IProps<T>) => {
140143 >
141144 < div
142145 className = { classnames ( 'condition__box' , {
143- disabled,
146+ disabled : composeDisabled ,
144147 } ) }
145148 style = { { height : lineHeight , bottom : bottom ?? MARGIN } }
146149 >
147150 < span
148151 className = { classnames ( 'condition__box--name' , {
149- disabled,
152+ disabled : composeDisabled ,
150153 } ) }
151154 onClick = { ( ) =>
155+ ! composeDisabled &&
152156 onChangeCondition ( item . key , item ?. type as ROW_PERMISSION_RELATION )
153157 }
154158 >
@@ -163,9 +167,9 @@ export const RulesController = <T,>(props: IProps<T>) => {
163167 ) }
164168 </ div >
165169 { item . children . map ( ( d : IFilterValue < T > , index : number ) =>
166- renderCondition ( d , childrenPath ( index ) , disabled )
170+ renderCondition ( d , childrenPath ( index ) , composeDisabled )
167171 ) }
168- { ! disabled && (
172+ { ! composeDisabled && (
169173 < div className = "condition__add" >
170174 < span className = "condition__add--line" />
171175 < PlusCircleOutlined
@@ -200,20 +204,18 @@ export const RulesController = <T,>(props: IProps<T>) => {
200204 < div className = "ruleController__item--component" >
201205 { component ( {
202206 rowKey : item . key ,
203- disabled,
207+ disabled : composeDisabled ,
204208 name : [ ...namePath , 'rowValues' ] ,
205209 rowValues : item . rowValues as T ,
206210 onChange : onChangeRowValues ,
207211 } ) }
208212 </ div >
209- { ! disabled && (
213+ { ! composeDisabled && (
210214 < div className = "ruleController__item--operation" >
211215 { item . level === maxLevel ? null : (
212216 < PlusCircleOutlined
213217 className = "icon"
214- onClick = { ( ) => {
215- onAddCondition ( { key : item . key } ) ;
216- } }
218+ onClick = { ( ) => onAddCondition ( { key : item . key } ) }
217219 />
218220 ) }
219221 < MinusCircleOutlined
@@ -225,7 +227,14 @@ export const RulesController = <T,>(props: IProps<T>) => {
225227 </ div >
226228 ) ;
227229 } ;
230+
228231 if ( ! value ) return null ;
232+
229233 calculateTreeItemHeight ( value , ! ! disabled ) ;
230- return < div className = "ruleController" > { renderCondition ( value , [ ] , ! ! disabled ) } </ div > ;
234+
235+ return (
236+ < div className = "ruleController" >
237+ { renderCondition ( value , [ ] , ! ! disabled || ! ! value . disabled ) }
238+ </ div >
239+ ) ;
231240} ;
0 commit comments