feat(phase-5): 后管京东数据库接口与页面+用户端采集入口——v1.4 Phase 5
This commit is contained in:
@@ -132,6 +132,13 @@ export const TOOL_GROUPS: ReadonlyArray<ToolGroup> = [
|
||||
href: '/convert',
|
||||
permissionKeys: ['convert'],
|
||||
},
|
||||
{
|
||||
id: 'jd',
|
||||
name: '京东采集',
|
||||
desc: '采集京东店铺商品列表与详情全部属性,同步到后台京东数据库',
|
||||
href: '/jd-collect',
|
||||
permissionKeys: ['jd-collect', 'jd_collect'],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -280,6 +287,7 @@ export const TOOL_ICON_GRADIENTS: Record<string, string> = {
|
||||
shop: 'linear-gradient(180deg, #93C5FD, #3B82F6)',
|
||||
purchase: 'linear-gradient(180deg, #C4B5FD, #8B5CF6)',
|
||||
erp: 'linear-gradient(180deg, #F9A8D4, #EC4899)',
|
||||
jd: 'linear-gradient(180deg, #FCA5A5, #DC2626)',
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,6 +335,8 @@ export const TOOL_ICON_SHAPES: Record<string, string> = {
|
||||
purchase: '<path d="M10 14 L34 14 L30 34 L14 34 Z"/><line x1="34" y1="14" x2="40" y2="14"/><line x1="40" y1="14" x2="38" y2="20"/><circle class="fill" cx="19" cy="39" r="3"/><circle class="fill" cx="33" cy="39" r="3"/>',
|
||||
// ERP:网格
|
||||
erp: '<rect x="8" y="8" width="32" height="32"/><line x1="24" y1="8" x2="24" y2="40"/><line x1="8" y1="24" x2="40" y2="24"/>',
|
||||
// 京东采集:商品袋
|
||||
jd: '<path d="M12 16 L36 16 L34 38 L14 38 Z"/><path d="M19 16 A 5 6 0 0 1 29 16"/><circle class="fill" cx="19" cy="26" r="2"/><circle class="fill" cx="29" cy="26" r="2"/>',
|
||||
}
|
||||
|
||||
export const TOOL_MAP: ReadonlyMap<string, ToolInfo> = new Map(
|
||||
@@ -349,6 +359,7 @@ export const TOOL_DETAILS: Readonly<Record<string, string>> = {
|
||||
qasin: '通过店小蜜导出出单 ASIN,上传后台,时不时排查是否还在店铺售卖,确保优质数据时刻在店。',
|
||||
scrape:
|
||||
'没排名、久未出单数据可优化删除;获取店铺所有数据的排名、品牌和销售情况。半个月到一个月复查一次品牌,确保数据没有被注册。',
|
||||
jd: '在本机已登录京麦的窗口里采集店铺商品(列表 + 详情全部属性 + 图片),同步到后台「京东数据库」。任务由本机客户端执行,提交后保持客户端在线。',
|
||||
}
|
||||
|
||||
export type VisibleGroup = ToolGroup & { tools: ToolInfo[] }
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref } from 'vue'
|
||||
import { createJdCollectTask, type JdListTab } from '../../shared/api/types/modules/jd-collect.ts'
|
||||
|
||||
/** 京东店铺商品采集建单页(v1.4 AC-1,蓝图 §3.2)。
|
||||
*
|
||||
* 页面只做建单:任务落 PENDING、执行通道固定 LOCAL,由本机客户端在已登录京麦的
|
||||
* 窗口内领取执行;进度与结果到客户端任务列表(或后台「京东数据库」)查看。
|
||||
*/
|
||||
|
||||
const form = reactive({
|
||||
shopName: '',
|
||||
onsale: true,
|
||||
offsale: false,
|
||||
maxProducts: 0,
|
||||
})
|
||||
|
||||
const submitting = ref(false)
|
||||
const successMessage = ref('')
|
||||
const errorMessage = ref('')
|
||||
|
||||
function buildListTabs(): JdListTab[] {
|
||||
const tabs: JdListTab[] = []
|
||||
if (form.onsale) tabs.push('ONSALE')
|
||||
if (form.offsale) tabs.push('OFFSALE')
|
||||
return tabs
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
errorMessage.value = ''
|
||||
successMessage.value = ''
|
||||
const tabs = buildListTabs()
|
||||
if (!form.shopName.trim()) {
|
||||
errorMessage.value = '请填写要采集的京东店铺名称'
|
||||
return
|
||||
}
|
||||
if (!tabs.length) {
|
||||
errorMessage.value = '请至少勾选一个商品页签(在售中 / 已下架)'
|
||||
return
|
||||
}
|
||||
submitting.value = true
|
||||
try {
|
||||
const vo = await createJdCollectTask(form.shopName.trim(), tabs, form.maxProducts)
|
||||
successMessage.value = `建单成功:任务号 ${vo.taskId}${vo.taskNo ? `(${vo.taskNo})` : ''}。` +
|
||||
'任务由本机客户端执行,请保持客户端在线并已登录京麦;采集进度在客户端任务列表查看,' +
|
||||
'落库数据到后台「京东数据库」菜单查询。'
|
||||
} catch (err) {
|
||||
errorMessage.value = err instanceof Error ? err.message : '建单失败,请稍后重试'
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="jd-collect-page">
|
||||
<div class="jd-collect-panel">
|
||||
<h2>京东采集</h2>
|
||||
<p class="jd-collect-desc">
|
||||
采集京东店铺商品(列表 + 详情全部属性 + 图片),同步到后台「京东数据库」。
|
||||
任务由本机客户端执行:提交后请保持客户端在线,并确保已在客户端登录京麦。
|
||||
</p>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="jd-shop-name">京东店铺名称</label>
|
||||
<input
|
||||
id="jd-shop-name"
|
||||
v-model="form.shopName"
|
||||
type="text"
|
||||
placeholder="填写京麦后台显示的店铺名称"
|
||||
:disabled="submitting"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>采集商品页签</label>
|
||||
<div class="tab-checks">
|
||||
<label class="tab-check">
|
||||
<input v-model="form.onsale" type="checkbox" :disabled="submitting" />
|
||||
在售中
|
||||
</label>
|
||||
<label class="tab-check">
|
||||
<input v-model="form.offsale" type="checkbox" :disabled="submitting" />
|
||||
已下架
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="jd-max-products">采集商品数上限(0 = 不限制)</label>
|
||||
<input
|
||||
id="jd-max-products"
|
||||
v-model.number="form.maxProducts"
|
||||
type="number"
|
||||
min="0"
|
||||
:disabled="submitting"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<button class="jd-submit" type="button" :disabled="submitting" @click="submit">
|
||||
{{ submitting ? '提交中…' : '开始采集' }}
|
||||
</button>
|
||||
|
||||
<p v-if="successMessage" class="jd-feedback success">{{ successMessage }}</p>
|
||||
<p v-if="errorMessage" class="jd-feedback error">{{ errorMessage }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.jd-collect-page {
|
||||
padding: 24px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.jd-collect-panel {
|
||||
width: 100%;
|
||||
max-width: 560px;
|
||||
background: #fff;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.jd-collect-desc {
|
||||
color: #6b7280;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
margin: 8px 0 20px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
color: #374151;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.form-group input[type='text'],
|
||||
.form-group input[type='number'] {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 8px;
|
||||
padding: 8px 10px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.tab-checks {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.tab-check {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 14px;
|
||||
color: #374151;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.jd-submit {
|
||||
width: 100%;
|
||||
background: #2dd4bf;
|
||||
color: #062a26;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
padding: 10px 0;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.jd-submit:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.jd-feedback {
|
||||
margin-top: 16px;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
border-radius: 8px;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
.jd-feedback.success {
|
||||
background: #ecfdf5;
|
||||
color: #047857;
|
||||
}
|
||||
|
||||
.jd-feedback.error {
|
||||
background: #fef2f2;
|
||||
color: #b91c1c;
|
||||
}
|
||||
</style>
|
||||
@@ -67,6 +67,11 @@ const routes = [
|
||||
name: 'appearance-patent',
|
||||
component: () => import('@/pages/brand/components/BrandAppearancePatentTab.vue'),
|
||||
},
|
||||
{
|
||||
path: '/jd-collect',
|
||||
name: 'jd-collect',
|
||||
component: () => import('@/pages/jd/JdCollectTab.vue'),
|
||||
},
|
||||
{
|
||||
path: '/split',
|
||||
name: 'split',
|
||||
|
||||
@@ -204,6 +204,12 @@ export const API_ENDPOINTS = {
|
||||
collectRouting: {
|
||||
get: '/api/collect-routing',
|
||||
},
|
||||
/** 京东店铺商品采集(v1.4):建单走 LOCAL 通道,由本机客户端在已登录京麦的窗口内执行。 */
|
||||
jdCollect: {
|
||||
create: '/api/jd-collect/tasks',
|
||||
heartbeat: '/api/jd-collect/tasks/{taskId}/heartbeat',
|
||||
chunk: '/api/jd-collect/tasks/{taskId}/chunk',
|
||||
},
|
||||
userSecret: {
|
||||
bundle: '/api/user-secrets',
|
||||
save: '/api/user-secrets/{moduleKey}',
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { post, type JavaApiResponse, unwrapJavaResponse } from '../../http.ts'
|
||||
import { buildJavaUrl } from '../../url.ts'
|
||||
import { getCurrentUserId } from '../../user.ts'
|
||||
import { API_ENDPOINTS } from '../../endpoints.ts'
|
||||
|
||||
/** 京东店铺采集建单回执(蓝图 §3.2):任务落 PENDING、执行通道固定 LOCAL,由本机客户端领取执行。 */
|
||||
export interface JdCollectTaskVo {
|
||||
taskId: number;
|
||||
taskNo?: string;
|
||||
collectChannel?: string;
|
||||
}
|
||||
|
||||
/** 可选采集 Tab(京麦商品列表页签):在售中 / 已下架。 */
|
||||
export type JdListTab = 'ONSALE' | 'OFFSALE'
|
||||
|
||||
/**
|
||||
* 建单(v1.4 AC-1):选择店铺 + 商品 Tab + 采集范围。未选店铺 / 未登记京麦登录态时
|
||||
* 服务端按蓝图 §3.2 拒绝并返回点名文案(业务码信封,unwrapJavaResponse 抛出)。
|
||||
*/
|
||||
export function createJdCollectTask(shopName: string, listTabs: JdListTab[], maxProducts = 0) {
|
||||
return unwrapJavaResponse(post<JavaApiResponse<JdCollectTaskVo>, Record<string, unknown>>(
|
||||
buildJavaUrl(API_ENDPOINTS.jdCollect.create),
|
||||
{
|
||||
user_id: getCurrentUserId(),
|
||||
shopName,
|
||||
listTabs,
|
||||
maxProducts,
|
||||
},
|
||||
))
|
||||
}
|
||||
Reference in New Issue
Block a user