feat(jd): 京东数据库行级编辑与删除+人工编辑锁/删除忽略保护(V199,2026-11-15 用户口径「每条数据可以编辑/删除」)——主链:PUT /api/admin/jd-products/{id} 主字段全量提交即置 manual_locked=1(采集回传 upsert/purge 对锁定行跳过,XML 侧 AND manual_locked=0 铁律 20);attrGroups 只重建 attr_json 的 tabs 段保留其它顶层键(铁律 30),原文形状不识别拒绝;skus 按 (productId,skuId) 改价改库存缺失拒绝;deleteImageIds 先删桶(共用对象保留)计数按表实数刷;删除链成功后写 biz_jd_product_ignore 防重爬复活(幂等吞 DuplicateKey);采集回传 filterProtectedRows 跳过锁定/忽略行不登记子表。后管:列表 11 列操作列(编辑/删除,@click.stop 防冒泡)+ JdProductEditDrawer(主字段/属性键值行删/SKU 价格库存/图片标删,保存提示人工维护后果),updateJdProduct 带 company_id;company-tab-wiring SEND_POINTS 26→32(补详情/删除/分组/类目/删分组/编辑六口一函数一钉对平)。判据:JdProductUpdateServiceTest 8 例+SyncServiceTest 保护闸/绊线+DeleteServiceTest 忽略登记+mount 操作列防冒泡/编辑抽屉;后端整量 5,607 例、后管 vue-tsc+1903+113 全绿。同窗交织笔(另一路会话类目下拉已收尾,文件级无法拆分一并入库):selectProductCategories/GET /categories/JdProductCategoryVo 类目筛选下拉+MigratedSqlEquivalenceTest/SqlLayeringConventionTest 适配。图片上传/替换链路记 BACKLOG B109-01;RawExceptionMessageSinkGuard/CatchSilenceRatchet 随笔抬格逐处记名

