优化:完善分类规则与Excel配置维护并加速查询翻页

This commit is contained in:
2026-10-31 17:50:14 +08:00
parent 9dbe85c65c
commit aa7c320dc6
56 changed files with 1709 additions and 440 deletions
+12 -5
View File
@@ -101,18 +101,18 @@ test('the actual summary click stores release A and filters until a new detail i
function drawerFixture() {
const source=read('QueryPage.tsx');const code=source.slice(source.indexOf('function RecordsDrawer(')).replace(/export \{ fullYearTrend \};/, '');
const requests=[],exports=[];let downloaded=0;
const requests=[],exports=[];let downloaded=0,refreshKey=0;
const props={open:true,row:null,stage:'black',onStage(){},onClose(){},query:freezeSourceRecordsQuery(baseQuery,'release-A','overall',null),onUnauthorized:()=>false};
const renderer=hookRenderer(hooks=>new Function('React','hooks','api',transpile(`
const {useState,useRef,useMemo,useEffect}=hooks;const TABLE_PAGE_SIZE=20,MONTHS=Array.from({length:12},(_,i)=>i+1+'月');
const {useState,useRef,useMemo,useEffect}=hooks;const usePageCache=()=>({refreshKey:api.refreshKey()});const TABLE_PAGE_SIZE=20,MONTHS=Array.from({length:12},(_,i)=>i+1+'月');
const Drawer='Drawer',Segmented='Segmented',Select='Select',Button='Button',Alert='Alert',Spin='Spin',Table='Table',Pagination='Pagination',SearchOutlined='SearchOutlined',DownloadOutlined='DownloadOutlined';
const Input='Input',readableSelectPopup={},Empty=Object.assign(()=>null,{PRESENTED_IMAGE_SIMPLE:'empty'}),App={useApp:()=>({message:{success(){},error(){}}})};
const isSystemVersionField=()=>false,chooseError=e=>e.message,withoutSystemVersionFields=v=>v;
const window={innerWidth:1400,setTimeout:fn=>fn()},document={createElement:()=>({click(){api.downloaded();},remove(){}}),body:{appendChild(){}}};
${code}
return RecordsDrawer;
`))(React,hooks,{records(params,signal){const d=deferred();requests.push({params,signal,...d});return d.promise;},async exportRecords(params,signal){exports.push({params,signal});return {blob:new Blob(['fixture']),filename:'fixture.xlsx'};},downloaded(){downloaded++;}}));
return {requests,exports,props,render:()=>renderer.render(props),unmount:()=>renderer.unmount(),get downloaded(){return downloaded;}};
`))(React,hooks,{refreshKey:()=>refreshKey,records(params,signal){const d=deferred();requests.push({params,signal,...d});return d.promise;},async exportRecords(params,signal){exports.push({params,signal});return {blob:new Blob(['fixture']),filename:'fixture.xlsx'};},downloaded(){downloaded++;}}));
return {requests,exports,props,render:()=>renderer.render(props),unmount:()=>renderer.unmount(),invalidate(){refreshKey++;},get downloaded(){return downloaded;}};
}
test('actual drawer clears prior rows during page load/failure and offers retry on the same frozen release',async()=>{
@@ -136,7 +136,14 @@ test('closing and reopening a different month remounts page/search state and ign
const next=drawerFixture();next.props.query=freezeSourceRecordsQuery({...baseQuery,month:2},'release-A','overall',null);next.render();
assert.equal(next.requests[0].params.page,1);assert.equal(next.requests[0].params.search,undefined);assert.equal(next.requests[0].params.month,2);
assert.equal(find(next.render(),n=>n.type==='Table'),undefined);next.unmount();
assert.match(read('QueryPage.tsx'),/recordsOpen && recordQuerySnapshot && <RecordsDrawer/);
assert.match(read('QueryPage.tsx'),/recordQuerySnapshot && <RecordsDrawer/);
assert.match(read('QueryPage.tsx'),/open=\{recordsOpen\}/);
});
test('reopening the same frozen drawer reuses its page until the workspace revision changes',async()=>{
const ui=drawerFixture();ui.render();ui.requests[0].resolve({rows:[{id:'cached'}],total:1,pageSize:20,page:1});await tick();ui.render();
ui.props.open=false;ui.render();ui.props.open=true;let tree=ui.render();assert.equal(ui.requests.length,1);assert.equal(find(tree,n=>n.type==='Table').props.dataSource[0].id,'cached');
ui.invalidate();tree=ui.render();assert.equal(ui.requests.length,2);assert.equal(find(tree,n=>n.type==='Table'),undefined);ui.unmount();
});
test('export from the actual drawer keeps the clicked release even after current publication changes',async()=>{