Commit 25b2b5cce1578669a094e8acc641921d49cd21e4

Authored by chenxt
1 parent aa13c26a

分页

src/components/Common/CommonHooks/useCommonBase.js
... ... @@ -285,6 +285,7 @@ const useCommonBase = props => {
285 285 isWait,
286 286 configData,
287 287 clearSelectData,
  288 + isPagination, // mes的通用列表需要真分页,所以增加isPagination参数控制是否分页
288 289 } = params;
289 290 const {
290 291 token,
... ... @@ -294,6 +295,7 @@ const useCommonBase = props => {
294 295 formData,
295 296 [`${name}DelData`]: tableDelData
296 297 } = state;
  298 +
297 299 let {
298 300 menuChildData,
299 301 [`${name}SelectedRowKeys`]: tableSelectedRowKeys,
... ... @@ -323,7 +325,10 @@ const useCommonBase = props => {
323 325 }
324 326 }
325 327 }
326   -
  328 + if ( isPagination ) {
  329 + condition.pageSize = condition.pageSize || 10; /* 前台传入页数或者默认页数 */
  330 + condition.pageNum = condition.pageNum || 1; /* 前台传入页数或者默认页数 */
  331 + }
327 332 // 凹印人检特殊处理
328 333 if (configData?.sGrd === "slaveWyrj2") {
329 334 const {
... ... @@ -436,7 +441,12 @@ const useCommonBase = props => {
436 441 menuChildData,
437 442 pageLoading: false,
438 443 iPageSize,
439   - masterConditionData
  444 + masterConditionData,
  445 + mesTotalCount: isPagination ? dataReturn.dataset.totalCount : null,
  446 + mesPageSize: isPagination ? dataReturn.dataset.pageSize : null,
  447 + mesPageNum: isPagination ? dataReturn.dataset.currentPageNo : null,
  448 + isPagination,
  449 + mesPageChange: false,
440 450 };
441 451  
442 452 // 添加动态列数据
... ...
src/components/Common/CommonTable/index.js
... ... @@ -50,7 +50,8 @@ import {
50 50 Tooltip,
51 51 Row,
52 52 Progress,
53   - Modal
  53 + Modal,
  54 + Pagination
54 55 } from "antd";
55 56 import { DndProvider, DropTarget, DragSource } from "react-dnd";
56 57 import {
... ... @@ -3347,6 +3348,9 @@ class CommonTableRc extends React.Component {
3347 3348 components.header = { cell: ResizeableTitle };
3348 3349 }
3349 3350 let bPagination = true; /* 默认表格分页s */
  3351 + let {mesTotalCount , mesPageSize, mesPageNum, isPagination} = this.props.tableProps || {};
  3352 + console.log(this.props.tableProps, 'this.props.tableProps');
  3353 +
3350 3354 if (commonUtils.isNotEmptyObject(this.props)) {
3351 3355 bPagination =
3352 3356 commonUtils.isNotEmptyObject(this.props.tableProps) &&
... ... @@ -3560,6 +3564,7 @@ class CommonTableRc extends React.Component {
3560 3564 const { expKeys } = this.state;
3561 3565 const { sModelType } = this.props?.parentProps || {}
3562 3566 /* 返回值 */
  3567 +
3563 3568 return {
3564 3569 components,
3565 3570 rowKey: sModelType?.includes('/indexPage/commonList') ? 'sSlaveId' : this.rowKey,
... ... @@ -3573,7 +3578,7 @@ class CommonTableRc extends React.Component {
3573 3578 columns: tableColumn /* 表头 */,
3574 3579 // rowSelection: this.props.rowSelection !== undefined ? this.props.rowSelection : this.getRowSelection(this.props.name, 'slave'), /* 添加的复选框(checkbox)功能 */
3575 3580 rowSelection,
3576   - // pagination: false, /* 不分页 */
  3581 + pagination: false, /* 不分页 */
3577 3582 rowClassName: this.setRowClassName.bind(this, "slave"),
3578 3583 onRow: (record, index) => {
3579 3584 if (this.isDragAndDrop) {
... ... @@ -3670,6 +3675,7 @@ class CommonTableRc extends React.Component {
3670 3675 }
3671 3676 }
3672 3677 : false /* 表格是否分页 */,
  3678 + isPagination: isPagination,
3673 3679 onChange: this.onChange
3674 3680 };
3675 3681 };
... ... @@ -10819,6 +10825,7 @@ class CommonTableRc extends React.Component {
10819 10825  
10820 10826 /* 获取table中的props */
10821 10827 const tableProps = this.getTableProps();
  10828 + console.log("🚀 ~ CommonTableRc ~ render ~ tableProps:", tableProps)
10822 10829 let autoHeight = this.props.tableProps.AutoTableHeight;
10823 10830  
10824 10831 const realizeHeight =
... ... @@ -11144,6 +11151,15 @@ class CommonTableRc extends React.Component {
11144 11151 this.setState({ affixMenuVisible: false });
11145 11152 }
11146 11153 };
  11154 + let { mesTotalCount , mesPageSize, mesPageNum, isPagination} = this.props.tableProps || {};
  11155 + const handleMesPaginationChange = (page, pageSize) => {
  11156 + this.props.onSaveState({
  11157 + mesPageNum: page,
  11158 + mesPageSize: pageSize,
  11159 + mesPageChange: true
  11160 + });
  11161 + }
  11162 + console.log(tableProps, 'tablePropstableProps');
11147 11163  
11148 11164 return (
11149 11165 <FormItem
... ... @@ -11242,7 +11258,8 @@ class CommonTableRc extends React.Component {
11242 11258 />
11243 11259 </DndProvider>
11244 11260 ) : (
11245   - <Table
  11261 + <div style={{position: 'relative', width: '100%', height: '100%'}}>
  11262 + <Table
11246 11263 {...tableProps}
11247 11264 addRow={addProps}
11248 11265 delProps={delProps}
... ... @@ -11260,7 +11277,15 @@ class CommonTableRc extends React.Component {
11260 11277 size="small"
11261 11278 sticky={this.sticky}
11262 11279 showSorterTooltip={false}
11263   - />
  11280 + >
  11281 +
  11282 + </Table>
  11283 + <div style={{textAlign: 'center', position: 'absolute', bottom: '50px', left: '50%', transform: 'translateX(-50%)', fontSize:'30px'}} >
  11284 + {
  11285 + isPagination && <Pagination size="default " simple defaultCurrent={mesPageNum} total={mesTotalCount} onChange={handleMesPaginationChange} />
  11286 + }
  11287 + </div>
  11288 + </div>
11264 11289 )}
11265 11290 </div>
11266 11291 {previewVisible ? (
... ...
src/components/VlistNew/index.js
... ... @@ -1051,3 +1051,4 @@ function scrollTo(option) {
1051 1051  
1052 1052 exports.VList = VList;
1053 1053 exports.scrollTo = scrollTo;
  1054 +exports.vidMap = vidMap;
... ...
src/mes/common/commonModelComponent/index.js
... ... @@ -260,9 +260,12 @@ const useCommonModelEvent = props =&gt; {
260 260 Array.isArray(formData) && formData.length > 0
261 261 ? (formData[0]?.sName || formData[0]?.sModelType || '')
262 262 : '';
  263 +
263 264 // 初始化事件
264 265 useEffect(
265 266 async () => {
  267 + console.log(props?.mesPageChange, 'props?.mesPageChange');
  268 +
266 269 if (commonUtils.isNotEmptyArr(formData)) {
267 270 let pageLayout = [];
268 271 let addState = {};
... ... @@ -287,7 +290,6 @@ const useCommonModelEvent = props =&gt; {
287 290 result = await handleGetDataPop(tableList, true, true)
288 291 } else if (!commonUtils.isEmptyObject(copyTo) && !refreshCount) {
289 292 result = await handleGetData(tableList, true, true);
290   -
291 293 } else if (noGetData) {
292 294 result = await handleGetData(
293 295 tableList.filter(
... ... @@ -298,7 +300,9 @@ const useCommonModelEvent = props =&gt; {
298 300 true
299 301 );
300 302 } else {
301   - result = await handleGetData(tableList, true, true);
  303 + if (props?.mesPageChange || props?.mesPageChange === undefined) {
  304 + result = await handleGetData(tableList, true, true);
  305 + }
302 306 }
303 307 if (!currentId) {
304 308 addState.bFinish = props.bFinish ? props.bFinish + 1 : 1;
... ... @@ -342,7 +346,8 @@ const useCommonModelEvent = props =&gt; {
342 346 formData.length,
343 347 refreshCount,
344 348 noGetData,
345   - JSON.stringify(sFilterConditions)
  349 + JSON.stringify(sFilterConditions),
  350 + props?.mesPageChange === true
346 351 ]
347 352 );
348 353 useEffect(() => {
... ... @@ -904,7 +909,14 @@ const useCommonModelEvent = props =&gt; {
904 909 if (currentIds && tableName !== 'master') {
905 910 conditonValues.sParentId = currentIds;
906 911 }
  912 + // 2026 新增如果是indexPage/commonList那么需要真分页
  913 + const { sName, bPagination = false } = config || {};
  914 + let isPagination = false
  915 + if (sName.includes('/indexPage/commonList') && bPagination) {
  916 + isPagination = true
  917 + console.log(props, 'isPagination');
907 918  
  919 + }
908 920 const result =
909 921 (await props.onGetDataSet({
910 922 name: tableName,
... ... @@ -913,14 +925,16 @@ const useCommonModelEvent = props =&gt; {
913 925 ...masterState,
914 926 sId: currentIds,
915 927 sSqlCondition: { ...conditonValues, ...sFilterConditions, },
916   - bFilter
  928 + bFilter,
  929 + pageNum: isPagination ? props?.mesPageNum || 1 : undefined,
  930 + pageSize: isPagination ? props?.mesPageSize || 10 : undefined,
917 931 },
918 932 sModelTypes: props.parentProps,
919   - isWait: true
  933 + isWait: true,
  934 + isPagination
920 935 })) || {};
921 936  
922 937 props.setTempRef(result);
923   -
924 938 if (tableName?.includes("master")) {
925 939 const masterData = result[`${tableName}Data`];
926 940 result[`${tableName}Data`] = masterData?.[0] || {};
... ... @@ -2547,35 +2561,49 @@ const CommonTableComponent = props =&gt; {
2547 2561 // }
2548 2562 props.onTableBtnClick(params);
2549 2563 };
2550   - const tableProps = {
2551   - ...baseProps,
2552   - tableBtnsConfig: btnsConfig,
2553   - // tableBtnsWidth: '100px',
2554   - // tableBtnsConfig: (params) => {
2555   - // console.log('=====params', params);
2556   - // return btnsConfig;
2557   - // },
2558   - onTableBtnClick,
2559   - tableProps: {
2560   - onChange: () => { },
2561   - rowKey: baseProps?.config?.sId === "17091154460006421964039036672000" ? 'sSlaveId' : 'sId'
2562   - // AutoTableHeight: 200
2563   - },
2564   - onViewClick: (tableName, sFieldName, record, index, config) => {
2565   - // 异常事件提报-提报信息-事件类型字段点击事件
2566   - if (tableName === "slave" && sFieldName === "sClassifyName") {
2567   - props.onTableBtnClick({
2568   - name: tableName,
2569   - record,
2570   - config
2571   - });
2572   - }
2573   - },
2574   - onViewChoose: (tableName, sFieldName, record, index, isColor) => {
2575   - handleViewChoose(tableName, sFieldName, record, index, isColor);
  2564 + // const pagination = {
  2565 + // pageSize: commonConfig.pageSize,
  2566 + // ...slavePagination,
  2567 + // size: isSmall ? 'small' : 'large',
  2568 + // pageSizeOptions: commonConfig.pageSizeOptions,
  2569 + // showSizeChanger: !isSmall,
  2570 + // showQuickJumper: !isSmall,
  2571 + // };
  2572 + const { mesTotalCount , mesPageSize, mesPageNum, isPagination } = baseProps?.parentProps || {};
  2573 + const tableProps = {
  2574 + ...baseProps,
  2575 + tableBtnsConfig: btnsConfig,
  2576 + // tableBtnsWidth: '100px',
  2577 + // tableBtnsConfig: (params) => {
  2578 + // console.log('=====params', params);
  2579 + // return btnsConfig;
  2580 + // },
  2581 + onTableBtnClick,
  2582 + tableProps: {
  2583 + onChange: () => { },
  2584 + rowKey: baseProps?.config?.sId === "17091154460006421964039036672000" ? 'sSlaveId' : 'sId',
  2585 + mesTotalCount,
  2586 + mesPageSize,
  2587 + mesPageNum,
  2588 + isPagination,
  2589 + // AutoTableHeight: 200
  2590 + },
  2591 + onViewClick: (tableName, sFieldName, record, index, config) => {
  2592 + // 异常事件提报-提报信息-事件类型字段点击事件
  2593 + if (tableName === "slave" && sFieldName === "sClassifyName") {
  2594 + props.onTableBtnClick({
  2595 + name: tableName,
  2596 + record,
  2597 + config
  2598 + });
  2599 + }
  2600 + },
  2601 + onViewChoose: (tableName, sFieldName, record, index, isColor) => {
  2602 + handleViewChoose(tableName, sFieldName, record, index, isColor);
2576 2603  
2577   - }
2578   - };
  2604 + }
  2605 + };
  2606 + console.log("🚀 ~ CommonTableComponent ~ tableProps:", tableProps)
2579 2607 const handleViewChoose = (tableName, sFieldName, record, index, isColor) => {
2580 2608 if (isColor) {
2581 2609 const { sId } = record; /* 控制表主键 */
... ...
src/mes/common/routerComponent/index.js
... ... @@ -68,7 +68,7 @@ const RouterComponent = props =&gt; {
68 68 const selectedType = Object.keys(types).find(type =>
69 69 sModelType?.includes(type)
70 70 );
71   -
  71 +
72 72 if (selectedType) {
73 73 return types[selectedType]({ sModelsId: keyId, props });
74 74 } else if (sModelsId === "12710101117126502477360") {
... ...
src/mes/productionExec/productionExecMain/index.js
... ... @@ -1080,7 +1080,7 @@ const ProductionExecContent0 = props =&gt; {
1080 1080  
1081 1081 } = props;
1082 1082 const viewRowOld = {...workOrderInfoData[0], ...changeExecInfo,};
1083   -
  1083 +
1084 1084 const newTableProps = {
1085 1085 ...tableProps,
1086 1086 data: tableProps.data.map((item, index) => {
... ...