lu-lowcode-package-form 0.10.42 → 0.10.44
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs.js +314 -314
- package/dist/index.es.js +31693 -31218
- package/package.json +1 -1
- package/src/App.jsx +6 -2
- package/src/components/field/base.jsx +1 -1
- package/src/components/field/table/index.jsx +23 -9
package/package.json
CHANGED
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="
|
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}
|
@@ -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
|
-
<
|
173
|
-
|
174
|
-
|
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>}
|