20260923230500
This commit is contained in:
1 parent
e6935b8fa4
commit
0405cd198a
36 files changed
+3668
-911
No files matched your search
@@ -34,7 +34,18 @@ function makeFields() {
|
||||
]
|
||||
}
|
||||
|
||||
function mountPanel() {
|
||||
/** 空查询配置(schemaVersion 3) */
|
||||
function makeQuerySchema() {
|
||||
return {
|
||||
schemaVersion: 3,
|
||||
views: [],
|
||||
keywordSearch: { fields: [] },
|
||||
quickFilters: [],
|
||||
queryFields: {},
|
||||
}
|
||||
}
|
||||
|
||||
function mountPanel(overrides = {}) {
|
||||
const localFields = makeFields()
|
||||
const wrapper = mount(ModuleFieldsPanel, {
|
||||
props: {
|
||||
@@ -43,10 +54,11 @@ function mountPanel() {
|
||||
// amount 已参与表单与列表;查询未配置
|
||||
editSchema: { schemaVersion: 1, children: [{ field: 'amount', span: 24 }] },
|
||||
viewSchema: { schemaVersion: 1, columns: [{ field: 'amount', width: 110 }] },
|
||||
querySchema: { schemaVersion: 1, quick: [], groups: [] },
|
||||
querySchema: makeQuerySchema(),
|
||||
i18n: [],
|
||||
module: { b_id: 'demo' },
|
||||
loading: false,
|
||||
...overrides,
|
||||
},
|
||||
attachTo: document.body,
|
||||
})
|
||||
@@ -80,10 +92,8 @@ describe('ModuleFieldsPanel 参与勾选', () => {
|
||||
const events = wrapper.emitted('update:querySchema')
|
||||
expect(events?.length).toBeGreaterThan(0)
|
||||
const schema = events.at(-1)[0]
|
||||
const condition = schema.groups[0].conditions[0]
|
||||
expect(condition.field).toBe('amount')
|
||||
expect(condition.operator).toBe('eq')
|
||||
expect(condition.component).toBe('number')
|
||||
// 手工勾查询 → 自定义行(不带 fromList 标记)
|
||||
expect(schema.queryFields.amount).toEqual({ component: 'number', operator: 'eq' })
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
@@ -101,6 +111,48 @@ describe('ModuleFieldsPanel 参与勾选', () => {
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('勾选列表 → 查询配置自动补一行(fromList 标记)', async () => {
|
||||
setActivePinia(createPinia())
|
||||
const { wrapper, localFields } = mountPanel()
|
||||
await settle()
|
||||
const table = wrapper.findComponent({ name: 'FmsTable' })
|
||||
// remark 未参与列表:勾选后查询里应自动出现该字段
|
||||
table.vm.$emit('change', localFields[1], { dataIndex: '__list' })
|
||||
await nextTick()
|
||||
const schema = wrapper.emitted('update:querySchema').at(-1)[0]
|
||||
expect(schema.queryFields.remark).toEqual({
|
||||
component: 'input',
|
||||
operator: 'like',
|
||||
fromList: true,
|
||||
})
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('取消列表 → 只回收自动补的行(fromList),自定义行保留', async () => {
|
||||
setActivePinia(createPinia())
|
||||
const { wrapper, localFields } = mountPanel({
|
||||
viewSchema: {
|
||||
schemaVersion: 1,
|
||||
columns: [{ field: 'amount', width: 110 }, { field: 'remark' }],
|
||||
},
|
||||
querySchema: {
|
||||
...makeQuerySchema(),
|
||||
queryFields: {
|
||||
amount: { component: 'number', operator: 'eq', fromList: true },
|
||||
remark: { component: 'input', operator: 'like' },
|
||||
},
|
||||
},
|
||||
})
|
||||
await settle()
|
||||
const table = wrapper.findComponent({ name: 'FmsTable' })
|
||||
table.vm.$emit('change', localFields[0], { dataIndex: '__list' })
|
||||
await nextTick()
|
||||
const schema = wrapper.emitted('update:querySchema').at(-1)[0]
|
||||
expect('amount' in schema.queryFields).toBe(false)
|
||||
expect(schema.queryFields.remark).toEqual({ component: 'input', operator: 'like' })
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('普通列 change → emit update:modelValue,派生虚拟字段可由 stripInternalKeys 剥离', async () => {
|
||||
setActivePinia(createPinia())
|
||||
const { wrapper, localFields } = mountPanel()
|
||||
|
||||
Reference in new issue
Block a user