Files
crawler-plugin/admin-frontend-vue/src/pages/jd/JdShopPickerDialog.vue
T
huangzd1997 10dec12ec0 refactor(前端): 前后台界面小字全面精简——删技术ID括号/页头操作提示条/机制解释句(2026-11-28 客户口径「这些小字都不需要多余,还有shopId啥的…除了必须要的比如任务ID密钥,其他精简一些」)
用户端 frontend-vue:
- jd-publish-shop.ts:shopLabel 只出店名(缺名兜底「店铺 N」),跨店/多店琥珀文案压成一两句,判据逻辑零改动
- JdPublishTab:删工具头/分类解释/品牌句后半,默认店铺/选品/collect-hint/中断回执/加价规则各压一句
- JdCollectTab:删工具头 desc、分类机制句、断点游标行,「页面筛选未生效兜底翻页中」从任务卡撤下
- jd-on-shelf 空态一句、JdConsolePage hero-sub 整段删(含过时的「正在建设中」)
- 品牌 10 个 tab:输入/筛选/加载长句压一句或删,任务卡删「结果ID/店铺ID/平台」技术行(店名已显形)
- 保留:错误出口、额度「当前在架X/Y」、GROUPS_EMPTY 空态动作句、检测按钮与店铺显形

后管 admin-frontend-vue:
- 每页顶部「当前页面操作提示」条整条下线(删 OperationGuide.vue+operation-guides.ts)
- 撞款/任务中心/关键词用量/密钥用量/客户端包/教程/软件版本/数字人/菜单/店铺密钥/登录页逐页删说明小字(保留:踢线警示、「留空=永不过期」、「不要带v前缀」、「仅支持.zip」、草稿需手动发布、已授权人数、安全提示)
- 编辑/建号弹窗 label 括号收短;代理弹窗/设备日志(删 pywebview/kk-browser 进程名)/密钥 pill title/授权弹窗 dim/品牌门控空态收短

测试同步(16 支改反钉或同步断言,全部当场绿):
- align-operation-guide 整份重写为反钉(组件与文案表不得回流)
- source-pin 台账 task-center-board 条目手工点名 7/3/5→24/14/28:旧值是切分器把正则字面量内裸引号当字符串开关吞掉 18 支用例的误量(stripNonCode 不识别 regex literal),本次改写恰好移除该文件最后两处带引号正则后测出真值;真实用例数反而 25→24(删 1 支 guide 用例),非真实增长

门禁:后管 node --test 1965/1965+vitest 253/253+vue-tsc rc=0;用户端 node 1150/mount 149/vue-tsc rc=0;ops 快检 --fast overall=pass(后端9.5/后管8.8/客户端9.8/用户端9.6)。本窗不发版;app_client/jar/后端零改动。
2026-11-28 01:14:51 +08:00

