feat: show lingxing sync switch status
This commit is contained in:
@@ -36,6 +36,10 @@ export interface MojiaSkuSyncQuery {
|
||||
syncStatus?: MojiaSkuSyncStatus
|
||||
}
|
||||
|
||||
export interface MojiaSkuSyncConfig {
|
||||
autoSyncEnabled: boolean
|
||||
}
|
||||
|
||||
const basePath = '/platform/v1/firstleg/mojia-sku-sync'
|
||||
|
||||
export async function listMojiaSkuSync(query: MojiaSkuSyncQuery) {
|
||||
@@ -45,6 +49,13 @@ export async function listMojiaSkuSync(query: MojiaSkuSyncQuery) {
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
|
||||
export async function getMojiaSkuSyncConfig() {
|
||||
const response = await http.get<ApiEnvelope<MojiaSkuSyncConfig>, ApiEnvelope<MojiaSkuSyncConfig>>(
|
||||
`${basePath}/config`,
|
||||
)
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
|
||||
export async function updateMojiaSkuSync(id: string, data: {
|
||||
skuCode: string
|
||||
lengthCm: number
|
||||
|
||||
@@ -10,7 +10,7 @@ import AppDialog from '@/shared/components/AppDialog.vue'
|
||||
import { useAccessPreviewStore } from '@/core/access/accessPreview'
|
||||
import { getApiErrorMessage } from '@/shared/api/http'
|
||||
import {
|
||||
listMojiaSkuSync, retryMojiaSkuSync, updateMojiaSkuSync,
|
||||
getMojiaSkuSyncConfig, listMojiaSkuSync, retryMojiaSkuSync, updateMojiaSkuSync,
|
||||
type MojiaSkuSyncRecord, type MojiaSkuSyncStatus,
|
||||
} from '../api/mojiaSkuSync'
|
||||
|
||||
@@ -25,6 +25,7 @@ const canRetry = computed(() => access.can(permission.retry))
|
||||
const rows = ref<MojiaSkuSyncRecord[]>([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const autoSyncEnabled = ref(false)
|
||||
const error = ref('')
|
||||
const actionId = ref('')
|
||||
const page = ref(1)
|
||||
@@ -65,6 +66,14 @@ async function load() {
|
||||
} finally { loading.value = false }
|
||||
}
|
||||
|
||||
async function loadConfig() {
|
||||
try {
|
||||
autoSyncEnabled.value = (await getMojiaSkuSyncConfig()).autoSyncEnabled
|
||||
} catch (cause) {
|
||||
error.value = getApiErrorMessage(cause, '自动同步配置加载失败')
|
||||
}
|
||||
}
|
||||
|
||||
function search() { page.value = 1; void load() }
|
||||
function reset() { form.skuCode = ''; form.syncStatus = ''; search() }
|
||||
function formatTime(value?: string | null) { return value ? value.replace('T', ' ').slice(0, 19) : '—' }
|
||||
@@ -104,7 +113,7 @@ async function retry(row: MojiaSkuSyncRecord) {
|
||||
finally { actionId.value = '' }
|
||||
}
|
||||
|
||||
onMounted(() => { void load() })
|
||||
onMounted(() => { void Promise.all([loadConfig(), load()]) })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -112,6 +121,13 @@ onMounted(() => { void load() })
|
||||
<ListPageLayout aria-label="一件代发 SKU 同步">
|
||||
<section class="surface-panel table-panel" :aria-busy="loading">
|
||||
<el-alert v-if="error" type="error" :title="error" show-icon :closable="false" />
|
||||
<el-alert
|
||||
:type="autoSyncEnabled ? 'warning' : 'info'"
|
||||
:title="autoSyncEnabled ? '领星自动同步已开启' : '领星自动同步已关闭,仅支持人工推送'"
|
||||
description="开关由 Nacos 配置 firstleg.lingxing.auto-sync-enabled 控制。"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<DataTable :data="rows" :columns="columns" :loading="loading" row-key="id" border stripe empty-text="暂无墨家 SKU 测量记录">
|
||||
<template #toolbar-start>
|
||||
<div class="sync-filters">
|
||||
@@ -127,7 +143,7 @@ onMounted(() => { void load() })
|
||||
<template #actions="{ row }">
|
||||
<div class="density-actions">
|
||||
<el-button v-if="canEdit" class="density-action" @click="openEdit(asRecord(row))"><Edit3 :size="15" />编辑</el-button>
|
||||
<el-button v-if="canRetry && row.syncStatus === 'FAILED'" class="density-action" data-tone="primary" :loading="actionId === row.id" @click="retry(asRecord(row))"><RotateCw :size="15" />重新推送</el-button>
|
||||
<el-button v-if="canRetry && row.syncStatus !== 'SUCCESS'" class="density-action" data-tone="primary" :loading="actionId === row.id" @click="retry(asRecord(row))"><RotateCw :size="15" />人工推送</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<template #image="{ row }"><el-image v-if="row.imageUrl" :src="row.imageUrl" fit="cover" class="sync-image" preview-teleported /><span v-else>—</span></template>
|
||||
|
||||
Reference in New Issue
Block a user