From 25b2b5cce1578669a094e8acc641921d49cd21e4 Mon Sep 17 00:00:00 2001
From: chenxt <10125295+chen-xintao97@user.noreply.gitee.com>
Date: Thu, 2 Apr 2026 16:43:18 +0800
Subject: [PATCH] 分页
---
src/components/Common/CommonHooks/useCommonBase.js | 14 ++++++++++++--
src/components/Common/CommonTable/index.js | 33 +++++++++++++++++++++++++++++----
src/components/VlistNew/index.js | 1 +
src/mes/common/commonModelComponent/index.js | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------
src/mes/common/routerComponent/index.js | 2 +-
src/mes/productionExec/productionExecMain/index.js | 2 +-
6 files changed, 106 insertions(+), 42 deletions(-)
diff --git a/src/components/Common/CommonHooks/useCommonBase.js b/src/components/Common/CommonHooks/useCommonBase.js
index 266ecc4..459ee27 100644
--- a/src/components/Common/CommonHooks/useCommonBase.js
+++ b/src/components/Common/CommonHooks/useCommonBase.js
@@ -285,6 +285,7 @@ const useCommonBase = props => {
isWait,
configData,
clearSelectData,
+ isPagination, // mes的通用列表需要真分页,所以增加isPagination参数控制是否分页
} = params;
const {
token,
@@ -294,6 +295,7 @@ const useCommonBase = props => {
formData,
[`${name}DelData`]: tableDelData
} = state;
+
let {
menuChildData,
[`${name}SelectedRowKeys`]: tableSelectedRowKeys,
@@ -323,7 +325,10 @@ const useCommonBase = props => {
}
}
}
-
+ if ( isPagination ) {
+ condition.pageSize = condition.pageSize || 10; /* 前台传入页数或者默认页数 */
+ condition.pageNum = condition.pageNum || 1; /* 前台传入页数或者默认页数 */
+ }
// 凹印人检特殊处理
if (configData?.sGrd === "slaveWyrj2") {
const {
@@ -436,7 +441,12 @@ const useCommonBase = props => {
menuChildData,
pageLoading: false,
iPageSize,
- masterConditionData
+ masterConditionData,
+ mesTotalCount: isPagination ? dataReturn.dataset.totalCount : null,
+ mesPageSize: isPagination ? dataReturn.dataset.pageSize : null,
+ mesPageNum: isPagination ? dataReturn.dataset.currentPageNo : null,
+ isPagination,
+ mesPageChange: false,
};
// 添加动态列数据
diff --git a/src/components/Common/CommonTable/index.js b/src/components/Common/CommonTable/index.js
index 9bec1da..424e125 100644
--- a/src/components/Common/CommonTable/index.js
+++ b/src/components/Common/CommonTable/index.js
@@ -50,7 +50,8 @@ import {
Tooltip,
Row,
Progress,
- Modal
+ Modal,
+ Pagination
} from "antd";
import { DndProvider, DropTarget, DragSource } from "react-dnd";
import {
@@ -3347,6 +3348,9 @@ class CommonTableRc extends React.Component {
components.header = { cell: ResizeableTitle };
}
let bPagination = true; /* 默认表格分页s */
+ let {mesTotalCount , mesPageSize, mesPageNum, isPagination} = this.props.tableProps || {};
+ console.log(this.props.tableProps, 'this.props.tableProps');
+
if (commonUtils.isNotEmptyObject(this.props)) {
bPagination =
commonUtils.isNotEmptyObject(this.props.tableProps) &&
@@ -3560,6 +3564,7 @@ class CommonTableRc extends React.Component {
const { expKeys } = this.state;
const { sModelType } = this.props?.parentProps || {}
/* 返回值 */
+
return {
components,
rowKey: sModelType?.includes('/indexPage/commonList') ? 'sSlaveId' : this.rowKey,
@@ -3573,7 +3578,7 @@ class CommonTableRc extends React.Component {
columns: tableColumn /* 表头 */,
// rowSelection: this.props.rowSelection !== undefined ? this.props.rowSelection : this.getRowSelection(this.props.name, 'slave'), /* 添加的复选框(checkbox)功能 */
rowSelection,
- // pagination: false, /* 不分页 */
+ pagination: false, /* 不分页 */
rowClassName: this.setRowClassName.bind(this, "slave"),
onRow: (record, index) => {
if (this.isDragAndDrop) {
@@ -3670,6 +3675,7 @@ class CommonTableRc extends React.Component {
}
}
: false /* 表格是否分页 */,
+ isPagination: isPagination,
onChange: this.onChange
};
};
@@ -10819,6 +10825,7 @@ class CommonTableRc extends React.Component {
/* 获取table中的props */
const tableProps = this.getTableProps();
+ console.log("🚀 ~ CommonTableRc ~ render ~ tableProps:", tableProps)
let autoHeight = this.props.tableProps.AutoTableHeight;
const realizeHeight =
@@ -11144,6 +11151,15 @@ class CommonTableRc extends React.Component {
this.setState({ affixMenuVisible: false });
}
};
+ let { mesTotalCount , mesPageSize, mesPageNum, isPagination} = this.props.tableProps || {};
+ const handleMesPaginationChange = (page, pageSize) => {
+ this.props.onSaveState({
+ mesPageNum: page,
+ mesPageSize: pageSize,
+ mesPageChange: true
+ });
+ }
+ console.log(tableProps, 'tablePropstableProps');
return (
) : (
-
+
+ {
+ isPagination &&
+ }
+
+
)}
{previewVisible ? (
diff --git a/src/components/VlistNew/index.js b/src/components/VlistNew/index.js
index a04be92..e96b706 100644
--- a/src/components/VlistNew/index.js
+++ b/src/components/VlistNew/index.js
@@ -1051,3 +1051,4 @@ function scrollTo(option) {
exports.VList = VList;
exports.scrollTo = scrollTo;
+exports.vidMap = vidMap;
diff --git a/src/mes/common/commonModelComponent/index.js b/src/mes/common/commonModelComponent/index.js
index a6c927e..f4e04d8 100644
--- a/src/mes/common/commonModelComponent/index.js
+++ b/src/mes/common/commonModelComponent/index.js
@@ -260,9 +260,12 @@ const useCommonModelEvent = props => {
Array.isArray(formData) && formData.length > 0
? (formData[0]?.sName || formData[0]?.sModelType || '')
: '';
+
// 初始化事件
useEffect(
async () => {
+ console.log(props?.mesPageChange, 'props?.mesPageChange');
+
if (commonUtils.isNotEmptyArr(formData)) {
let pageLayout = [];
let addState = {};
@@ -287,7 +290,6 @@ const useCommonModelEvent = props => {
result = await handleGetDataPop(tableList, true, true)
} else if (!commonUtils.isEmptyObject(copyTo) && !refreshCount) {
result = await handleGetData(tableList, true, true);
-
} else if (noGetData) {
result = await handleGetData(
tableList.filter(
@@ -298,7 +300,9 @@ const useCommonModelEvent = props => {
true
);
} else {
- result = await handleGetData(tableList, true, true);
+ if (props?.mesPageChange || props?.mesPageChange === undefined) {
+ result = await handleGetData(tableList, true, true);
+ }
}
if (!currentId) {
addState.bFinish = props.bFinish ? props.bFinish + 1 : 1;
@@ -342,7 +346,8 @@ const useCommonModelEvent = props => {
formData.length,
refreshCount,
noGetData,
- JSON.stringify(sFilterConditions)
+ JSON.stringify(sFilterConditions),
+ props?.mesPageChange === true
]
);
useEffect(() => {
@@ -904,7 +909,14 @@ const useCommonModelEvent = props => {
if (currentIds && tableName !== 'master') {
conditonValues.sParentId = currentIds;
}
+ // 2026 新增如果是indexPage/commonList那么需要真分页
+ const { sName, bPagination = false } = config || {};
+ let isPagination = false
+ if (sName.includes('/indexPage/commonList') && bPagination) {
+ isPagination = true
+ console.log(props, 'isPagination');
+ }
const result =
(await props.onGetDataSet({
name: tableName,
@@ -913,14 +925,16 @@ const useCommonModelEvent = props => {
...masterState,
sId: currentIds,
sSqlCondition: { ...conditonValues, ...sFilterConditions, },
- bFilter
+ bFilter,
+ pageNum: isPagination ? props?.mesPageNum || 1 : undefined,
+ pageSize: isPagination ? props?.mesPageSize || 10 : undefined,
},
sModelTypes: props.parentProps,
- isWait: true
+ isWait: true,
+ isPagination
})) || {};
props.setTempRef(result);
-
if (tableName?.includes("master")) {
const masterData = result[`${tableName}Data`];
result[`${tableName}Data`] = masterData?.[0] || {};
@@ -2547,35 +2561,49 @@ const CommonTableComponent = props => {
// }
props.onTableBtnClick(params);
};
- const tableProps = {
- ...baseProps,
- tableBtnsConfig: btnsConfig,
- // tableBtnsWidth: '100px',
- // tableBtnsConfig: (params) => {
- // console.log('=====params', params);
- // return btnsConfig;
- // },
- onTableBtnClick,
- tableProps: {
- onChange: () => { },
- rowKey: baseProps?.config?.sId === "17091154460006421964039036672000" ? 'sSlaveId' : 'sId'
- // AutoTableHeight: 200
- },
- onViewClick: (tableName, sFieldName, record, index, config) => {
- // 异常事件提报-提报信息-事件类型字段点击事件
- if (tableName === "slave" && sFieldName === "sClassifyName") {
- props.onTableBtnClick({
- name: tableName,
- record,
- config
- });
- }
- },
- onViewChoose: (tableName, sFieldName, record, index, isColor) => {
- handleViewChoose(tableName, sFieldName, record, index, isColor);
+ // const pagination = {
+ // pageSize: commonConfig.pageSize,
+ // ...slavePagination,
+ // size: isSmall ? 'small' : 'large',
+ // pageSizeOptions: commonConfig.pageSizeOptions,
+ // showSizeChanger: !isSmall,
+ // showQuickJumper: !isSmall,
+ // };
+ const { mesTotalCount , mesPageSize, mesPageNum, isPagination } = baseProps?.parentProps || {};
+ const tableProps = {
+ ...baseProps,
+ tableBtnsConfig: btnsConfig,
+ // tableBtnsWidth: '100px',
+ // tableBtnsConfig: (params) => {
+ // console.log('=====params', params);
+ // return btnsConfig;
+ // },
+ onTableBtnClick,
+ tableProps: {
+ onChange: () => { },
+ rowKey: baseProps?.config?.sId === "17091154460006421964039036672000" ? 'sSlaveId' : 'sId',
+ mesTotalCount,
+ mesPageSize,
+ mesPageNum,
+ isPagination,
+ // AutoTableHeight: 200
+ },
+ onViewClick: (tableName, sFieldName, record, index, config) => {
+ // 异常事件提报-提报信息-事件类型字段点击事件
+ if (tableName === "slave" && sFieldName === "sClassifyName") {
+ props.onTableBtnClick({
+ name: tableName,
+ record,
+ config
+ });
+ }
+ },
+ onViewChoose: (tableName, sFieldName, record, index, isColor) => {
+ handleViewChoose(tableName, sFieldName, record, index, isColor);
- }
- };
+ }
+ };
+ console.log("🚀 ~ CommonTableComponent ~ tableProps:", tableProps)
const handleViewChoose = (tableName, sFieldName, record, index, isColor) => {
if (isColor) {
const { sId } = record; /* 控制表主键 */
diff --git a/src/mes/common/routerComponent/index.js b/src/mes/common/routerComponent/index.js
index 11fe4e7..168c473 100644
--- a/src/mes/common/routerComponent/index.js
+++ b/src/mes/common/routerComponent/index.js
@@ -68,7 +68,7 @@ const RouterComponent = props => {
const selectedType = Object.keys(types).find(type =>
sModelType?.includes(type)
);
-
+
if (selectedType) {
return types[selectedType]({ sModelsId: keyId, props });
} else if (sModelsId === "12710101117126502477360") {
diff --git a/src/mes/productionExec/productionExecMain/index.js b/src/mes/productionExec/productionExecMain/index.js
index 2c167be..cb38532 100644
--- a/src/mes/productionExec/productionExecMain/index.js
+++ b/src/mes/productionExec/productionExecMain/index.js
@@ -1080,7 +1080,7 @@ const ProductionExecContent0 = props => {
} = props;
const viewRowOld = {...workOrderInfoData[0], ...changeExecInfo,};
-
+
const newTableProps = {
...tableProps,
data: tableProps.data.map((item, index) => {
--
libgit2 0.22.2