同城有仓按仓库绑定承运商自动推单或自管填单,无仓/跨城走总部快递;新增仓配注册表、FulfillmentService 及三端运单追踪。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
Descriptions,
|
||||
Form,
|
||||
Input,
|
||||
InputNumber,
|
||||
Modal,
|
||||
Popconfirm,
|
||||
Select,
|
||||
@@ -17,10 +18,13 @@ import {
|
||||
} from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import {
|
||||
WAREHOUSE_FULFILLMENT_MODE_LABELS,
|
||||
WAREHOUSE_MANAGER_LABELS,
|
||||
WAREHOUSE_STATUS_LABELS,
|
||||
WarehouseFulfillmentMode,
|
||||
WarehouseManagerType,
|
||||
WarehouseStatus,
|
||||
type FulfillmentProviderDto,
|
||||
} from '@dukang/shared-types';
|
||||
import { request, type Paginated } from '../lib/api';
|
||||
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
||||
@@ -39,6 +43,13 @@ type Row = {
|
||||
partnerAccountId: string | null;
|
||||
partnerCompanyName?: string | null;
|
||||
status: string;
|
||||
fulfillmentMode?: string;
|
||||
fulfillmentProviderId?: string | null;
|
||||
fulfillmentProviderName?: string | null;
|
||||
manualCarrierLabel?: string | null;
|
||||
manualQueryUrlTemplate?: string | null;
|
||||
lng?: number | null;
|
||||
lat?: number | null;
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
@@ -48,6 +59,54 @@ type PartnerOption = { id: string; companyName: string };
|
||||
const MANAGER_OPTIONS = Object.entries(WAREHOUSE_MANAGER_LABELS).map(([value, label]) => ({ value, label }));
|
||||
const STATUS_OPTIONS = Object.entries(WAREHOUSE_STATUS_LABELS).map(([value, label]) => ({ value, label }));
|
||||
|
||||
const FULFILLMENT_MODE_OPTIONS = Object.entries(WAREHOUSE_FULFILLMENT_MODE_LABELS).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
}));
|
||||
|
||||
function FulfillmentFields({
|
||||
mode,
|
||||
providerOptions,
|
||||
}: {
|
||||
mode: WarehouseFulfillmentMode;
|
||||
providerOptions: FulfillmentProviderDto[];
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
{mode === WarehouseFulfillmentMode.API_AUTO && (
|
||||
<Form.Item name="fulfillmentProviderId" label="仓配承运商" rules={[{ required: true }]}>
|
||||
<Select
|
||||
placeholder={providerOptions.length ? '选择已注册承运商' : '请先在仓配管理注册'}
|
||||
options={providerOptions.map((p) => ({ value: p.id, label: `${p.name} (${p.code})` }))}
|
||||
/>
|
||||
</Form.Item>
|
||||
)}
|
||||
{mode === WarehouseFulfillmentMode.MANUAL && (
|
||||
<>
|
||||
<Form.Item name="manualCarrierLabel" label="默认承运商名称">
|
||||
<Input placeholder="如 顺丰速运" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="manualQueryUrlTemplate"
|
||||
label="物流查询链接模板"
|
||||
extra="可用 {trackingNo} 占位符"
|
||||
>
|
||||
<Input placeholder="https://example.com/track?no={trackingNo}" />
|
||||
</Form.Item>
|
||||
</>
|
||||
)}
|
||||
<Space>
|
||||
<Form.Item name="lng" label="经度">
|
||||
<InputNumber step={0.001} placeholder="API推单寄件坐标" />
|
||||
</Form.Item>
|
||||
<Form.Item name="lat" label="纬度">
|
||||
<InputNumber step={0.001} />
|
||||
</Form.Item>
|
||||
</Space>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default function CityWarehousesPage() {
|
||||
const [filterForm] = Form.useForm();
|
||||
const [createForm] = Form.useForm();
|
||||
@@ -73,6 +132,13 @@ export default function CityWarehousesPage() {
|
||||
const [createManagerType, setCreateManagerType] = useState<WarehouseManagerType>(WarehouseManagerType.HQ);
|
||||
const [editManagerType, setEditManagerType] = useState<WarehouseManagerType>(WarehouseManagerType.HQ);
|
||||
const [createCityId, setCreateCityId] = useState<string | undefined>();
|
||||
const [createFulfillmentMode, setCreateFulfillmentMode] = useState<WarehouseFulfillmentMode>(
|
||||
WarehouseFulfillmentMode.MANUAL,
|
||||
);
|
||||
const [editFulfillmentMode, setEditFulfillmentMode] = useState<WarehouseFulfillmentMode>(
|
||||
WarehouseFulfillmentMode.MANUAL,
|
||||
);
|
||||
const [providerOptions, setProviderOptions] = useState<FulfillmentProviderDto[]>([]);
|
||||
|
||||
const loadCities = useCallback(async () => {
|
||||
const res = await request<Paginated<CityOption>>(`/admin/cities?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`);
|
||||
@@ -88,6 +154,9 @@ export default function CityWarehousesPage() {
|
||||
|
||||
useEffect(() => {
|
||||
void loadCities();
|
||||
void request<FulfillmentProviderDto[]>('/admin/fulfillment-providers/active-api')
|
||||
.then(setProviderOptions)
|
||||
.catch(() => {});
|
||||
}, [loadCities]);
|
||||
|
||||
async function openEdit(row: Row) {
|
||||
@@ -102,7 +171,14 @@ export default function CityWarehousesPage() {
|
||||
managerType: row.managerType,
|
||||
partnerAccountId: row.partnerAccountId,
|
||||
status: row.status,
|
||||
fulfillmentMode: row.fulfillmentMode ?? WarehouseFulfillmentMode.MANUAL,
|
||||
fulfillmentProviderId: row.fulfillmentProviderId ?? undefined,
|
||||
manualCarrierLabel: row.manualCarrierLabel ?? undefined,
|
||||
manualQueryUrlTemplate: row.manualQueryUrlTemplate ?? undefined,
|
||||
lng: row.lng ?? undefined,
|
||||
lat: row.lat ?? undefined,
|
||||
});
|
||||
setEditFulfillmentMode((row.fulfillmentMode as WarehouseFulfillmentMode) ?? WarehouseFulfillmentMode.MANUAL);
|
||||
setEditOpen(true);
|
||||
}
|
||||
|
||||
@@ -149,6 +225,14 @@ export default function CityWarehousesPage() {
|
||||
'—'
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '履约',
|
||||
width: 120,
|
||||
render: (_, row) =>
|
||||
row.fulfillmentMode === 'API_AUTO'
|
||||
? row.fulfillmentProviderName || 'API'
|
||||
: WAREHOUSE_FULFILLMENT_MODE_LABELS[WarehouseFulfillmentMode.MANUAL],
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
@@ -341,6 +425,13 @@ export default function CityWarehousesPage() {
|
||||
<Form.Item name="status" label="状态" initialValue={WarehouseStatus.ACTIVE}>
|
||||
<Select options={STATUS_OPTIONS} />
|
||||
</Form.Item>
|
||||
<Form.Item name="fulfillmentMode" label="履约方式" initialValue={WarehouseFulfillmentMode.MANUAL}>
|
||||
<Select
|
||||
options={FULFILLMENT_MODE_OPTIONS}
|
||||
onChange={(v) => setCreateFulfillmentMode(v)}
|
||||
/>
|
||||
</Form.Item>
|
||||
<FulfillmentFields mode={createFulfillmentMode} providerOptions={providerOptions} />
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
@@ -399,6 +490,13 @@ export default function CityWarehousesPage() {
|
||||
<Form.Item name="status" label="状态">
|
||||
<Select options={STATUS_OPTIONS} />
|
||||
</Form.Item>
|
||||
<Form.Item name="fulfillmentMode" label="履约方式">
|
||||
<Select
|
||||
options={FULFILLMENT_MODE_OPTIONS}
|
||||
onChange={(v) => setEditFulfillmentMode(v)}
|
||||
/>
|
||||
</Form.Item>
|
||||
<FulfillmentFields mode={editFulfillmentMode} providerOptions={providerOptions} />
|
||||
</Form>
|
||||
</Modal>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user