|
@@ -21,6 +21,7 @@ import { Switch } from '@/client/components/ui/switch';
|
|
|
import { Skeleton } from '@/client/components/ui/skeleton';
|
|
import { Skeleton } from '@/client/components/ui/skeleton';
|
|
|
import { DataTablePagination } from '@/client/admin-shadcn/components/DataTablePagination';
|
|
import { DataTablePagination } from '@/client/admin-shadcn/components/DataTablePagination';
|
|
|
import { UserSelector } from '@/client/admin-shadcn/components/UserSelector';
|
|
import { UserSelector } from '@/client/admin-shadcn/components/UserSelector';
|
|
|
|
|
+import { CityCascadeSelector } from '@/client/admin-shadcn/components/CityCascadeSelector';
|
|
|
|
|
|
|
|
// 类型定义
|
|
// 类型定义
|
|
|
type DeliveryAddressResponse = InferResponseType<typeof deliveryAddressClient.$get, 200>['data'][0];
|
|
type DeliveryAddressResponse = InferResponseType<typeof deliveryAddressClient.$get, 200>['data'][0];
|
|
@@ -213,6 +214,18 @@ export const DeliveryAddressesPage = () => {
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ // 格式化地址显示
|
|
|
|
|
+ const formatAddressDisplay = (address: DeliveryAddressResponse) => {
|
|
|
|
|
+ const parts = [
|
|
|
|
|
+ address.province?.name,
|
|
|
|
|
+ address.city?.name,
|
|
|
|
|
+ address.district?.name,
|
|
|
|
|
+ address.town?.name,
|
|
|
|
|
+ address.address
|
|
|
|
|
+ ].filter(Boolean);
|
|
|
|
|
+ return parts.join(' ');
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
// 加载状态
|
|
// 加载状态
|
|
|
if (isLoading) {
|
|
if (isLoading) {
|
|
|
return (
|
|
return (
|
|
@@ -316,8 +329,8 @@ export const DeliveryAddressesPage = () => {
|
|
|
<TableCell>{address.user?.username || '-'}</TableCell>
|
|
<TableCell>{address.user?.username || '-'}</TableCell>
|
|
|
<TableCell>{address.name}</TableCell>
|
|
<TableCell>{address.name}</TableCell>
|
|
|
<TableCell>{address.phone}</TableCell>
|
|
<TableCell>{address.phone}</TableCell>
|
|
|
- <TableCell className="max-w-xs truncate" title={address.address}>
|
|
|
|
|
- {address.address}
|
|
|
|
|
|
|
+ <TableCell className="max-w-xs truncate" title={formatAddressDisplay(address)}>
|
|
|
|
|
+ {formatAddressDisplay(address)}
|
|
|
</TableCell>
|
|
</TableCell>
|
|
|
<TableCell>{getStatusBadge(address.state)}</TableCell>
|
|
<TableCell>{getStatusBadge(address.state)}</TableCell>
|
|
|
<TableCell>{getIsDefaultBadge(address.isDefault)}</TableCell>
|
|
<TableCell>{getIsDefaultBadge(address.isDefault)}</TableCell>
|
|
@@ -441,61 +454,18 @@ export const DeliveryAddressesPage = () => {
|
|
|
)}
|
|
)}
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
|
- <div className="grid grid-cols-4 gap-4">
|
|
|
|
|
- <FormField
|
|
|
|
|
- control={createForm.control}
|
|
|
|
|
- name="receiverProvince"
|
|
|
|
|
- render={({ field }) => (
|
|
|
|
|
- <FormItem>
|
|
|
|
|
- <FormLabel>省份ID</FormLabel>
|
|
|
|
|
- <FormControl>
|
|
|
|
|
- <Input type="number" placeholder="省份ID" {...field} />
|
|
|
|
|
- </FormControl>
|
|
|
|
|
- <FormMessage />
|
|
|
|
|
- </FormItem>
|
|
|
|
|
- )}
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
- <FormField
|
|
|
|
|
- control={createForm.control}
|
|
|
|
|
- name="receiverCity"
|
|
|
|
|
- render={({ field }) => (
|
|
|
|
|
- <FormItem>
|
|
|
|
|
- <FormLabel>城市ID</FormLabel>
|
|
|
|
|
- <FormControl>
|
|
|
|
|
- <Input type="number" placeholder="城市ID" {...field} />
|
|
|
|
|
- </FormControl>
|
|
|
|
|
- <FormMessage />
|
|
|
|
|
- </FormItem>
|
|
|
|
|
- )}
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
- <FormField
|
|
|
|
|
- control={createForm.control}
|
|
|
|
|
- name="receiverDistrict"
|
|
|
|
|
- render={({ field }) => (
|
|
|
|
|
- <FormItem>
|
|
|
|
|
- <FormLabel>区县ID</FormLabel>
|
|
|
|
|
- <FormControl>
|
|
|
|
|
- <Input type="number" placeholder="区县ID" {...field} />
|
|
|
|
|
- </FormControl>
|
|
|
|
|
- <FormMessage />
|
|
|
|
|
- </FormItem>
|
|
|
|
|
- )}
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
- <FormField
|
|
|
|
|
- control={createForm.control}
|
|
|
|
|
- name="receiverTown"
|
|
|
|
|
- render={({ field }) => (
|
|
|
|
|
- <FormItem>
|
|
|
|
|
- <FormLabel>街道ID</FormLabel>
|
|
|
|
|
- <FormControl>
|
|
|
|
|
- <Input type="number" placeholder="街道ID" {...field} />
|
|
|
|
|
- </FormControl>
|
|
|
|
|
- <FormMessage />
|
|
|
|
|
- </FormItem>
|
|
|
|
|
- )}
|
|
|
|
|
|
|
+ <div className="space-y-2">
|
|
|
|
|
+ <FormLabel>四级地址选择<span className="text-red-500 ml-1">*</span></FormLabel>
|
|
|
|
|
+ <CityCascadeSelector
|
|
|
|
|
+ provinceValue={createForm.watch('receiverProvince') || 0}
|
|
|
|
|
+ cityValue={createForm.watch('receiverCity') || 0}
|
|
|
|
|
+ districtValue={createForm.watch('receiverDistrict') || 0}
|
|
|
|
|
+ townValue={createForm.watch('receiverTown') || 0}
|
|
|
|
|
+ onProvinceChange={(value) => createForm.setValue('receiverProvince', value)}
|
|
|
|
|
+ onCityChange={(value) => createForm.setValue('receiverCity', value)}
|
|
|
|
|
+ onDistrictChange={(value) => createForm.setValue('receiverDistrict', value)}
|
|
|
|
|
+ onTownChange={(value) => createForm.setValue('receiverTown', value)}
|
|
|
|
|
+ showLabels={false}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
@@ -573,61 +543,18 @@ export const DeliveryAddressesPage = () => {
|
|
|
)}
|
|
)}
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
|
- <div className="grid grid-cols-4 gap-4">
|
|
|
|
|
- <FormField
|
|
|
|
|
- control={updateForm.control}
|
|
|
|
|
- name="receiverProvince"
|
|
|
|
|
- render={({ field }) => (
|
|
|
|
|
- <FormItem>
|
|
|
|
|
- <FormLabel>省份ID</FormLabel>
|
|
|
|
|
- <FormControl>
|
|
|
|
|
- <Input type="number" placeholder="省份ID" {...field} />
|
|
|
|
|
- </FormControl>
|
|
|
|
|
- <FormMessage />
|
|
|
|
|
- </FormItem>
|
|
|
|
|
- )}
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
- <FormField
|
|
|
|
|
- control={updateForm.control}
|
|
|
|
|
- name="receiverCity"
|
|
|
|
|
- render={({ field }) => (
|
|
|
|
|
- <FormItem>
|
|
|
|
|
- <FormLabel>城市ID</FormLabel>
|
|
|
|
|
- <FormControl>
|
|
|
|
|
- <Input type="number" placeholder="城市ID" {...field} />
|
|
|
|
|
- </FormControl>
|
|
|
|
|
- <FormMessage />
|
|
|
|
|
- </FormItem>
|
|
|
|
|
- )}
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
- <FormField
|
|
|
|
|
- control={updateForm.control}
|
|
|
|
|
- name="receiverDistrict"
|
|
|
|
|
- render={({ field }) => (
|
|
|
|
|
- <FormItem>
|
|
|
|
|
- <FormLabel>区县ID</FormLabel>
|
|
|
|
|
- <FormControl>
|
|
|
|
|
- <Input type="number" placeholder="区县ID" {...field} />
|
|
|
|
|
- </FormControl>
|
|
|
|
|
- <FormMessage />
|
|
|
|
|
- </FormItem>
|
|
|
|
|
- )}
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
- <FormField
|
|
|
|
|
- control={updateForm.control}
|
|
|
|
|
- name="receiverTown"
|
|
|
|
|
- render={({ field }) => (
|
|
|
|
|
- <FormItem>
|
|
|
|
|
- <FormLabel>街道ID</FormLabel>
|
|
|
|
|
- <FormControl>
|
|
|
|
|
- <Input type="number" placeholder="街道ID" {...field} />
|
|
|
|
|
- </FormControl>
|
|
|
|
|
- <FormMessage />
|
|
|
|
|
- </FormItem>
|
|
|
|
|
- )}
|
|
|
|
|
|
|
+ <div className="space-y-2">
|
|
|
|
|
+ <FormLabel>四级地址选择<span className="text-red-500 ml-1">*</span></FormLabel>
|
|
|
|
|
+ <CityCascadeSelector
|
|
|
|
|
+ provinceValue={updateForm.watch('receiverProvince') || 0}
|
|
|
|
|
+ cityValue={updateForm.watch('receiverCity') || 0}
|
|
|
|
|
+ districtValue={updateForm.watch('receiverDistrict') || 0}
|
|
|
|
|
+ townValue={updateForm.watch('receiverTown') || 0}
|
|
|
|
|
+ onProvinceChange={(value) => updateForm.setValue('receiverProvince', value)}
|
|
|
|
|
+ onCityChange={(value) => updateForm.setValue('receiverCity', value)}
|
|
|
|
|
+ onDistrictChange={(value) => updateForm.setValue('receiverDistrict', value)}
|
|
|
|
|
+ onTownChange={(value) => updateForm.setValue('receiverTown', value)}
|
|
|
|
|
+ showLabels={false}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|