szld-libs 0.2.77 → 0.2.80

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,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const antd = require("antd");
3
4
  const dayjs = require("dayjs");
4
5
  const _ = require("lodash");
5
6
  function getJson(jsonStr) {
@@ -300,7 +301,7 @@ function handleKebabToCamel(str) {
300
301
  return letter.toUpperCase();
301
302
  });
302
303
  }
303
- const handleAttrListToObj = (attrList) => {
304
+ const handleAttrListToObj = (attrList, num) => {
304
305
  var _a;
305
306
  const result = {
306
307
  data: {
@@ -315,12 +316,19 @@ const handleAttrListToObj = (attrList) => {
315
316
  if (item.children && item.children.length > 0 && item.attrtype == 1) {
316
317
  attrItem[key] = {
317
318
  asid: ((_a2 = item.children[0]) == null ? void 0 : _a2.asid) || "",
318
- data_list: {}
319
+ data_list: [],
320
+ data_list_obj: {}
319
321
  };
320
322
  item.children.forEach((child) => {
321
- attrItem[key].data_list[child.attrid] = child.attrvalue || "";
323
+ attrItem[key].data_list_obj[child.attrid] = child.attrvalue || "";
322
324
  });
323
- attrItem[key].data_list = [attrItem[key].data_list];
325
+ if (num && num > 1) {
326
+ for (let i = 0; i < num; i++) {
327
+ attrItem[key].data_list.push(attrItem[key].data_list_obj);
328
+ }
329
+ } else {
330
+ attrItem[key].data_list.push(attrItem[key].data_list_obj);
331
+ }
324
332
  } else {
325
333
  attrItem[key] = item.attrvalue || "";
326
334
  }
@@ -332,13 +340,122 @@ const handleAttrListToObj = (attrList) => {
332
340
  result.data.data_list = [Object.assign({}, ...result.data.data_list)];
333
341
  return result;
334
342
  };
343
+ const handleAttrListToObjDetail = ({
344
+ attrList,
345
+ detail,
346
+ extra
347
+ }) => {
348
+ return attrList == null ? void 0 : attrList.map((v) => ({
349
+ ...v,
350
+ ...extra,
351
+ attrvalue: (detail == null ? void 0 : detail[v.attrid]) || ""
352
+ }));
353
+ };
354
+ const handleUrlOptions = (val, delimiter, list) => {
355
+ let arr = [];
356
+ list.forEach((item) => {
357
+ arr.push(val == null ? void 0 : val[item]);
358
+ });
359
+ return arr.join(delimiter || "-");
360
+ };
361
+ const handleSelectOptions = async ({
362
+ commonRequestWidthParams,
363
+ commonRequest,
364
+ interfaceTypeDict = "YLZDDictList",
365
+ interfaceTypeSysDict = "YLZDSysConfigList",
366
+ actionUrlKey = "action-url",
367
+ actionUrlExtraParams = {},
368
+ item
369
+ }) => {
370
+ var _a;
371
+ let options = [];
372
+ const getDict = async (interfaceType) => {
373
+ var _a2;
374
+ let list = [];
375
+ if (item.classify) {
376
+ try {
377
+ const response = await commonRequest(interfaceType, {
378
+ asctypeid: item.classify
379
+ });
380
+ if (((_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.list) && Array.isArray(response.data.list)) {
381
+ list = response.data.list.map((dictItem) => ({
382
+ label: `${dictItem.dicid || ""}-${dictItem.info || ""}`,
383
+ value: `${dictItem.dicid || ""}-${dictItem.info || ""}`
384
+ }));
385
+ }
386
+ } catch (error) {
387
+ antd.message.error("加载选项失败");
388
+ }
389
+ }
390
+ return list;
391
+ };
392
+ const getUrlOptions = async () => {
393
+ var _a2, _b;
394
+ try {
395
+ const keyFieldList = ((_a2 = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a2.list) || [];
396
+ const delimiter = ((_b = item == null ? void 0 : item["key-field"]) == null ? void 0 : _b.delimiter) || "";
397
+ if (!keyFieldList.length) {
398
+ antd.message.error("请配置key-field");
399
+ return;
400
+ }
401
+ const response = await commonRequestWidthParams(
402
+ {
403
+ PageName: "dns_relay",
404
+ Controlname: "CallActionUrl",
405
+ InterfaceType: ""
406
+ },
407
+ {
408
+ [actionUrlKey]: item == null ? void 0 : item["action-url"],
409
+ ...actionUrlExtraParams
410
+ }
411
+ );
412
+ if (response == null ? void 0 : response.data) {
413
+ const data = response == null ? void 0 : response.data;
414
+ const list = (data == null ? void 0 : data.list) || [];
415
+ let urlData = [];
416
+ if (Array.isArray(data)) {
417
+ urlData = data;
418
+ }
419
+ if (Array.isArray(list)) {
420
+ urlData = list;
421
+ }
422
+ options = urlData.map((val) => ({
423
+ label: handleUrlOptions(val, delimiter, keyFieldList),
424
+ value: handleUrlOptions(val, delimiter, keyFieldList)
425
+ }));
426
+ }
427
+ } catch (error) {
428
+ antd.message.error("加载选项失败");
429
+ }
430
+ };
431
+ if (item.inputType === "local") {
432
+ options = ((_a = item.data) == null ? void 0 : _a.map((val) => ({
433
+ label: val,
434
+ value: val
435
+ }))) || [];
436
+ if (item.options && Array.isArray(item.options)) {
437
+ options = item.options;
438
+ }
439
+ } else if (item.inputType === "dictionary") {
440
+ options = await getDict(interfaceTypeDict);
441
+ } else if (item.inputType === "system-dictionary") {
442
+ options = await getDict(interfaceTypeSysDict);
443
+ }
444
+ if (item.inputType === "url" && (item == null ? void 0 : item["action-url"])) {
445
+ await getUrlOptions();
446
+ }
447
+ return options;
448
+ };
335
449
  exports.base64ToString = base64ToString;
336
450
  exports.getJson = getJson;
337
451
  exports.handleAttrList = handleAttrList;
338
452
  exports.handleAttrListToObj = handleAttrListToObj;
453
+ exports.handleAttrListToObjDetail = handleAttrListToObjDetail;
339
454
  exports.handleBaseAttrList = handleBaseAttrList;
340
455
  exports.handleFormConfig = handleFormConfig;
341
456
  exports.handleKebabToCamel = handleKebabToCamel;
342
457
  exports.handleOperationFile = handleOperationFile;
458
+ exports.handleSelectOptions = handleSelectOptions;
343
459
  exports.handleSubmitForm = handleSubmitForm;
460
+ exports.handleUrlOptions = handleUrlOptions;
344
461
  exports.isBase64 = isBase64;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "szld-libs",
3
3
  "private": false,
4
- "version": "0.2.77",
4
+ "version": "0.2.80",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",