This commit is contained in:
wujinliang
2026-08-26 18:13:12 +08:00
parent a67f6300f8
commit 9eec68f7c5
7 changed files with 49 additions and 15 deletions
@@ -187,6 +187,7 @@ type WarehouseForm = Omit<Warehouse, 'updatedAt'> & {
countryCode: string
timezone: string
postalCode: string
receivingCutoffTime: string
}
function generatedCode(type: WarehouseType) {
@@ -204,10 +205,11 @@ const emptyForm = (type: WarehouseType = 'FBA'): WarehouseForm => ({
postalCode: '',
contactName: '',
contactPhone: '',
businessHours: '',
warehouseType: type,
countryCode: type === 'DOMESTIC' ? 'CN' : 'US',
timezone: type === 'DOMESTIC' ? 'UTC+8' : '',
businessHours: type === 'FBA' ? '' : '周一至周六 08:30-18:00',
receivingCutoffTime: type === 'FBA' ? '' : '18:00:00',
status: 'ACTIVE',
remark: '',
})
@@ -309,7 +311,7 @@ function toRow(warehouse: PlatformWarehouseSummaryResource): WarehouseRow {
address: addressText,
postalCode: address?.postalCode || '',
contactName: warehouse.contactName || '',
contactPhone: warehouse.contactPhone || '',
contactPhone: digitsOnly(warehouse.contactPhone),
businessHours: '',
status: warehouse.status,
remark: warehouse.remark || '',
@@ -464,8 +466,8 @@ async function openEdit(warehouse: WarehouseRow) {
address: address?.addressLine1 || '',
postalCode: address?.postalCode || '',
contactName: detail.warehouse.contactName || '',
contactPhone: detail.warehouse.contactPhone || '',
businessHours: receiving?.description || '',
contactPhone: digitsOnly(detail.warehouse.contactPhone),
receivingCutoffTime: receiving?.cutoffTime || '',
status: detail.warehouse.status,
remark: detail.warehouse.remark || '',
})
@@ -481,6 +483,10 @@ function nullable(value: string) {
return value.trim() || null
}
function digitsOnly(value: unknown) {
return String(value || '').replace(/\D/g, '').slice(0, 32)
}
function buildSaveRequest(): SavePlatformWarehouseRequest {
const existing = form.id ? rows.value.find((item) => item.id === form.id)?.detail : null
const warehouse = existing?.warehouse
@@ -491,13 +497,13 @@ function buildSaveRequest(): SavePlatformWarehouseRequest {
capabilityCode: capability.capabilityCode,
capabilityName: capability.capabilityName,
enabled: capability.enabled ?? true,
cutoffTime: capability.cutoffTime,
description: capability.capabilityCode === 'RECEIVING' ? nullable(form.businessHours) : capability.description,
cutoffTime: capability.capabilityCode === 'RECEIVING' ? nullable(form.receivingCutoffTime) : capability.cutoffTime,
description: capability.description,
}))
if (form.warehouseType !== 'FBA' && !capabilities.some((item) => item.capabilityCode === 'RECEIVING')) {
capabilities.push({
capabilityCode: 'RECEIVING', capabilityName: '收货服务', enabled: true, cutoffTime: null,
description: nullable(form.businessHours),
description: null,
})
}
return {
@@ -790,8 +796,8 @@ onMounted(() => void loadWarehouses())
<FormSection v-if="!isFbaCreate" title="联系信息">
<div class="form-grid two-cols compact-grid">
<el-form-item label="联系人"><el-input v-model="form.contactName" maxlength="64" placeholder="选填" /></el-form-item>
<el-form-item label="联系电话"><el-input v-model="form.contactPhone" maxlength="32" placeholder="选填" /></el-form-item>
<el-form-item label="收货时间"><el-input v-model="form.businessHours" maxlength="500" placeholder="例如 周一至周六 08:30-18:00" /></el-form-item>
<el-form-item label="联系电话"><el-input v-model="form.contactPhone" maxlength="32" inputmode="numeric" placeholder="选填" @input="form.contactPhone = digitsOnly($event)" /></el-form-item>
<el-form-item label="收货时间"><el-time-picker v-model="form.receivingCutoffTime" value-format="HH:mm:ss" format="HH:mm" placeholder="请选择收货截止时间" /></el-form-item>
</div>
<el-form-item label="备注"><el-input v-model="form.remark" maxlength="500" type="textarea" :rows="3" show-word-limit placeholder="选填" /></el-form-item>
</FormSection>