szld-libs 0.3.2 → 0.3.4

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.
@@ -33,7 +33,7 @@ const handleSubmitForm = (originalData, allValues) => {
33
33
  var _a;
34
34
  let updatedData = _.cloneDeep(originalData);
35
35
  const { attr_list = [] } = updatedData;
36
- const { isMobile = false, guid, isListToObj = false } = originalData;
36
+ const { isMobile = false, guid, isListToObj = false, isAutoFill = true } = originalData;
37
37
  let uploadedFiles = [];
38
38
  const processAttrList = (attrList, values) => {
39
39
  try {
@@ -51,14 +51,14 @@ const handleSubmitForm = (originalData, allValues) => {
51
51
  attrItem = handleDealValue(attrItem, formValue, isMobile);
52
52
  }
53
53
  attrList.forEach((item) => {
54
- if (item.children && Array.isArray(item.children) && item.children.length > 0 && !Array.isArray(item.children[0])) {
54
+ if (item.children && Array.isArray(item.children) && item.children.length > 0 && !Array.isArray(item.children[0]) && values[item.attrid]) {
55
55
  processAttrList(item.children, values[item.attrid]);
56
56
  }
57
57
  if (item.children && Array.isArray(item.children) && item.children.length > 0 && Array.isArray(item.children[0])) {
58
58
  item.children.forEach((v, i) => {
59
- var _a2;
60
- if (v && Array.isArray(v)) {
61
- processAttrList(v, (_a2 = values == null ? void 0 : values[item.attrid]) == null ? void 0 : _a2[i]);
59
+ var _a2, _b;
60
+ if (v && Array.isArray(v) && ((_a2 = values == null ? void 0 : values[item.attrid]) == null ? void 0 : _a2[i])) {
61
+ processAttrList(v, (_b = values == null ? void 0 : values[item.attrid]) == null ? void 0 : _b[i]);
62
62
  }
63
63
  });
64
64
  }
@@ -160,20 +160,22 @@ const handleSubmitForm = (originalData, allValues) => {
160
160
  if (updatedData.attr_list && Array.isArray(updatedData.attr_list)) {
161
161
  processAttrList(attr_list, allValues);
162
162
  }
163
- (_a = updatedData == null ? void 0 : updatedData.attr_list) == null ? void 0 : _a.forEach((v) => {
164
- var _a2, _b, _c, _d, _e, _f;
165
- if (((_a2 = v == null ? void 0 : v.json) == null ? void 0 : _a2["auto-generate"]) && ((_b = v == null ? void 0 : v.json) == null ? void 0 : _b["auto-generate-type"])) {
166
- if (((_c = v == null ? void 0 : v.json) == null ? void 0 : _c["auto-generate-type"]) === "currenttime") {
167
- v.attrvalue = dayjs().format("YYYY-MM-DD HH:mm:ss");
163
+ if (isAutoFill) {
164
+ (_a = updatedData == null ? void 0 : updatedData.attr_list) == null ? void 0 : _a.forEach((v) => {
165
+ var _a2, _b, _c, _d, _e, _f;
166
+ if (((_a2 = v == null ? void 0 : v.json) == null ? void 0 : _a2["auto-generate"]) && ((_b = v == null ? void 0 : v.json) == null ? void 0 : _b["auto-generate-type"])) {
167
+ if (((_c = v == null ? void 0 : v.json) == null ? void 0 : _c["auto-generate-type"]) === "currenttime") {
168
+ v.attrvalue = dayjs().format("YYYY-MM-DD HH:mm:ss");
169
+ }
170
+ if (((_d = v == null ? void 0 : v.json) == null ? void 0 : _d["auto-generate-type"]) === "guid") {
171
+ v.attrvalue = guid || "";
172
+ }
168
173
  }
169
- if (((_d = v == null ? void 0 : v.json) == null ? void 0 : _d["auto-generate-type"]) === "guid") {
170
- v.attrvalue = guid || "";
174
+ if ((_e = v == null ? void 0 : v.json) == null ? void 0 : _e["default"]) {
175
+ v.attrvalue = (_f = v == null ? void 0 : v.json) == null ? void 0 : _f["default"];
171
176
  }
172
- }
173
- if ((_e = v == null ? void 0 : v.json) == null ? void 0 : _e["default"]) {
174
- v.attrvalue = (_f = v == null ? void 0 : v.json) == null ? void 0 : _f["default"];
175
- }
176
- });
177
+ });
178
+ }
177
179
  return {
178
180
  updatedData: isListToObj ? handleAttrListToObj(updatedData.attr_list || []) : updatedData,
179
181
  uploadedFiles
@@ -343,7 +345,7 @@ const handleAttrListToObj = (attrList) => {
343
345
  function processLevel(arr) {
344
346
  const result = {};
345
347
  arr.forEach((item) => {
346
- var _a2, _b, _c, _d, _e;
348
+ var _a2, _b, _c, _d;
347
349
  const key = `${item.attrid}_${item.attrtype}`;
348
350
  if (item.attrtype === 1 && item.children.length > 0 && !Array.isArray(item.children)) {
349
351
  result[key] = {
@@ -351,11 +353,35 @@ const handleAttrListToObj = (attrList) => {
351
353
  data_list: [processLevel(item.children)]
352
354
  };
353
355
  } else if (item.attrtype === 1 && item.children.length > 0 && Array.isArray(item.children)) {
354
- const { children = [] } = item || {};
356
+ let { children = [], attrvalue } = item || {};
357
+ if (attrvalue && (attrvalue == null ? void 0 : attrvalue.length) && Array.isArray(attrvalue)) {
358
+ children = attrvalue.map((v) => {
359
+ var _a3, _b2, _c2, _d2;
360
+ const index = (_a3 = Object.values(v)) == null ? void 0 : _a3.findIndex((y) => Array.isArray(y));
361
+ const uploadAttrId = ((_b2 = Object.keys(v)) == null ? void 0 : _b2[index]) || "";
362
+ if (uploadAttrId) {
363
+ const uploadAttrItem = ((_c2 = children == null ? void 0 : children[0]) == null ? void 0 : _c2.find((z) => z.attrid === uploadAttrId)) || {};
364
+ const { input } = (uploadAttrItem == null ? void 0 : uploadAttrItem.json) || {};
365
+ if (["file", "image", "video", "audio"].includes(input)) {
366
+ const parsedValue = ((_d2 = Object.values(v)) == null ? void 0 : _d2[index]) || [];
367
+ const existingFiles = parsedValue.filter((file) => file.FileId);
368
+ const uploadedFileList = parsedValue.filter((file) => {
369
+ var _a4;
370
+ return file.status === "done" && ((_a4 = file.response) == null ? void 0 : _a4.data);
371
+ }).map((file) => file.response.data);
372
+ const allFiles = [...existingFiles, ...uploadedFileList];
373
+ v[uploadAttrId] = allFiles;
374
+ }
375
+ }
376
+ return handleObjDetailToSignleAttrList((children == null ? void 0 : children[0]) || [], v);
377
+ });
378
+ } else {
379
+ children = [];
380
+ }
355
381
  if ((children == null ? void 0 : children.length) && Array.isArray(children == null ? void 0 : children[0])) {
356
382
  result[key] = {
357
- asid: ((_e = (_d = (_c = item.children) == null ? void 0 : _c[0]) == null ? void 0 : _d[0]) == null ? void 0 : _e.asid) || "",
358
- data_list: item.children.map((child) => {
383
+ asid: ((_d = (_c = children == null ? void 0 : children[0]) == null ? void 0 : _c[0]) == null ? void 0 : _d.asid) || "",
384
+ data_list: children.map((child) => {
359
385
  return processLevel(child);
360
386
  })
361
387
  };
@@ -505,6 +531,12 @@ const handleSelectOptions = async ({
505
531
  }
506
532
  return options;
507
533
  };
534
+ const handleObjDetailToSignleAttrList = (attrList, detail) => {
535
+ return attrList.map((item) => ({
536
+ ...item,
537
+ attrvalue: detail[item.attrid] || ""
538
+ }));
539
+ };
508
540
  exports.base64ToString = base64ToString;
509
541
  exports.getJson = getJson;
510
542
  exports.handleAttrList = handleAttrList;
@@ -513,6 +545,7 @@ exports.handleAttrListToObjDetail = handleAttrListToObjDetail;
513
545
  exports.handleBaseAttrList = handleBaseAttrList;
514
546
  exports.handleFormConfig = handleFormConfig;
515
547
  exports.handleKebabToCamel = handleKebabToCamel;
548
+ exports.handleObjDetailToSignleAttrList = handleObjDetailToSignleAttrList;
516
549
  exports.handleOperationFile = handleOperationFile;
517
550
  exports.handleSelectOptions = handleSelectOptions;
518
551
  exports.handleSubmitForm = handleSubmitForm;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "szld-libs",
3
3
  "private": false,
4
- "version": "0.3.2",
4
+ "version": "0.3.4",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",