This commit is contained in:
2026-11-15 18:38:27 +08:00
parent 7a117187b7
commit dea9891e19
30 changed files with 2449 additions and 517 deletions
@@ -1,10 +1,12 @@
<script setup lang="ts">
/** 京东数据库页(v1.4 Phase 5):公司隔离的京东商品库,筛选行(店铺/商品编码/标题关键字/商品状态/
* 分组/同步起止 date 对)+查询/导出/重置/管理分组 + 自绘明细表(勾选列+点行开详情抽屉)
/** 京东数据库页(v1.4 Phase 5):公司隔离的京东商品库,筛选行(店铺/商品编码/标题关键字/
* 分组/同步起止 date 对)+查询/重置/管理分组 + 自绘明细表(勾选列+点行开详情抽屉)
* + 删除(单行/批量,先删桶对象、全成功才删库行,确认弹窗点名数量)+ OldPagination。
* 列表按京麦商品列表样式(2026-11-15 用户口径):店铺/分组前置为第 1/2 列;商品信息列=京麦同款
* 合并布局(主图+图下信息分+标题两行+商品编码/货号+SKU 数标签,编码带一键复制);类目/上架
* 时间/京东创建/修改时间仍收详情抽屉基本信息(B104「详情显示全部属性」口径不变)。
* 商品状态筛选框/列与导出按钮随 2026-11-15 客户口径「这两个不要/导出也不用」从前端下线
* (后端 sale_status 参数与 /export 端点保留;状态仍收详情抽屉)。
* 骨架像素复刻「外观专利数据库」页(panel-box + LoadFailureBar + 自绘 table + 旧式分页);
* 公司 tab 切换=清筛选重取(watch 体照外观专利页逐字形状);日期对护栏:起侧 max=止侧、
* 止侧 min=起侧、两侧 @change 用 orderedPair 把倒挂交换回来(clampJdSyncedRange 照 clampDatePair)。
@@ -13,15 +15,17 @@
import { computed, onMounted, reactive, ref, watch } from 'vue'
import {
deleteJdProducts,
exportJdProductList,
fetchJdProductCategories,
fetchJdProductGroups,
fetchJdProductList,
type JdProductCategoryOption,
type JdProductGroup,
} from './jd-product-api.ts'
import type { JdProductItem } from './jd-product-model.ts'
import { jdPriceRange } from './jd-product-model.ts'
import { createJdProductFilterState, JD_SALE_STATUS_HINT } from './jd-product-filter.ts'
import { createJdProductFilterState } from './jd-product-filter.ts'
import JdProductDetailDrawer from './JdProductDetailDrawer.vue'
import JdProductEditDrawer from './JdProductEditDrawer.vue'
import JdProductGroupDialog from './JdProductGroupDialog.vue'
import OldPagination from '@/components/OldPagination.vue'
import { useCompanyTabStore } from '@/stores/company-tab'
@@ -39,15 +43,34 @@ const rows = ref<JdProductItem[]>([])
const total = ref(0)
const page = ref(1)
const pageSize = ref(20)
/** 导出在途锁:避免连点导出把同一份过滤面重复请求两遍。 */
const exporting = ref(false)
const filter = reactive(createJdProductFilterState())
/** 分组下拉选项:公司 tab 切换时重取;选项失败不拦列表,只回空下拉(可见「全部分组」)。 */
const groupOptions = ref<JdProductGroup[]>([])
/** 类目下拉选项(京麦末级类目):同分组口径——公司隔离取数、失败静默回空。 */
const categoryOptions = ref<JdProductCategoryOption[]>([])
/** 分组管理弹窗与详情抽屉。 */
const groupDialogVisible = ref(false)
const detailItem = ref<JdProductItem | null>(null)
const detailVisible = ref(false)
/** 行级编辑抽屉(2026-11-15 用户口径「每一条数据后面 需要编辑或者删除;编辑的话
* 这里面都是可以编辑的」):删除走下面的 removeOne(同一条删除链),编辑走独立抽屉。 */
const editItem = ref<JdProductItem | null>(null)
const editVisible = ref(false)
function openEdit(item: JdProductItem): void {
editItem.value = item
editVisible.value = true
}
function closeEdit(): void {
editVisible.value = false
editItem.value = null
}
/** 编辑保存成功:刷新列表(该行已置人工编辑锁,标题/价格等即时可见且不再被采集覆盖)。 */
async function onEditSaved(): Promise<void> {
await load()
}
/** min/max 挡不住手输,落值后把倒挂的起止交换回来。 */
function clampJdSyncedRange(): void {
@@ -67,6 +90,15 @@ async function loadGroupOptions(): Promise<void> {
}
}
/** 类目选项同分组口径:失败静默回空下拉(可见「全部类目」),不拦首屏行集。 */
async function loadCategoryOptions(): Promise<void> {
try {
categoryOptions.value = await fetchJdProductCategories(companyTab.requestCompanyId)
} catch {
categoryOptions.value = []
}
}
/** 分组管理弹窗里做过变更:分组下拉与列表都刷新(删除分组后行集的 groupName 会变)。 */
async function onGroupChanged(): Promise<void> {
await loadGroupOptions()
@@ -84,7 +116,7 @@ async function load(): Promise<void> {
shopName: filter.shopName,
productCode: filter.productCode,
titleKeyword: filter.titleKeyword,
saleStatus: filter.saleStatus,
category: filter.category,
groupId: filter.groupId,
syncedFrom: filter.syncedFrom,
syncedTo: filter.syncedTo,
@@ -103,38 +135,6 @@ async function load(): Promise<void> {
}
}
/** 导出与页签同一过滤面(含公司 tab 与分组),服务端全量出 xlsx;成功后浏览器落盘,失败弹可读文案。 */
async function exportAll(): Promise<void> {
if (exporting.value) return
exporting.value = true
try {
const result = await exportJdProductList({
shopName: filter.shopName,
productCode: filter.productCode,
titleKeyword: filter.titleKeyword,
saleStatus: filter.saleStatus,
groupId: filter.groupId,
syncedFrom: filter.syncedFrom,
syncedTo: filter.syncedTo,
companyId: companyTab.requestCompanyId,
})
const url = URL.createObjectURL(result.blob)
const anchor = document.createElement('a')
anchor.href = url
anchor.download = result.filename
document.body.appendChild(anchor)
anchor.click()
anchor.remove()
URL.revokeObjectURL(url)
showAdminFeedback(`已导出 ${result.filename}`, 'success')
} catch (error) {
const message = error instanceof Error && error.message ? error.message : '导出失败,请稍后重试'
showAdminFeedback(message, 'error')
} finally {
exporting.value = false
}
}
function apply(): void {
page.value = 1
void load()
@@ -233,12 +233,13 @@ async function removeMany(picked: JdProductItem[], message: string): Promise<voi
}
}
// 切公司 = 重新取数:店铺/编码/关键字/状态/分组是上一家选中的值,在新一家的行集里筛不出东西,
// 必须一起清,分组选项也按新公司重取(选项集是公司隔离的)。
watch(() => companyTab.activeId, () => { filter.shopName = ''; filter.productCode = ''; filter.titleKeyword = ''; filter.saleStatus = ''; filter.groupId = ''; filter.syncedFrom = ''; filter.syncedTo = ''; page.value = 1; void loadGroupOptions(); void load() })
// 切公司 = 重新取数:店铺/编码/关键字/类目/分组是上一家选中的值,在新一家的行集里筛不出东西,
// 必须一起清,分组/类目选项也按新公司重取(选项集是公司隔离的)。
watch(() => companyTab.activeId, () => { filter.shopName = ''; filter.productCode = ''; filter.titleKeyword = ''; filter.category = ''; filter.groupId = ''; filter.syncedFrom = ''; filter.syncedTo = ''; page.value = 1; void loadGroupOptions(); void loadCategoryOptions(); void load() })
onMounted(() => {
void loadGroupOptions()
void loadCategoryOptions()
void load()
})
</script>
@@ -264,10 +265,6 @@ onMounted(() => {
<label>标题关键字</label>
<input v-model="filter.titleKeyword" type="text" placeholder="输入标题关键字" @keyup.enter="apply" />
</div>
<div class="form-group">
<label>商品状态</label>
<input v-model="filter.saleStatus" type="text" :placeholder="JD_SALE_STATUS_HINT" @keyup.enter="apply" />
</div>
<div class="form-group">
<label>分组</label>
<!-- 分组选中即查:选完立刻按该分组过滤刷新(回第一页),不必再点查询。 -->
@@ -276,6 +273,16 @@ onMounted(() => {
<option v-for="group in groupOptions" :key="group.id" :value="String(group.id)">{{ group.name }}</option>
</select>
</div>
<div class="form-group">
<label>类目</label>
<!-- 类目(京麦末级类目)选中即查:同分组口径,选完立刻按该类目过滤刷新(回第一页)。 -->
<select v-model="filter.category" @change="apply">
<option value="">全部类目</option>
<option v-for="cat in categoryOptions" :key="cat.name" :value="cat.name">
{{ cat.name }}({{ cat.productCount }})
</option>
</select>
</div>
<div class="form-group">
<label>同步开始日期</label>
<input v-model="filter.syncedFrom" type="date" :max="filter.syncedTo" @change="clampJdSyncedRange" />
@@ -286,9 +293,6 @@ onMounted(() => {
</div>
<div class="jd-filter-actions">
<button class="btn" type="button" @click="apply">查询</button>
<button class="btn btn-export" type="button" :disabled="exporting" @click="exportAll">
{{ exporting ? '导出中...' : '导出' }}
</button>
<button class="btn btn-secondary" type="button" @click="reset">重置</button>
</div>
</div>
@@ -314,11 +318,13 @@ onMounted(() => {
<th style="width: 130px">店铺</th>
<th style="width: 96px">分组</th>
<th>商品信息</th>
<th style="width: 90px">品牌</th>
<th style="width: 110px">价格区间</th>
<th style="width: 76px">总库存</th>
<th style="width: 86px">商品状态</th>
<th style="width: 120px">价格</th>
<th style="width: 170px">上架时间 / 商品状态</th>
<th style="width: 150px">创建时间</th>
<th style="width: 150px">修改时间</th>
<th style="width: 170px">同步时间</th>
<th style="width: 120px">操作</th>
</tr>
</thead>
<tbody>
@@ -341,22 +347,37 @@ onMounted(() => {
<button v-if="row.productCode" class="jd-copy-btn" type="button" title="复制商品编码" @click.stop="copyText(row.productCode)">⧉</button>
</div>
<div class="jd-info-meta">货号:<span class="jd-info-code">{{ row.itemNum || '-' }}</span></div>
<!-- 品牌·类目行:京麦列表同款(末级类目名紧随品牌),字段与顺序 2026-11-15 对齐京麦。 -->
<div v-if="row.brand || row.categoryPath" class="jd-info-meta jd-brand-cat">
<span class="jd-brand-name">{{ row.brand || '' }}</span>&nbsp;{{ row.categoryPath || '' }}
</div>
<div v-if="row.skuCount" class="jd-info-tags"><span class="jd-tag">{{ row.skuCount }}个SKU</span></div>
</div>
</div>
</td>
<td>{{ row.brand || '-' }}</td>
<td>{{ jdPriceRange(row) || '-' }}</td>
<td>{{ row.stockTotal ?? '-' }}</td>
<td>{{ row.saleStatus || '-' }}</td>
<td>{{ jdPriceRange(row) || '-' }}</td>
<td class="jd-online-cell">
<div>{{ formatDateTime(row.jdOnlineAt || '') || '-' }}</div>
<div v-if="row.saleStatus" class="jd-sale-status" :class="{ off: row.saleStatus !== '上架中' }">
<span class="jd-sale-dot"></span>{{ row.saleStatus }}
</div>
</td>
<td>{{ formatDateTime(row.jdCreatedAt || '') || '-' }}</td>
<td>{{ formatDateTime(row.jdUpdatedAt || '') || '-' }}</td>
<td>{{ formatDateTime(row.syncedAt || '') }}</td>
<!-- 操作列(2026-11-15 用户口径):编辑/删除;@click.stop 防冒泡开详情抽屉。 -->
<td class="jd-ops-cell" @click.stop>
<button class="btn btn-sm" type="button" @click="openEdit(row)">编辑</button>
<button class="btn btn-sm btn-danger" type="button" :disabled="deleting" @click="removeOne(row)">删除</button>
</td>
</tr>
</template>
<tr v-else-if="loading">
<td colspan="9" class="empty-tip">加载中...</td>
<td colspan="11" class="empty-tip">加载中...</td>
</tr>
<tr v-else>
<td colspan="9" class="empty-tip">暂无京东商品数据</td>
<td colspan="11" class="empty-tip">暂无京东商品数据</td>
</tr>
</tbody>
</table>
@@ -371,6 +392,13 @@ onMounted(() => {
:company-id="companyTab.requestCompanyId"
@close="closeDetail"
/>
<JdProductEditDrawer
:item="editItem"
:visible="editVisible"
:company-id="companyTab.requestCompanyId"
@close="closeEdit"
@saved="onEditSaved"
/>
<JdProductGroupDialog
:visible="groupDialogVisible"
:company-id="companyTab.requestCompanyId"
@@ -415,14 +443,18 @@ h3 {
margin: 0;
}
.jd-filter-row {
display: grid;
grid-template-columns: repeat(7, minmax(140px, 1fr)) auto;
/* 可换行流式布局:固定 6 列 minmax(140px) 的网格在窄面板下最小宽超出容器,
把查询/重置挤出面板右缘(与「管理分组」重叠)。flex-wrap 让放不下的项自然折行。 */
display: flex;
flex-wrap: wrap;
gap: 12px;
align-items: end;
align-items: flex-end;
margin-bottom: 16px;
}
.jd-filter-row .form-group {
min-width: 0;
flex: 1 1 160px;
min-width: 150px;
max-width: 260px;
}
.jd-filter-actions {
display: flex;
@@ -542,7 +574,21 @@ h3 {
table-layout: fixed;
}
.jd-table-scroll > table {
min-width: 1180px;
min-width: 1500px;
}
/* 操作列(编辑/删除):双小按钮,放开换行不让按钮被裁。 */
.jd-ops-cell {
white-space: normal;
text-overflow: clip;
}
.btn-sm {
min-height: 28px;
padding: 3px 10px;
font-size: 12.5px;
margin-right: 6px;
}
.btn-sm:last-child {
margin-right: 0;
}
.table-scroll th,
.table-scroll td {
@@ -556,6 +602,14 @@ h3 {
text-overflow: ellipsis;
white-space: nowrap;
}
/* 首列勾选格:checkbox 的 UA 默认 margin(3px 3px 3px 4px)使其 margin-box 溢出
42px 格的内容盒(42−24 padding=18px),配合上面的 overflow:hidden,Chromium 在
首次渲染时会把被裁的 checkbox 碎片留在裁剪边缘,看起来像格子右边多出 ".."。
margin 归零后 margin-box 收进内容盒,首渲染即干净(playwright 三次冷加载已验)。 */
.table-scroll th:first-child input,
.table-scroll td:first-child input {
margin: 0;
}
.table-scroll th {
background: #edf4fa;
color: #4e6479;
@@ -666,6 +720,31 @@ h3 {
gap: 6px;
margin-top: 2px;
}
/* 品牌·类目行(京麦列表同款深色文字):信息 meta 是灰色,这行按京麦用主文字色。 */
.jd-brand-cat {
color: #3d5368;
font-weight: 550;
}
.jd-online-cell {
line-height: 1.45;
}
/* 商品状态(京麦同款圆点):上架中绿点,其余灰点。 */
.jd-sale-status {
display: flex;
align-items: center;
gap: 5px;
color: #24384d;
}
.jd-sale-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: #2fb26b;
flex-shrink: 0;
}
.jd-sale-status.off .jd-sale-dot {
background: #9fb0c0;
}
.jd-tag {
display: inline-flex;
align-items: center;