@hzab/list-render 1.10.21-alpha.4 → 1.10.21-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/list-render",
3
- "version": "1.10.21-alpha.4",
3
+ "version": "1.10.21-alpha.5",
4
4
  "description": "",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -13,6 +13,6 @@
13
13
  }
14
14
 
15
15
  .expandList-template-indent {
16
- margin-left: 26px;
16
+ margin-left: 32px;
17
17
  }
18
18
  }
@@ -1,4 +1,4 @@
1
- import { MinusSquareOutlined, PlusCircleOutlined } from "@ant-design/icons";
1
+ import { MinusCircleOutlined, MinusSquareOutlined, PlusCircleOutlined } from "@ant-design/icons";
2
2
  import { useEffect, useState, memo } from "react";
3
3
  import "./index.less";
4
4
  export const ExpandListTemplate = (props) => {
@@ -63,7 +63,7 @@ export const ExpandListTemplate = (props) => {
63
63
  }}
64
64
  />
65
65
  ) : (
66
- <MinusSquareOutlined
66
+ <MinusCircleOutlined
67
67
  className="expandList-template-icon"
68
68
  onClick={() => {
69
69
  props.record["expand"] = !expand;
@@ -81,7 +81,10 @@ export const ExpandListTemplate = (props) => {
81
81
  </>
82
82
  )}
83
83
 
84
- <div className={`expandList-template-name ${props?.record?.children ? "" : "expandList-template-indent"}`}>
84
+ <div
85
+ className={`expandList-template-name ${record?.spiltTag == 0 ? "expandList-template-indent" : ""}`}
86
+ style={record?.spiltTag == 1 && !record?.children ? { marginLeft: "22px" } : {}}
87
+ >
85
88
  {Slots?.[item?.columnId] ? colRender("", record) : record[item?.columnId]}
86
89
  </div>
87
90
  </div>
@@ -152,7 +152,10 @@ export const WidthWrap = (opt: any, edit = false) => {
152
152
  ): React.ReactNode {
153
153
  if (edit) {
154
154
  return (
155
- <div onPointerDown={(e) => e.stopPropagation()}>
155
+ <div
156
+ onPointerDown={(e) => e.stopPropagation()}
157
+ style={{ display: "flex", justifyContent: "center", alignItems: "center" }}
158
+ >
156
159
  <WrapComponent record={cell?.record} rowId={cell?.rowId} item={cell}></WrapComponent>
157
160
  </div>
158
161
  );
@@ -203,7 +206,7 @@ export const WidthWrap = (opt: any, edit = false) => {
203
206
 
204
207
  return (
205
208
  <div
206
- style={{ width: "100%", height: "100%", display: "flex", alignItems: "center" }}
209
+ style={{ width: "100%", height: "100%", display: "flex", alignItems: "center", justifyContent: "center" }}
207
210
  onDoubleClick={(e) => {
208
211
  if (cell?.nonEditable) {
209
212
  return;
@@ -221,7 +224,7 @@ export const WidthWrap = (opt: any, edit = false) => {
221
224
  }
222
225
  }}
223
226
  open={isOpen}
224
- style={{ width: "100%", display: "flex", alignItems: "center" }}
227
+ style={{ width: "100%", display: "flex", alignItems: "center", justifyContent: "center" }}
225
228
  value={cell[_value]}
226
229
  options={cell.values}
227
230
  onChange={(e) => {
@@ -246,7 +249,9 @@ export const WidthWrap = (opt: any, edit = false) => {
246
249
  item={cell}
247
250
  />
248
251
  ) : (
249
- <div style={{ height: "100%", display: "flex", alignItems: "center" }}>{echoValue}</div>
252
+ <div style={{ height: "100%", display: "flex", alignItems: "center", justifyContent: "center" }}>
253
+ {echoValue}
254
+ </div>
250
255
  )}
251
256
  </div>
252
257
  )}
@@ -1,6 +1,7 @@
1
1
  .grid-container {
2
2
  overflow: auto;
3
3
  position: relative;
4
+ max-height: 80vh;
4
5
 
5
6
 
6
7
 
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useMemo, useState } from "react";
1
+ import React, { memo, useEffect, useMemo, useState } from "react";
2
2
  import { ReactGrid, Column, Row, CellChange, Cell, CellTemplate } from "@silevis/reactgrid";
3
3
  import "@silevis/reactgrid/styles.css";
4
4
  import _ from "lodash";
@@ -7,11 +7,11 @@ import { TextTemplate } from "./Template/TextCellTemplate";
7
7
  import { antdComponents, customComponents } from "@hzab/form-render/src/index";
8
8
  import { WidthWrap } from "./Template/widthWrap";
9
9
  import { NumberTemplate } from "./Template/NumberCellTemplate";
10
- import { Checkbox } from "antd";
10
+ import { Checkbox, Spin } from "antd";
11
11
  import { ExpandListTemplate } from "./Template/ExpandListTemplate";
12
12
  import { convertColumnsToRows, flattenColumns } from "./Template/utils";
13
13
 
14
- export default function CellEditTable(props: any) {
14
+ export default memo(function CellEditTable(props: any) {
15
15
  const {
16
16
  columns,
17
17
  dataSource,
@@ -27,6 +27,7 @@ export default function CellEditTable(props: any) {
27
27
  rowSelection,
28
28
  rowKey,
29
29
  query,
30
+ loading,
30
31
  } = props;
31
32
 
32
33
  const [headerList, setHeaderList] = useState<any>([]);
@@ -143,6 +144,7 @@ export default function CellEditTable(props: any) {
143
144
  ...(columnsItem?.cellProps || {}),
144
145
  setNewDataSource,
145
146
  setExpandKeys,
147
+ rowKey,
146
148
  expandKeys,
147
149
  Slots,
148
150
  ...newCell,
@@ -158,6 +160,9 @@ export default function CellEditTable(props: any) {
158
160
 
159
161
  // 单元格编辑回调
160
162
  const handleCellsChanged = (changes) => {
163
+ if (!Array.isArray(changes) || changes.length === 0) return;
164
+ const hasDiff = changes.some((c) => JSON.stringify(c.previousCell) !== JSON.stringify(c.newCell));
165
+ if (!hasDiff) return;
161
166
  setRows((prevRows) => {
162
167
  changes.forEach((change) => {
163
168
  const changeRowIdx = prevRows.findIndex((el) => el.rowId == change.rowId);
@@ -230,7 +235,7 @@ export default function CellEditTable(props: any) {
230
235
  {...props}
231
236
  checked={
232
237
  rowSelection?.selectedRowKeys?.includes((props?.record && props?.record[rowKey]) || "") ||
233
- rowSelection?.selectedRowKeys?.length == dataSource?.length
238
+ (rowSelection?.selectedRowKeys?.length == dataSource?.length && dataSource?.length > 0)
234
239
  }
235
240
  indeterminate={
236
241
  !props?.rowId &&
@@ -277,61 +282,63 @@ export default function CellEditTable(props: any) {
277
282
  }, [query?.pageNum]);
278
283
 
279
284
  return (
280
- <div className={`grid-container ${className}`} style={reactGridStyle}>
281
- <ReactGrid
282
- rows={rows}
283
- columns={tableColumns}
284
- onCellsChanged={handleCellsChanged}
285
- enableFillHandle={true}
286
- enableRangeSelection={true}
287
- horizontalStickyBreakpoint={120}
288
- // stickyLeftColumns={1}
289
- // onFocusLocationChanging={(location) => {
290
- // return false;
291
- // }}
292
- {...reactGridProps}
293
- onFocusLocationChanging={(cell: any) => {
294
- const datatypeId = cell?.columnId + cell?.rowId;
295
- window.gridEditId = datatypeId;
285
+ <Spin spinning={loading}>
286
+ <div className={`grid-container ${className}`} style={reactGridStyle}>
287
+ <ReactGrid
288
+ rows={rows}
289
+ columns={tableColumns}
290
+ onCellsChanged={handleCellsChanged}
291
+ enableFillHandle={true}
292
+ enableRangeSelection={true}
293
+ horizontalStickyBreakpoint={120}
294
+ // stickyLeftColumns={1}
295
+ // onFocusLocationChanging={(location) => {
296
+ // return false;
297
+ // }}
298
+ {...reactGridProps}
299
+ onFocusLocationChanging={(cell: any) => {
300
+ const datatypeId = cell?.columnId + cell?.rowId;
301
+ window.gridEditId = datatypeId;
296
302
 
297
- if (["_$actions", "rowSelection"]?.includes(cell?.columnId)) {
298
- return false;
299
- }
303
+ if (["_$actions", "rowSelection"]?.includes(cell?.columnId)) {
304
+ return false;
305
+ }
300
306
 
301
- if (reactGridProps?.onFocusLocationChanging) {
302
- return reactGridProps?.onFocusLocationChanging(cell, rows);
303
- }
304
- return cell;
305
- }}
306
- customCellTemplates={{
307
- ...baseTemplate,
308
- ...reactGridProps?.customCellTemplates,
309
- _$actions: WidthWrap(
310
- {
311
- WrapComponent: ActionDom,
312
- },
313
- true,
314
- ),
315
- rowSelection: WidthWrap(
316
- {
317
- WrapComponent: CheckBoxDom,
318
- },
319
- true,
320
- ),
321
- Input: TextTemplate,
322
- Number: NumberTemplate,
323
- ExpandListTemplate: WidthWrap(
324
- {
325
- WrapComponent: ExpandListTemplate,
326
- },
327
- true,
328
- ),
329
- }}
307
+ if (reactGridProps?.onFocusLocationChanging) {
308
+ return reactGridProps?.onFocusLocationChanging(cell, rows);
309
+ }
310
+ return cell;
311
+ }}
312
+ customCellTemplates={{
313
+ ...baseTemplate,
314
+ ...reactGridProps?.customCellTemplates,
315
+ _$actions: WidthWrap(
316
+ {
317
+ WrapComponent: ActionDom,
318
+ },
319
+ true,
320
+ ),
321
+ rowSelection: WidthWrap(
322
+ {
323
+ WrapComponent: CheckBoxDom,
324
+ },
325
+ true,
326
+ ),
327
+ Input: TextTemplate,
328
+ Number: NumberTemplate,
329
+ ExpandListTemplate: WidthWrap(
330
+ {
331
+ WrapComponent: ExpandListTemplate,
332
+ },
333
+ true,
334
+ ),
335
+ }}
330
336
 
331
- // onSelectionChanged={(newSelection) => {
332
- // console.log("选区发生变化", newSelection[0]);
333
- // }}
334
- />
335
- </div>
337
+ // onSelectionChanged={(newSelection) => {
338
+ // console.log("选区发生变化", newSelection[0]);
339
+ // }}
340
+ />
341
+ </div>
342
+ </Spin>
336
343
  );
337
- }
344
+ });