1- import { useState , useRef } from 'react' ;
1+ import { useRef , useState } from 'react' ;
22import type { SysI18nListVo , SysMenuDto , SysMenuQo , SysMenuVo } from '@/services/ballcat/system' ;
3+ import { i18n , menu } from '@/services/ballcat/system' ;
34import type { ActionType , ProColumns } from '@ant-design/pro-table' ;
45import { EditableProTable } from '@ant-design/pro-table' ;
56import type { FormStatus , ModalFormRef } from '@/components/Form' ;
6- import Form , { FormNumber } from '@/components/Form' ;
7- import { FormDictRadio } from '@/components/Form' ;
7+ import Form , { FormDictRadio , FormNumber } from '@/components/Form' ;
88import { ProFormRadio , ProFormSelect , ProFormText , ProFormTextArea } from '@ant-design/pro-form' ;
99import Page from '@/components/Page' ;
10- import { message , Button , Form as AntdForm , Modal , TreeSelect , Typography } from 'antd' ;
11- import { menu , i18n } from '@/services/ballcat/system' ;
10+ import { Button , Form as AntdForm , message , Modal , TreeSelect , Typography } from 'antd' ;
1211import TreeUtils from '@/utils/TreeUtils' ;
1312import Icon , { IconSelect } from '@/components/Icon' ;
1413import I18n from '@/utils/I18nUtils' ;
1514import Auth from '@/components/Auth' ;
1615import SysI18nCreate from '@/pages/i18n/SysI18nCreate' ;
1716import { DownOutlined , EditTwoTone , UpOutlined } from '@ant-design/icons' ;
1817import { settings } from '@/utils/ConfigUtils' ;
18+ import { FormInstance } from 'antd/es' ;
1919
2020const isBtn = ( data : SysMenuVo | any ) => {
2121 return data . type === 2 || data === 2 ;
@@ -29,6 +29,7 @@ const isDir = (data: SysMenuVo | any) => {
2929} ;
3030
3131export default ( ) => {
32+ const searchFormRef = useRef < FormInstance > ( ) ;
3233 const formRef = useRef < ModalFormRef < SysMenuDto > > ( ) ;
3334 const tableRef = useRef < ActionType > ( ) ;
3435 const [ status , setStatus ] = useState < FormStatus > ( undefined ) ;
@@ -144,6 +145,14 @@ export default () => {
144145 < >
145146 < Page . Modal < SysMenuVo , SysMenuQo , SysMenuDto >
146147 { ...menu }
148+ query = { ( params ) => {
149+ return menu . query ( {
150+ size : params . size ,
151+ current : params . current ,
152+ sortFields : params . sortFields ,
153+ sortOrders : params . sortOrders ,
154+ } ) ;
155+ } }
147156 title = "菜单权限"
148157 rowKey = "id"
149158 columns = { dataColumns }
@@ -186,6 +195,7 @@ export default () => {
186195 } }
187196 tableProps = { {
188197 pagination : false ,
198+ formRef : searchFormRef ,
189199 expandable : { expandIconColumnIndex : 1 } ,
190200 postData : ( data ) => {
191201 const treeData = TreeUtils . ofList ( data , 0 , ( item ) => {
@@ -202,7 +212,30 @@ export default () => {
202212 } ) ;
203213 treeSelectData [ 0 ] . children = treeData ;
204214 setTreeSelectData ( treeSelectData ) ;
205- return treeData ;
215+ return TreeUtils . treeFilter (
216+ treeData ,
217+ ( item ) => {
218+ const queryParams = searchFormRef . current ?. getFieldsValue ( ) ;
219+ let show = true ;
220+ if ( show && queryParams . id ) {
221+ show = String ( item . id ) === queryParams . id ;
222+ }
223+
224+ if ( show && queryParams . path && queryParams . path . length > 0 ) {
225+ show = item . path === queryParams . path ;
226+ }
227+
228+ if ( show && queryParams . title ) {
229+ show =
230+ ( item . i18nTitle && item . i18nTitle . indexOf ( queryParams . title ) > - 1 ) ||
231+ ( item . title && item . title . indexOf ( queryParams . title ) > - 1 ) ;
232+ }
233+ return show ;
234+ } ,
235+ ( _ , children ) => {
236+ return isBtn ( children [ 0 ] ) ;
237+ } ,
238+ ) ;
206239 } ,
207240 } }
208241 formProps = { { titleSuffix : '菜单' } }
0 commit comments