| 
						
						
						
					 | 
				
				 | 
				
					@ -1,5 +1,5 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { atom } from 'jotai' | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { IApiResult, IPage } from '@/global' | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { IApiResult, IPage, IPageResult } from '@/global' | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { atomWithMutation, atomWithQuery, queryClientAtom } from 'jotai-tanstack-query' | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { message } from 'antd' | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { t } from 'i18next' | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -32,13 +32,12 @@ export const modelPageAtom = atom<IPage>({ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  page: 1, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					}) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					export const modelCURDAtom = atomWithQuery<IApiResult<XForm.IModelCURD>, any, any>((get) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  const api = get(apiAtom) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  console.log('api', api) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					export const modelCURDAtom = atomWithQuery<IApiResult<XForm.IModelCURD>, any, any, any>((get) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  return { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    enabled: !!api, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    queryKey: [ 'modelCURD' ], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    queryFn: async () => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    enabled: !!get(apiAtom), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    queryKey: [ 'modelCURD', get(apiAtom) ], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    queryFn: async ({ queryKey: [ , api ] }) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      return await modelServ.model(api).proxy() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    }, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    select: (res) => { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -47,14 +46,13 @@ export const modelCURDAtom = atomWithQuery<IApiResult<XForm.IModelCURD>, any, an | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					}) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					export const modelsAtom = atomWithQuery((get) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  const api = get(apiAtom) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  const curd = get(modelCURDAtom) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					export const modelsAtom = atomWithQuery<IApiResult<IPageResult<any>>, any, any, any>((get) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  const curd = get(modelCURDAtom) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  return { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    enabled: curd.isSuccess && !!api, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    queryKey: [ 'models', get(modelSearchAtom) ], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    queryFn: async ({ queryKey: [ , params ] }) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    enabled: curd.isSuccess && !!get(apiAtom), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    queryKey: [ 'models', get(modelSearchAtom), get(apiAtom) ], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    queryFn: async ({ queryKey: [ , params, api ] }) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      if (api.startsWith('http')) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return await modelServ.model(api).proxy<XForm.IModel>({ | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -81,7 +79,7 @@ export const modelsAtom = atomWithQuery((get) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					export const saveOrUpdateModelAtom = atomWithMutation<IApiResult, XForm.IModel>((get) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  return { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    mutationKey: [ 'updateModel' ], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    mutationKey: [ 'updateModel', get(apiAtom) ], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    mutationFn: async (data) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      const api = get(apiAtom) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      if (!api) { | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -119,13 +117,14 @@ export const saveOrUpdateModelAtom = atomWithMutation<IApiResult, XForm.IModel>( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					}) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					export const deleteModelAtom = atomWithMutation((get) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  return { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    mutationKey: [ 'deleteModel' ], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    mutationKey: [ 'deleteModel', get(apiAtom) ], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    mutationFn: async (ids: number[]) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      const api = get(apiAtom) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      if (api.startsWith('http')) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return await modelServ.model(api).proxy<XForm.IModel>({ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          body: ids ?? get(modelIdsAtom) , | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          body: ids ?? get(modelIdsAtom), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          path: '/deletes', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      } | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |