收口(时间控件): 后管 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:
@@ -5,7 +5,7 @@
|
||||
import { computed, nextTick, onMounted, ref, watch } from 'vue'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { formatDateTime, todayDateInput } from '@/utils/datetime'
|
||||
import { formatDateTime, orderedPair, todayDateInput } from '@/utils/datetime'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { fetchHistoryUserOptions } from './history-api.ts'
|
||||
import type { HistoryUserOption } from './history-user-option.ts'
|
||||
@@ -63,6 +63,13 @@ const userOptions = ref<HistoryUserOption[]>([])
|
||||
const usersLoading = ref(false)
|
||||
const startDate = ref(todayDateInput())
|
||||
const endDate = ref(todayDateInput())
|
||||
/** min/max 挡不住手输,落值后把倒挂的起止交换回来。 */
|
||||
function clampDatePair(): void {
|
||||
const [s, e] = orderedPair(startDate.value, endDate.value)
|
||||
startDate.value = s
|
||||
endDate.value = e
|
||||
}
|
||||
|
||||
const retentionDays = ref(7)
|
||||
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||
@@ -294,11 +301,11 @@ onMounted(() => {
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 150px">
|
||||
<label>日志日期(起)</label>
|
||||
<input v-model="startDate" type="date" />
|
||||
<input v-model="startDate" type="date" :max="endDate" @change="clampDatePair" />
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 150px">
|
||||
<label>日志日期(止)</label>
|
||||
<input v-model="endDate" type="date" />
|
||||
<input v-model="endDate" type="date" :min="startDate" @change="clampDatePair" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label> </label>
|
||||
|
||||
Reference in New Issue
Block a user