feat(jd): 采集分类换 el-select 下拉多选(2026-11-17 客户口径「不要全展示出来,弄个下拉式多选」)——9 行复选列表收进 collapse-tags 下拉(+N 徽标),选择模型改 id 数组、双键按快照原序同源反查(点选先后不进请求体);暗色主题套壳。判据:纯测试钉 el-select multiple 在册+shop-cat-list 旧形状反向钉;挂载两格改用真实 ElementPlus 经 update:modelValue 模拟点选(轮询格保持轻量桩——真件在 fake timers 下会打断任务面板轮询链,实测教训写进注释)。node --test 9 例+vitest 挂载 10 例+vue-tsc rc=0
This commit is contained in:
@@ -21,7 +21,7 @@ import { userNotice } from '@/shared/utils/user-notice'
|
||||
import { formatDateTime } from '@/shared/utils/datetime'
|
||||
import { useLiveTaskBoard } from '@/shared/composables/useLiveTaskBoard'
|
||||
import NotificationBell from '@/shared/components/NotificationBell.vue'
|
||||
import { JD_SHOP_CATEGORY_SNAPSHOT, type JdShopCategory } from './jd-shop-category.ts'
|
||||
import { JD_SHOP_CATEGORY_SNAPSHOT } from './jd-shop-category.ts'
|
||||
|
||||
/** 京东「获取店铺数据」(v1.5):一键建单 → 推送本机客户端 → 右侧任务面板实时进度。
|
||||
*
|
||||
@@ -55,23 +55,23 @@ const submitting = ref(false)
|
||||
const errorMessage = ref('')
|
||||
const successMessage = ref('')
|
||||
|
||||
// ---- 采集分类(可选,多选;空=全店采集)----
|
||||
// ---- 采集分类(可选,下拉多选;空=全店采集)----
|
||||
/** 选项集=京麦「店内分类」快照(getShopCategoryList,2026-11-16 真机取证 9 个;
|
||||
* 京麦侧改分类后按取证路重抓,见 jd-shop-category.ts 头注释——快照不会自动过期告警)。 */
|
||||
* 京麦侧改分类后按取证路重抓,见 jd-shop-category.ts 头注释——快照不会自动过期告警)。
|
||||
* 2026-11-17 客户口径「不要全展示出来,弄个下拉式多选」:复选列表换 el-select 多选
|
||||
* (collapse-tags 折叠成「+N」徽标),选择模型改存分类 id 数组,label/id 双键从快照反查。 */
|
||||
const shopCategoryOptions = JD_SHOP_CATEGORY_SNAPSHOT
|
||||
const selectedShopCategories = ref<JdShopCategory[]>([])
|
||||
|
||||
function toggleShopCategory(category: JdShopCategory) {
|
||||
const hit = selectedShopCategories.value.find((item) => item.value === category.value)
|
||||
selectedShopCategories.value = hit
|
||||
? selectedShopCategories.value.filter((item) => item.value !== category.value)
|
||||
: [...selectedShopCategories.value, category]
|
||||
}
|
||||
const selectedShopCategoryValues = ref<string[]>([])
|
||||
|
||||
function clearShopCategories() {
|
||||
selectedShopCategories.value = []
|
||||
selectedShopCategoryValues.value = []
|
||||
}
|
||||
|
||||
/** 选中项按快照原序反查回对象(下拉里点选的先后不进请求体——双键顺序恒等于快照序)。 */
|
||||
const selectedShopCategories = computed(() =>
|
||||
shopCategoryOptions.filter((item) => selectedShopCategoryValues.value.includes(item.value)),
|
||||
)
|
||||
|
||||
/** 建单/推送载荷的选中值:label 与 id 双键同发(行级填充形状未取证,任一键命中即命中)。 */
|
||||
const selectedShopCategoryNames = computed(() => selectedShopCategories.value.map((item) => item.label))
|
||||
const selectedShopCategoryIds = computed(() => selectedShopCategories.value.map((item) => item.value))
|
||||
@@ -413,22 +413,17 @@ onUnmounted(() => {
|
||||
<aside class="left-panel">
|
||||
<div class="category-block">
|
||||
<span class="category-label">采集分类(可选,多选)</span>
|
||||
<ul class="shop-cat-list">
|
||||
<li v-for="category in shopCategoryOptions" :key="category.value">
|
||||
<label class="shop-cat-item" :title="`${category.label}(id ${category.value})`">
|
||||
<input type="checkbox" class="shop-cat-check"
|
||||
:checked="selectedShopCategories.some((item) => item.value === category.value)"
|
||||
@change="toggleShopCategory(category)" />
|
||||
<span class="shop-cat-name">{{ category.label }}</span>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
<el-select v-model="selectedShopCategoryValues" multiple collapse-tags collapse-tags-tooltip
|
||||
:max-collapse-tags="1" placeholder="不选=全店采集(点击选择分类)" class="shop-cat-select">
|
||||
<el-option v-for="category in shopCategoryOptions" :key="category.value"
|
||||
:label="category.label" :value="category.value" />
|
||||
</el-select>
|
||||
<p class="category-hint">
|
||||
{{ selectedShopCategories.length
|
||||
? `只采选中 ${selectedShopCategories.length} 个分类的商品;`
|
||||
{{ selectedShopCategoryValues.length
|
||||
? `只采选中 ${selectedShopCategoryValues.length} 个分类的商品;`
|
||||
: '不选=全店采集。' }}
|
||||
分类是京麦后台「店内分类」(2026-11-16 快照);商品要先在京麦挂上分类才会被选中。
|
||||
<button v-if="selectedShopCategories.length" class="shop-cat-clear" type="button"
|
||||
<button v-if="selectedShopCategoryValues.length" class="shop-cat-clear" type="button"
|
||||
@click="clearShopCategories">清空</button>
|
||||
</p>
|
||||
</div>
|
||||
@@ -667,42 +662,21 @@ onUnmounted(() => {
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* 采集分类多选块(2026-11-16 京麦店内分类快照):label 复用 category-label,
|
||||
* 列表项按暗色主题复选行样式(快照是纯前端数据,无加载失败分支)。 */
|
||||
.shop-cat-list {
|
||||
margin: 8px 0 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
/* 采集分类下拉多选(2026-11-17 客户口径「别全展示,弄下拉式多选」):
|
||||
* 暗色主题套品牌页 el-select 同款壳(wrapper 底色/描边/文字色),
|
||||
* 面板内弹层由 Element Plus 自带样式,不再逐条铺 9 行复选框。 */
|
||||
.shop-cat-select {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.shop-cat-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 5px 10px;
|
||||
border: 1px solid #3e4a62;
|
||||
border-radius: 6px;
|
||||
background: #232b3d;
|
||||
.shop-cat-select :deep(.el-select__wrapper) {
|
||||
background-color: #232b3d;
|
||||
box-shadow: 0 0 0 1px #3e4a62 inset;
|
||||
}
|
||||
|
||||
.shop-cat-select :deep(.el-select__placeholder),
|
||||
.shop-cat-select :deep(.el-select__selected-item) {
|
||||
color: #c8d2e2;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.shop-cat-item:hover {
|
||||
border-color: #5a6b8c;
|
||||
}
|
||||
|
||||
.shop-cat-check {
|
||||
accent-color: #e1251b;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.shop-cat-name {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.shop-cat-clear {
|
||||
|
||||
Reference in New Issue
Block a user