szld-libs 0.2.90 → 0.2.92

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.
@@ -1,6 +1,7 @@
1
1
  import { message } from "antd";
2
2
  import dayjs from "dayjs";
3
3
  import _ from "lodash";
4
+ import { handleObjDetailToSignleAttrList } from "./szxkFunc";
4
5
  function getJson(jsonStr) {
5
6
  try {
6
7
  return JSON.parse(jsonStr);
@@ -30,42 +31,32 @@ function isBase64(str) {
30
31
  const handleSubmitForm = (originalData, allValues) => {
31
32
  let updatedData = _.cloneDeep(originalData);
32
33
  let uploadedFiles = [];
33
- const processAttrList = (attrList, item) => {
34
- var _a;
34
+ const processAttrList = (attrList) => {
35
35
  try {
36
- if ((_a = item == null ? void 0 : item.json) == null ? void 0 : _a["properties-multiple"]) {
37
- const attrValue = allValues[item.attrid];
38
- if (Array.isArray(attrValue)) {
39
- const childrenObj = {};
40
- attrValue.forEach((item2, index) => {
41
- var _a2;
42
- childrenObj[index] = _.cloneDeep(attrList);
43
- for (const [fieldName, formValue] of Object.entries(item2)) {
44
- const attrItem = (_a2 = childrenObj[index]) == null ? void 0 : _a2.find((item3) => item3.attrid === fieldName);
45
- handleDealValue(attrItem, formValue);
36
+ const attrMap = new Map(attrList.map((item, index) => [item.attrid, index]));
37
+ for (const [fieldName, formValue] of Object.entries(allValues)) {
38
+ const index = attrMap.get(fieldName);
39
+ if (index === void 0)
40
+ continue;
41
+ const attrItem = attrList[index];
42
+ if (!formValue && formValue !== 0) {
43
+ attrItem.attrvalue = "";
44
+ continue;
45
+ }
46
+ handleDealValue(attrItem, formValue);
47
+ }
48
+ attrList.forEach((item) => {
49
+ if (item.children && Array.isArray(item.children) && item.children.length > 0 && !Array.isArray(item.children[0])) {
50
+ processAttrList(item.children);
51
+ }
52
+ if (item.children && Array.isArray(item.children) && item.children.length > 0 && Array.isArray(item.children[0])) {
53
+ item.children.forEach((v) => {
54
+ if (v.children && Array.isArray(v.children)) {
55
+ processAttrList(v.children);
46
56
  }
47
57
  });
48
- item.children = childrenObj;
49
- }
50
- } else {
51
- const attrMap = new Map(attrList.map((item2, index) => [item2.attrid, index]));
52
- for (const [fieldName, formValue] of Object.entries(allValues)) {
53
- const index = attrMap.get(fieldName);
54
- if (index === void 0)
55
- continue;
56
- const attrItem = attrList[index];
57
- if (!formValue && formValue !== 0) {
58
- attrItem.attrvalue = "";
59
- continue;
60
- }
61
- handleDealValue(attrItem, formValue);
62
58
  }
63
- attrList.forEach((item2) => {
64
- if (item2.children && Array.isArray(item2.children) && item2.children.length > 0) {
65
- processAttrList(item2.children, item2);
66
- }
67
- });
68
- }
59
+ });
69
60
  } catch (error) {
70
61
  }
71
62
  };
@@ -147,15 +138,21 @@ const handleSubmitForm = (originalData, allValues) => {
147
138
  processAttrList(updatedData.attr_list);
148
139
  }
149
140
  return {
150
- updatedData,
141
+ updatedData: handleAttrListToObj(updatedData.attr_list || []),
151
142
  uploadedFiles
152
143
  };
153
144
  };
154
145
  const processChildren = (items, extraAttrs) => {
155
146
  return items.map((item) => {
147
+ var _a, _b, _c;
156
148
  const processedItem = processItem(item, extraAttrs);
157
- if (processedItem.children && Array.isArray(processedItem.children)) {
158
- processedItem.children = processChildren(processedItem.children);
149
+ const { children } = processedItem;
150
+ if (children && !Array.isArray(children == null ? void 0 : children[0]) && (children == null ? void 0 : children.length)) {
151
+ processedItem.children = [processChildren(children)];
152
+ }
153
+ if ((processedItem == null ? void 0 : processedItem.children) && Array.isArray((_a = processedItem == null ? void 0 : processedItem.children) == null ? void 0 : _a[0]) && ((_b = processedItem == null ? void 0 : processedItem.children) == null ? void 0 : _b.length)) {
154
+ const list = (_c = processedItem == null ? void 0 : processedItem.children) == null ? void 0 : _c.map((child) => child == null ? void 0 : child.map((v) => processItem(v)));
155
+ processedItem.children = list;
159
156
  }
160
157
  return processedItem;
161
158
  });
@@ -208,13 +205,15 @@ const handleAttrList = (attrList, extraAttrs) => {
208
205
  combinations: combinationGroups[combinationId]
209
206
  }
210
207
  };
211
- if (processedItem.children && Array.isArray(processedItem.children)) {
212
- processedItem.children = filterAndCombine(processedItem.children);
208
+ const { children: children2 } = processedItem;
209
+ if (children2 && Array.isArray(children2 == null ? void 0 : children2[0]) && (children2 == null ? void 0 : children2.length)) {
210
+ processedItem.children = children2 == null ? void 0 : children2.map((child) => filterAndCombine(child));
213
211
  }
214
212
  return processedItem;
215
213
  }
216
- if (item.children && Array.isArray(item.children)) {
217
- item.children = filterAndCombine(item.children);
214
+ const { children } = item;
215
+ if (children && Array.isArray(children == null ? void 0 : children[0]) && (children == null ? void 0 : children.length)) {
216
+ item.children = children == null ? void 0 : children.map((child) => filterAndCombine(child));
218
217
  }
219
218
  return item;
220
219
  });
@@ -304,13 +303,26 @@ const handleAttrListToObj = (attrList) => {
304
303
  function processLevel(arr) {
305
304
  const result = {};
306
305
  arr.forEach((item) => {
307
- var _a2, _b;
306
+ var _a2, _b, _c, _d, _e;
308
307
  const key = `${item.attrid}_${item.attrtype}`;
309
- if (item.attrtype === 1 && item.children.length > 0) {
308
+ if (item.attrtype === 1 && item.children.length > 0 && !Array.isArray(item.children)) {
310
309
  result[key] = {
311
310
  asid: ((_b = (_a2 = item.children) == null ? void 0 : _a2[0]) == null ? void 0 : _b.asid) || "",
312
311
  data_list: [processLevel(item.children)]
313
312
  };
313
+ } else if (item.attrtype === 1 && item.children.length > 0 && Array.isArray(item.children)) {
314
+ const { attrvalue = [], children = [] } = item || {};
315
+ if (Array.isArray(attrvalue) && (attrvalue == null ? void 0 : attrvalue.length)) {
316
+ item.children = attrvalue.map((v) => {
317
+ return handleObjDetailToSignleAttrList((children == null ? void 0 : children[0]) || [], v);
318
+ });
319
+ result[key] = {
320
+ asid: ((_e = (_d = (_c = item.children) == null ? void 0 : _c[0]) == null ? void 0 : _d[0]) == null ? void 0 : _e.asid) || "",
321
+ data_list: item.children.map((child) => {
322
+ return processLevel(child);
323
+ })
324
+ };
325
+ }
314
326
  } else {
315
327
  result[key] = item.attrvalue;
316
328
  }
@@ -359,7 +371,7 @@ const handleAttrListToObjDetail = async ({
359
371
  return processedAttrList;
360
372
  })
361
373
  );
362
- return processedDetailList.length === 1 ? processedDetailList[0] : processedDetailList;
374
+ return processedDetailList || [];
363
375
  };
364
376
  const handleUrlOptions = (val, delimiter, list) => {
365
377
  let arr = [];
@@ -2,6 +2,8 @@ import { AxiosResponse } from 'axios';
2
2
  /**
3
3
  * 获取属性集列表
4
4
  * @param params
5
+ * @param commonRequest 通用请求函数
6
+ * @param interfaceType 接口类型,默认值为'SERATTALLList'
5
7
  * @returns
6
8
  */
7
9
  export declare const handleGetAttrList: (params: {
@@ -14,7 +16,11 @@ export declare const handleGetAttrList: (params: {
14
16
  * @param interfaceType 接口类型,默认值为'YLFWLRDataDetails'
15
17
  * @returns 属性集详情 {attrid_attrtype: attrvalue} 格式的数据
16
18
  */
17
- export declare const handleGetAttrDetail: (params: any, commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>, interfaceType?: string) => Promise<any>;
19
+ export declare const handleGetAttrDetail: (params: {
20
+ instanceid: string;
21
+ asid: string;
22
+ tname?: string;
23
+ }, commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>, interfaceType?: string) => Promise<any>;
18
24
  /**
19
25
  * 单层详情数据对应到单个属性集
20
26
  * @param attrList 属性集列表
@@ -1,5 +1,6 @@
1
- import { IformConfigItem } from './index.d';
1
+ import { IformConfigItem, Ijson } from './index.d';
2
2
  import { RangePickerProps } from 'antd/es/date-picker';
3
+ import { AxiosResponse } from 'axios';
3
4
  export declare const handleGetPlaceholder: (itemWithJson: IformConfigItem) => string;
4
5
  /**
5
6
  * 处理表单项目初始值
@@ -7,3 +8,28 @@ export declare const handleGetPlaceholder: (itemWithJson: IformConfigItem) => st
7
8
  */
8
9
  export declare const handleSetFormItemInitialValue: (itemWithJson: IformConfigItem) => any;
9
10
  export declare const disabledDate: RangePickerProps['disabledDate'];
11
+ /**
12
+ * 处理URL选项
13
+ * 将URL中的指定字段拼接为字符串
14
+ */
15
+ export declare const handleUrlOptions: (val: any, delimiter: string, list: any[]) => string;
16
+ /**
17
+ * 根据配置处理成下拉数据
18
+ * @param param0
19
+ * @returns
20
+ */
21
+ export declare const handleSelectOptions: ({ commonRequestWidthParams, commonRequest, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, item, }: {
22
+ commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
23
+ commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
24
+ interfaceTypeDict?: string | undefined;
25
+ interfaceTypeSysDict?: string | undefined;
26
+ actionUrlKey?: string | undefined;
27
+ actionUrlExtraParams?: object | undefined;
28
+ item: Ijson;
29
+ }) => Promise<any[]>;
30
+ /**
31
+ * attrList 格式的单层数组 处理成对象{attrid:attrname}
32
+ */
33
+ export declare const handleGetSingleAttrListObj: (children: any[]) => {
34
+ [key: string]: any;
35
+ }[];
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const dayjs = require("dayjs");
4
+ const antd = require("antd");
4
5
  const handleGetPlaceholder = (itemWithJson) => {
5
6
  const { input = "" } = itemWithJson.json || {};
6
7
  let placeholder = "请输入";
@@ -28,25 +29,16 @@ const handleGetPlaceholder = (itemWithJson) => {
28
29
  return placeholder;
29
30
  };
30
31
  const handleSetFormItemInitialValue = (itemWithJson) => {
31
- var _a, _b, _c, _d, _e;
32
+ var _a, _b, _c, _d;
32
33
  const inputType = (_a = itemWithJson.json) == null ? void 0 : _a.input;
33
- const isFormList = (_b = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _b["properties-multiple"];
34
- let initialValue = itemWithJson.attrvalue || ((_c = itemWithJson.json) == null ? void 0 : _c.default);
34
+ let initialValue = itemWithJson.attrvalue || ((_b = itemWithJson.json) == null ? void 0 : _b.default);
35
35
  if (inputType === "label" && initialValue) {
36
- initialValue = ((_d = itemWithJson.json) == null ? void 0 : _d["label-value"]) ?? initialValue ?? "-";
37
- }
38
- if ((inputType === "date-picker" || inputType === "time-picker") && initialValue) {
39
- try {
40
- const date = dayjs(initialValue);
41
- initialValue = date.isValid() ? date : void 0;
42
- } catch (error) {
43
- initialValue = void 0;
44
- }
36
+ initialValue = ((_c = itemWithJson.json) == null ? void 0 : _c["label-value"]) ?? initialValue ?? "-";
45
37
  }
46
38
  if (inputType === "range-picker" && initialValue) {
47
39
  try {
48
40
  initialValue = initialValue == null ? void 0 : initialValue.split("~");
49
- initialValue = initialValue.map((v) => dayjs(v));
41
+ initialValue = initialValue.map((v) => v);
50
42
  } catch (error) {
51
43
  initialValue = void 0;
52
44
  }
@@ -54,13 +46,13 @@ const handleSetFormItemInitialValue = (itemWithJson) => {
54
46
  if (inputType === "multiple-date-picker" && initialValue) {
55
47
  try {
56
48
  initialValue = initialValue == null ? void 0 : initialValue.split(",");
57
- initialValue = initialValue.map((v) => dayjs(v));
49
+ initialValue = initialValue.map((v) => dayjs());
58
50
  } catch (error) {
59
51
  initialValue = void 0;
60
52
  }
61
53
  }
62
54
  if (inputType === "cascader" && initialValue && typeof initialValue === "string") {
63
- const delimiter = (_e = itemWithJson.json) == null ? void 0 : _e["cascader-delimiter"];
55
+ const delimiter = (_d = itemWithJson.json) == null ? void 0 : _d["cascader-delimiter"];
64
56
  if (delimiter) {
65
57
  initialValue = initialValue.split(delimiter).filter(Boolean);
66
58
  }
@@ -81,24 +73,130 @@ const handleSetFormItemInitialValue = (itemWithJson) => {
81
73
  initialValue = [];
82
74
  }
83
75
  }
84
- if (isFormList && itemWithJson.attrtype === 1) {
85
- const children = itemWithJson.children || [];
86
- if (Array.isArray(children)) {
87
- initialValue = [
88
- Object.assign(
89
- {},
90
- ...children == null ? void 0 : children.map((child) => ({
91
- [child.attrid]: handleSetFormItemInitialValue(child)
92
- }))
93
- )
94
- ];
95
- }
76
+ if (itemWithJson.attrtype === 1) {
77
+ initialValue = handleGetSingleAttrListObj(itemWithJson.children || []);
96
78
  }
97
79
  return initialValue || null;
98
80
  };
99
81
  const disabledDate = (current) => {
100
82
  return current && current < dayjs().startOf("day");
101
83
  };
84
+ const handleUrlOptions = (val, delimiter, list) => {
85
+ let arr = [];
86
+ list.forEach((item) => {
87
+ arr.push(val == null ? void 0 : val[item]);
88
+ });
89
+ return arr.join(delimiter || "-");
90
+ };
91
+ const handleSelectOptions = async ({
92
+ commonRequestWidthParams,
93
+ commonRequest,
94
+ interfaceTypeDict = "YLZDDictList",
95
+ interfaceTypeSysDict = "YLZDSysConfigList",
96
+ actionUrlKey = "action-url",
97
+ actionUrlExtraParams = {},
98
+ item
99
+ }) => {
100
+ var _a;
101
+ let options = [];
102
+ const getDict = async (interfaceType) => {
103
+ var _a2;
104
+ let list = [];
105
+ if (item.classify) {
106
+ try {
107
+ const response = await commonRequest(interfaceType, {
108
+ asctypeid: item.classify
109
+ });
110
+ if (((_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.list) && Array.isArray(response.data.list)) {
111
+ list = response.data.list.map((dictItem) => ({
112
+ label: `${dictItem.dicid || ""}-${dictItem.info || ""}`,
113
+ value: `${dictItem.dicid || ""}-${dictItem.info || ""}`
114
+ }));
115
+ }
116
+ } catch (error) {
117
+ antd.message.error("加载选项失败");
118
+ }
119
+ }
120
+ return list;
121
+ };
122
+ const getUrlOptions = async () => {
123
+ var _a2, _b;
124
+ try {
125
+ const keyFieldList = ((_a2 = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a2.list) || [];
126
+ const delimiter = ((_b = item == null ? void 0 : item["key-field"]) == null ? void 0 : _b.delimiter) || "";
127
+ if (!keyFieldList.length) {
128
+ antd.message.error("请配置key-field");
129
+ return;
130
+ }
131
+ const response = await commonRequestWidthParams(
132
+ {
133
+ PageName: "dns_relay",
134
+ Controlname: "CallActionUrl",
135
+ InterfaceType: ""
136
+ },
137
+ {
138
+ [actionUrlKey]: item == null ? void 0 : item["action-url"],
139
+ ...actionUrlExtraParams
140
+ }
141
+ );
142
+ if (response == null ? void 0 : response.data) {
143
+ const data = response == null ? void 0 : response.data;
144
+ const list = (data == null ? void 0 : data.list) || [];
145
+ let urlData = [];
146
+ if (Array.isArray(data)) {
147
+ urlData = data;
148
+ }
149
+ if (Array.isArray(list)) {
150
+ urlData = list;
151
+ }
152
+ options = urlData.map((val) => ({
153
+ label: handleUrlOptions(val, delimiter, keyFieldList),
154
+ value: handleUrlOptions(val, delimiter, keyFieldList)
155
+ }));
156
+ }
157
+ } catch (error) {
158
+ antd.message.error("加载选项失败");
159
+ }
160
+ };
161
+ if (item.inputType === "local") {
162
+ options = ((_a = item.data) == null ? void 0 : _a.map((val) => ({
163
+ label: val,
164
+ value: val
165
+ }))) || [];
166
+ if (item.options && Array.isArray(item.options)) {
167
+ options = item.options;
168
+ }
169
+ } else if (item.inputType === "dictionary") {
170
+ options = await getDict(interfaceTypeDict);
171
+ } else if (item.inputType === "system-dictionary") {
172
+ options = await getDict(interfaceTypeSysDict);
173
+ }
174
+ if (item.inputType === "url" && (item == null ? void 0 : item["action-url"])) {
175
+ await getUrlOptions();
176
+ }
177
+ return options;
178
+ };
179
+ const handleGetSingleAttrListObj = (children) => {
180
+ if (!(children == null ? void 0 : children.length)) {
181
+ return [];
182
+ }
183
+ const dealList = (children2) => children2 == null ? void 0 : children2.map((v) => {
184
+ const obj = {};
185
+ v.forEach((x) => {
186
+ var _a;
187
+ if ((_a = x == null ? void 0 : x.children) == null ? void 0 : _a.length) {
188
+ obj[x.attrid] = dealList(x.children);
189
+ } else {
190
+ obj[x.attrid] = x.attrvalue;
191
+ }
192
+ });
193
+ return obj;
194
+ });
195
+ return dealList(children);
196
+ };
102
197
  exports.disabledDate = disabledDate;
103
198
  exports.handleGetPlaceholder = handleGetPlaceholder;
199
+ exports.handleGetSingleAttrListObj = handleGetSingleAttrListObj;
200
+ exports.handleSelectOptions = handleSelectOptions;
104
201
  exports.handleSetFormItemInitialValue = handleSetFormItemInitialValue;
202
+ exports.handleUrlOptions = handleUrlOptions;
@@ -13,7 +13,7 @@ export interface IformConfigItem {
13
13
  createtime: string;
14
14
  attrvalue: any;
15
15
  serialnum: number;
16
- children: IformConfigItem[];
16
+ children: any[];
17
17
  json: Ijson;
18
18
  }
19
19
 
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const jsxRuntime = require("react/jsx-runtime");
3
- const method = require("../../../utils/method");
3
+ const func = require("../func");
4
4
  const react = require("react");
5
5
  const antd = require("antd");
6
6
  const MySelect = ({
@@ -23,7 +23,7 @@ const MySelect = ({
23
23
  }, [item.inputType, item.classify, item.data, item.options]);
24
24
  const handleLoadOptions = async () => {
25
25
  setLoading(true);
26
- const list = await method.handleSelectOptions({
26
+ const list = await func.handleSelectOptions({
27
27
  commonRequestWidthParams,
28
28
  commonRequest,
29
29
  interfaceTypeDict,
@@ -19,6 +19,9 @@ interface IDynamicFormProps {
19
19
  setAttrList?: (config: IformConfigItem[]) => void;
20
20
  hideAttrList?: string[];
21
21
  }
22
+ type NestedFormListFieldData = FormListFieldData & {
23
+ parentName?: (string | number)[];
24
+ };
22
25
  declare function useDynamicForm(props: IDynamicFormProps): {
23
26
  handleRenderItem: ({ item, readonly, colNum, instructionShowMode, relatedid, form, defaultWidth, formItemStyle, radioAlign, isFormListItem, formListField, isShowLabel, }: {
24
27
  item: IformConfigItem;
@@ -31,7 +34,7 @@ declare function useDynamicForm(props: IDynamicFormProps): {
31
34
  formItemStyle: IformItemStyle[] | undefined;
32
35
  radioAlign?: "horizontal" | "vertical" | undefined;
33
36
  isFormListItem?: boolean | undefined;
34
- formListField?: FormListFieldData | undefined;
37
+ formListField?: NestedFormListFieldData | undefined;
35
38
  isShowLabel?: boolean | undefined;
36
39
  }) => import("react/jsx-runtime").JSX.Element | null;
37
40
  handleSetFormItemInitialValue: (itemWithJson: IformConfigItem) => any;