@hzab/list-render 1.9.15 → 1.9.16

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # @hzab/list-render@1.9.16
2
+
3
+ fix: modal弹窗标题支持配置
4
+
1
5
  # @hzab/list-render@1.9.15
2
6
 
3
7
  fix: components改为外部可配置
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/list-render",
3
- "version": "1.9.15",
3
+ "version": "1.9.16",
4
4
  "description": "",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -11,11 +11,14 @@ function DetailModal(props, parentRef) {
11
11
  const { modalMode, Slots = {}, modalConf = {}, modalProps = {} } = props;
12
12
  const [open, setOpen] = useState(false);
13
13
  const [data, setData] = useState({});
14
+ const [title, setTitle] = useState("详情");
15
+
14
16
  const formRef = useRef();
15
- function show(formData = props.formInitialValues) {
17
+ function show(formData = props.formInitialValues, title) {
16
18
  setOpen(true);
17
19
  // 处理 formRef.current 为 undefined 的问题
18
20
  setData(formData);
21
+ setTitle(title || '详情')
19
22
  }
20
23
 
21
24
  function close() {
@@ -72,7 +75,7 @@ function DetailModal(props, parentRef) {
72
75
  const _modalProps = {
73
76
  className: "detail-modal",
74
77
  wrapClassName: "detail-modal",
75
- title: "详情",
78
+ title: title,
76
79
  visible: open,
77
80
  open: open,
78
81
  onClose: close,
@@ -221,7 +221,8 @@ const ListRender = forwardRef(function (props, parentRef) {
221
221
 
222
222
  function onCreate() {
223
223
  setFormState("create");
224
- formModalRef.current.show();
224
+ let title = props.formInitialValues?.[modalConf?.title?.createKey] || modalConf?.title?.createText || '新增'
225
+ formModalRef.current.show(props.formInitialValues, title);
225
226
  }
226
227
 
227
228
  async function onCreateSubmit(data) {
@@ -268,7 +269,8 @@ const ListRender = forwardRef(function (props, parentRef) {
268
269
 
269
270
  function handleDetail(data, id) {
270
271
  setRowId(id);
271
- detailModalRef.current.show(data);
272
+ let title = data[modalConf?.title?.detailKey] || modalConf?.title?.detailText || '详情'
273
+ detailModalRef.current.show(data, title);
272
274
  }
273
275
 
274
276
  function onEdit(row, idx) {
@@ -297,7 +299,8 @@ const ListRender = forwardRef(function (props, parentRef) {
297
299
  function handleEdit(data, id) {
298
300
  setRowId(id);
299
301
  setFormState("edit");
300
- formModalRef.current.show(data, "编辑", "edit");
302
+ let title = data[modalConf?.title?.editKey] || modalConf?.title?.editText || '编辑'
303
+ formModalRef.current.show(data, title, "edit");
301
304
  }
302
305
 
303
306
  async function onEditSubmit(data) {