|
|
@@ -34,7 +34,7 @@ import { toast } from 'sonner';
|
|
|
import { AreaSelect } from '@d8d/area-management-ui';
|
|
|
import { OrderStatus, WorkStatus } from '@d8d/allin-enums';
|
|
|
import { orderClient } from '../api/orderClient';
|
|
|
-import type { OrderFormData, OrderDetail } from '../api/types';
|
|
|
+import type { OrderDetail } from '../api/types';
|
|
|
|
|
|
// 订单表单Schema
|
|
|
const orderFormSchema = z.object({
|
|
|
@@ -44,8 +44,8 @@ const orderFormSchema = z.object({
|
|
|
channelId: z.number().int().positive('请选择渠道'),
|
|
|
expectedStartDate: z.string().datetime('请选择有效的开始日期'),
|
|
|
expectedEndDate: z.string().datetime('请选择有效的结束日期').optional(),
|
|
|
- orderStatus: z.nativeEnum(OrderStatus).default(OrderStatus.DRAFT),
|
|
|
- workStatus: z.nativeEnum(WorkStatus).default(WorkStatus.NOT_WORKING),
|
|
|
+ orderStatus: z.nativeEnum(OrderStatus),
|
|
|
+ workStatus: z.nativeEnum(WorkStatus),
|
|
|
provinceId: z.number().int().positive('请选择省份').optional(),
|
|
|
cityId: z.number().int().positive('请选择城市').optional(),
|
|
|
districtId: z.number().int().positive('请选择区县').optional(),
|
|
|
@@ -99,22 +99,24 @@ export const OrderForm: React.FC<OrderFormProps> = ({
|
|
|
// 当订单数据变化时,重置表单
|
|
|
useEffect(() => {
|
|
|
if (order && open) {
|
|
|
+ // 使用类型断言,因为OrderDetail可能不包含所有表单字段
|
|
|
+ const orderData = order as any;
|
|
|
form.reset({
|
|
|
- orderName: order.orderName || '',
|
|
|
- platformId: order.platformId || 0,
|
|
|
- companyId: order.companyId || 0,
|
|
|
- channelId: order.channelId || 0,
|
|
|
- expectedStartDate: order.expectedStartDate || new Date().toISOString(),
|
|
|
- expectedEndDate: order.expectedEndDate || '',
|
|
|
- orderStatus: order.orderStatus || OrderStatus.DRAFT,
|
|
|
- workStatus: order.workStatus || WorkStatus.NOT_WORKING,
|
|
|
- provinceId: order.provinceId || undefined,
|
|
|
- cityId: order.cityId || undefined,
|
|
|
- districtId: order.districtId || undefined,
|
|
|
- address: order.address || '',
|
|
|
- contactPerson: order.contactPerson || '',
|
|
|
- contactPhone: order.contactPhone || '',
|
|
|
- remark: order.remark || '',
|
|
|
+ orderName: orderData.orderName || '',
|
|
|
+ platformId: orderData.platformId || 0,
|
|
|
+ companyId: orderData.companyId || 0,
|
|
|
+ channelId: orderData.channelId || 0,
|
|
|
+ expectedStartDate: orderData.expectedStartDate || new Date().toISOString(),
|
|
|
+ expectedEndDate: orderData.expectedEndDate || '',
|
|
|
+ orderStatus: orderData.orderStatus || OrderStatus.DRAFT,
|
|
|
+ workStatus: orderData.workStatus || WorkStatus.NOT_WORKING,
|
|
|
+ provinceId: orderData.provinceId || undefined,
|
|
|
+ cityId: orderData.cityId || undefined,
|
|
|
+ districtId: orderData.districtId || undefined,
|
|
|
+ address: orderData.address || '',
|
|
|
+ contactPerson: orderData.contactPerson || '',
|
|
|
+ contactPhone: orderData.contactPhone || '',
|
|
|
+ remark: orderData.remark || '',
|
|
|
});
|
|
|
} else if (!order && open) {
|
|
|
form.reset({
|
|
|
@@ -416,7 +418,7 @@ export const OrderForm: React.FC<OrderFormProps> = ({
|
|
|
<FormField
|
|
|
control={form.control}
|
|
|
name="provinceId"
|
|
|
- render={({ field }) => (
|
|
|
+ render={() => (
|
|
|
<FormItem>
|
|
|
<FormLabel>区域选择</FormLabel>
|
|
|
<FormControl>
|