szld-libs 0.2.78 → 0.2.81

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