From 33fc30911ef5d4b8f90547858e3308691d308d0e Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Tue, 22 Sep 2026 11:44:07 +0800 Subject: [PATCH] feat: add lingxing connection test action --- .../overseas-warehouse/api/mojiaSkuSync.ts | 26 ++++++++++++++ .../pages/MojiaSkuSyncView.vue | 35 +++++++++++++++++-- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/src/modules/overseas-warehouse/api/mojiaSkuSync.ts b/src/modules/overseas-warehouse/api/mojiaSkuSync.ts index 0ba0d4f8..31db04d6 100644 --- a/src/modules/overseas-warehouse/api/mojiaSkuSync.ts +++ b/src/modules/overseas-warehouse/api/mojiaSkuSync.ts @@ -40,6 +40,25 @@ export interface MojiaSkuSyncConfig { autoSyncEnabled: boolean } +export interface LingxingWarehouseTestResult { + whCode: string + reachable: boolean + matched: boolean + maintained: boolean + productSku?: string | null + barcode?: string | null + length?: number | null + width?: number | null + height?: number | null + weight?: number | null + message: string +} + +export interface LingxingConnectionTestResult { + skuCode: string + warehouses: LingxingWarehouseTestResult[] +} + const basePath = '/platform/v1/firstleg/mojia-sku-sync' export async function listMojiaSkuSync(query: MojiaSkuSyncQuery) { @@ -56,6 +75,13 @@ export async function getMojiaSkuSyncConfig() { return unwrapApiResponse(response) } +export async function testLingxingConnection(skuCode: string) { + const response = await http.post, ApiEnvelope>( + `${basePath}/test-connection`, { skuCode }, + ) + return unwrapApiResponse(response) +} + export async function updateMojiaSkuSync(id: string, data: { skuCode: string lengthCm: number diff --git a/src/modules/overseas-warehouse/pages/MojiaSkuSyncView.vue b/src/modules/overseas-warehouse/pages/MojiaSkuSyncView.vue index 7dba08a0..eecd5f33 100644 --- a/src/modules/overseas-warehouse/pages/MojiaSkuSyncView.vue +++ b/src/modules/overseas-warehouse/pages/MojiaSkuSyncView.vue @@ -2,7 +2,7 @@ import '@/styles/adminDensity.css' import { computed, onMounted, reactive, ref } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' -import { Edit3, RefreshCw, RotateCw } from '@lucide/vue' +import { Cable, Edit3, RefreshCw, RotateCw } from '@lucide/vue' import AdminPage from '@/shared/components/AdminPage.vue' import DataTable, { type DataTableColumn } from '@/shared/components/DataTable.vue' import ListPageLayout from '@/shared/components/ListPageLayout.vue' @@ -10,8 +10,8 @@ import AppDialog from '@/shared/components/AppDialog.vue' import { useAccessPreviewStore } from '@/core/access/accessPreview' import { getApiErrorMessage } from '@/shared/api/http' import { - getMojiaSkuSyncConfig, listMojiaSkuSync, retryMojiaSkuSync, updateMojiaSkuSync, - type MojiaSkuSyncRecord, type MojiaSkuSyncStatus, + getMojiaSkuSyncConfig, listMojiaSkuSync, retryMojiaSkuSync, testLingxingConnection, updateMojiaSkuSync, + type LingxingConnectionTestResult, type MojiaSkuSyncRecord, type MojiaSkuSyncStatus, } from '../api/mojiaSkuSync' const permission = { @@ -28,6 +28,9 @@ const loading = ref(false) const autoSyncEnabled = ref(false) const error = ref('') const actionId = ref('') +const testingConnection = ref(false) +const testOpen = ref(false) +const testResult = ref(null) const page = ref(1) const size = ref(20) const form = reactive({ skuCode: '', syncStatus: '' as '' | MojiaSkuSyncStatus }) @@ -81,6 +84,17 @@ function asRecord(row: unknown) { return row as MojiaSkuSyncRecord } function syncLabel(row: unknown) { return statusLabel[asRecord(row).syncStatus] } function syncTagType(row: unknown) { return statusType[asRecord(row).syncStatus] } +async function testConnection() { + const skuCode = form.skuCode.trim() + if (!skuCode) { ElMessage.warning('请先输入要查询的 SKU'); return } + testingConnection.value = true + try { + testResult.value = await testLingxingConnection(skuCode) + testOpen.value = true + } catch (cause) { ElMessage.error(getApiErrorMessage(cause, '领星连接测试失败')) } + finally { testingConnection.value = false } +} + function openEdit(row: MojiaSkuSyncRecord) { editing.value = row Object.assign(editForm, { skuCode: row.skuCode, lengthCm: row.lengthCm, widthCm: row.widthCm, heightCm: row.heightCm, weightKg: row.weightKg, revision: row.revision }) @@ -137,6 +151,7 @@ onMounted(() => { void Promise.all([loadConfig(), load()]) }) 查询 重置 + 测试连接 @@ -168,6 +183,17 @@ onMounted(() => { void Promise.all([loadConfig(), load()]) }) + +
+
查询 SKU:{{ testResult.skuCode }}
+ + + + + + +
+
@@ -179,5 +205,8 @@ onMounted(() => { void Promise.all([loadConfig(), load()]) }) .sync-pagination { display: flex; justify-content: flex-end; padding: var(--admin-space-4); } .sync-edit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; } .sync-edit-grid :deep(.el-input-number) { width: 100%; } +.connection-result { display: grid; gap: var(--admin-space-4); } +.connection-result__sku { color: var(--cc-muted); } +.connection-result__sku strong { color: var(--cc-text); } @media (max-width: 900px) { .sync-filters .el-input { width: 180px; } }