@@ -48,13 +48,14 @@ export const RulesController = <T,>(props: IProps<T>) => {
48
48
49
49
// 计算每个节点的高度(height)/线条高度(lineHeight)/距离底部高度(bottom)
50
50
const calculateTreeItemHeight = ( item : IFilterValue < T > , disabled : boolean ) => {
51
+ const composeDisabled = disabled || ! ! item . disabled ;
51
52
if ( ! item ?. children )
52
53
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 ) ) ;
54
55
const isLastCondition = ! item . children . some ( isCondition ) ;
55
56
const firstNodeIsCondition = isCondition ( item . children [ 0 ] ) ;
56
57
// 编辑模式下计算
57
- if ( ! disabled ) {
58
+ if ( ! composeDisabled ) {
58
59
const height = item . children . reduce (
59
60
( prev , curr ) => prev + weakMap . get ( curr ) . height ,
60
61
ITEM_HEIGHT
@@ -123,6 +124,8 @@ export const RulesController = <T,>(props: IProps<T>) => {
123
124
namePath : InternalNamePath ,
124
125
disabled : boolean
125
126
) => {
127
+ const composeDisabled = disabled || ! ! item . disabled ;
128
+
126
129
// 渲染条件节点和线条
127
130
if ( item ?. children ?. length ) {
128
131
const childrenPath = ( index : number ) => {
@@ -140,15 +143,16 @@ export const RulesController = <T,>(props: IProps<T>) => {
140
143
>
141
144
< div
142
145
className = { classnames ( 'condition__box' , {
143
- disabled,
146
+ disabled : composeDisabled ,
144
147
} ) }
145
148
style = { { height : lineHeight , bottom : bottom ?? MARGIN } }
146
149
>
147
150
< span
148
151
className = { classnames ( 'condition__box--name' , {
149
- disabled,
152
+ disabled : composeDisabled ,
150
153
} ) }
151
154
onClick = { ( ) =>
155
+ ! composeDisabled &&
152
156
onChangeCondition ( item . key , item ?. type as ROW_PERMISSION_RELATION )
153
157
}
154
158
>
@@ -163,9 +167,9 @@ export const RulesController = <T,>(props: IProps<T>) => {
163
167
) }
164
168
</ div >
165
169
{ item . children . map ( ( d : IFilterValue < T > , index : number ) =>
166
- renderCondition ( d , childrenPath ( index ) , disabled )
170
+ renderCondition ( d , childrenPath ( index ) , composeDisabled )
167
171
) }
168
- { ! disabled && (
172
+ { ! composeDisabled && (
169
173
< div className = "condition__add" >
170
174
< span className = "condition__add--line" />
171
175
< PlusCircleOutlined
@@ -200,20 +204,18 @@ export const RulesController = <T,>(props: IProps<T>) => {
200
204
< div className = "ruleController__item--component" >
201
205
{ component ( {
202
206
rowKey : item . key ,
203
- disabled,
207
+ disabled : composeDisabled ,
204
208
name : [ ...namePath , 'rowValues' ] ,
205
209
rowValues : item . rowValues as T ,
206
210
onChange : onChangeRowValues ,
207
211
} ) }
208
212
</ div >
209
- { ! disabled && (
213
+ { ! composeDisabled && (
210
214
< div className = "ruleController__item--operation" >
211
215
{ item . level === maxLevel ? null : (
212
216
< PlusCircleOutlined
213
217
className = "icon"
214
- onClick = { ( ) => {
215
- onAddCondition ( { key : item . key } ) ;
216
- } }
218
+ onClick = { ( ) => onAddCondition ( { key : item . key } ) }
217
219
/>
218
220
) }
219
221
< MinusCircleOutlined
@@ -225,7 +227,14 @@ export const RulesController = <T,>(props: IProps<T>) => {
225
227
</ div >
226
228
) ;
227
229
} ;
230
+
228
231
if ( ! value ) return null ;
232
+
229
233
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
+ ) ;
231
240
} ;
0 commit comments