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.
- package/dist/szld-components.es.js +12467 -12424
- package/dist/szld-components.umd.js +52 -52
- package/es/components/DynamicForm/func.d.ts +27 -1
- package/es/components/DynamicForm/func.js +126 -28
- package/es/components/DynamicForm/index.d.ts +1 -1
- package/es/components/DynamicForm/mySelect/index.js +1 -1
- package/es/components/DynamicForm/useDynamicForm.d.ts +4 -1
- package/es/components/DynamicForm/useDynamicForm.js +110 -132
- package/es/utils/method.d.ts +8 -3
- package/es/utils/method.js +54 -42
- package/es/utils/szxkFunc.d.ts +7 -1
- package/lib/components/DynamicForm/func.d.ts +27 -1
- package/lib/components/DynamicForm/func.js +125 -27
- package/lib/components/DynamicForm/index.d.ts +1 -1
- package/lib/components/DynamicForm/mySelect/index.js +2 -2
- package/lib/components/DynamicForm/useDynamicForm.d.ts +4 -1
- package/lib/components/DynamicForm/useDynamicForm.js +104 -126
- package/lib/utils/method.d.ts +8 -3
- package/lib/utils/method.js +54 -42
- package/lib/utils/szxkFunc.d.ts +7 -1
- package/package.json +1 -1
|
@@ -12,7 +12,6 @@ const RadioCard = require("./radioCard");
|
|
|
12
12
|
const MySelect = require("./mySelect");
|
|
13
13
|
const MyUpload = require("./myUpload");
|
|
14
14
|
const MyRadio = require("./myRadio");
|
|
15
|
-
const _ = require("lodash");
|
|
16
15
|
const icons = require("@ant-design/icons");
|
|
17
16
|
const antd = require("antd");
|
|
18
17
|
dayjs.extend(isoWeek);
|
|
@@ -152,7 +151,7 @@ function useDynamicForm(props) {
|
|
|
152
151
|
) }) || /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: ((_d = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _d["instruction-color"]) ?? "red" }, children: (_e = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _e.instruction })
|
|
153
152
|
] });
|
|
154
153
|
};
|
|
155
|
-
const
|
|
154
|
+
const renderNestedFormList = react.useCallback(
|
|
156
155
|
({
|
|
157
156
|
itemWithJson,
|
|
158
157
|
colNum = 1,
|
|
@@ -163,80 +162,67 @@ function useDynamicForm(props) {
|
|
|
163
162
|
relatedid,
|
|
164
163
|
form,
|
|
165
164
|
defaultWidth = 358,
|
|
166
|
-
|
|
167
|
-
formListField,
|
|
165
|
+
parentFormListField,
|
|
168
166
|
isShowLabel = true
|
|
169
167
|
}) => {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
formListInitValue = func.handleSetFormItemInitialValue(itemWithJson);
|
|
168
|
+
const formListInitValue = func.handleSetFormItemInitialValue(itemWithJson);
|
|
169
|
+
let children = itemWithJson.children || [];
|
|
170
|
+
if (Array.isArray(children == null ? void 0 : children[0]) && children.length) {
|
|
171
|
+
children = children[0];
|
|
175
172
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const list = ((_b2 = res == null ? void 0 : res.data) == null ? void 0 : _b2.list) || [];
|
|
198
|
-
const arr = method.handleAttrList(list, { instanceid: relatedid, tname: itemWithJson.tname });
|
|
199
|
-
const _formConfig = _.cloneDeep(formConfigRef.current);
|
|
200
|
-
const _item = _formConfig.find((item) => item.attrid === itemWithJson.attrid);
|
|
201
|
-
if (_item) {
|
|
202
|
-
_item.children = [...arr];
|
|
203
|
-
}
|
|
204
|
-
setFormConfig == null ? void 0 : setFormConfig(_formConfig);
|
|
205
|
-
setAttrList == null ? void 0 : setAttrList(_formConfig);
|
|
206
|
-
}
|
|
173
|
+
const getFormListName = (field) => {
|
|
174
|
+
const parentPath = (parentFormListField == null ? void 0 : parentFormListField.parentName) || (parentFormListField == null ? void 0 : parentFormListField.name);
|
|
175
|
+
if (parentPath) {
|
|
176
|
+
return Array.isArray(parentPath) ? [...parentPath, itemWithJson.attrid, field.name] : [parentPath, itemWithJson.attrid, field.name];
|
|
177
|
+
}
|
|
178
|
+
return [itemWithJson.attrid, field.name];
|
|
179
|
+
};
|
|
180
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24 / colNum, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
181
|
+
antd.Collapse,
|
|
182
|
+
{
|
|
183
|
+
bordered: false,
|
|
184
|
+
defaultActiveKey: [itemWithJson.attrid],
|
|
185
|
+
style: { backgroundColor: "transparent" },
|
|
186
|
+
expandIcon: ({ isActive }) => handleCollapseIcon({ isActive }),
|
|
187
|
+
items: [
|
|
188
|
+
{
|
|
189
|
+
key: itemWithJson.attrid,
|
|
190
|
+
label: itemWithJson.attrname,
|
|
191
|
+
styles: {
|
|
192
|
+
header: {
|
|
193
|
+
paddingLeft: 0
|
|
207
194
|
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
styles: {
|
|
216
|
-
header: {
|
|
217
|
-
paddingLeft: 0
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
children: isFormList ? /* @__PURE__ */ jsxRuntime.jsx(antd.Form.List, { name: itemWithJson.attrid, initialValue: formListInitValue, children: (fields, { add, remove }) => {
|
|
221
|
-
var _a2;
|
|
222
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", rowGap: 16, flexDirection: "column" }, children: [
|
|
195
|
+
},
|
|
196
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
197
|
+
antd.Form.List,
|
|
198
|
+
{
|
|
199
|
+
name: parentFormListField ? Array.isArray(parentFormListField.name) ? [...parentFormListField.name, itemWithJson.attrid] : [parentFormListField.name, itemWithJson.attrid] : itemWithJson.attrid,
|
|
200
|
+
initialValue: formListInitValue,
|
|
201
|
+
children: (fields, { add, remove }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", rowGap: 16, flexDirection: "column" }, children: [
|
|
223
202
|
fields.map((field) => {
|
|
224
|
-
|
|
203
|
+
const nestedField = {
|
|
204
|
+
...field,
|
|
205
|
+
parentName: getFormListName(field)
|
|
206
|
+
};
|
|
225
207
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
226
208
|
antd.Card,
|
|
227
209
|
{
|
|
228
|
-
style: { width:
|
|
210
|
+
style: { width: defaultWidth + 100 },
|
|
229
211
|
size: "small",
|
|
230
212
|
title: `${itemWithJson.attrname} ${field.name + 1}`,
|
|
231
213
|
extra: /* @__PURE__ */ jsxRuntime.jsx(
|
|
232
214
|
icons.CloseOutlined,
|
|
233
215
|
{
|
|
234
216
|
onClick: () => {
|
|
235
|
-
|
|
217
|
+
if (fields.length > 1) {
|
|
218
|
+
remove(field.name);
|
|
219
|
+
} else {
|
|
220
|
+
message.warning("至少需要保留一个!");
|
|
221
|
+
}
|
|
236
222
|
}
|
|
237
223
|
}
|
|
238
224
|
),
|
|
239
|
-
children: (
|
|
225
|
+
children: (children || []).map((child, index) => {
|
|
240
226
|
return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: handleRenderItem({
|
|
241
227
|
item: child,
|
|
242
228
|
readonly,
|
|
@@ -246,8 +232,9 @@ function useDynamicForm(props) {
|
|
|
246
232
|
form,
|
|
247
233
|
defaultWidth,
|
|
248
234
|
formItemStyle,
|
|
235
|
+
radioAlign,
|
|
249
236
|
isFormListItem: true,
|
|
250
|
-
formListField:
|
|
237
|
+
formListField: nestedField,
|
|
251
238
|
isShowLabel: true
|
|
252
239
|
}) }, child.attrid || `child-${index}`);
|
|
253
240
|
})
|
|
@@ -255,40 +242,66 @@ function useDynamicForm(props) {
|
|
|
255
242
|
field.key
|
|
256
243
|
);
|
|
257
244
|
}),
|
|
258
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { style: { width:
|
|
259
|
-
] })
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
245
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { style: { width: 200 }, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "dashed", onClick: () => add(), block: true, children: "+ 新增" }) })
|
|
246
|
+
] })
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
itemWithJson.attrid
|
|
253
|
+
) });
|
|
254
|
+
},
|
|
255
|
+
[handleCollapseIcon, func.handleSetFormItemInitialValue]
|
|
256
|
+
);
|
|
257
|
+
const handleRenderFunc = react.useCallback(
|
|
258
|
+
({
|
|
259
|
+
itemWithJson,
|
|
260
|
+
colNum = 1,
|
|
261
|
+
readonly = false,
|
|
262
|
+
instructionShowMode = "icon",
|
|
263
|
+
radioAlign = "horizontal",
|
|
264
|
+
formItemStyle,
|
|
265
|
+
relatedid,
|
|
266
|
+
form,
|
|
267
|
+
defaultWidth = 358,
|
|
268
|
+
isFormListItem = false,
|
|
269
|
+
formListField,
|
|
270
|
+
isShowLabel = true
|
|
271
|
+
}) => {
|
|
272
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
273
|
+
if (((_a = itemWithJson.json) == null ? void 0 : _a.hide) === true || (hideAttrList == null ? void 0 : hideAttrList.includes(itemWithJson.attrid))) {
|
|
274
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
275
|
+
}
|
|
276
|
+
if (itemWithJson.attrtype === 1) {
|
|
277
|
+
return renderNestedFormList({
|
|
278
|
+
itemWithJson,
|
|
279
|
+
colNum,
|
|
280
|
+
readonly,
|
|
281
|
+
instructionShowMode,
|
|
282
|
+
radioAlign,
|
|
283
|
+
formItemStyle,
|
|
284
|
+
relatedid,
|
|
285
|
+
form,
|
|
286
|
+
defaultWidth,
|
|
287
|
+
parentFormListField: formListField,
|
|
288
|
+
isShowLabel
|
|
289
|
+
});
|
|
277
290
|
}
|
|
278
291
|
if (itemWithJson.attrtype === 2) {
|
|
279
292
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: "实例信息" });
|
|
280
293
|
}
|
|
281
294
|
if (itemWithJson.attrtype === 0) {
|
|
282
|
-
|
|
283
|
-
const message2 = (
|
|
295
|
+
const initialValue = func.handleSetFormItemInitialValue(itemWithJson);
|
|
296
|
+
const message2 = (_b = itemWithJson.json) == null ? void 0 : _b["default-prompt"];
|
|
284
297
|
const placeholder = func.handleGetPlaceholder(itemWithJson);
|
|
285
298
|
const { combinations = [] } = itemWithJson.json || {};
|
|
286
299
|
if (combinations == null ? void 0 : combinations.length) {
|
|
287
300
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24 / colNum, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
288
301
|
antd.Form.Item,
|
|
289
302
|
{
|
|
290
|
-
label: (
|
|
291
|
-
required: (
|
|
303
|
+
label: (_c = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _c["combination-name"],
|
|
304
|
+
required: (_d = itemWithJson.json) == null ? void 0 : _d.must,
|
|
292
305
|
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Space.Compact, { children: combinations.map((item, index) => {
|
|
293
306
|
var _a2, _b2, _c2, _d2;
|
|
294
307
|
let initValue = func.handleSetFormItemInitialValue(item);
|
|
@@ -303,21 +316,20 @@ function useDynamicForm(props) {
|
|
|
303
316
|
}
|
|
304
317
|
}
|
|
305
318
|
const widthRatio = (_a2 = item == null ? void 0 : item.json) == null ? void 0 : _a2["combination-width-ratio"];
|
|
306
|
-
const placeholder2 = func.handleGetPlaceholder(item);
|
|
307
319
|
if (widthRatio) {
|
|
308
320
|
width = defaultWidth * widthRatio;
|
|
309
321
|
}
|
|
310
322
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
311
323
|
antd.Form.Item,
|
|
312
324
|
{
|
|
313
|
-
name: item.attrid,
|
|
325
|
+
name: formListField ? Array.isArray(formListField.name) ? [...formListField.name, item.attrid] : [formListField.name, item.attrid] : item.attrid,
|
|
314
326
|
noStyle: true,
|
|
315
327
|
initialValue: initValue,
|
|
316
328
|
rules: [
|
|
317
329
|
...((_b2 = item.json) == null ? void 0 : _b2.must) ? [
|
|
318
330
|
{
|
|
319
331
|
required: true,
|
|
320
|
-
message: message2 || `${
|
|
332
|
+
message: message2 || `${placeholder}${item.attrname}`
|
|
321
333
|
}
|
|
322
334
|
] : [],
|
|
323
335
|
...((_c2 = itemWithJson.json) == null ? void 0 : _c2.regexp) ? [
|
|
@@ -346,58 +358,24 @@ function useDynamicForm(props) {
|
|
|
346
358
|
`${itemWithJson.attrid}+1`
|
|
347
359
|
) });
|
|
348
360
|
}
|
|
349
|
-
|
|
350
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24 / colNum, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
351
|
-
antd.Form.Item,
|
|
352
|
-
{
|
|
353
|
-
name: [formListField == null ? void 0 : formListField.name, itemWithJson.attrid],
|
|
354
|
-
label: isShowLabel && handleDealInstruction(itemWithJson, instructionShowMode) || null,
|
|
355
|
-
initialValue,
|
|
356
|
-
rules: [
|
|
357
|
-
...((_f = itemWithJson.json) == null ? void 0 : _f.must) ? [
|
|
358
|
-
{
|
|
359
|
-
required: true,
|
|
360
|
-
message: `${placeholder}${itemWithJson.attrname}`
|
|
361
|
-
}
|
|
362
|
-
] : [],
|
|
363
|
-
...((_g = itemWithJson.json) == null ? void 0 : _g.regexp) ? [
|
|
364
|
-
{
|
|
365
|
-
pattern: new RegExp(itemWithJson.json.regexp.replace(/^\/|\/$/g, "")),
|
|
366
|
-
message: ((_h = itemWithJson.json) == null ? void 0 : _h["regexp-message"]) || `${itemWithJson.attrname}格式不正确`
|
|
367
|
-
}
|
|
368
|
-
] : []
|
|
369
|
-
],
|
|
370
|
-
...handleSetFormItemProps(itemWithJson),
|
|
371
|
-
children: handleRenderItemInputMode({
|
|
372
|
-
item: itemWithJson,
|
|
373
|
-
readonly,
|
|
374
|
-
formItemStyle,
|
|
375
|
-
radioAlign,
|
|
376
|
-
relatedid,
|
|
377
|
-
form,
|
|
378
|
-
defaultWidth
|
|
379
|
-
})
|
|
380
|
-
},
|
|
381
|
-
itemWithJson.attrid
|
|
382
|
-
) });
|
|
383
|
-
}
|
|
361
|
+
const formItemName = isFormListItem && formListField ? Array.isArray(formListField.name) ? [...formListField.name, itemWithJson.attrid] : [formListField.name, itemWithJson.attrid] : itemWithJson.attrid;
|
|
384
362
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24 / colNum, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
385
363
|
antd.Form.Item,
|
|
386
364
|
{
|
|
387
|
-
name:
|
|
365
|
+
name: formItemName,
|
|
388
366
|
label: isShowLabel && handleDealInstruction(itemWithJson, instructionShowMode) || null,
|
|
389
367
|
initialValue,
|
|
390
368
|
rules: [
|
|
391
|
-
...((
|
|
369
|
+
...((_e = itemWithJson.json) == null ? void 0 : _e.must) ? [
|
|
392
370
|
{
|
|
393
371
|
required: true,
|
|
394
372
|
message: `${placeholder}${itemWithJson.attrname}`
|
|
395
373
|
}
|
|
396
374
|
] : [],
|
|
397
|
-
...((
|
|
375
|
+
...((_f = itemWithJson.json) == null ? void 0 : _f.regexp) ? [
|
|
398
376
|
{
|
|
399
377
|
pattern: new RegExp(itemWithJson.json.regexp.replace(/^\/|\/$/g, "")),
|
|
400
|
-
message: ((
|
|
378
|
+
message: ((_g = itemWithJson.json) == null ? void 0 : _g["regexp-message"]) || `${itemWithJson.attrname}格式不正确`
|
|
401
379
|
}
|
|
402
380
|
] : []
|
|
403
381
|
],
|
|
@@ -417,7 +395,7 @@ function useDynamicForm(props) {
|
|
|
417
395
|
}
|
|
418
396
|
return null;
|
|
419
397
|
},
|
|
420
|
-
[
|
|
398
|
+
[handleDealInstruction, func.handleSetFormItemInitialValue, handleSetFormItemProps, hideAttrList, renderNestedFormList]
|
|
421
399
|
);
|
|
422
400
|
const handleOnRemove = async (file) => {
|
|
423
401
|
var _a;
|
package/lib/utils/method.d.ts
CHANGED
|
@@ -10,7 +10,12 @@ export declare function isBase64(str: string): boolean;
|
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
12
|
export declare const handleSubmitForm: (originalData: any, allValues: any) => {
|
|
13
|
-
updatedData:
|
|
13
|
+
updatedData: {
|
|
14
|
+
data: {
|
|
15
|
+
asid: any;
|
|
16
|
+
data_list: any[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
14
19
|
uploadedFiles: any[];
|
|
15
20
|
};
|
|
16
21
|
/**
|
|
@@ -69,7 +74,7 @@ export declare const handleOperationFile: (params: any, data: any, commonRequest
|
|
|
69
74
|
*/
|
|
70
75
|
export declare function handleKebabToCamel(str: string): string;
|
|
71
76
|
/**
|
|
72
|
-
*
|
|
77
|
+
* 处理属性列表为接口提交格式(修复children的data_list为空问题)
|
|
73
78
|
* @param {Array} attrList 原始属性列表
|
|
74
79
|
* @returns {Object} 目标格式的data对象
|
|
75
80
|
*/
|
|
@@ -94,7 +99,7 @@ export declare const handleAttrListToObjDetail: ({ attrList, params, extra, comm
|
|
|
94
99
|
[key: string]: any;
|
|
95
100
|
} | undefined;
|
|
96
101
|
commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
97
|
-
}) => Promise<any>;
|
|
102
|
+
}) => Promise<any[]>;
|
|
98
103
|
/**
|
|
99
104
|
* 处理URL选项 根据远程接口获取下拉、单选、多选数据
|
|
100
105
|
* 将URL中的指定字段拼接为字符串
|
package/lib/utils/method.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const antd = require("antd");
|
|
4
4
|
const dayjs = require("dayjs");
|
|
5
5
|
const _ = require("lodash");
|
|
6
|
+
const szxkFunc = require("./szxkFunc");
|
|
6
7
|
function getJson(jsonStr) {
|
|
7
8
|
try {
|
|
8
9
|
return JSON.parse(jsonStr);
|
|
@@ -32,42 +33,32 @@ function isBase64(str) {
|
|
|
32
33
|
const handleSubmitForm = (originalData, allValues) => {
|
|
33
34
|
let updatedData = _.cloneDeep(originalData);
|
|
34
35
|
let uploadedFiles = [];
|
|
35
|
-
const processAttrList = (attrList
|
|
36
|
-
var _a;
|
|
36
|
+
const processAttrList = (attrList) => {
|
|
37
37
|
try {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
const attrMap = new Map(attrList.map((item, index) => [item.attrid, index]));
|
|
39
|
+
for (const [fieldName, formValue] of Object.entries(allValues)) {
|
|
40
|
+
const index = attrMap.get(fieldName);
|
|
41
|
+
if (index === void 0)
|
|
42
|
+
continue;
|
|
43
|
+
const attrItem = attrList[index];
|
|
44
|
+
if (!formValue && formValue !== 0) {
|
|
45
|
+
attrItem.attrvalue = "";
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
handleDealValue(attrItem, formValue);
|
|
49
|
+
}
|
|
50
|
+
attrList.forEach((item) => {
|
|
51
|
+
if (item.children && Array.isArray(item.children) && item.children.length > 0 && !Array.isArray(item.children[0])) {
|
|
52
|
+
processAttrList(item.children);
|
|
53
|
+
}
|
|
54
|
+
if (item.children && Array.isArray(item.children) && item.children.length > 0 && Array.isArray(item.children[0])) {
|
|
55
|
+
item.children.forEach((v) => {
|
|
56
|
+
if (v.children && Array.isArray(v.children)) {
|
|
57
|
+
processAttrList(v.children);
|
|
48
58
|
}
|
|
49
59
|
});
|
|
50
|
-
item.children = childrenObj;
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
const attrMap = new Map(attrList.map((item2, index) => [item2.attrid, index]));
|
|
54
|
-
for (const [fieldName, formValue] of Object.entries(allValues)) {
|
|
55
|
-
const index = attrMap.get(fieldName);
|
|
56
|
-
if (index === void 0)
|
|
57
|
-
continue;
|
|
58
|
-
const attrItem = attrList[index];
|
|
59
|
-
if (!formValue && formValue !== 0) {
|
|
60
|
-
attrItem.attrvalue = "";
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
handleDealValue(attrItem, formValue);
|
|
64
60
|
}
|
|
65
|
-
|
|
66
|
-
if (item2.children && Array.isArray(item2.children) && item2.children.length > 0) {
|
|
67
|
-
processAttrList(item2.children, item2);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
61
|
+
});
|
|
71
62
|
} catch (error) {
|
|
72
63
|
}
|
|
73
64
|
};
|
|
@@ -149,15 +140,21 @@ const handleSubmitForm = (originalData, allValues) => {
|
|
|
149
140
|
processAttrList(updatedData.attr_list);
|
|
150
141
|
}
|
|
151
142
|
return {
|
|
152
|
-
updatedData,
|
|
143
|
+
updatedData: handleAttrListToObj(updatedData.attr_list || []),
|
|
153
144
|
uploadedFiles
|
|
154
145
|
};
|
|
155
146
|
};
|
|
156
147
|
const processChildren = (items, extraAttrs) => {
|
|
157
148
|
return items.map((item) => {
|
|
149
|
+
var _a, _b, _c;
|
|
158
150
|
const processedItem = processItem(item, extraAttrs);
|
|
159
|
-
|
|
160
|
-
|
|
151
|
+
const { children } = processedItem;
|
|
152
|
+
if (children && !Array.isArray(children == null ? void 0 : children[0]) && (children == null ? void 0 : children.length)) {
|
|
153
|
+
processedItem.children = [processChildren(children)];
|
|
154
|
+
}
|
|
155
|
+
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)) {
|
|
156
|
+
const list = (_c = processedItem == null ? void 0 : processedItem.children) == null ? void 0 : _c.map((child) => child == null ? void 0 : child.map((v) => processItem(v)));
|
|
157
|
+
processedItem.children = list;
|
|
161
158
|
}
|
|
162
159
|
return processedItem;
|
|
163
160
|
});
|
|
@@ -210,13 +207,15 @@ const handleAttrList = (attrList, extraAttrs) => {
|
|
|
210
207
|
combinations: combinationGroups[combinationId]
|
|
211
208
|
}
|
|
212
209
|
};
|
|
213
|
-
|
|
214
|
-
|
|
210
|
+
const { children: children2 } = processedItem;
|
|
211
|
+
if (children2 && Array.isArray(children2 == null ? void 0 : children2[0]) && (children2 == null ? void 0 : children2.length)) {
|
|
212
|
+
processedItem.children = children2 == null ? void 0 : children2.map((child) => filterAndCombine(child));
|
|
215
213
|
}
|
|
216
214
|
return processedItem;
|
|
217
215
|
}
|
|
218
|
-
|
|
219
|
-
|
|
216
|
+
const { children } = item;
|
|
217
|
+
if (children && Array.isArray(children == null ? void 0 : children[0]) && (children == null ? void 0 : children.length)) {
|
|
218
|
+
item.children = children == null ? void 0 : children.map((child) => filterAndCombine(child));
|
|
220
219
|
}
|
|
221
220
|
return item;
|
|
222
221
|
});
|
|
@@ -306,13 +305,26 @@ const handleAttrListToObj = (attrList) => {
|
|
|
306
305
|
function processLevel(arr) {
|
|
307
306
|
const result = {};
|
|
308
307
|
arr.forEach((item) => {
|
|
309
|
-
var _a2, _b;
|
|
308
|
+
var _a2, _b, _c, _d, _e;
|
|
310
309
|
const key = `${item.attrid}_${item.attrtype}`;
|
|
311
|
-
if (item.attrtype === 1 && item.children.length > 0) {
|
|
310
|
+
if (item.attrtype === 1 && item.children.length > 0 && !Array.isArray(item.children)) {
|
|
312
311
|
result[key] = {
|
|
313
312
|
asid: ((_b = (_a2 = item.children) == null ? void 0 : _a2[0]) == null ? void 0 : _b.asid) || "",
|
|
314
313
|
data_list: [processLevel(item.children)]
|
|
315
314
|
};
|
|
315
|
+
} else if (item.attrtype === 1 && item.children.length > 0 && Array.isArray(item.children)) {
|
|
316
|
+
const { attrvalue = [], children = [] } = item || {};
|
|
317
|
+
if (Array.isArray(attrvalue) && (attrvalue == null ? void 0 : attrvalue.length)) {
|
|
318
|
+
item.children = attrvalue.map((v) => {
|
|
319
|
+
return szxkFunc.handleObjDetailToSignleAttrList((children == null ? void 0 : children[0]) || [], v);
|
|
320
|
+
});
|
|
321
|
+
result[key] = {
|
|
322
|
+
asid: ((_e = (_d = (_c = item.children) == null ? void 0 : _c[0]) == null ? void 0 : _d[0]) == null ? void 0 : _e.asid) || "",
|
|
323
|
+
data_list: item.children.map((child) => {
|
|
324
|
+
return processLevel(child);
|
|
325
|
+
})
|
|
326
|
+
};
|
|
327
|
+
}
|
|
316
328
|
} else {
|
|
317
329
|
result[key] = item.attrvalue;
|
|
318
330
|
}
|
|
@@ -361,7 +373,7 @@ const handleAttrListToObjDetail = async ({
|
|
|
361
373
|
return processedAttrList;
|
|
362
374
|
})
|
|
363
375
|
);
|
|
364
|
-
return processedDetailList
|
|
376
|
+
return processedDetailList || [];
|
|
365
377
|
};
|
|
366
378
|
const handleUrlOptions = (val, delimiter, list) => {
|
|
367
379
|
let arr = [];
|
package/lib/utils/szxkFunc.d.ts
CHANGED
|
@@ -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:
|
|
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 属性集列表
|