szld-libs 0.2.59 → 0.2.63

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.
@@ -22,7 +22,8 @@ const DynamicForm = forwardRef((props, ref) => {
22
22
  interfaceTypeDict = "YLZDDictList",
23
23
  relatedidKey = "relatedid",
24
24
  actionUrlKey = "action-url",
25
- actionUrlExtraParams = {}
25
+ actionUrlExtraParams = {},
26
+ CustomModalComponent
26
27
  } = props;
27
28
  const delFileListRef = useRef([]);
28
29
  const updateDelFileList = (file) => {
@@ -39,7 +40,8 @@ const DynamicForm = forwardRef((props, ref) => {
39
40
  interfaceTypeDict,
40
41
  relatedidKey,
41
42
  actionUrlKey,
42
- actionUrlExtraParams
43
+ actionUrlExtraParams,
44
+ CustomModalComponent
43
45
  });
44
46
  useImperativeHandle(ref, () => ({
45
47
  getDelFileList: () => {
@@ -9,6 +9,7 @@ interface SelectModelProps {
9
9
  style?: React.CSSProperties;
10
10
  commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
11
11
  commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
12
+ CustomModalComponent?: React.FC<ICustomModal>;
12
13
  }
13
14
  declare function SelectModel(props: SelectModelProps): import("react/jsx-runtime").JSX.Element;
14
15
  /**
@@ -1,8 +1,8 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
- import { App, Select, Modal, Table } from "antd";
2
+ import { App, Select, Table, Modal } from "antd";
3
3
  import { useState, useEffect } from "react";
4
4
  function SelectModel(props) {
5
- const { item, disabled, style, commonRequestWidthParams } = props;
5
+ const { item, disabled, style, commonRequestWidthParams, CustomModalComponent } = props;
6
6
  const { message } = App.useApp();
7
7
  const mode = item.input;
8
8
  const [value, setValue] = useState(props.value);
@@ -12,14 +12,17 @@ function SelectModel(props) {
12
12
  const [loading, setLoading] = useState(false);
13
13
  const [params, setParams] = useState({
14
14
  PageNum: 1,
15
- PageSize: 10
15
+ PageSize: 6
16
16
  });
17
17
  const [dataSource, setDataSource] = useState([]);
18
18
  const [total, setTotal] = useState(0);
19
19
  const columns = buildColumns();
20
20
  useEffect(() => {
21
+ if (!modalVisible) {
22
+ return;
23
+ }
21
24
  getData();
22
- }, [modalVisible]);
25
+ }, [modalVisible, params]);
23
26
  const onSelectChange = (keys, selectedRows) => {
24
27
  setSelectedRowKeys(keys);
25
28
  setSelectedRecords(selectedRows);
@@ -67,7 +70,7 @@ function SelectModel(props) {
67
70
  message.error("请配置action-url");
68
71
  };
69
72
  const openModal = () => {
70
- var _a, _b, _c;
73
+ var _a, _b;
71
74
  if (disabled) {
72
75
  return;
73
76
  }
@@ -80,15 +83,16 @@ function SelectModel(props) {
80
83
  }
81
84
  switch (mode) {
82
85
  case "modal-select":
83
- const id = (_c = value == null ? void 0 : value.split("-")) == null ? void 0 : _c[0];
84
- const index = dataSource == null ? void 0 : dataSource.findIndex((item2) => item2.typeid === id);
86
+ const id = value == null ? void 0 : value.split("-");
87
+ const index = dataSource == null ? void 0 : dataSource.findIndex((item2) => id.includes((item2 == null ? void 0 : item2.typeid) || (item2 == null ? void 0 : item2.instanceid)));
85
88
  setSelectedRowKeys([index]);
89
+ break;
86
90
  case "modal-mult-select":
87
91
  const values = value == null ? void 0 : value.split(",");
88
92
  const tempKeys = values == null ? void 0 : values.map((item2) => {
89
93
  var _a2;
90
94
  const id2 = (_a2 = item2.split(delimiter)) == null ? void 0 : _a2[0];
91
- return dataSource == null ? void 0 : dataSource.findIndex((item3) => item3.typeid === id2);
95
+ return dataSource == null ? void 0 : dataSource.findIndex((item3) => id2.includes((item3 == null ? void 0 : item3.typeid) || (item3 == null ? void 0 : item3.instanceid)));
92
96
  });
93
97
  setSelectedRowKeys(tempKeys);
94
98
  break;
@@ -107,6 +111,10 @@ function SelectModel(props) {
107
111
  }
108
112
  };
109
113
  const handleCancel = () => {
114
+ setParams({
115
+ ...params,
116
+ PageNum: 1
117
+ });
110
118
  setModalVisible(false);
111
119
  };
112
120
  function buildColumns() {
@@ -137,7 +145,37 @@ function SelectModel(props) {
137
145
  style
138
146
  }
139
147
  ),
140
- /* @__PURE__ */ jsx(
148
+ CustomModalComponent && /* @__PURE__ */ jsx(
149
+ CustomModalComponent,
150
+ {
151
+ title: item["modal-caption"] || "",
152
+ open: modalVisible,
153
+ onOk: handleOk,
154
+ onCancel: handleCancel,
155
+ modalStyle: { width: item["modal-width"] ?? 600, minHeight: item["modal-height"] ?? 400 },
156
+ children: /* @__PURE__ */ jsx(
157
+ Table,
158
+ {
159
+ columns,
160
+ loading,
161
+ dataSource,
162
+ rowKey: (record) => record._rowKey,
163
+ scroll: { y: "calc(80vh - 300px)" },
164
+ rowSelection: {
165
+ type: mode === "modal-select" ? "radio" : "checkbox",
166
+ selectedRowKeys,
167
+ onChange: onSelectChange
168
+ },
169
+ pagination: {
170
+ total,
171
+ current: params.PageNum,
172
+ pageSize: params.PageSize,
173
+ onChange: onPageChange
174
+ }
175
+ }
176
+ )
177
+ }
178
+ ) || /* @__PURE__ */ jsx(
141
179
  Modal,
142
180
  {
143
181
  title: item["modal-caption"],
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { IformConfigItem, IformItemStyle } from './index.d';
2
3
  import { AxiosResponse } from 'axios';
3
4
  import { FormInstance, UploadFile } from 'antd';
@@ -13,6 +14,7 @@ interface IDynamicFormProps {
13
14
  relatedidKey: string;
14
15
  actionUrlKey: string;
15
16
  actionUrlExtraParams: object;
17
+ CustomModalComponent?: React.FC<ICustomModal>;
16
18
  }
17
19
  declare function useDynamicForm(props: IDynamicFormProps): {
18
20
  handleRenderItem: ({ item, readonly, colNum, instructionShowMode, relatedid, form, defaultWidth, formItemStyle, radioAlign, }: {
@@ -26,7 +26,8 @@ function useDynamicForm(props) {
26
26
  interfaceTypeDict,
27
27
  relatedidKey,
28
28
  actionUrlKey,
29
- actionUrlExtraParams
29
+ actionUrlExtraParams,
30
+ CustomModalComponent
30
31
  } = props;
31
32
  const formConfigRef = useRef([]);
32
33
  const { message } = App.useApp();
@@ -253,6 +254,27 @@ function useDynamicForm(props) {
253
254
  }
254
255
  if (itemWithJson.attrtype === 0) {
255
256
  let initialValue = handleSetFormItemInitialValue(itemWithJson);
257
+ let placeholder = "请输入";
258
+ const { input = "" } = itemWithJson.json || {};
259
+ if ([
260
+ "radio",
261
+ "checkbox",
262
+ "select",
263
+ "mult-select",
264
+ "modal-select",
265
+ "date-picker",
266
+ "time-picker",
267
+ "week-picker",
268
+ "month-picker",
269
+ "quarter-picker",
270
+ "year-picker",
271
+ "second-picker"
272
+ ].includes(input)) {
273
+ placeholder = "请选择";
274
+ }
275
+ if (["image", "file", "video", "audio"].includes(input)) {
276
+ placeholder = "请上传";
277
+ }
256
278
  return /* @__PURE__ */ jsx(Col, { span: 24 / colNum, children: /* @__PURE__ */ jsx(
257
279
  Form.Item,
258
280
  {
@@ -263,7 +285,7 @@ function useDynamicForm(props) {
263
285
  ...((_b = itemWithJson.json) == null ? void 0 : _b.must) ? [
264
286
  {
265
287
  required: true,
266
- message: `请输入${itemWithJson.attrname}`
288
+ message: `${placeholder}${itemWithJson.attrname}`
267
289
  }
268
290
  ] : []
269
291
  ],
@@ -403,7 +425,8 @@ function useDynamicForm(props) {
403
425
  onSure: async (value) => {
404
426
  form.setFieldValue(item.attrid, value);
405
427
  },
406
- disabled: readonly
428
+ disabled: readonly,
429
+ CustomModalComponent
407
430
  }
408
431
  );
409
432
  }
package/es/vite-env.d.ts CHANGED
@@ -1 +1,14 @@
1
1
  /// <reference types="vite/client" />
2
+
3
+ interface ICustomModal {
4
+ open: boolean;
5
+ title: string;
6
+ children: React.ReactNode;
7
+ onCancel: () => void;
8
+ onOk: () => void;
9
+ confirmLoading?: boolean;
10
+ closable?: boolean;
11
+ maskClosable?: boolean;
12
+ footer?: React.ReactNode;
13
+ modalStyle?: React.CSSProperties;
14
+ }
@@ -23,7 +23,8 @@ const DynamicForm = react.forwardRef((props, ref) => {
23
23
  interfaceTypeDict = "YLZDDictList",
24
24
  relatedidKey = "relatedid",
25
25
  actionUrlKey = "action-url",
26
- actionUrlExtraParams = {}
26
+ actionUrlExtraParams = {},
27
+ CustomModalComponent
27
28
  } = props;
28
29
  const delFileListRef = react.useRef([]);
29
30
  const updateDelFileList = (file) => {
@@ -40,7 +41,8 @@ const DynamicForm = react.forwardRef((props, ref) => {
40
41
  interfaceTypeDict,
41
42
  relatedidKey,
42
43
  actionUrlKey,
43
- actionUrlExtraParams
44
+ actionUrlExtraParams,
45
+ CustomModalComponent
44
46
  });
45
47
  react.useImperativeHandle(ref, () => ({
46
48
  getDelFileList: () => {
@@ -9,6 +9,7 @@ interface SelectModelProps {
9
9
  style?: React.CSSProperties;
10
10
  commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
11
11
  commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
12
+ CustomModalComponent?: React.FC<ICustomModal>;
12
13
  }
13
14
  declare function SelectModel(props: SelectModelProps): import("react/jsx-runtime").JSX.Element;
14
15
  /**
@@ -4,7 +4,7 @@ const jsxRuntime = require("react/jsx-runtime");
4
4
  const antd = require("antd");
5
5
  const react = require("react");
6
6
  function SelectModel(props) {
7
- const { item, disabled, style, commonRequestWidthParams } = props;
7
+ const { item, disabled, style, commonRequestWidthParams, CustomModalComponent } = props;
8
8
  const { message } = antd.App.useApp();
9
9
  const mode = item.input;
10
10
  const [value, setValue] = react.useState(props.value);
@@ -14,14 +14,17 @@ function SelectModel(props) {
14
14
  const [loading, setLoading] = react.useState(false);
15
15
  const [params, setParams] = react.useState({
16
16
  PageNum: 1,
17
- PageSize: 10
17
+ PageSize: 6
18
18
  });
19
19
  const [dataSource, setDataSource] = react.useState([]);
20
20
  const [total, setTotal] = react.useState(0);
21
21
  const columns = buildColumns();
22
22
  react.useEffect(() => {
23
+ if (!modalVisible) {
24
+ return;
25
+ }
23
26
  getData();
24
- }, [modalVisible]);
27
+ }, [modalVisible, params]);
25
28
  const onSelectChange = (keys, selectedRows) => {
26
29
  setSelectedRowKeys(keys);
27
30
  setSelectedRecords(selectedRows);
@@ -69,7 +72,7 @@ function SelectModel(props) {
69
72
  message.error("请配置action-url");
70
73
  };
71
74
  const openModal = () => {
72
- var _a, _b, _c;
75
+ var _a, _b;
73
76
  if (disabled) {
74
77
  return;
75
78
  }
@@ -82,15 +85,16 @@ function SelectModel(props) {
82
85
  }
83
86
  switch (mode) {
84
87
  case "modal-select":
85
- const id = (_c = value == null ? void 0 : value.split("-")) == null ? void 0 : _c[0];
86
- const index = dataSource == null ? void 0 : dataSource.findIndex((item2) => item2.typeid === id);
88
+ const id = value == null ? void 0 : value.split("-");
89
+ const index = dataSource == null ? void 0 : dataSource.findIndex((item2) => id.includes((item2 == null ? void 0 : item2.typeid) || (item2 == null ? void 0 : item2.instanceid)));
87
90
  setSelectedRowKeys([index]);
91
+ break;
88
92
  case "modal-mult-select":
89
93
  const values = value == null ? void 0 : value.split(",");
90
94
  const tempKeys = values == null ? void 0 : values.map((item2) => {
91
95
  var _a2;
92
96
  const id2 = (_a2 = item2.split(delimiter)) == null ? void 0 : _a2[0];
93
- return dataSource == null ? void 0 : dataSource.findIndex((item3) => item3.typeid === id2);
97
+ return dataSource == null ? void 0 : dataSource.findIndex((item3) => id2.includes((item3 == null ? void 0 : item3.typeid) || (item3 == null ? void 0 : item3.instanceid)));
94
98
  });
95
99
  setSelectedRowKeys(tempKeys);
96
100
  break;
@@ -109,6 +113,10 @@ function SelectModel(props) {
109
113
  }
110
114
  };
111
115
  const handleCancel = () => {
116
+ setParams({
117
+ ...params,
118
+ PageNum: 1
119
+ });
112
120
  setModalVisible(false);
113
121
  };
114
122
  function buildColumns() {
@@ -139,7 +147,37 @@ function SelectModel(props) {
139
147
  style
140
148
  }
141
149
  ),
142
- /* @__PURE__ */ jsxRuntime.jsx(
150
+ CustomModalComponent && /* @__PURE__ */ jsxRuntime.jsx(
151
+ CustomModalComponent,
152
+ {
153
+ title: item["modal-caption"] || "",
154
+ open: modalVisible,
155
+ onOk: handleOk,
156
+ onCancel: handleCancel,
157
+ modalStyle: { width: item["modal-width"] ?? 600, minHeight: item["modal-height"] ?? 400 },
158
+ children: /* @__PURE__ */ jsxRuntime.jsx(
159
+ antd.Table,
160
+ {
161
+ columns,
162
+ loading,
163
+ dataSource,
164
+ rowKey: (record) => record._rowKey,
165
+ scroll: { y: "calc(80vh - 300px)" },
166
+ rowSelection: {
167
+ type: mode === "modal-select" ? "radio" : "checkbox",
168
+ selectedRowKeys,
169
+ onChange: onSelectChange
170
+ },
171
+ pagination: {
172
+ total,
173
+ current: params.PageNum,
174
+ pageSize: params.PageSize,
175
+ onChange: onPageChange
176
+ }
177
+ }
178
+ )
179
+ }
180
+ ) || /* @__PURE__ */ jsxRuntime.jsx(
143
181
  antd.Modal,
144
182
  {
145
183
  title: item["modal-caption"],
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { IformConfigItem, IformItemStyle } from './index.d';
2
3
  import { AxiosResponse } from 'axios';
3
4
  import { FormInstance, UploadFile } from 'antd';
@@ -13,6 +14,7 @@ interface IDynamicFormProps {
13
14
  relatedidKey: string;
14
15
  actionUrlKey: string;
15
16
  actionUrlExtraParams: object;
17
+ CustomModalComponent?: React.FC<ICustomModal>;
16
18
  }
17
19
  declare function useDynamicForm(props: IDynamicFormProps): {
18
20
  handleRenderItem: ({ item, readonly, colNum, instructionShowMode, relatedid, form, defaultWidth, formItemStyle, radioAlign, }: {
@@ -27,7 +27,8 @@ function useDynamicForm(props) {
27
27
  interfaceTypeDict,
28
28
  relatedidKey,
29
29
  actionUrlKey,
30
- actionUrlExtraParams
30
+ actionUrlExtraParams,
31
+ CustomModalComponent
31
32
  } = props;
32
33
  const formConfigRef = react.useRef([]);
33
34
  const { message } = antd.App.useApp();
@@ -254,6 +255,27 @@ function useDynamicForm(props) {
254
255
  }
255
256
  if (itemWithJson.attrtype === 0) {
256
257
  let initialValue = handleSetFormItemInitialValue(itemWithJson);
258
+ let placeholder = "请输入";
259
+ const { input = "" } = itemWithJson.json || {};
260
+ if ([
261
+ "radio",
262
+ "checkbox",
263
+ "select",
264
+ "mult-select",
265
+ "modal-select",
266
+ "date-picker",
267
+ "time-picker",
268
+ "week-picker",
269
+ "month-picker",
270
+ "quarter-picker",
271
+ "year-picker",
272
+ "second-picker"
273
+ ].includes(input)) {
274
+ placeholder = "请选择";
275
+ }
276
+ if (["image", "file", "video", "audio"].includes(input)) {
277
+ placeholder = "请上传";
278
+ }
257
279
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24 / colNum, children: /* @__PURE__ */ jsxRuntime.jsx(
258
280
  antd.Form.Item,
259
281
  {
@@ -264,7 +286,7 @@ function useDynamicForm(props) {
264
286
  ...((_b = itemWithJson.json) == null ? void 0 : _b.must) ? [
265
287
  {
266
288
  required: true,
267
- message: `请输入${itemWithJson.attrname}`
289
+ message: `${placeholder}${itemWithJson.attrname}`
268
290
  }
269
291
  ] : []
270
292
  ],
@@ -404,7 +426,8 @@ function useDynamicForm(props) {
404
426
  onSure: async (value) => {
405
427
  form.setFieldValue(item.attrid, value);
406
428
  },
407
- disabled: readonly
429
+ disabled: readonly,
430
+ CustomModalComponent
408
431
  }
409
432
  );
410
433
  }
package/lib/vite-env.d.ts CHANGED
@@ -1 +1,14 @@
1
1
  /// <reference types="vite/client" />
2
+
3
+ interface ICustomModal {
4
+ open: boolean;
5
+ title: string;
6
+ children: React.ReactNode;
7
+ onCancel: () => void;
8
+ onOk: () => void;
9
+ confirmLoading?: boolean;
10
+ closable?: boolean;
11
+ maskClosable?: boolean;
12
+ footer?: React.ReactNode;
13
+ modalStyle?: React.CSSProperties;
14
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "szld-libs",
3
3
  "private": false,
4
- "version": "0.2.59",
4
+ "version": "0.2.63",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",