fix(#82): separate PDD linking from mapping

This commit is contained in:
QiuSW
2026-08-25 10:21:10 +08:00
parent 66ea01c02e
commit 7b488e2c68
7 changed files with 92 additions and 22 deletions
@@ -183,7 +183,7 @@ export default {
created() {
this.load()
const productId = Number(this.$route.query.productId)
if (Number.isInteger(productId) && productId > 0) this.openDetail(productId)
if (Number.isInteger(productId) && productId > 0) this.openRouteDetail(productId).catch(() => {})
},
methods: {
emptyCreate() { return { shopeeItemId: '', title: '', shopName: '', pddProductId: null } },
@@ -281,6 +281,13 @@ export default {
},
// ---------------- 详情 / 映射 ----------------
async openRouteDetail(id) {
try {
await this.openDetail(id)
} finally {
if (String(this.$route.query.action || '') === 'link_pdd' && this.detail.product?.id === id) this.openPddPicker('link')
}
},
async openDetail(id) {
this.detail = { ...this.emptyDetail(), open: true, loading: true, highlightColor: String(this.$route.query.targetColor || '').trim() }
try {
+4 -2
View File
@@ -207,7 +207,7 @@ export default {
purchaseReady(row) { return this.purchaseReadiness[row.id] || { sybProductId: row.id, eligible: false, reason: this.purchaseReadinessLoading ? '正在检查' : '请刷新后重试' } },
purchasePriceText(item) { if (item.minUnitPriceCent === undefined || item.maxUnitPriceCent === undefined) return ''; return `允许单价 ¥${(item.minUnitPriceCent / 100).toFixed(2)}~¥${(item.maxUnitPriceCent / 100).toFixed(2)}` },
processMeta(stage) { return { manual_action: { label: '待人工处理', type: 'warning' }, pdd_unlinked: { label: '未关联 PDD', type: 'info' }, pdd_pending: { label: 'PDD 待采集', type: 'info' }, pdd_collecting: { label: 'PDD 采集中', type: 'primary' }, pdd_collection_failed: { label: 'PDD 采集失败', type: 'danger' }, color_mapping: { label: '颜色待匹配', type: 'warning' }, purchase_ready: { label: '可创建采购', type: 'success' }, task_created: { label: '已创建任务', type: 'primary' }, purchase_succeeded: { label: '采购成功', type: 'success' }, order_review: { label: '待人工核对', type: 'danger' }}[stage] || { label: '待人工处理', type: 'warning' } },
purchaseActionLabel(item) { return { open_mapping: '去匹配', open_shopee: '查看蝦皮商品', open_pdd: '查看 PDD 商品', open_task: '查看任务', reparse: '查看并处理', select_device: '重新选择设备', refresh: '刷新' }[item.nextAction] || '' },
purchaseActionLabel(item) { return { open_pdd_link: '去关联', open_mapping: '去匹配', open_shopee: '查看蝦皮商品', open_pdd: '查看 PDD 商品', open_task: '查看任务', reparse: '查看并处理', select_device: '重新选择设备', refresh: '刷新' }[item.nextAction] || '' },
async loadPurchaseReadiness(ids, requestOptions = {}, generation = this.loadGeneration) {
if (generation !== this.loadGeneration) return
this.purchaseReadiness = {}
@@ -226,10 +226,11 @@ export default {
},
priceText(row) { if (row.unitPriceCent === null || row.unitPriceCent === undefined) return '—'; return `¥${(row.unitPriceCent / 100).toFixed(2)}` },
parseMeta(status) { return { success: { label: '成功', type: 'success' }, uncertain: { label: '存疑', type: 'warning' }, failed: { label: '失败', type: 'danger' }}[status] || { label: status || '-', type: 'info' } },
openShopeeDetail(shopeeProductId, targetColor = '') {
openShopeeDetail(shopeeProductId, targetColor = '', action = '') {
if (!shopeeProductId) { ElMessage.warning('该明细尚未关联虾皮商品'); return }
const query = { productId: shopeeProductId }
if (targetColor) query.targetColor = targetColor
if (action) query.action = action
const route = this.$router.resolve({ path: '/shopee-products/index', query })
window.open(route.href, '_blank', 'noopener')
},
@@ -240,6 +241,7 @@ export default {
},
openPurchaseTask(taskId) { this.$router.push({ path: '/purchase-tasks/index', query: { taskId }}) },
runPurchaseNextAction(row, readiness) {
if (readiness.nextAction === 'open_pdd_link') return this.openShopeeDetail(row.shopeeProductId, '', 'link_pdd')
if (readiness.nextAction === 'open_mapping' || readiness.nextAction === 'open_shopee') return this.openShopeeDetail(row.shopeeProductId, row.targetColor)
if (readiness.nextAction === 'open_pdd') return this.openPddDetail(readiness.pddProductId)
if (readiness.nextAction === 'open_task' && readiness.activeTaskId) return this.openPurchaseTask(readiness.activeTaskId)