feat(distribution): 独立分销前台商城多租户体系、货源与订单数据严格隔离
This commit is contained in:
@@ -244,3 +244,16 @@ export async function fetchDistributionSettlementItems(batchId: number) {
|
||||
)
|
||||
return data.data.items ?? []
|
||||
}
|
||||
|
||||
export interface SyncSiteAccountsResult {
|
||||
synced_count: number
|
||||
skipped_count: number
|
||||
total_active: number
|
||||
}
|
||||
|
||||
export async function syncDistributionSiteAccounts(siteId: number) {
|
||||
const { data } = await apiClient.post<ApiResponse<SyncSiteAccountsResult>>(
|
||||
`/admin/distribution/sites/${siteId}/sync-accounts`
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { Plus, Shop, Link, DocumentCopy } from '@element-plus/icons-vue'
|
||||
import { Plus, Shop, Link, DocumentCopy, Refresh } from '@element-plus/icons-vue'
|
||||
import {
|
||||
fetchDistributionSites,
|
||||
onboardDistributionSite,
|
||||
syncDistributionSiteAccounts,
|
||||
type DistributionSite,
|
||||
type OnboardDistributionSitePayload,
|
||||
type OnboardDistributionSiteResult,
|
||||
@@ -126,6 +127,22 @@ function openDistributionAdmin() {
|
||||
window.open(`http://${window.location.hostname}:5190`, '_blank')
|
||||
}
|
||||
|
||||
const syncingSiteId = ref<number | null>(null)
|
||||
|
||||
async function handleSyncAccounts(row: DistributionSite) {
|
||||
syncingSiteId.value = row.id
|
||||
try {
|
||||
const res = await syncDistributionSiteAccounts(row.id)
|
||||
ElMessage.success(
|
||||
`同步成功!为【${row.site_name}】新增可售账号 ${res.synced_count} 个,已存在 ${res.skipped_count} 个(主站当前可上架总数 ${res.total_active})`
|
||||
)
|
||||
} catch (err) {
|
||||
ElMessage.error(readError(err, '同步商品失败'))
|
||||
} finally {
|
||||
syncingSiteId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadSites()
|
||||
})
|
||||
@@ -191,6 +208,19 @@ onMounted(() => {
|
||||
{{ formatDateTime(row.created_at) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="140" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:icon="Refresh"
|
||||
:loading="syncingSiteId === row.id"
|
||||
@click="handleSyncAccounts(row)"
|
||||
>
|
||||
同步商品
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user