feat(公司tab): 接线 生成记录——company_id 走 DataReadScope,空成员集一律空页
「tab 画出来了、请求真带了 company_id、后端读都不读」是撒谎窗口,比不接更坏: 页面标题写某公司、数据仍是全量。所以后半页必须同时落地读侧与前端。 - controller 收显式 company_id,菜单闸门仍在算范围之前;范围只在 DataReadScope 一处出口(不再有第二个 if)。DELETE /history 与 clearAllHistory 一字未动: 写操作不吃 company_id。 - service 的总数与行集共用同一个 filterOf,"同范围"由结构保证;空成员集在 分页归一之后早退,绝不把 [] 交给 in()(渲染成 IN () 就是 500)。 - 前端从原始 params 读 companyId——normalizeHistoryParams 是白名单构造,从 normalized 读会静默拿到 undefined,编译绿、请求里没有参数。 验证:ImageHistoryServiceTest 7/0,后端全量 3663 例 0 红;G1 缺口清单 7 页 → 6 页(admin_history 消失);前端 1726/1725/1(那条红是刻意留的接线缺口尺子)、 vue-tsc rc=0。变异 M-A(删 filter.in)与 M-B(早退改永假)各杀 2 支。
This commit is contained in:
@@ -2,15 +2,17 @@
|
||||
/** 生成记录页 · 像素复刻旧版 admin.html panel-history(自绘:form-box 筛选 + panel-box 表格 + 旧式分页 + thumb 缩略图)。
|
||||
* script 逻辑沿用现有 Vue 实现(查询/翻页/跳页/点击缩略图放大预览)。 */
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { fetchHistoryList, fetchHistoryUserOptions } from './history-api.ts'
|
||||
import type { HistoryUserOption } from './history-user-option.ts'
|
||||
import type { HistoryRecordItem } from './history-dto.ts'
|
||||
import { historyEmptyText, historyErrorText } from './history-feedback.ts'
|
||||
import { historyPanelTypeLabel } from './history-type.ts'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
|
||||
const companyTab = useCompanyTabStore()
|
||||
const loading = ref(false)
|
||||
const userLoading = ref(false)
|
||||
const rows = ref<HistoryRecordItem[]>([])
|
||||
@@ -62,6 +64,7 @@ async function load() {
|
||||
userId: filter.userId ? Number(filter.userId) : undefined,
|
||||
timeStart: toApiTime(filter.timeStart),
|
||||
timeEnd: toApiTime(filter.timeEnd),
|
||||
companyId: companyTab.requestCompanyId,
|
||||
})
|
||||
rows.value = result.items
|
||||
total.value = result.total
|
||||
@@ -73,6 +76,9 @@ async function load() {
|
||||
}
|
||||
}
|
||||
|
||||
// 切公司 = 重新取数。不重取的页 = tab 在那页上是假的(G1 的 pageFiles 断言盯着这条)。
|
||||
watch(() => companyTab.activeId, () => void load())
|
||||
|
||||
async function loadUserOptions() {
|
||||
userLoading.value = true
|
||||
try {
|
||||
|
||||
@@ -8,7 +8,12 @@ export const HISTORY_ENDPOINT = '/api/admin/history'
|
||||
|
||||
export async function fetchHistoryList(params: Partial<HistoryListParams> = {}): Promise<HistoryPageResult> {
|
||||
const normalized = normalizeHistoryParams(params)
|
||||
const { data } = await http.get<unknown>(HISTORY_ENDPOINT, { params: toHistoryListQuery(normalized) })
|
||||
// 公司 tab 的值落在 builder 之后、发请求之前的唯一一处:normalizeHistoryParams 是白名单构造
|
||||
// (只点名 page/pageSize/userId/timeStart/timeEnd),所以这里必须从原始 params 读 companyId,
|
||||
// 从 normalized 读会拿到 undefined —— TS 绿、请求里没参数、页面永远看全量。
|
||||
const query = toHistoryListQuery(normalized)
|
||||
if (params.companyId != null) query.company_id = params.companyId
|
||||
const { data } = await http.get<unknown>(HISTORY_ENDPOINT, { params: query })
|
||||
return parseHistoryPage(data)
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ export interface HistoryListParams {
|
||||
userId?: number | null
|
||||
timeStart?: string
|
||||
timeEnd?: string
|
||||
/** 公司 tab 的当前值;页面传入,不参与 normalizeHistoryParams 的归一(它是白名单构造)。 */
|
||||
companyId?: number | null
|
||||
}
|
||||
|
||||
export interface HistoryListQuery {
|
||||
@@ -41,6 +43,7 @@ export interface HistoryListQuery {
|
||||
user_id?: number
|
||||
time_start?: string
|
||||
time_end?: string
|
||||
company_id?: number
|
||||
}
|
||||
|
||||
function finiteInt(value: unknown): number | null {
|
||||
|
||||
Reference in New Issue
Block a user