lu-lowcode-package-form 0.10.42 → 0.10.44

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": "lu-lowcode-package-form",
3
- "version": "0.10.42",
3
+ "version": "0.10.44",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^4.8.1",
6
6
  "@dnd-kit/core": "^6.1.0",
package/src/App.jsx CHANGED
@@ -259,9 +259,13 @@ function App() {
259
259
  <Layout.FormRow layout={'1'}>
260
260
  <Field.Number label="测试规则" isRequired={true} __id="ceshi_rule1" />
261
261
  </Layout.FormRow>
262
-
263
262
  <Layout.FormRow layout={'1'}>
264
- <Field.Table label="子表格" __id="table" >
263
+ <Field.Table label="子表格" __id="table2" >
264
+ <Field.Number label="测试规则2" __id="ceshi_rule2" />
265
+ </Field.Table>
266
+ </Layout.FormRow>
267
+ <Layout.FormRow layout={'1'}>
268
+ <Field.Table label="子表格" __id="table" isAllowAdd={false} isAllowCopy={false} >
265
269
 
266
270
  <Field.WithSingleSelect
267
271
  isRequired={true} ref={testRef}
@@ -24,7 +24,7 @@ export const BaseWrapper = ({
24
24
  hidePrompt = false,
25
25
  subTableIndex,
26
26
  addWrapper = true,
27
- calcHidden,
27
+ calcHidden = false,
28
28
  defaultValue,
29
29
  value,
30
30
  onChange,
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useRef, useState } from "react";
2
- import { Button, Form, Input } from "antd";
3
- import { DeleteOutlined } from "@ant-design/icons";
2
+ import { Button, Form, Input,Popconfirm } from "antd";
3
+ import { CopyOutlined, DeleteOutlined } from "@ant-design/icons";
4
4
  import { BaseWrapper } from "../base.jsx"
5
5
  import { type } from "@testing-library/user-event/dist/type/index.js";
6
6
  import { nanoid } from "nanoid";
@@ -11,7 +11,7 @@ const TableAction = ({ label, subTableIndex, children, subTableHead = false, ...
11
11
  return <div className="fw-12 ">
12
12
  <div className="frelative fw-full fh-full fflex fflex-col foverflow-hidden">
13
13
  {label && subTableHead && <div className='fh-12 ffont-semibold fbg-[#fafafa] ftext-sm fflex fflex-nowrap ftext-nowrap fjustify-between fitems-center fpx-2 fborder-b'>{label}</div>}
14
- <div className="fw-full fflex-1 fflex fitems-center fjustify-center fp-2 fbox-border ">
14
+ <div className="fw-full fflex-1 fflex fitems-center fjustify-center fp-2 fbox-border fgap-2 ">
15
15
  {children}
16
16
  </div>
17
17
  </div>
@@ -30,7 +30,7 @@ const TableCol = ({ children, width, hidden, ...props }) => {
30
30
  </div>
31
31
  }
32
32
 
33
- const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow, form, fieldName, initializeFormRender,recordFieldsChange, mode, ...props }) => {
33
+ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow, form, fieldName, initializeFormRender, recordFieldsChange, mode, isAllowCopy=true, isAllowAdd=true, ...props }) => {
34
34
  useEffect(() => {
35
35
  // console.log("Table form reload", form)
36
36
  }, [form])
@@ -169,15 +169,29 @@ const Table = ({ children, onTableAddRow, disabled, readonly, onTableRemoveRow,
169
169
  </TableCol>
170
170
  })}
171
171
  {disabled != true && readonly != true && <TableAction subTableHead={index == 0} key={`row_${index}_action`} subTable={true} subTableIndex={index} label={"操作"}>
172
- <DeleteOutlined className="fcursor-pointer" onClick={() => {
173
- remove(index)
174
- typeof onTableRemoveRow === "function" && onTableRemoveRow(childrenIds);
175
- }} />
172
+ {isAllowCopy && <CopyOutlined className="fcursor-pointer" onClick={() => {
173
+ let tableValues = form.getFieldValue(fieldName)
174
+ const copyRow = {...tableValues[index]}
175
+ tableValues.splice(index + 1, 0, copyRow)
176
+ form?.setFieldValue(fieldName, tableValues)
177
+ }} />}
178
+ <Popconfirm
179
+ title="删除确认"
180
+ description="确定要删除这一行吗?"
181
+ onConfirm={() => {
182
+ remove(index)
183
+ typeof onTableRemoveRow === "function" && onTableRemoveRow(childrenIds);
184
+ }}
185
+ okText="确定"
186
+ cancelText="取消"
187
+ >
188
+ <DeleteOutlined className="fcursor-pointer ftext-red-500" />
189
+ </Popconfirm>
176
190
  </TableAction>}
177
191
  </div>
178
192
  ))}
179
193
  </div>
180
- {disabled != true && readonly != true && <Button onClick={() => {
194
+ {disabled != true && readonly != true && isAllowAdd && <Button onClick={() => {
181
195
  add({ key: nanoid() })
182
196
  typeof onTableAddRow === "function" && onTableAddRow(childrenIds);
183
197
  }} className="fmy-2">新增一行</Button>}