d1368ed00e
- 管理后台:店铺数据记录改为列表分页展示(去任务号/文件列/累计标题,'最新'改'更新时间'),新增'重复 ASIN' Tab 按跨店聚合展示 ASIN/店铺/分组/国家/日期/价格;修复失败/进行中任务被过滤不显示的问题 - task-169: BrandCheckHttpConfigResolver 从 aiimage.http-client.* 读取品牌检查超时/重试(默认同现状、钳制),附 8 条测试 - task-170: surefire 内存调整为 1536m - dedupe: DedupeRunService 重构(事务边界/进度)、新增 DedupeRunProgressVo、Controller 与结果 VO 调整,PermissionMenuService 相应适配 - brand/dedupe 前端:BrandDedupeTab/BrandPatrolDeleteTab 改造、新增 CountrySelector 组件与 country-options、类型与接口端对齐、测试更新 - 移除无引用文件:backend/static/logo.jpg、prompts/
133 lines
4.6 KiB
Vue
133 lines
4.6 KiB
Vue
<template>
|
||
<section class="country-selector">
|
||
<div v-if="title" class="selector-title">{{ title }}</div>
|
||
<div class="country-pref-checks">
|
||
<label v-for="row in checkboxRows" :key="row.code" class="country-check-row">
|
||
<input
|
||
type="checkbox"
|
||
class="country-check-input"
|
||
:checked="isSelected(row.code)"
|
||
:disabled="disabled || isLastSelected(row.code)"
|
||
@change="onNativeChange(row.code, $event)"
|
||
/>
|
||
<span>{{ row.text }}</span>
|
||
</label>
|
||
</div>
|
||
<div class="country-order-panel">
|
||
<div class="country-order-caption">{{ orderCaption }}</div>
|
||
<div v-if="!modelValue.length" class="country-order-empty">尚未选择国家</div>
|
||
<div v-else class="country-order-list">
|
||
<div
|
||
v-for="(code, index) in modelValue"
|
||
:key="code"
|
||
class="country-drag-row"
|
||
:class="{ dragging: dragIndex === index }"
|
||
:draggable="!disabled"
|
||
@dragstart="dragIndex = index"
|
||
@dragend="dragIndex = null"
|
||
@dragover.prevent
|
||
@drop.prevent="onDrop(index)"
|
||
>
|
||
<span class="drag-handle" title="拖动排序">⋮⋮</span>
|
||
<span>{{ textOf(code) }}</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { computed, ref } from 'vue'
|
||
import { ElMessage } from 'element-plus'
|
||
import { EU_COUNTRY_OPTIONS, type CountryOption } from '@/shared/country-options'
|
||
|
||
const props = withDefaults(
|
||
defineProps<{
|
||
/** 已选国家代码,数组顺序即执行顺序 */
|
||
modelValue: string[]
|
||
options?: readonly CountryOption[]
|
||
title?: string
|
||
orderCaption?: string
|
||
minSelectedWarning?: string
|
||
disabled?: boolean
|
||
}>(),
|
||
{
|
||
options: () => EU_COUNTRY_OPTIONS,
|
||
title: '国家与顺序',
|
||
orderCaption: '已选顺序(拖动可调整执行先后)',
|
||
minSelectedWarning: '至少保留 1 个国家',
|
||
disabled: false,
|
||
},
|
||
)
|
||
|
||
const emit = defineEmits<{ 'update:modelValue': [value: string[]] }>()
|
||
|
||
const dragIndex = ref<number | null>(null)
|
||
|
||
/** 国家代码和展示名相同时(例如直接用中文名作 code)不再重复追加括号 */
|
||
function textOf(code: string) {
|
||
const label = props.options.find((row) => row.code === code)?.label || code
|
||
return label === code ? label : `${label}(${code})`
|
||
}
|
||
|
||
// 已勾选的按当前顺序排在前面,未勾选的按选项原始顺序补在后面
|
||
const checkboxRows = computed(() => {
|
||
const selected = new Set(props.modelValue)
|
||
return [
|
||
...props.modelValue.map((code) => ({ code, text: textOf(code) })),
|
||
...props.options
|
||
.filter((row) => !selected.has(row.code))
|
||
.map((row) => ({ code: row.code, text: textOf(row.code) })),
|
||
]
|
||
})
|
||
|
||
function isSelected(code: string) {
|
||
return props.modelValue.includes(code)
|
||
}
|
||
|
||
function isLastSelected(code: string) {
|
||
return props.modelValue.length === 1 && props.modelValue[0] === code
|
||
}
|
||
|
||
function onNativeChange(code: string, event: Event) {
|
||
const input = event.target as HTMLInputElement
|
||
if (!input.checked && isLastSelected(code)) {
|
||
input.checked = true
|
||
ElMessage.warning(props.minSelectedWarning)
|
||
return
|
||
}
|
||
emit(
|
||
'update:modelValue',
|
||
input.checked
|
||
? [...props.modelValue, code]
|
||
: props.modelValue.filter((item) => item !== code),
|
||
)
|
||
}
|
||
|
||
function onDrop(toIndex: number) {
|
||
const from = dragIndex.value
|
||
dragIndex.value = null
|
||
if (props.disabled || from == null || from === toIndex) return
|
||
const next = [...props.modelValue]
|
||
const [moved] = next.splice(from, 1)
|
||
next.splice(toIndex, 0, moved)
|
||
emit('update:modelValue', next)
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
.country-selector { margin: 16px 0; }
|
||
.selector-title { margin-bottom: 10px; color: #bbb; font-size: 13px; }
|
||
.country-pref-checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
|
||
.country-check-row { display: flex; align-items: center; gap: 7px; min-height: 32px; color: #ccc; font-size: 13px; }
|
||
.country-check-input { width: 15px; height: 15px; }
|
||
.country-check-input:disabled { cursor: not-allowed; }
|
||
.country-order-panel { padding: 10px; border: 1px solid #333; border-radius: 6px; background: #242424; }
|
||
.country-order-caption { margin-bottom: 8px; color: #888; font-size: 12px; }
|
||
.country-order-empty { color: #666; font-size: 12px; }
|
||
.country-order-list { display: flex; flex-direction: column; gap: 6px; }
|
||
.country-drag-row { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 0 9px; border: 1px solid #383838; border-radius: 4px; color: #ccc; font-size: 13px; cursor: grab; }
|
||
.country-drag-row.dragging { opacity: .5; }
|
||
.drag-handle { color: #777; }
|
||
</style>
|