szld-libs 0.2.69 → 0.2.71

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.
@@ -29,7 +29,9 @@ function useDynamicForm(props) {
29
29
  relatedidKey,
30
30
  actionUrlKey,
31
31
  actionUrlExtraParams,
32
- CustomModalComponent
32
+ CustomModalComponent,
33
+ setAttrList,
34
+ hideAttrList = []
33
35
  } = props;
34
36
  const formConfigRef = react.useRef([]);
35
37
  const { message } = antd.App.useApp();
@@ -119,17 +121,24 @@ function useDynamicForm(props) {
119
121
  value: value ? dayjs(value, format || "HH:mm:ss") : null
120
122
  });
121
123
  break;
124
+ case "range-picker":
125
+ baseProps.getValueFromEvent = (date) => date == null ? void 0 : date.map((d) => d == null ? void 0 : d.format(format || "YYYY-MM-DD"));
126
+ baseProps.getValueProps = (value) => ({
127
+ value: (value == null ? void 0 : value.map((v) => dayjs(v))) || null
128
+ });
129
+ break;
122
130
  }
123
131
  return baseProps;
124
132
  },
125
133
  [handleNormFile]
126
134
  );
127
135
  const handleSetFormItemInitialValue = react.useCallback((itemWithJson) => {
128
- var _a, _b, _c, _d;
136
+ var _a, _b, _c, _d, _e;
129
137
  const inputType = (_a = itemWithJson.json) == null ? void 0 : _a.input;
130
- let initialValue = itemWithJson.attrvalue ?? ((_b = itemWithJson.json) == null ? void 0 : _b.default);
138
+ const isFormList = (_b = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _b["properties-multiple"];
139
+ let initialValue = itemWithJson.attrvalue ?? ((_c = itemWithJson.json) == null ? void 0 : _c.default);
131
140
  if (inputType === "label" && initialValue) {
132
- initialValue = ((_c = itemWithJson.json) == null ? void 0 : _c["label-value"]) ?? initialValue ?? "-";
141
+ initialValue = ((_d = itemWithJson.json) == null ? void 0 : _d["label-value"]) ?? initialValue ?? "-";
133
142
  }
134
143
  if ((inputType === "date-picker" || inputType === "time-picker") && initialValue) {
135
144
  try {
@@ -139,8 +148,16 @@ function useDynamicForm(props) {
139
148
  initialValue = void 0;
140
149
  }
141
150
  }
151
+ if (inputType === "range-picker" && initialValue) {
152
+ try {
153
+ initialValue = initialValue == null ? void 0 : initialValue.split("~");
154
+ initialValue = initialValue.map((v) => dayjs(v));
155
+ } catch (error) {
156
+ initialValue = void 0;
157
+ }
158
+ }
142
159
  if (inputType === "cascader" && initialValue && typeof initialValue === "string") {
143
- const delimiter = (_d = itemWithJson.json) == null ? void 0 : _d["cascader-delimiter"];
160
+ const delimiter = (_e = itemWithJson.json) == null ? void 0 : _e["cascader-delimiter"];
144
161
  if (delimiter) {
145
162
  initialValue = initialValue.split(delimiter).filter(Boolean);
146
163
  }
@@ -161,6 +178,19 @@ function useDynamicForm(props) {
161
178
  initialValue = [];
162
179
  }
163
180
  }
181
+ if (isFormList && itemWithJson.attrtype === 1) {
182
+ const children = itemWithJson.children || [];
183
+ if (Array.isArray(children)) {
184
+ initialValue = [
185
+ Object.assign(
186
+ {},
187
+ ...children == null ? void 0 : children.map((child) => ({
188
+ [child.attrid]: handleSetFormItemInitialValue(child)
189
+ }))
190
+ )
191
+ ];
192
+ }
193
+ }
164
194
  return initialValue || null;
165
195
  }, []);
166
196
  const handleCollapseIcon = react.useCallback(
@@ -193,10 +223,18 @@ function useDynamicForm(props) {
193
223
  formItemStyle,
194
224
  relatedid,
195
225
  form,
196
- defaultWidth = 358
226
+ defaultWidth = 358,
227
+ isFormListItem = false,
228
+ formListField,
229
+ isShowLabel = true
197
230
  }) => {
198
- var _a, _b;
199
- if (((_a = itemWithJson.json) == null ? void 0 : _a.hide) === true) {
231
+ var _a, _b, _c, _d, _e;
232
+ const isFormList = (_a = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _a["properties-multiple"];
233
+ let formListInitValue = [];
234
+ if (isFormList) {
235
+ formListInitValue = handleSetFormItemInitialValue(itemWithJson);
236
+ }
237
+ if (((_b = itemWithJson.json) == null ? void 0 : _b.hide) === true || (hideAttrList == null ? void 0 : hideAttrList.includes(itemWithJson.attrid))) {
200
238
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
201
239
  }
202
240
  if (itemWithJson.attrtype === 1) {
@@ -207,23 +245,25 @@ function useDynamicForm(props) {
207
245
  style: { backgroundColor: "transparent" },
208
246
  expandIcon: ({ isActive }) => handleCollapseIcon({ isActive }),
209
247
  onChange: async (key) => {
210
- var _a2;
248
+ var _a2, _b2;
211
249
  try {
212
250
  const { children = [] } = itemWithJson;
213
- if (key && (key == null ? void 0 : key.length) && setFormConfig && formConfigRef.current && interfaceTypeChildren && !(children == null ? void 0 : children.length)) {
251
+ if (key && (key == null ? void 0 : key.length) && formConfigRef.current && interfaceTypeChildren && !(children == null ? void 0 : children.length)) {
214
252
  const res = await commonRequest(interfaceTypeChildren, {
215
253
  instanceid: relatedid,
216
- asid: itemWithJson.asid,
217
- tname: itemWithJson.tname
254
+ asid: (_a2 = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _a2.propertiesID,
255
+ tname: itemWithJson.attrvalue
218
256
  });
219
257
  if ((res == null ? void 0 : res.ReturnValue) === 1) {
220
- const arr = ((_a2 = res == null ? void 0 : res.data) == null ? void 0 : _a2.list) || [];
258
+ const list = ((_b2 = res == null ? void 0 : res.data) == null ? void 0 : _b2.list) || [];
259
+ const arr = method.handleAttrList(list, { instanceid: relatedid, tname: itemWithJson.tname });
221
260
  const _formConfig = _.cloneDeep(formConfigRef.current);
222
261
  const _item = _formConfig.find((item) => item.attrid === itemWithJson.attrid);
223
262
  if (_item) {
224
263
  _item.children = [...arr];
225
264
  }
226
- setFormConfig(_formConfig);
265
+ setFormConfig == null ? void 0 : setFormConfig(_formConfig);
266
+ setAttrList == null ? void 0 : setAttrList(_formConfig);
227
267
  }
228
268
  }
229
269
  } catch (error) {
@@ -233,7 +273,52 @@ function useDynamicForm(props) {
233
273
  {
234
274
  key: itemWithJson.attrid,
235
275
  label: itemWithJson.attrname,
236
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: (itemWithJson.children || []).map((child, index) => {
276
+ styles: {
277
+ header: {
278
+ paddingLeft: 0
279
+ }
280
+ },
281
+ children: isFormList ? /* @__PURE__ */ jsxRuntime.jsx(antd.Form.List, { name: itemWithJson.attrid, initialValue: formListInitValue, children: (fields, { add, remove }) => {
282
+ var _a2;
283
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", rowGap: 16, flexDirection: "column" }, children: [
284
+ fields.map((field) => {
285
+ var _a3;
286
+ return /* @__PURE__ */ jsxRuntime.jsx(
287
+ antd.Card,
288
+ {
289
+ style: { width: ((_a3 = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _a3["properties-width"]) || defaultWidth + 100 },
290
+ size: "small",
291
+ title: `${itemWithJson.attrname} ${field.name + 1}`,
292
+ extra: /* @__PURE__ */ jsxRuntime.jsx(
293
+ icons.CloseOutlined,
294
+ {
295
+ onClick: () => {
296
+ remove(field.name);
297
+ }
298
+ }
299
+ ),
300
+ children: (itemWithJson.children || []).map((child, index) => {
301
+ return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: handleRenderItem({
302
+ item: child,
303
+ readonly,
304
+ colNum,
305
+ instructionShowMode,
306
+ relatedid,
307
+ form,
308
+ defaultWidth,
309
+ formItemStyle,
310
+ isFormListItem: true,
311
+ formListField: field,
312
+ isShowLabel: true
313
+ }) }, child.attrid || `child-${index}`);
314
+ })
315
+ },
316
+ field.key
317
+ );
318
+ }),
319
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { style: { width: ((_a2 = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _a2["properties-width"]) || defaultWidth + 100 }, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "dashed", onClick: () => add(), block: true, children: "+ 新增" }) })
320
+ ] });
321
+ } }) : /* @__PURE__ */ jsxRuntime.jsx("div", { children: (itemWithJson.children || []).map((child, index) => {
237
322
  return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: handleRenderItem({
238
323
  item: child,
239
324
  readonly,
@@ -265,6 +350,8 @@ function useDynamicForm(props) {
265
350
  "mult-select",
266
351
  "modal-select",
267
352
  "date-picker",
353
+ "range-picker",
354
+ "multiple-date-picker",
268
355
  "time-picker",
269
356
  "week-picker",
270
357
  "month-picker",
@@ -277,14 +364,92 @@ function useDynamicForm(props) {
277
364
  if (["image", "file", "video", "audio"].includes(input)) {
278
365
  placeholder = "请上传";
279
366
  }
367
+ const { combinations = [] } = itemWithJson.json || {};
368
+ if (combinations == null ? void 0 : combinations.length) {
369
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24 / colNum, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { label: (_c = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _c["combination-name"], children: /* @__PURE__ */ jsxRuntime.jsx(antd.Space.Compact, { children: combinations.map((item, index) => {
370
+ var _a2, _b2;
371
+ let initValue = handleSetFormItemInitialValue(item);
372
+ let width = defaultWidth;
373
+ const customWidth = {};
374
+ const mode = item.json.input || "text";
375
+ const itemStyle = formItemStyle == null ? void 0 : formItemStyle.find((v) => v.type === mode);
376
+ if (itemStyle) {
377
+ const { width: width2 } = (itemStyle == null ? void 0 : itemStyle.style) || {};
378
+ if (width2) {
379
+ customWidth["width"] = width2;
380
+ }
381
+ }
382
+ const widthRatio = (_a2 = item == null ? void 0 : item.json) == null ? void 0 : _a2["combination-width-ratio"];
383
+ if (widthRatio) {
384
+ width = defaultWidth * widthRatio;
385
+ }
386
+ return /* @__PURE__ */ jsxRuntime.jsx(
387
+ antd.Form.Item,
388
+ {
389
+ name: item.attrid,
390
+ noStyle: true,
391
+ initialValue: initValue,
392
+ rules: [
393
+ ...((_b2 = item.json) == null ? void 0 : _b2.must) ? [
394
+ {
395
+ required: true,
396
+ message: `${placeholder}${item.attrname}`
397
+ }
398
+ ] : []
399
+ ],
400
+ ...handleSetFormItemProps(item),
401
+ children: handleRenderItemInputMode({
402
+ item,
403
+ readonly,
404
+ formItemStyle,
405
+ radioAlign,
406
+ relatedid,
407
+ form,
408
+ defaultWidth: width,
409
+ customWidth
410
+ })
411
+ },
412
+ index
413
+ );
414
+ }) }) }, `${itemWithJson.attrid}+1`) });
415
+ }
416
+ if (isFormListItem && formListField) {
417
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24 / colNum, children: /* @__PURE__ */ jsxRuntime.jsx(
418
+ antd.Form.Item,
419
+ {
420
+ name: [formListField == null ? void 0 : formListField.name, itemWithJson.attrid],
421
+ label: isShowLabel && handleDealInstruction(itemWithJson, instructionShowMode) || null,
422
+ initialValue,
423
+ rules: [
424
+ ...((_d = itemWithJson.json) == null ? void 0 : _d.must) ? [
425
+ {
426
+ required: true,
427
+ message: `${placeholder}${itemWithJson.attrname}`
428
+ }
429
+ ] : []
430
+ ],
431
+ ...handleSetFormItemProps(itemWithJson),
432
+ children: handleRenderItemInputMode({
433
+ item: itemWithJson,
434
+ readonly,
435
+ formItemStyle,
436
+ radioAlign,
437
+ relatedid,
438
+ form,
439
+ defaultWidth
440
+ })
441
+ },
442
+ itemWithJson.attrid
443
+ ) });
444
+ }
280
445
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24 / colNum, children: /* @__PURE__ */ jsxRuntime.jsx(
281
446
  antd.Form.Item,
282
447
  {
283
448
  name: itemWithJson.attrid,
284
- label: handleDealInstruction(itemWithJson, instructionShowMode),
449
+ label: isShowLabel && handleDealInstruction(itemWithJson, instructionShowMode) || null,
285
450
  initialValue,
286
451
  rules: [
287
- ...((_b = itemWithJson.json) == null ? void 0 : _b.must) ? [
452
+ ...((_e = itemWithJson.json) == null ? void 0 : _e.must) ? [
288
453
  {
289
454
  required: true,
290
455
  message: `${placeholder}${itemWithJson.attrname}`
@@ -340,7 +505,8 @@ function useDynamicForm(props) {
340
505
  radioAlign = "horizontal",
341
506
  relatedid,
342
507
  form,
343
- defaultWidth = 358
508
+ defaultWidth = 358,
509
+ customWidth = {}
344
510
  }) => {
345
511
  var _a, _b;
346
512
  const mode = item.json.input || "text";
@@ -356,7 +522,7 @@ function useDynamicForm(props) {
356
522
  {
357
523
  disabled: true,
358
524
  value: ((_a = item.json) == null ? void 0 : _a["label-value"]) || item.attrvalue || ((_b = item.json) == null ? void 0 : _b.default) || "-",
359
- style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style }
525
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
360
526
  }
361
527
  );
362
528
  case "text":
@@ -367,7 +533,7 @@ function useDynamicForm(props) {
367
533
  ...params,
368
534
  disabled: readonly,
369
535
  allowClear: true,
370
- style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style }
536
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
371
537
  }
372
538
  );
373
539
  case "textarea":
@@ -379,7 +545,7 @@ function useDynamicForm(props) {
379
545
  rows: 5,
380
546
  ...params,
381
547
  disabled: readonly,
382
- style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style }
548
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
383
549
  }
384
550
  );
385
551
  case "number":
@@ -390,7 +556,7 @@ function useDynamicForm(props) {
390
556
  placeholder: "请输入",
391
557
  ...params,
392
558
  disabled: readonly,
393
- style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style }
559
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
394
560
  }
395
561
  );
396
562
  case "select":
@@ -401,7 +567,7 @@ function useDynamicForm(props) {
401
567
  handleUrlOptions,
402
568
  item: item.json,
403
569
  readonly,
404
- style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style },
570
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
405
571
  commonRequestWidthParams,
406
572
  commonRequest,
407
573
  value: formatValue,
@@ -420,7 +586,7 @@ function useDynamicForm(props) {
420
586
  return /* @__PURE__ */ jsxRuntime.jsx(
421
587
  SelectModel,
422
588
  {
423
- style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style },
589
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
424
590
  item: item.json,
425
591
  value: item.attrvalue || item.json.default || "",
426
592
  commonRequestWidthParams,
@@ -456,10 +622,18 @@ function useDynamicForm(props) {
456
622
  picker: pickerObj[mode] || "date",
457
623
  disabled: readonly,
458
624
  placement: "bottomLeft",
459
- style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style }
625
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
460
626
  }
461
627
  );
462
628
  }
629
+ case "range-picker":
630
+ return /* @__PURE__ */ jsxRuntime.jsx(
631
+ antd.DatePicker.RangePicker,
632
+ {
633
+ disabled: readonly,
634
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
635
+ }
636
+ );
463
637
  case "radio":
464
638
  return /* @__PURE__ */ jsxRuntime.jsx(
465
639
  MyRadio,
@@ -527,7 +701,7 @@ function useDynamicForm(props) {
527
701
  commonRequest,
528
702
  item: item.json,
529
703
  value: item.attrvalue,
530
- style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style },
704
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
531
705
  interfaceTypeDict,
532
706
  interfaceTypeSysDict,
533
707
  actionUrlKey,
@@ -547,7 +721,16 @@ function useDynamicForm(props) {
547
721
  }
548
722
  );
549
723
  default:
550
- return /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { placeholder: "请输入", ...params, showCount: true, disabled: readonly, style: { ...itemStyle == null ? void 0 : itemStyle.style } });
724
+ return /* @__PURE__ */ jsxRuntime.jsx(
725
+ antd.Input,
726
+ {
727
+ placeholder: "请输入",
728
+ ...params,
729
+ showCount: true,
730
+ disabled: readonly,
731
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
732
+ }
733
+ );
551
734
  }
552
735
  };
553
736
  const handleRenderItem = ({
@@ -559,40 +742,41 @@ function useDynamicForm(props) {
559
742
  form,
560
743
  defaultWidth = 358,
561
744
  formItemStyle,
562
- radioAlign = "horizontal"
745
+ radioAlign = "horizontal",
746
+ isFormListItem = false,
747
+ formListField,
748
+ isShowLabel = true
563
749
  }) => {
564
750
  var _a;
565
751
  const json = item.info_base64 === 1 ? method.getJson(method.base64ToString(item.info)) : method.getJson(item.info);
566
- const itemWithJson = { ...item, json };
752
+ const itemWithJson = {
753
+ ...item,
754
+ json: {
755
+ ...item == null ? void 0 : item.json,
756
+ ...json
757
+ }
758
+ };
567
759
  if (((_a = itemWithJson.json) == null ? void 0 : _a.hide) === true) {
568
760
  return null;
569
761
  }
570
- return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
571
- handleRenderFunc({
572
- itemWithJson,
573
- readonly,
574
- colNum,
575
- instructionShowMode,
576
- relatedid,
577
- form,
578
- defaultWidth,
579
- formItemStyle,
580
- radioAlign
581
- }),
582
- /* @__PURE__ */ jsxRuntime.jsx(
583
- antd.Form.Item,
584
- {
585
- name: itemWithJson.attrid + "_objs",
586
- style: { display: "none" },
587
- initialValue: itemWithJson,
588
- children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { type: "hidden" })
589
- },
590
- itemWithJson.attrid + "_objs"
591
- )
592
- ] }, itemWithJson.attrid);
762
+ return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: handleRenderFunc({
763
+ itemWithJson,
764
+ readonly,
765
+ colNum,
766
+ instructionShowMode,
767
+ relatedid,
768
+ form,
769
+ defaultWidth,
770
+ formItemStyle,
771
+ radioAlign,
772
+ isFormListItem,
773
+ formListField,
774
+ isShowLabel
775
+ }) }, itemWithJson.attrid);
593
776
  };
594
777
  return {
595
- handleRenderItem
778
+ handleRenderItem,
779
+ handleSetFormItemInitialValue
596
780
  };
597
781
  }
598
782
  module.exports = useDynamicForm;
@@ -11,7 +11,21 @@ export declare const handleSubmitForm: (originalData: any, allValues: any) => {
11
11
  updatedData: any;
12
12
  uploadedFiles: any[];
13
13
  };
14
- export declare const handleAttrList: (attrList: any[]) => any[];
14
+ /**
15
+ * 处理基础属性数组
16
+ */
17
+ export declare const handleBaseAttrList: (attrList: any[], extraAttrs?: {
18
+ [key: string]: any;
19
+ } | undefined) => any[];
20
+ /**
21
+ * 处理属性列表,合并组合属性
22
+ * @param attrList 属性列表
23
+ * @param extraAttrs 额外属性
24
+ * @returns
25
+ */
26
+ export declare const handleAttrList: (attrList: any[], extraAttrs?: {
27
+ [key: string]: any;
28
+ } | undefined) => any[];
15
29
  export declare const handleFormConfig: ({ number, key, sourceNumber, guidInterfaceName, SelPCParamInterfaceName, servicerAttrListInterfaceName, accepterAttrListInterfaceName, defaultAttrListInterfaceName, commonRequest, guidParams, pcParam, attrReqKey, attrListExtraParams, }: {
16
30
  number: string | number;
17
31
  key: string;
@@ -46,3 +60,9 @@ export declare const handleFormConfig: ({ number, key, sourceNumber, guidInterfa
46
60
  * @returns
47
61
  */
48
62
  export declare const handleOperationFile: (params: any, data: any, commonRequestWidthParams: any) => Promise<any>;
63
+ /**
64
+ * 命名转换为驼峰命名
65
+ * @param str 烤肉串命名
66
+ * @returns 驼峰命名
67
+ */
68
+ export declare function handleKebabToCamel(str: string): string;