|
|
@@ -168,7 +168,7 @@
|
|
|
<a-input-number
|
|
|
v-model:value="form.sweepProcessCount"
|
|
|
:min="1"
|
|
|
- :max="32"
|
|
|
+ :max="configStore.config.buff_sweep_max_worker_count ?? 32"
|
|
|
:precision="0"
|
|
|
placeholder="并行路数"
|
|
|
class="input-narrow"
|
|
|
@@ -285,6 +285,18 @@
|
|
|
<div class="section-header section-header-with-action">
|
|
|
<span class="section-icon">📋</span>
|
|
|
<span class="section-title">选品数据</span>
|
|
|
+ <div class="selection-search-bar">
|
|
|
+ <a-input
|
|
|
+ v-model:value="selectionSearchKeyword"
|
|
|
+ placeholder="按饰品ID或名称搜索"
|
|
|
+ class="selection-search-input"
|
|
|
+ allow-clear
|
|
|
+ @pressEnter="onSelectionSearch"
|
|
|
+ />
|
|
|
+ <span v-if="selectionSearchKeyword && filteredSelectionList.length !== selectionList.length" class="selection-search-hint">
|
|
|
+ 匹配 {{ filteredSelectionList.length }} / {{ selectionList.length }}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
<div class="section-actions">
|
|
|
<a-button
|
|
|
type="link"
|
|
|
@@ -312,8 +324,8 @@
|
|
|
<div class="section-body table-wrap">
|
|
|
<a-table
|
|
|
:columns="columns"
|
|
|
- :data-source="selectionList"
|
|
|
- :pagination="{ ...tablePagination, total: selectionList.length }"
|
|
|
+ :data-source="filteredSelectionList"
|
|
|
+ :pagination="{ ...tablePagination, total: filteredSelectionList.length }"
|
|
|
:loading="tableLoading"
|
|
|
:row-key="rowKey"
|
|
|
:row-selection="{ selectedRowKeys: selectionSelectedRowKeys, onChange: onSelectionListSelectionChange }"
|
|
|
@@ -360,8 +372,10 @@
|
|
|
<!-- 第五部分:扫货成功数据展示 -->
|
|
|
<div class="section table-section">
|
|
|
<div class="section-header section-header-with-action">
|
|
|
- <span class="section-icon">🧾</span>
|
|
|
- <span class="section-title">扫货成功数据</span>
|
|
|
+ <div class="section-header-left">
|
|
|
+ <span class="section-icon">🧾</span>
|
|
|
+ <span class="section-title">扫货成功数据</span>
|
|
|
+ </div>
|
|
|
<div class="section-actions">
|
|
|
<a-button type="link" size="small" class="btn-log" @click="openSweepLogModal">
|
|
|
扫货日志查看
|
|
|
@@ -419,17 +433,21 @@
|
|
|
<!-- 第六部分:已绑定 Steam 账号 -->
|
|
|
<div class="section table-section">
|
|
|
<div class="section-header section-header-with-action">
|
|
|
- <span class="section-icon">🎮</span>
|
|
|
- <span class="section-title">已绑定 Steam 账号</span>
|
|
|
- <a-button
|
|
|
- type="link"
|
|
|
- size="small"
|
|
|
- :loading="boundSteamRefreshingAll"
|
|
|
- :disabled="boundSteamLoading || !boundSteamAccounts.length || boundSteamRefreshingAll"
|
|
|
- @click="handleRefreshAllBoundSteamBalances"
|
|
|
- >
|
|
|
- 立即刷新全部余额
|
|
|
- </a-button>
|
|
|
+ <div class="section-header-left">
|
|
|
+ <span class="section-icon">🎮</span>
|
|
|
+ <span class="section-title">已绑定 Steam 账号</span>
|
|
|
+ </div>
|
|
|
+ <div class="section-actions">
|
|
|
+ <a-button
|
|
|
+ type="link"
|
|
|
+ size="small"
|
|
|
+ :loading="boundSteamRefreshingAll"
|
|
|
+ :disabled="boundSteamLoading || !boundSteamAccounts.length || boundSteamRefreshingAll"
|
|
|
+ @click="handleRefreshAllBoundSteamBalances"
|
|
|
+ >
|
|
|
+ 立即刷新全部余额
|
|
|
+ </a-button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<div class="section-body table-wrap">
|
|
|
<a-table
|
|
|
@@ -660,12 +678,14 @@ import { invoke } from '@tauri-apps/api/tauri'
|
|
|
import { secureApiClient } from '../utils/secureApiClient'
|
|
|
import { useAuthStore } from '../stores/authStore'
|
|
|
import { useBuffSweepStore } from '../stores/buffSweepStore'
|
|
|
+import { useConfigStore } from '../stores/configStore'
|
|
|
import { formatDate } from '../utils/formatDate'
|
|
|
|
|
|
const STORAGE_KEY = 'buff_selection_conditions'
|
|
|
const DEBOUNCE_SAVE_MS = 600
|
|
|
const authStore = useAuthStore()
|
|
|
const buffSweepStore = useBuffSweepStore()
|
|
|
+const configStore = useConfigStore()
|
|
|
const emit = defineEmits<{
|
|
|
(
|
|
|
e: 'status-change',
|
|
|
@@ -917,6 +937,22 @@ const conditionsSummary = computed(() => {
|
|
|
const running = computed(() => buffSweepStore.selectionRunning)
|
|
|
const tableLoading = ref(false)
|
|
|
const selectionList = ref<any[]>([])
|
|
|
+const selectionSearchKeyword = ref('')
|
|
|
+const filteredSelectionList = computed(() => {
|
|
|
+ if (!selectionSearchKeyword.value.trim()) {
|
|
|
+ return selectionList.value
|
|
|
+ }
|
|
|
+ const keyword = selectionSearchKeyword.value.trim().toLowerCase()
|
|
|
+ return selectionList.value.filter((item) => {
|
|
|
+ const idMatch = String(item.goods_id || item.id || '').toLowerCase().includes(keyword)
|
|
|
+ const nameMatch = (item.goods_name || item.name || '').toLowerCase().includes(keyword)
|
|
|
+ return idMatch || nameMatch
|
|
|
+ })
|
|
|
+})
|
|
|
+const onSelectionSearch = () => {
|
|
|
+ // 搜索时回到第一页
|
|
|
+ tablePagination.current = 1
|
|
|
+}
|
|
|
const selectionSelectedRowKeys = ref<(string | number)[]>([])
|
|
|
const selectionDeleting = ref(false)
|
|
|
const batchImportLoading = ref(false)
|
|
|
@@ -964,6 +1000,8 @@ function notifyBuffStatusChange() {
|
|
|
const selectionListPollTimer = ref<ReturnType<typeof setInterval> | null>(null)
|
|
|
const sweepPollTimer = ref<ReturnType<typeof setInterval> | null>(null)
|
|
|
const sweepPollConsecutiveErrors = ref(0) // 扫货轮询连续错误计数
|
|
|
+// 扫货成功列表定时刷新:每分钟刷新一次
|
|
|
+const sweepResultRefreshTimer = ref<ReturnType<typeof setInterval> | null>(null)
|
|
|
const autoSelectionTimer = ref<ReturnType<typeof setInterval> | null>(null)
|
|
|
/**
|
|
|
* 允许自动扫货的选品请求单白名单:
|
|
|
@@ -1313,7 +1351,8 @@ function applyConfigToForm(data: Record<string, any>) {
|
|
|
if (data.sweepAssistantLevel) form.sweepAssistantLevel = data.sweepAssistantLevel
|
|
|
if (data.sweepProcessCount != null && Number.isFinite(Number(data.sweepProcessCount))) {
|
|
|
const n = Math.floor(Number(data.sweepProcessCount))
|
|
|
- form.sweepProcessCount = n >= 1 ? Math.min(32, n) : 3
|
|
|
+ const maxWorkerCount = configStore.config.buff_sweep_max_worker_count ?? 32
|
|
|
+ form.sweepProcessCount = n >= 1 ? Math.min(maxWorkerCount, n) : 3
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1407,6 +1446,17 @@ async function saveConditions() {
|
|
|
message.warning('Steam 卡价比例不能小于 4,请重新填写')
|
|
|
return
|
|
|
}
|
|
|
+ // 验证系统配置限制
|
|
|
+ const maxWorkerCount = configStore.config.buff_sweep_max_worker_count ?? 32
|
|
|
+ const minSteamCardRatio = configStore.config.buff_steam_card_ratio_min ?? 4
|
|
|
+ if (form.sweepProcessCount > maxWorkerCount) {
|
|
|
+ message.error(`保存失败:扫货线程数不能超过系统配置的最大值 ${maxWorkerCount}`)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (form.steamCardRatio < minSteamCardRatio) {
|
|
|
+ message.error(`保存失败:Steam卡价比例不能小于系统配置的最小值 ${minSteamCardRatio}`)
|
|
|
+ return
|
|
|
+ }
|
|
|
await doSaveConditions(false)
|
|
|
}
|
|
|
|
|
|
@@ -2318,6 +2368,21 @@ function stopSweepPoll() {
|
|
|
sweepPollConsecutiveErrors.value = 0
|
|
|
}
|
|
|
|
|
|
+// 扫货成功列表定时刷新:每分钟刷新一次
|
|
|
+function startSweepResultRefreshTimer() {
|
|
|
+ if (sweepResultRefreshTimer.value) return
|
|
|
+ sweepResultRefreshTimer.value = setInterval(() => {
|
|
|
+ fetchSweepResult(false)
|
|
|
+ }, 60000) // 60秒 = 1分钟
|
|
|
+}
|
|
|
+
|
|
|
+function stopSweepResultRefreshTimer() {
|
|
|
+ if (sweepResultRefreshTimer.value) {
|
|
|
+ clearInterval(sweepResultRefreshTimer.value)
|
|
|
+ sweepResultRefreshTimer.value = null
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const SWEEP_POLL_MAX_CONSECUTIVE_ERRORS = 10 // 连续 10 次错误后停止轮询(约 30 秒)
|
|
|
|
|
|
/**
|
|
|
@@ -2519,6 +2584,25 @@ async function handleStart(source: 'manual' | 'auto' = 'manual') {
|
|
|
if (source === 'manual') message.warning('请先填写利润率')
|
|
|
return
|
|
|
}
|
|
|
+ // 验证系统配置限制
|
|
|
+ const maxWorkerCount = configStore.config.buff_sweep_max_worker_count ?? 32
|
|
|
+ const minSteamCardRatio = configStore.config.buff_steam_card_ratio_min ?? 4
|
|
|
+ if (form.sweepProcessCount > maxWorkerCount) {
|
|
|
+ if (source === 'manual') {
|
|
|
+ message.error(`选品失败:扫货线程数不能超过系统配置的最大值 ${maxWorkerCount}`)
|
|
|
+ } else {
|
|
|
+ message.error(`自动选品失败:扫货线程数不能超过系统配置的最大值 ${maxWorkerCount}`)
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (form.steamCardRatio < minSteamCardRatio) {
|
|
|
+ if (source === 'manual') {
|
|
|
+ message.error(`选品失败:Steam卡价比例不能小于系统配置的最小值 ${minSteamCardRatio}`)
|
|
|
+ } else {
|
|
|
+ message.error(`自动选品失败:Steam卡价比例不能小于系统配置的最小值 ${minSteamCardRatio}`)
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
const sessionId = authStore.sessionId
|
|
|
const machineCode = authStore.machineCode
|
|
|
if (!sessionId || !machineCode) {
|
|
|
@@ -2738,6 +2822,23 @@ async function handleStartSweep(isAuto: boolean, sourceSelectionRequestId?: numb
|
|
|
if (!isAuto) message.warning('暂无可扫货的选品数据')
|
|
|
return
|
|
|
}
|
|
|
+ // 验证系统配置限制
|
|
|
+ const maxWorkerCount = configStore.config.buff_sweep_max_worker_count ?? 32
|
|
|
+ const minSteamCardRatio = configStore.config.buff_steam_card_ratio_min ?? 4
|
|
|
+ if (form.sweepProcessCount > maxWorkerCount) {
|
|
|
+ if (!isAuto) {
|
|
|
+ message.error(`扫货启动失败:扫货线程数不能超过系统配置的最大值 ${maxWorkerCount}`)
|
|
|
+ }
|
|
|
+ buffSweepStore.sweepRunning = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (form.steamCardRatio != null && form.steamCardRatio < minSteamCardRatio) {
|
|
|
+ if (!isAuto) {
|
|
|
+ message.error(`扫货启动失败:Steam卡价比例不能小于系统配置的最小值 ${minSteamCardRatio}`)
|
|
|
+ }
|
|
|
+ buffSweepStore.sweepRunning = false
|
|
|
+ return
|
|
|
+ }
|
|
|
await prepareBuffEnvironmentBeforeStart('sweep', { manualHint: !isAuto })
|
|
|
if (isAuto) {
|
|
|
const requestId = sourceSelectionRequestId ?? null
|
|
|
@@ -2784,7 +2885,7 @@ async function handleStartSweep(isAuto: boolean, sourceSelectionRequestId?: numb
|
|
|
if (sweepRid != null && selRid != null) {
|
|
|
const wc =
|
|
|
form.sweepProcessCount != null && Number.isFinite(Number(form.sweepProcessCount))
|
|
|
- ? Math.max(1, Math.min(32, Math.floor(Number(form.sweepProcessCount))))
|
|
|
+ ? Math.max(1, Math.min(maxWorkerCount, Math.floor(Number(form.sweepProcessCount))))
|
|
|
: 3
|
|
|
const spawned = await secureApiClient.spawnBuffSweepLocalRunner(
|
|
|
sessionId,
|
|
|
@@ -3064,6 +3165,7 @@ onMounted(async () => {
|
|
|
initialLoadDone.value = true
|
|
|
startAutoSelectionScheduler()
|
|
|
scheduleDeferredBoundSteamLoad()
|
|
|
+ startSweepResultRefreshTimer()
|
|
|
})
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
@@ -3073,6 +3175,7 @@ onUnmounted(() => {
|
|
|
stopSelectionLogPoll()
|
|
|
stopSweepPoll()
|
|
|
stopSweepLogPoll()
|
|
|
+ stopSweepResultRefreshTimer()
|
|
|
stopBoundSteamBalancePoll()
|
|
|
if (deferredBoundSteamLoadTimer.value) {
|
|
|
clearTimeout(deferredBoundSteamLoadTimer.value)
|
|
|
@@ -3291,12 +3394,44 @@ onUnmounted(() => {
|
|
|
|
|
|
.section-header-with-action {
|
|
|
justify-content: space-between;
|
|
|
+ gap: 12px;
|
|
|
+}
|
|
|
+
|
|
|
+.section-header-left {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 8px;
|
|
|
+}
|
|
|
+
|
|
|
+.selection-search-bar {
|
|
|
+ flex: 1;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 8px;
|
|
|
+ min-width: 0;
|
|
|
+}
|
|
|
+
|
|
|
+.selection-search-input {
|
|
|
+ max-width: 260px;
|
|
|
+ line-height: 1;
|
|
|
+}
|
|
|
+
|
|
|
+.selection-search-input :deep(.ant-input) {
|
|
|
+ height: 30px;
|
|
|
+ line-height: 30px;
|
|
|
+}
|
|
|
+
|
|
|
+.selection-search-hint {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #999;
|
|
|
+ white-space: nowrap;
|
|
|
}
|
|
|
|
|
|
.section-actions {
|
|
|
display: inline-flex;
|
|
|
align-items: center;
|
|
|
gap: 4px;
|
|
|
+ flex-shrink: 0;
|
|
|
}
|
|
|
|
|
|
.section-header-with-action .btn-log {
|