refactor(frontend): 金额正则/分页/抽屉状态/行编辑与下拉收口
- 金额形态正则收进 utils/validate.ts 单点导出(此前四页各写,精度 调整漏改一页即「A 页拦得住 B 页放行后端 400」或历史行无法编辑) - params 版本/历史两抽屉的手写分页五件套换 usePagedList(白得请求 序号防竞态——快速翻页旧响应覆盖新页的手写坑不再复现) - 业务抽屉三份 id 状态收为 drawerRowId computed(单一状态源,消除 「标题 A 业务、留痕表 B 业务」的失同步面) - useEditingRow(三页逐字相同的 computed)与 useDropdownOptions (取数失败不阻断列表的骨架)收口,映射函数由调用方给出 - e2e 冒烟:基础数据 13 步 + 业务全链路 16 步全过 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
1 parent
60f6af6494
commit
0ef3adec21
8 files changed
+117
-98
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import { ref, type Ref } from 'vue'
|
||||
|
||||
import { handledError } from '@/utils/error'
|
||||
|
||||
/**
|
||||
* 下拉选项的加载状态:取数失败不阻断列表使用(下拉为空 + 拦截器提示)。
|
||||
*
|
||||
* 业务/客户/人员等参照下拉在多个页面重复同一「try 取数 → map 成选项 →
|
||||
* 失败吞掉」骨架,映射函数由调用方给出(各页字段不同),骨架收口单点。
|
||||
*/
|
||||
export function useDropdownOptions<T>(fetch: () => Promise<T[]>): {
|
||||
options: Ref<T[]>
|
||||
load: () => Promise<void>
|
||||
} {
|
||||
const options = ref([]) as Ref<T[]>
|
||||
async function load(): Promise<void> {
|
||||
try {
|
||||
options.value = await fetch()
|
||||
} catch (error) {
|
||||
handledError(error) // 下拉为空不阻断列表使用
|
||||
}
|
||||
}
|
||||
return { options, load }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { computed, type Ref } from 'vue'
|
||||
|
||||
/**
|
||||
* 编辑中的行:editingId 非空时从当前页记录里找出行(回显兜底用)。
|
||||
*
|
||||
* 回款/发货/人员三页此前各持一份逐字相同的 computed(行对象上要展示
|
||||
* 「编辑中」的派生信息,如业务编号、停用岗位回显),收口后口径一处维护。
|
||||
*/
|
||||
export function useEditingRow<T extends { id: number }>(
|
||||
records: Ref<T[]>,
|
||||
editingId: Ref<number | null>,
|
||||
) {
|
||||
return computed(() =>
|
||||
editingId.value === null ? null : (records.value.find((r) => r.id === editingId.value) ?? null),
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user