Selaa lähdekoodia

♻️ refactor(order-form): 替换直接导入的 orderClient 为 orderClientManager

- 在 OrderForm 组件中,将直接导入的 orderClient 替换为 orderClientManager.get() 以使用客户端管理器
- 在 OrderPersonAssetAssociation 组件中,将直接导入的 orderClient 替换为 orderClientManager.get() 以使用客户端管理器
- 在 PersonSelector 组件中,将直接导入的 orderClient 替换为 orderClientManager.get() 以使用客户端管理器
yourname 1 päivä sitten
vanhempi
sitoutus
cb1855dee7

+ 5 - 5
allin-packages/order-management-ui/src/components/OrderForm.tsx

@@ -48,7 +48,7 @@ import { DisabledPersonSelector } from '@d8d/allin-disability-person-management-
 import { PlatformSelector } from '@d8d/allin-platform-management-ui';
 import { CompanySelector } from '@d8d/allin-company-management-ui';
 import { ChannelSelector } from '@d8d/allin-channel-management-ui';
-import { orderClient } from '../api/orderClient';
+import { orderClient, orderClientManager } from '../api/orderClient';
 import type { OrderDetail } from '../api/types';
 import type { DisabledPersonData } from '@d8d/allin-disability-person-management-ui';
 
@@ -196,7 +196,7 @@ export const OrderForm: React.FC<OrderFormProps> = ({
   // 创建订单Mutation
   const createMutation = useMutation({
     mutationFn: async (data: OrderFormValues) => {
-      const response = await orderClient.create.$post({
+      const response = await orderClientManager.get().create.$post({
         json: data,
       });
       if (!response.ok) {
@@ -220,7 +220,7 @@ export const OrderForm: React.FC<OrderFormProps> = ({
   // 更新订单Mutation
   const updateMutation = useMutation({
     mutationFn: async (data: OrderFormValues & { id: number }) => {
-      const response = await orderClient.update[':id'].$put({
+      const response = await orderClientManager.get().update[':id'].$put({
         param: { id: data.id },
         json: data,
       });
@@ -256,7 +256,7 @@ export const OrderForm: React.FC<OrderFormProps> = ({
         const { orderPersons, ...orderData } = data;
 
         // 创建订单
-        const createResponse = await orderClient.create.$post({
+        const createResponse = await orderClientManager.get().create.$post({
           json: orderData,
         });
 
@@ -271,7 +271,7 @@ export const OrderForm: React.FC<OrderFormProps> = ({
         // 如果有人员信息,批量添加人员
         if (orderPersons && orderPersons.length > 0) {
           try {
-            const batchResponse = await orderClient[':orderId'].persons.batch.$post({
+            const batchResponse = await orderClientManager.get()[':orderId'].persons.batch.$post({
               param: { orderId: createdOrder.id },
               json: { persons: orderPersons },
             });

+ 4 - 4
allin-packages/order-management-ui/src/components/OrderPersonAssetAssociation.tsx

@@ -38,7 +38,7 @@ import { toast } from 'sonner';
 import { FileText, Trash2, Eye, User, Plus } from 'lucide-react';
 import { FileSelector } from '@d8d/file-management-ui/components';
 import { AssetType, AssetFileType } from '@d8d/allin-order-module/schemas';
-import { orderClient } from '../api/orderClient';
+import { orderClient, orderClientManager } from '../api/orderClient';
 
 // 资产关联表单Schema
 const assetAssociationSchema = z.object({
@@ -117,7 +117,7 @@ export const OrderPersonAssetAssociation: React.FC<OrderPersonAssetAssociationPr
   const { data: assetsData, isLoading: isLoadingAssets, refetch: refetchAssets } = useQuery({
     queryKey: ['order-assets', orderId, selectedPerson?.id],
     queryFn: async () => {
-      const response = await orderClient.assets.query.$get({
+      const response = await orderClientManager.get().assets.query.$get({
         query: {
           orderId,
           personId: selectedPerson?.id,
@@ -137,7 +137,7 @@ export const OrderPersonAssetAssociation: React.FC<OrderPersonAssetAssociationPr
   // 创建资产关联Mutation
   const createMutation = useMutation({
     mutationFn: async (data: AssetAssociationFormValues) => {
-      const response = await orderClient.assets.create.$post({
+      const response = await orderClientManager.get().assets.create.$post({
         json: data,
       });
       if (!response.ok) {
@@ -162,7 +162,7 @@ export const OrderPersonAssetAssociation: React.FC<OrderPersonAssetAssociationPr
   // 删除资产关联Mutation
   const deleteMutation = useMutation({
     mutationFn: async (assetId: number) => {
-      const response = await orderClient.assets.delete[':id'].$delete({
+      const response = await orderClientManager.get().assets.delete[':id'].$delete({
         param: { id: assetId },
       });
       if (!response.ok) {

+ 2 - 2
allin-packages/order-management-ui/src/components/PersonSelector.tsx

@@ -26,7 +26,7 @@ import { toast } from 'sonner';
 import { User, Users, X } from 'lucide-react';
 import { DisabledPersonSelector } from '@d8d/allin-disability-person-management-ui';
 import { WorkStatus } from '@d8d/allin-enums';
-import { orderClient } from '../api/orderClient';
+import { orderClient, orderClientManager } from '../api/orderClient';
 import type { DisabledPersonData } from '@d8d/allin-disability-person-management-ui';
 
 // 批量添加人员表单Schema
@@ -77,7 +77,7 @@ export const PersonSelector: React.FC<PersonSelectorProps> = ({
   // 批量添加人员Mutation
   const batchAddMutation = useMutation({
     mutationFn: async (data: BatchAddPersonsFormValues) => {
-      const response = await orderClient[':orderId'].persons.batch.$post({
+      const response = await orderClientManager.get()[':orderId'].persons.batch.$post({
         param: { orderId },
         json: data,
       });