bxs-tools-ui 3.1.3 → 3.2.0-0

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/es/utils/index.js CHANGED
@@ -14,6 +14,14 @@ function _typeof$1(o) {
14
14
  }, _typeof$1(o);
15
15
  }
16
16
 
17
+ var enableLizhaoDebug = document && document.cookie && document.cookie.match('ENABLE_LIZHAO_DEBUG=1');
18
+ function consoleLogWhenEnable() {
19
+ if (enableLizhaoDebug) {
20
+ var _console;
21
+ (_console = console).log.apply(_console, arguments);
22
+ }
23
+ }
24
+
17
25
  /**
18
26
  * **将对象下的 eleOrderList 数组中的子元素下的 value,转换为 key-value 键值对**
19
27
  * @author Lizhao <lz@winbaoxian.com>
@@ -276,6 +284,167 @@ function textOverflowEllipsis(str, n) {
276
284
  }
277
285
  return text;
278
286
  }
287
+ function getExpressionParamMap(personData, product, ins, options) {
288
+ var map = {
289
+ planbookId: null,
290
+ // 计划书id
291
+ productId: null,
292
+ // 产品id
293
+ insured: {},
294
+ // 被保人
295
+ insured2: {},
296
+ // 第二被保人
297
+ applicant: {},
298
+ // 投保人
299
+ recipient: {},
300
+ // 收件人
301
+ p: {},
302
+ // 当前产品
303
+ m: {},
304
+ // 主险
305
+ me: {},
306
+ // 当前险种
307
+ common: {},
308
+ // 通用信息
309
+ customVariable: null,
310
+ // 自定义变量
311
+ cv: null // 简写,自定义变量
312
+ };
313
+ if (personData) {
314
+ var insuredInfo = (personData.personOrderList || []).find(function (p) {
315
+ return p.key === 'insuredInfo';
316
+ });
317
+ var insured2Info = (personData.personOrderList || []).find(function (p) {
318
+ return p.key === 'insured2Info';
319
+ });
320
+ var applicantInfo = (personData.personOrderList || []).find(function (p) {
321
+ return p.key === 'applicantInfo';
322
+ });
323
+ var recipientInfo = personData !== null && personData !== void 0 && personData.recipientInfo ? personData.recipientInfo : null;
324
+ map.insured = insuredInfo ? convertEleOrderListToObj(insuredInfo) : {};
325
+ map.insured2 = insured2Info ? convertEleOrderListToObj(insured2Info) : {};
326
+ map.applicant = applicantInfo ? convertEleOrderListToObj(applicantInfo) : {};
327
+ map.recipient = recipientInfo ? convertEleOrderListToObj(recipientInfo) : {};
328
+ }
329
+ if (ins) {
330
+ map.me = ins ? convertEleOrderListToObj(ins) : {};
331
+ map["i".concat(ins.key)] = ins;
332
+ }
333
+ if (product) {
334
+ map.productId = product.key;
335
+ Object.keys(product).filter(function (k) {
336
+ return !['mulInsOrderList'].includes(k);
337
+ }).forEach(function (k) {
338
+ map.p[k] = product[k];
339
+ });
340
+ if (Array.isArray(product.mulInsOrderList)) {
341
+ var common = product.mulInsOrderList.find(function (item) {
342
+ return item.key === 'common';
343
+ });
344
+ var insuranceList = product.mulInsOrderList.filter(function (item) {
345
+ return !['common'].includes(item.key);
346
+ }).map(function (item) {
347
+ return convertEleOrderListToObj(item);
348
+ });
349
+ map.m = insuranceList[0] ? insuranceList[0] : {};
350
+ map.me = ins && ins.key ? insuranceList.find(function (e) {
351
+ return e.key === ins.key;
352
+ }) || {} : {};
353
+ map.common = common ? convertEleOrderListToObj(common) : {};
354
+ insuranceList.forEach(function (item) {
355
+ map["i".concat(item.key)] = item;
356
+ });
357
+ }
358
+ }
359
+ if (options && options.planbookId) {
360
+ map.planbookId = options.planbookId;
361
+ }
362
+ if (ins && ins.customVariableExp) {
363
+ var exp = ins.customVariableExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'map.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'map.$2');
364
+ map.customVariable = eval(exp);
365
+ map.cv = map.customVariable;
366
+ }
367
+ return map;
368
+ }
369
+ function executeElementRule(personData, product, ins, ele) {
370
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
371
+ var paramMap = getExpressionParamMap(personData, product, ins, options);
372
+ var newEleMap = {};
373
+ if (paramMap) {
374
+ if (['cmCommonTitle'].includes(ele.componentName)) {
375
+ if (ele.underwriteExp) {
376
+ var exp = ele.underwriteExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2');
377
+ var evalValue = eval(exp);
378
+ if (Array.isArray(evalValue)) {
379
+ if ([0, 1].includes(evalValue[0])) {
380
+ newEleMap.value = evalValue[0] === 1;
381
+ }
382
+ if ([0, 1].includes(evalValue[1])) {
383
+ newEleMap.isDisabled = evalValue[1] === 0;
384
+ }
385
+ }
386
+ consoleLogWhenEnable("".concat(ele.key, ": underwriteExp"), exp, evalValue);
387
+ }
388
+ }
389
+ if (['cmCommonSelect', 'cmCommonRadioBtn', 'cmCommonRadio', 'cmCommonCheckbox'].includes(ele.componentName)) {
390
+ if (ele.defaultValueExp) {
391
+ if (ele.value !== 0 && !ele.value) {
392
+ var _exp = ele.defaultValueExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2');
393
+ newEleMap.value = eval(_exp);
394
+ consoleLogWhenEnable("".concat(ele.key, ": defaultValueExp"), _exp, newEleMap.value);
395
+ }
396
+ }
397
+ if (ele.underwriteExp) {
398
+ var _exp2 = ele.underwriteExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2');
399
+ var _evalValue = eval(_exp2);
400
+ if (Array.isArray(_evalValue) && Array.isArray(ele.opts)) {
401
+ if (_evalValue.length === 2) {
402
+ newEleMap.opts = (ele.opts || []).filter(function (o) {
403
+ return o.val >= _evalValue[0] && o.val <= _evalValue[1];
404
+ });
405
+ } else {
406
+ newEleMap.opts = (ele.opts || []).filter(function (o) {
407
+ return _evalValue.includes(o.val);
408
+ });
409
+ }
410
+ }
411
+ if (Array.isArray(newEleMap.opts)) {
412
+ if (newEleMap.opts.length && !newEleMap.opts.some(function (o) {
413
+ return o.val === ele.value;
414
+ })) {
415
+ newEleMap.value = newEleMap.opts[0].val;
416
+ }
417
+ }
418
+ consoleLogWhenEnable("".concat(ele.key, ": underwriteExp"), _exp2, _evalValue);
419
+ }
420
+ }
421
+ if (['cmCommonInput'].includes(ele.componentName)) {
422
+ if (ele.defaultValueExp) {
423
+ if (!ele.value) {
424
+ var _exp3 = ele.defaultValueExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2');
425
+ newEleMap.value = eval(_exp3);
426
+ consoleLogWhenEnable("".concat(ele.key, ": defaultValueExp"), _exp3, newEleMap.value);
427
+ }
428
+ }
429
+ if (ele.minExp) {
430
+ var _exp4 = ele.minExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2');
431
+ newEleMap.min = eval(_exp4);
432
+ consoleLogWhenEnable("".concat(ele.key, ": minExp"), _exp4, newEleMap.min);
433
+ }
434
+ if (ele.maxExp) {
435
+ var _exp5 = ele.maxExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2');
436
+ newEleMap.max = eval(_exp5);
437
+ consoleLogWhenEnable("".concat(ele.key, ": maxExp"), _exp5, newEleMap.max);
438
+ }
439
+ if (ele.multiExp) {
440
+ var _exp6 = ele.multiExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2');
441
+ newEleMap.multi = eval(_exp6);
442
+ consoleLogWhenEnable("".concat(ele.key, ": multiExp"), _exp6, newEleMap.multi);
443
+ }
444
+ }
445
+ }
446
+ return newEleMap;
447
+ }
279
448
 
280
449
  /**
281
450
  * **初始化人员数据**
@@ -579,9 +748,7 @@ function getInsuredAgeRange(inputData, verifyData) {
579
748
  prod.mulInsOrderList.forEach(function (ins) {
580
749
  // 险种是否有费率
581
750
  if (!verifyData[prod.key][ins.key]) {
582
- if (window.DEBUG_TEMP_CONSOLE_FLAG) {
583
- console.log("".concat(prod.titleName, "-").concat(prod.key, " -> ").concat(ins.name, "-").concat(ins.key, ": \u5F53\u524D\u9669\u79CD\u6CA1\u6709\u8D39\u7387\u8868"));
584
- }
751
+ consoleLogWhenEnable("".concat(prod.titleName, "-").concat(prod.key, " -> ").concat(ins.name, "-").concat(ins.key, ": \u5F53\u524D\u9669\u79CD\u6CA1\u6709\u8D39\u7387\u8868"));
585
752
  return;
586
753
  }
587
754
  // 产品中是否有必选险种
@@ -9718,8 +9885,8 @@ function _productDataHandler() {
9718
9885
  insuranceDataHandler(ins, prodData);
9719
9886
  var insuranceVerifyData = productVerifyData[ins.key];
9720
9887
  if (!insuranceVerifyData) {
9721
- if (window.DEBUG_TEMP_CONSOLE_FLAG) {
9722
- console.log("".concat(prodData.titleName, "-").concat(prodData.key, " -> ").concat(ins.name, "-").concat(ins.key, ": \u5F53\u524D\u9669\u79CD\u6CA1\u6709\u8D39\u7387\u8868"));
9888
+ if (ins.key !== 'common') {
9889
+ consoleLogWhenEnable("".concat(prodData.titleName, "-").concat(prodData.key, " -> ").concat(ins.name, "-").concat(ins.key, ": \u5F53\u524D\u9669\u79CD\u6CA1\u6709\u8D39\u7387\u8868"));
9723
9890
  }
9724
9891
  return;
9725
9892
  }
@@ -9771,9 +9938,7 @@ function _productDataHandler() {
9771
9938
  if (isNotAllowSelect) {
9772
9939
  eleTitle.isDisabled = true;
9773
9940
  eleTitle.value = false;
9774
- if (window.DEBUG_TEMP_CONSOLE_FLAG) {
9775
- console.log(curCondition ? "".concat(eleTitle.labelName, "-").concat(ins.key, ": \u8D39\u7387\u5B58\u5728\uFF01\u4F46\u6295\u4FDD\u4EBA\u672A\u9009\u4E2D\u6216\u6295\u88AB\u4FDD\u4EBA\u4E3A\u540C\u4E00\u4EBA\uFF0C\u8BE5\u8C41\u514D\u9669\uFF08\u4E0D\u80FD\u9644\u52A0\u5230\u88AB\u4FDD\u4EBA\uFF09\u4E0D\u53EF\u9009") : "".concat(eleTitle.labelName, "-").concat(ins.key, ": \u8D39\u7387\u4E0D\u5B58\u5728\uFF01"));
9776
- }
9941
+ consoleLogWhenEnable(curCondition ? "".concat(eleTitle.labelName, "-").concat(ins.key, ": \u8D39\u7387\u5B58\u5728\uFF01\u4F46\u6295\u4FDD\u4EBA\u672A\u9009\u4E2D\u6216\u6295\u88AB\u4FDD\u4EBA\u4E3A\u540C\u4E00\u4EBA\uFF0C\u8BE5\u8C41\u514D\u9669\uFF08\u4E0D\u80FD\u9644\u52A0\u5230\u88AB\u4FDD\u4EBA\uFF09\u4E0D\u53EF\u9009") : "".concat(eleTitle.labelName, "-").concat(ins.key, ": \u8D39\u7387\u4E0D\u5B58\u5728\uFF01"));
9777
9942
  } else {
9778
9943
  // 存在费率,险种可选
9779
9944
  eleTitle.isDisabled = false;
@@ -9781,9 +9946,7 @@ function _productDataHandler() {
9781
9946
  if (ins.required && (!ins.groupKey || ins.isCheckbox)) {
9782
9947
  eleTitle.value = true;
9783
9948
  eleTitle.isDisabled = true;
9784
- if (window.DEBUG_TEMP_CONSOLE_FLAG) {
9785
- console.log("".concat(eleTitle.labelName, "-").concat(ins.key, ": \u8D39\u7387\u5B58\u5728\uFF0C\u9669\u79CD\u4E3A\u5FC5\u9009\u9669\u4E14(\u4E3A\u975E\u7EC4\u5408\u9669\u6216\u4E3A\u591A\u9009\u4E00\u9669\u79CD)"));
9786
- }
9949
+ consoleLogWhenEnable("".concat(eleTitle.labelName, "-").concat(ins.key, ": \u8D39\u7387\u5B58\u5728\uFF0C\u9669\u79CD\u4E3A\u5FC5\u9009\u9669\u4E14(\u4E3A\u975E\u7EC4\u5408\u9669\u6216\u4E3A\u591A\u9009\u4E00\u9669\u79CD)"));
9787
9950
  }
9788
9951
  }
9789
9952
  if (!curCondition) {
@@ -9802,9 +9965,7 @@ function _productDataHandler() {
9802
9965
  });
9803
9966
  }
9804
9967
  if (!eleData) {
9805
- if (window.DEBUG_TEMP_CONSOLE_FLAG) {
9806
- console.log("".concat(ins.name, " - ").concat(curCondition && curCondition.key, "\u5143\u7D20\u4E0D\u5B58\u5728\uFF1A"));
9807
- }
9968
+ consoleLogWhenEnable("".concat(ins.name, " - ").concat(curCondition && curCondition.key, "\u5143\u7D20\u4E0D\u5B58\u5728\uFF1A"));
9808
9969
  curCondition = null;
9809
9970
  return 0; // break
9810
9971
  }
@@ -9833,9 +9994,7 @@ function _productDataHandler() {
9833
9994
  eleData.value = refEleData.value;
9834
9995
  }
9835
9996
  } else {
9836
- if (window.DEBUG_TEMP_CONSOLE_FLAG) {
9837
- console.log("".concat(ins.name, "-").concat(ins.key, "\uFF1A\u5173\u8054\u9669\u79CD").concat(ins.refInsuranceId, "\u4E0D\u5B58\u5728"));
9838
- }
9997
+ consoleLogWhenEnable("".concat(ins.name, "-").concat(ins.key, "\uFF1A\u5173\u8054\u9669\u79CD").concat(ins.refInsuranceId, "\u4E0D\u5B58\u5728"));
9839
9998
  }
9840
9999
  } else {
9841
10000
  var backupOpts = eleData.opts && eleData.opts.length ? eleData.opts.slice(0) : [];
@@ -9904,9 +10063,7 @@ function _productDataHandler() {
9904
10063
  if (!curCondition) {
9905
10064
  eleTitle.isDisabled = true;
9906
10065
  eleTitle.value = false;
9907
- if (window.DEBUG_TEMP_CONSOLE_FLAG) {
9908
- console.log("".concat(eleTitle.labelName, "-").concat(ins.key, ": \u8D39\u7387\u4E0D\u5B58\u5728\uFF01"));
9909
- }
10066
+ consoleLogWhenEnable("".concat(eleTitle.labelName, "-").concat(ins.key, ": \u8D39\u7387\u4E0D\u5B58\u5728\uFF01"));
9910
10067
  }
9911
10068
 
9912
10069
  // 如果当前元素是隐藏的且不可修改,则过滤上一元素的选项,即,删除上一元素中不包含当前元素值的选项。
@@ -9943,6 +10100,15 @@ function _productDataHandler() {
9943
10100
  _ret = _loop2();
9944
10101
  if (_ret === 0) break;
9945
10102
  } while (curCondition && curCondition.key && curCondition[curCondition.key]);
10103
+ if (Array.isArray(ins.eleOrderList)) {
10104
+ ins.eleOrderList.forEach(function (ele) {
10105
+ var newEleMap = executeElementRule(personData, prodData, ins, ele, parmas);
10106
+ for (var k in newEleMap) {
10107
+ ele[k] = newEleMap[k];
10108
+ }
10109
+ });
10110
+ insuranceDataHandler(ins, prodData);
10111
+ }
9946
10112
  });
9947
10113
  }
9948
10114
  setGroupInsurance(prodData);
@@ -10686,22 +10852,22 @@ function clearAddAndTakeAndAdjustBaoeData(productData) {
10686
10852
  return productData;
10687
10853
  }
10688
10854
 
10689
- if (document && document.cookie && document.cookie.match('LIZHAO_DEBUG_CONSOLE_FLAG=1')) {
10690
- window.DEBUG_TEMP_CONSOLE_FLAG = true;
10691
- }
10692
-
10693
10855
  const planbook = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
10694
10856
  __proto__: null,
10695
10857
  calcTotalBaof,
10696
10858
  clearAddAndTakeAndAdjustBaoeData,
10859
+ consoleLogWhenEnable,
10697
10860
  converUnit10000,
10698
10861
  convertEleOrderListToObj,
10699
10862
  convertPersonData,
10700
10863
  convertProductData,
10701
10864
  deepCopy,
10865
+ enableLizhaoDebug,
10866
+ executeElementRule,
10702
10867
  formatNumberToThousand,
10703
10868
  getAgeFromBirth,
10704
10869
  getElementVerifyFromProductVerify,
10870
+ getExpressionParamMap,
10705
10871
  getHuomianPeriodValue,
10706
10872
  getInsuredAgeRange,
10707
10873
  getNumberFromYear,
@@ -11249,4 +11415,4 @@ const index = {
11249
11415
  trade: trade
11250
11416
  };
11251
11417
 
11252
- export { calcTotalBaof, checkInsureCalculate, checkInsureCalculateIn, clearAddAndTakeAndAdjustBaoeData, converUnit10000, convertEleOrderListToObj, convertPersonData, convertProductData, deepCopy, index as default, formatNumberToThousand, getAddress, getAgeFromBirth, getElementVerifyFromProductVerify, getHuomianPeriodValue, getInsuredAgeRange, getNumberFromYear, getUuid, hasPlanParams, initElementValidateRules, initInsuranceData, initPersonData, initProductData, insuranceDataHandler, insureCalculate, isHideProduct, personDataHandler, productDataHandler, restrictElementsInInsurance, restrictInsurancesInProduct, setCommonInfo, setGroupInsurance, setPersonAgeOptions, textOverflowEllipsis, verifyProductRules };
11418
+ export { calcTotalBaof, checkInsureCalculate, checkInsureCalculateIn, clearAddAndTakeAndAdjustBaoeData, consoleLogWhenEnable, converUnit10000, convertEleOrderListToObj, convertPersonData, convertProductData, deepCopy, index as default, enableLizhaoDebug, executeElementRule, formatNumberToThousand, getAddress, getAgeFromBirth, getElementVerifyFromProductVerify, getExpressionParamMap, getHuomianPeriodValue, getInsuredAgeRange, getNumberFromYear, getUuid, hasPlanParams, initElementValidateRules, initInsuranceData, initPersonData, initProductData, insuranceDataHandler, insureCalculate, isHideProduct, personDataHandler, productDataHandler, restrictElementsInInsurance, restrictInsurancesInProduct, setCommonInfo, setGroupInsurance, setPersonAgeOptions, textOverflowEllipsis, verifyProductRules };
@@ -8615,6 +8615,8 @@
8615
8615
  desc: '自定义'
8616
8616
  }];
8617
8617
 
8618
+ document && document.cookie && document.cookie.match('ENABLE_LIZHAO_DEBUG=1');
8619
+
8618
8620
  /**
8619
8621
  * 将数值转换为千分位
8620
8622
  * @author Lizhao <lz@winbaoxian.com>
@@ -8664,10 +8666,6 @@
8664
8666
  return QS.stringify(params);
8665
8667
  });
8666
8668
 
8667
- if (document && document.cookie && document.cookie.match('LIZHAO_DEBUG_CONSOLE_FLAG=1')) {
8668
- window.DEBUG_TEMP_CONSOLE_FLAG = true;
8669
- }
8670
-
8671
8669
  //
8672
8670
  //
8673
8671
  //
@@ -471,6 +471,8 @@
471
471
  });
472
472
  }
473
473
 
474
+ document && document.cookie && document.cookie.match('ENABLE_LIZHAO_DEBUG=1');
475
+
474
476
  /**
475
477
  * **将对象下的 eleOrderList 数组中的子元素下的 value,转换为 key-value 键值对**
476
478
  * @author Lizhao <lz@winbaoxian.com>
@@ -9127,10 +9129,6 @@
9127
9129
  return productData;
9128
9130
  }
9129
9131
 
9130
- if (document && document.cookie && document.cookie.match('LIZHAO_DEBUG_CONSOLE_FLAG=1')) {
9131
- window.DEBUG_TEMP_CONSOLE_FLAG = true;
9132
- }
9133
-
9134
9132
  var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
9135
9133
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9136
9134
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }