收口(时间控件): 后管 8 对起止加 min/max 禁选 + 倒挂交换,并落全项目尺子
指令是"项目所有的前端时间控件 开始日期不能晚于结束日期"。普查(ops 仓 scripts/_census_time_controls.py)数出 55 个控件实例、21 个成对区间,裸奔的是 后管 8 对与麦象控制台 2 对:起止能选到倒挂,查询恒定返回空表且页面没有任何提示。 - utils/datetime.ts 新增 orderedPair;8 页两头各绑 :max/:min,并在 @change 把 倒挂的两端交换回状态——min/max 只灰掉日历面板里的非法日,手输、粘贴仍能越界。 - tests/date-range-order.test.ts(10 例):分母硬钉 19/2/30/4 实例与 8/0/11/2 对, 含真文件反例自证(裸对、只一头、只有 min/max、换成没登记的写法都要露出来); 同时钉住财务系统与麦象的分母,那两面回归也会在这支判红。 - tests/mount/date-range-order.mount.test.ts(3 例):真组件填倒挂值 → 两头落回 有序,且发出去的 startDate/endDate 同一条。 - 摘掉 DedupeRegistryPage 导出与 DuplicateCheckPage 查询里的两条 "开始日期不能晚于结束日期"拦截(交换接管后够不着,属死分支), task-254 那条"导出需做日期区间校验"的钉子改指 min/max + clampDatePair。 验证:npm test 1792 passed / 0 failed、vitest mount 10 passed、vue-tsc rc=0。
This commit is contained in:
@@ -12,6 +12,7 @@ import { fetchDuplicateConsole, fetchDuplicateLedger, requestDuplicateExportBlob
|
||||
import { aggregateDrawerRows, drawerSummaryOf, dupWithinGroup, indexShopGroups, type DrawerAggRow, type DrawerSummary, type ShopGroups } from './duplicate-console-logic.ts'
|
||||
import type { DuplicateConsole, LedgerRow } from './duplicate-console-model.ts'
|
||||
import { ASIN_COUNTRY_CODES, asinCountryLabel } from '../asin/asin-country.ts'
|
||||
import { orderedPair } from '@/utils/datetime'
|
||||
|
||||
type Tab = 'dup' | 'ledger'
|
||||
type Scope = 'global' | 'group'
|
||||
@@ -22,6 +23,13 @@ const loadError = ref('')
|
||||
const reanalyzing = ref(false)
|
||||
|
||||
const filter = reactive({ asin: '', shop: '', group: '', country: '', dateFrom: '', dateTo: '' })
|
||||
/** min/max 挡不住手输,落值后把倒挂的起止交换回来。 */
|
||||
function clampDatePair(): void {
|
||||
const [s, e] = orderedPair(filter.dateFrom, filter.dateTo)
|
||||
filter.dateFrom = s
|
||||
filter.dateTo = e
|
||||
}
|
||||
|
||||
|
||||
/** 角色范围:超管可看全部分组店铺并可跨分组筛选;管理员数据已由后端裁剪到自己分组,无需分组筛选。 */
|
||||
const session = useAdminSessionStore()
|
||||
@@ -248,10 +256,6 @@ async function loadLedger(page: number, resetSort = false) {
|
||||
}
|
||||
|
||||
function applyQuery() {
|
||||
if (filter.dateFrom && filter.dateTo && filter.dateFrom > filter.dateTo) {
|
||||
toast('开始日期不能晚于结束日期')
|
||||
return
|
||||
}
|
||||
loadConsole()
|
||||
if (activeTab.value === 'ledger') loadLedger(1)
|
||||
}
|
||||
@@ -462,11 +466,11 @@ onMounted(() => {
|
||||
</div>
|
||||
<div class="f-group">
|
||||
<label>上架时间开始</label>
|
||||
<input type="date" v-model="filter.dateFrom" />
|
||||
<input type="date" v-model="filter.dateFrom" :max="filter.dateTo" @change="clampDatePair" />
|
||||
</div>
|
||||
<div class="f-group">
|
||||
<label>上架时间结束</label>
|
||||
<input type="date" v-model="filter.dateTo" />
|
||||
<input type="date" v-model="filter.dateTo" :min="filter.dateFrom" @change="clampDatePair" />
|
||||
</div>
|
||||
<div class="f-group">
|
||||
<label> </label>
|
||||
|
||||
Reference in New Issue
Block a user