20260914224947

This commit is contained in:
oneao committed 2026-09-14 22:49:48 +08:00
1 parent 63514476d7
commit d26afb5fec
69 files changed
+158 -1008

No files matched your search

@@ -2,7 +2,7 @@ import { ref } from 'vue'
import { loadDataApi } from '@/services/api'
/**
* 文件分类逻辑 —— 加载 bf_files_cateid 扁平表,供 FmsTree 展示(分类为平铺列表,无层级)。
* 文件分类逻辑 —— 加载 bf_files_category 扁平表,供 FmsTree 展示(分类为平铺列表,无层级)。
* 「全部分类」虚拟根由 FmsTree 的 showRoot 注入,本组合式函数只负责取数与选中状态。
*/
export function useFileCategory() {
@@ -16,11 +16,7 @@ export function useFileCategory() {
loading.value = true
error.value = null
try {
const res = await loadDataApi(
'bf_files_cateid',
'b_canuse = 1',
'b_xh ASC, b_id ASC',
)
const res = await loadDataApi('bf_files_category', 'b_canuse = 1', 'b_xh ASC, b_id ASC')
categories.value = res.data || []
} catch (e) {
error.value = e?.message || String(e)
@@ -2,7 +2,7 @@
/**
* 往来单位(合作伙伴)—— 左侧分类树 + 右侧模块列表。
*
* 左树是 b_othercompany_bmfl(b_parent_id 是权威关系,b_depth / b_path 为派生字段),
* 左树是 b_othercompany_category(b_parent_id 是权威关系,b_depth / b_path 为派生字段),
* 右表由 FmsModuleListPage 按模块 v_b_othercompany 的配置驱动。页面负责三件事:
* 选中分类 → 固定查询条件(含全部下级)、b_cate_id 列显示分类名称、分类树的维护
* (新增 / 修改 / 删除 / 刷新 / 拖拽调层级与顺序)。
@@ -30,7 +30,7 @@ import { usePermissionStore } from '@/stores/permissions'
import { buildTree, collectAllKeys, filterTreeByText, findTreeNode, sortTree } from '@/utils/tree'
const MODULE_CODE = 'v_b_othercompany' // 右侧列表模块
const CATEGORY_TABLE = 'b_othercompany_bmfl' // 左侧分类树表
const CATEGORY_TABLE = 'b_othercompany_category' // 左侧分类树表
/** 必须与 FmsTree 的 rootKey 默认值一致 */
const ALL_CATEGORY_KEY = '__fms_tree_root__'
@@ -1,5 +1,5 @@
/**
* 回归用例:往来单位分类树(b_othercompany_bmfl)的新增 / 修改 / 删除 / 拖拽排序。
* 回归用例:往来单位分类树(b_othercompany_category)的新增 / 修改 / 删除 / 拖拽排序。
*
* 1) b_path 为 not null 且无默认值(b_depth / b_xh / b_canuse 才有默认值),新增分类时
* 必须按父级派生 b_depth / b_path 一起写入,否则插入直接失败;
@@ -77,7 +77,7 @@ beforeEach(() => {
Message.warning.mockClear()
modalConfirm.mockReset()
loadDataApi.mockImplementation((view) => {
if (view === 'b_othercompany_bmfl')
if (view === 'b_othercompany_category')
return Promise.resolve({ data: CATEGORIES.map((row) => ({ ...row })) })
return Promise.resolve({ data: [] })
})
@@ -110,7 +110,7 @@ describe('往来单位:新增分类写派生树字段', () => {
await wrapper.vm.onCategorySubmit({ b_id: 'newcat', b_name: '新分类', b_xh: 30 })
await flushPromises()
const request = lastRequestOf('b_othercompany_bmfl')
const request = lastRequestOf('b_othercompany_category')
expect(request.key_field).toBe('b_id')
expect(request.inserts).toHaveLength(1)
expect(request.inserts[0]).toMatchObject({
@@ -131,7 +131,7 @@ describe('往来单位:新增分类写派生树字段', () => {
await wrapper.vm.onCategorySubmit({ b_id: 'child2', b_name: '三级分类', b_xh: 20 })
await flushPromises()
expect(lastRequestOf('b_othercompany_bmfl').inserts[0]).toMatchObject({
expect(lastRequestOf('b_othercompany_category').inserts[0]).toMatchObject({
b_id: 'child2',
b_parent_id: 'root1',
b_depth: 1,
@@ -148,7 +148,7 @@ describe('往来单位:修改分类', () => {
await wrapper.vm.onCategorySubmit({ b_id: 'child1', b_name: '改过的名字', b_xh: 99 })
await flushPromises()
const request = lastRequestOf('b_othercompany_bmfl')
const request = lastRequestOf('b_othercompany_category')
expect(request.inserts).toBeUndefined()
expect(request.updates).toHaveLength(1)
expect(request.updates[0]).toEqual({ b_id: 'child1', b_name: '改过的名字', b_xh: 99 })
@@ -190,7 +190,7 @@ describe('往来单位:删除分类的两条守卫', () => {
await modalConfirm.mock.calls[0][0].onOk()
await flushPromises()
const request = lastRequestOf('b_othercompany_bmfl')
const request = lastRequestOf('b_othercompany_category')
expect(request.deletes).toEqual([{ b_id: 'child1' }])
})
})