437 lines
11 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
/** 添加店铺弹窗(v1.7 F6 对齐原型《商品数据商城》的「店铺名单维度」):
* 侧栏店铺分类 Tab 展开某分类后的「+ 添加店铺」行打开。候选=服务端
* fetchJdAvailableShops(biz_jd_product.shop_name DISTINCT,关键词包含匹配+排除本分类
* 已有名单,limit ≤ 200——商品行 shop_name 是京麦店铺全名,与名单来源同源);
* 勾选候选+手输自定义项(不在候选里的新店名)合并成一个待添加清单,一次批量提交
* (服务侧 trim/去重/上限 100,INSERT IGNORE 幂等跳过已存在行,回执=实际新增行数)。
* 结构复制 JdBatchAssignDialog(modal-mask+modal-head/tip/foot 同款皮肤)。 */
import { computed, ref, watch } from 'vue'
import { addJdGroupShops, fetchJdAvailableShops } from './jd-product-api.ts'
import { requestErrorMessage } from '../../api/envelope.ts'
const props = defineProps<{
visible: boolean
/** 目标分类(名单挂在分类下)。 */
categoryId: number
categoryName: string
}>()
const emit = defineEmits<{ (event: 'close'): void; (event: 'done', added: number, categoryName: string): void }>()
/** 候选搜索(关键词输入后手动点「搜索」或 Enter 触发——不随输入逐键打后端)。 */
const keyword = ref('')
const candidates = ref<string[]>([])
const searching = ref(false)
const searched = ref(false)
/** 待添加清单(勾选的候选+手输自定义项,Set 保序去重)。 */
const pending = ref<string[]>([])
/** 手输自定义项输入框。 */
const customName = ref('')
const submitting = ref(false)
const errorText = ref('')
/** 批量上限与服务端 JdGroupShopService.MAX_ADD_SHOPS 同值(文案点名 100)。 */
const MAX_ADD_SHOPS = 100
const canSubmit = computed(() => pending.value.length > 0 && !submitting.value)
watch(
() => props.visible,
(visible) => {
if (visible) {
keyword.value = ''
candidates.value = []
searched.value = false
pending.value = []
customName.value = ''
errorText.value = ''
// 打开即拉一次空关键词候选(让用户不输词也有东西可勾)。
void search()
}
},
)
async function search(): Promise<void> {
searching.value = true
errorText.value = ''
try {
candidates.value = await fetchJdAvailableShops(keyword.value, props.categoryId)
searched.value = true
} catch (error) {
errorText.value = requestErrorMessage(error) || '候选店铺加载失败'
} finally {
searching.value = false
}
}
function toggleCandidate(name: string): void {
const index = pending.value.indexOf(name)
if (index >= 0) pending.value = pending.value.filter((item) => item !== name)
else pending.value = [...pending.value, name]
}
/** 手输自定义项:空白不收;与待添加清单重复不收(静默忽略——清单里已有就是同一个)。 */
function addCustom(): void {
const name = customName.value.trim()
if (!name) return
if (!pending.value.includes(name)) pending.value = [...pending.value, name]
customName.value = ''
}
function removePending(name: string): void {
pending.value = pending.value.filter((item) => item !== name)
}
async function submit(): Promise<void> {
if (!canSubmit.value) return
submitting.value = true
errorText.value = ''
try {
const added = await addJdGroupShops(props.categoryId, pending.value)
emit('done', added, props.categoryName)
emit('close')
} catch (error) {
errorText.value = requestErrorMessage(error) || '添加店铺失败'
} finally {
submitting.value = false
}
}
</script>
<template>
<div v-if="visible" class="modal-mask" @click.self="emit('close')">
<div class="shop-picker-modal">
<div class="modal-head">
<h3>添加店铺<span v-if="categoryName" class="modal-sub">· {{ categoryName }}</span></h3>
<button class="modal-close" type="button" aria-label="关闭" @click="emit('close')">×</button>
</div>
<p class="modal-tip">一次最多添加 {{ MAX_ADD_SHOPS }} 个,已有的会自动跳过。</p>
<p v-if="errorText" class="group-error">{{ errorText }}</p>
<!-- 候选搜索:关键词包含匹配(服务端 DISTINCT+like),Enter 或按钮触发。 -->
<div class="shop-search">
<input
v-model="keyword"
type="text"
placeholder="搜索店铺名"
aria-label="候选店铺关键词"
@keyup.enter="search"
/>
<button type="button" :disabled="searching" @click="search">{{ searching ? '搜索中...' : '搜索' }}</button>
</div>
<ul class="shop-candidate-list">
<li v-if="searching" class="shop-list-tip">搜索中...</li>
<li v-else-if="!candidates.length && searched" class="shop-list-tip">没有可添加的候选店铺</li>
<li
v-for="name in candidates"
:key="name"
class="shop-candidate-row"
:class="{ active: pending.includes(name) }"
:title="name"
@click="toggleCandidate(name)"
>
<span class="shop-check" aria-hidden="true"></span>
<span class="shop-name">{{ name }}</span>
<span v-if="pending.includes(name)" class="shop-picked-tag">已选</span>
</li>
</ul>
<!-- 手输自定义项+待添加清单(chips 可移除)。 -->
<div class="shop-custom">
<input
v-model="customName"
type="text"
placeholder="手动输入店铺名(自定义)"
aria-label="自定义店铺名"
@keyup.enter="addCustom"
/>
<button type="button" :disabled="!customName.trim() || pending.length >= MAX_ADD_SHOPS" @click="addCustom">加入</button>
</div>
<div v-if="pending.length" class="shop-pending">
<span v-for="name in pending" :key="name" class="shop-chip">
{{ name }}
<button type="button" :aria-label="`移除待添加 ${name}`" @click="removePending(name)">×</button>
</span>
</div>
<div class="modal-foot">
<button class="btn btn-secondary" type="button" @click="emit('close')">取消</button>
<button class="btn" type="button" :disabled="!canSubmit" @click="submit">
{{ submitting ? '提交中...' : `添加(${pending.length})` }}
</button>
</div>
</div>
</div>
</template>
<style scoped>
.modal-mask {
position: fixed;
inset: 0;
z-index: 2800;
display: flex;
align-items: center;
justify-content: center;
padding: 40px 20px;
background: rgba(45, 66, 86, 0.36);
backdrop-filter: blur(6px);
}
.shop-picker-modal {
display: flex;
flex-direction: column;
width: min(460px, 100%);
max-height: 80vh;
padding: 18px 20px 20px;
border: 1px solid #c7d7e5;
border-radius: 14px;
background: #ffffff;
box-shadow: 0 22px 60px rgba(39, 67, 94, 0.2);
}
.modal-head {
display: flex;
align-items: center;
justify-content: space-between;
}
.modal-head h3 {
margin: 0;
font-size: 15px;
font-weight: 650;
color: #24384d;
}
.modal-sub {
margin-left: 6px;
color: #5b6f83;
font-size: 13px;
font-weight: 500;
}
.modal-close {
width: 30px;
height: 30px;
border: 1px solid transparent;
border-radius: 9px;
background: none;
color: #5b6f83;
font-size: 20px;
line-height: 1;
cursor: pointer;
}
.modal-close:hover {
border-color: #cbd9e6;
background: #eef4fa;
color: #24384d;
}
.modal-tip {
margin: 8px 0 10px;
color: #8293a5;
font-size: 12.5px;
line-height: 1.5;
}
.group-error {
margin: 0 0 8px;
padding: 10px 12px;
border: 1px solid #f0c9c2;
border-radius: 10px;
background: #fdf1ef;
color: #a04432;
font-size: 13px;
}
.shop-search {
display: flex;
gap: 8px;
margin-bottom: 10px;
}
.shop-search input {
flex: 1;
min-width: 0;
min-height: 36px;
padding: 6px 10px;
border: 1px solid #cbd9e6;
border-radius: 8px;
font-size: 13px;
font-family: inherit;
outline: none;
}
.shop-search input:focus {
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
}
.shop-search button {
padding: 6px 14px;
border: 1px solid #c7d7e5;
border-radius: 8px;
background: #ffffff;
color: #5b6f83;
font-size: 13px;
font-family: inherit;
cursor: pointer;
}
.shop-search button:disabled {
cursor: not-allowed;
opacity: 0.6;
}
.shop-candidate-list {
flex: 1;
min-height: 0;
overflow-y: auto;
margin: 0 0 10px;
padding: 0;
list-style: none;
border: 1px solid #e7eef5;
border-radius: 10px;
}
.shop-candidate-row {
display: flex;
align-items: center;
gap: 10px;
padding: 9px 10px;
border-bottom: 1px solid #eef3f8;
font-size: 13px;
cursor: pointer;
}
.shop-candidate-row:last-child {
border-bottom: none;
}
.shop-candidate-row:hover {
background: #f1f7fb;
}
.shop-candidate-row.active {
background: #e8f1fa;
box-shadow: inset 3px 0 0 #4f78a5;
}
.shop-check {
flex: none;
width: 14px;
height: 14px;
border: 1.6px solid #9fb7cd;
border-radius: 4px;
background: #ffffff;
}
.shop-candidate-row.active .shop-check {
border-color: #4f78a5;
background: linear-gradient(135deg, #5f85ad, #4f78a5);
box-shadow: inset 0 0 0 2.4px #ffffff;
}
.shop-name {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: #24384d;
}
.shop-picked-tag {
flex: none;
padding: 1px 7px;
border-radius: 9px;
background: #d9ecff;
color: #2f5d8b;
font-size: 12px;
}
.shop-list-tip {
padding: 22px 12px;
color: #8293a5;
font-size: 12.5px;
text-align: center;
}
.shop-custom {
display: flex;
gap: 8px;
}
.shop-custom input {
flex: 1;
min-width: 0;
min-height: 36px;
padding: 6px 10px;
border: 1px solid #cbd9e6;
border-radius: 8px;
font-size: 13px;
font-family: inherit;
outline: none;
}
.shop-custom input:focus {
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
}
.shop-custom button {
padding: 6px 14px;
border: 1px solid #c7d7e5;
border-radius: 8px;
background: #ffffff;
color: #5b6f83;
font-size: 13px;
font-family: inherit;
cursor: pointer;
}
.shop-custom button:disabled {
cursor: not-allowed;
opacity: 0.55;
}
.shop-pending {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-top: 10px;
}
.shop-chip {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 3px 6px 3px 10px;
border-radius: 999px;
background: #e8f1f9;
color: #3d5a77;
font-size: 12.5px;
}
.shop-chip button {
width: 18px;
height: 18px;
padding: 0;
border: none;
border-radius: 50%;
background: #c9dcea;
color: #3d5a77;
font-size: 12px;
line-height: 1;
cursor: pointer;
}
.shop-chip button:hover {
background: #b3cde4;
}
.modal-foot {
display: flex;
justify-content: flex-end;
gap: 10px;
margin-top: 14px;
}
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
min-height: 38px;
padding: 7px 16px;
border: 1px solid #4f78a5;
border-radius: 9px;
background: linear-gradient(135deg, #5f85ad, #4f78a5);
color: #ffffff;
font-family: inherit;
font-size: 13px;
cursor: pointer;
}
.btn:disabled {
cursor: not-allowed;
opacity: 0.6;
}
.btn-secondary {
background: #ffffff;
color: #5b6f83;
border-color: #c7d7e5;
}
.btn-secondary:hover:not(:disabled) {
color: #2f5d8b;
border-color: #95b1cb;
background: #edf5fb;
}
</style>