From 9cbfaa22c35822e4f2f985907fce5da4c9ef7ac9 Mon Sep 17 00:00:00 2001 From: xusd <330628789@qq.com> Date: Tue, 24 Jun 2025 17:30:07 +0800 Subject: [PATCH] fix:超时办件优化 --- src/views/workEfficiency/index.jsx | 66 +++++++++++++++++++-- src/utils/selectOption.js | 13 ++++ src/views/workEfficiency/component/TimeoutDialog.jsx | 53 ++++++++++++++--- 3 files changed, 114 insertions(+), 18 deletions(-) diff --git a/src/utils/selectOption.js b/src/utils/selectOption.js index 03b2c80..ec0203c 100644 --- a/src/utils/selectOption.js +++ b/src/utils/selectOption.js @@ -787,6 +787,18 @@ }, ]; +// 是否 +const isOrNot = [ + { + value: '1', + label: '是', + }, + { + value: '0', + label: '否', + }, +]; + // VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV 暂时用不到,防止以后会用的,先保留 VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV // 调解类型 @@ -1603,6 +1615,7 @@ resultList, rmtjList, inputWay, + isOrNot, }; export default obj; diff --git a/src/views/workEfficiency/component/TimeoutDialog.jsx b/src/views/workEfficiency/component/TimeoutDialog.jsx index 0d788a0..09f51a7 100644 --- a/src/views/workEfficiency/component/TimeoutDialog.jsx +++ b/src/views/workEfficiency/component/TimeoutDialog.jsx @@ -211,23 +211,56 @@ caseId: '', type: 0, }) + const [isResetting, setIsResetting] = useState(false); // 添加重置标志位 useEffect(() => { - getTableData() + if (!isResetting) { + getTableData() + } }, [searchData]) + + // 监听timeoutKey变化,重置数据 + useEffect(() => { + setIsResetting(true); // 开始重置 + // 重置表格数据 + setTableData([]); + setTotal(0); + // 重置搜索条件 + setSearchData({ + page: 1, + size: 10, + sortType: 2, + sortColmn: 1, + }); + // 重置表单 + form.resetFields(); + // 重置选择状态 + setSelectedRowKeys([]); + setSelectedRows([]); + + // 延迟重置标志位,确保重置完成后再允许API调用 + setTimeout(() => { + setIsResetting(false); + }, 100); + }, [props.timeoutKey]); //获取表格数据 const getTableData = async () => { setLoading(true) - const res = await getTable({ - ...searchData, - queryType: dialogTypeMap[props.timeoutKey], - ...props.search, - }) - if (res.type) { - const { data } = res - setTableData(data?.content) - setTotal(data.totalElements) + try { + const res = await getTable({ + ...searchData, + queryType: dialogTypeMap[props.timeoutKey], + ...props.search, + }) + if (res.type) { + const { data } = res + setTableData(data?.content) + setTotal(data.totalElements) + } + } catch (error) { + console.error('获取表格数据失败:', error) + } finally { setLoading(false) } } diff --git a/src/views/workEfficiency/index.jsx b/src/views/workEfficiency/index.jsx index 4e32ec0..253b429 100644 --- a/src/views/workEfficiency/index.jsx +++ b/src/views/workEfficiency/index.jsx @@ -295,13 +295,38 @@ // 超时办件列表 async function pageQuantity(search, values = {}) { global.setSpinning(true); - const res = await pageQuantityApi({ ...search, ...values }); - global.setSpinning(false); - if (res.type) { - let data = res.data.content || []; - let total = res?.data?.totalElements || 0; - setTableData({ list: data, total }); - setTimeoutSearch(search); + try { + const res = await pageQuantityApi({ ...search, ...values }); + if (res.type) { + let data = res.data.content || []; + let total = res?.data?.totalElements || 0; + setTableData({ + list: data, + total, + page: search.page || 1, + size: search.size || 10 + }); + setTimeoutSearch(search); + } else { + // API调用失败时,确保数据状态正确 + setTableData({ + list: [], + total: 0, + page: search.page || 1, + size: search.size || 10 + }); + } + } catch (error) { + console.error('获取超时办件列表失败:', error); + // 异常时,确保数据状态正确 + setTableData({ + list: [], + total: 0, + page: search.page || 1, + size: search.size || 10 + }); + } finally { + global.setSpinning(false); } } @@ -525,6 +550,13 @@ }, }, { + title: '任务节点', + dataIndex: 'nodeName', + width: 150, + sorter: true, + sortNumber: 1, //设置这个传给后端的 + }, + { title: '处理时限', dataIndex: 'timeLimit', defaultSortOrder: 'descend', @@ -537,6 +569,14 @@ {`超${$$.formatHoursToDaysAndHours(text)}`} </div> ); + }, + }, + { + title: '是否处理', + dataIndex: 'taskStatus', + width: 80, + render: (text) => { + return <span>{text === 1 ? '是' : '否'}</span>; }, }, { @@ -753,6 +793,7 @@ treedata: $$.caseTypeSelect.caseTypeSelect, }, { type: 'Select', name: 'canal', label: '事项来源', placeholder: '请选择', span: 8, selectdata: $$.options.caseCanal }, + { type: 'Select', name: 'taskStatus', label: '任务是否处理', placeholder: '请选择', span: 8, selectdata: $$.options.isOrNot }, ]} handleReset={() => { form.resetFields(); @@ -1112,7 +1153,15 @@ activeKey={radioData.tab2} onChange={(v) => { setRadioData({ ...radioData, tab2: v }); - pageQuantity({ ...timeoutSearch, queryType: v }, search); + // 立即清空数据,确保TableView显示清空状态 + setTableData({ list: [], total: 0, page: 1, size: 10 }); + // 重置分页状态,避免列表内容重复 + const resetSearch = { + ...timeoutSearch, + queryType: v, + page: 1 + }; + pageQuantity(resetSearch, search); listTimeOutTaskGroup({ queryType: v }, search); }} /> @@ -1132,6 +1181,7 @@ <div> {radioData.radio2 === '1' && ( <TableView + key={`timeout-table-${radioData.tab2}`} // 添加key强制重新渲染 columns={fxColumns} dataSource={tableData.list} size="small" -- Gitblit v1.8.0