import React, { useEffect, useRef, useState } from 'react';
interface AffixRowProps {
  position: 'prefix' | 'affix',
  items: Array<any>,
  rowIndex?: number
}
const AffixRow = (props: AffixRowProps) => {

  // const renderSummaryRow = (
  //   position: 'prefix' | 'affix',
  //   items?: Array<any>,
  //   rowIndex?: number
  // ) => {
  //   const { columns, render, data, classnames: cx, rows, store, setBorder, stickyWidths, tableLayout } = this.props;
  //   if (!(Array.isArray(items) && items.length) || tableLayout !== 'horizontal') {
  //     return null;
  //   }
  //   let offset = 0;
  //   // 将列的隐藏对应的把总结行也隐藏起来
  //   const result: any[] = items.map((item, index) => {
  //     let colIdxs: number[] = [offset + index];
  //     if (item.colSpan > 1) {
  //       for (let i = 1; i < item.colSpan; i++) {
  //         colIdxs.push(offset + index + i);
  //       }
  //       offset += item.colSpan - 1;
  //     }
  //     const matchedColumns = colIdxs
  //       .map(idx => columns.find(col => col.rawIndex === idx))
  //       .filter(item => item);
  //     return {
  //       ...item,
  //       colSpan: matchedColumns.length,
  //       firstColumn: matchedColumns[0],
  //       lastColumn: matchedColumns[matchedColumns.length - 1]
  //     };
  //   }).filter(item => item.colSpan);
  //   if (result.length == 0) return null;
  //   //  如果是勾选栏，展开栏，拖拽栏，序号栏让它和下一列合并。
  //   if (result[0] && typeof columns[0]?.type === 'string' && columns[0]?.type.substring(0, 2) === '__') {
  //     store.hideCheckToggler && isMobile() ? null : result[0].colSpan = (result[0].colSpan || 1) + 1;
  //   }
  //   if (result[1] && typeof columns[1]?.type === 'string' && columns[1]?.type.substring(0, 2) === '__') {
  //     result[0].colSpan = (result[0].colSpan || 1) + 1;
  //   }
  //   // 缺少的单元格补齐
  //   let appendLen = columns.length - result.reduce((p, c) => p + (c.colSpan || 1), 0);
  //   // 多了则干掉一些
  //   while (appendLen < 0) {
  //     const item = result.pop();
  //     if (!item) {
  //       break;
  //     }
  //     appendLen += item.colSpan || 1;
  //   }
  //   // 少了则补个空的
  //   if (appendLen) {
  //     const item = /*result.length
  //       ? result.pop()
  //       : */ {
  //       type: 'html',
  //       html: '&nbsp;'
  //     };
  //     const column = store.filteredColumns[store.filteredColumns.length - 1];
  //     result.push({
  //       ...item,
  //       colSpan: /*(item.colSpan || 1)*/ 1 + appendLen,
  //       firstColumn: column,
  //       lastColumn: column
  //     });
  //   }
  //   return (
  //     <tr
  //       className={cx('Table-tr', 'is-summary')}
  //       key={`summary-${position}-${rowIndex || 0}`}
  //       style={{ position: 'sticky', bottom: 0, zIndex: 1 }}
  //       onClick={() => isMobile() ? this.setState({ summaryVisible: true }) : null}
  //     >
  //       {result.map((item, index) => {
  //         const column = item.firstColumn;
  //         const tdStyle = {
  //           position: 'sticky', bottom: 0, zIndex: column.fixed == 'left' || column.fixed == 'right' ? 4 : 1,
  //           left: column.fixed === 'left' && stickyWidths?.[`${column.index}`],
  //           right: column.fixed === 'right' && stickyWidths?.[`${column.index}`],
  //           maxWidth: column.pristine.width || "200px",
  //           width: column.pristine.width,
  //           textAlign: column.align
  //         }
  //         const Com = item.isHead ? 'th' : 'td';
  //         if (item.tpl) {
  //           const str = item.tpl.split('pick:')[1];
  //           const fieldList = str.split('|');
  //           const fieldName = fieldList[0];
  //           let unitName = fieldList[1];
  //           if (unitName.includes('}')) unitName = unitName.split('}')[0];
  //           const targetCol = columns.find(col => col.name === fieldName);
  //           const prevStr = item.tpl.split('${')[0];
  //           const nextStr = item.tpl.split('}')[1];
  //           const selectedList = data.selectedItems.toJSON();
  //           const calc = calcFn(unitName, targetCol?.name ?? '', selectedList.length ? selectedList : data.items)
  //           let newValue: any = calc;
  //           if (typeof newValue === 'number' && targetCol?.pristine?.precision) {
  //             newValue = newValue.toFixed(targetCol.pristine.precision);
  //           }
  //           if (targetCol?.pristine?.kilobitSeparator) {
  //             newValue = numberFormatter(newValue, targetCol.pristine.precision);
  //           }
  //           return (
  //             <Com
  //               key={index}
  //               colSpan={item.colSpan}
  //               className={cx({ 'td-border': setBorder }, item.cellClassName)}
  //               style={tdStyle}
  //             >
  //               {prevStr + (unitName === 'count' ? calc : newValue) + nextStr}
  //             </Com>
  //           )
  //         }
  //         return (
  //           <Com
  //             key={index}
  //             colSpan={item.colSpan}
  //             className={cx({ 'td-border': setBorder }, item.cellClassName)}
  //             style={tdStyle}
  //           >
  //             {render(`summary-row/${index}`, item, {
  //               data: data.items
  //             })}
  //           </Com>
  //         );
  //       })}
  //     </tr>
  //   );
  // }
  return (
    <>
      {/* {renderSummaryRow()} */}
    </>
  )
}
export default AffixRow;