feat(phase-5): 后管京东数据库接口与页面+用户端采集入口——v1.4 Phase 5
This commit is contained in:
@@ -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>
|
||||
Reference in New Issue
Block a user