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.
@@ -14,6 +14,14 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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
  var planbook = /*#__PURE__*/Object.freeze({
10694
10856
  __proto__: null,
10695
10857
  calcTotalBaof: calcTotalBaof,
10696
10858
  clearAddAndTakeAndAdjustBaoeData: clearAddAndTakeAndAdjustBaoeData,
10859
+ consoleLogWhenEnable: consoleLogWhenEnable,
10697
10860
  converUnit10000: converUnit10000,
10698
10861
  convertEleOrderListToObj: convertEleOrderListToObj,
10699
10862
  convertPersonData: convertPersonData,
10700
10863
  convertProductData: convertProductData,
10701
10864
  deepCopy: deepCopy,
10865
+ enableLizhaoDebug: enableLizhaoDebug,
10866
+ executeElementRule: executeElementRule,
10702
10867
  formatNumberToThousand: formatNumberToThousand,
10703
10868
  getAgeFromBirth: getAgeFromBirth,
10704
10869
  getElementVerifyFromProductVerify: getElementVerifyFromProductVerify,
10870
+ getExpressionParamMap: getExpressionParamMap,
10705
10871
  getHuomianPeriodValue: getHuomianPeriodValue,
10706
10872
  getInsuredAgeRange: getInsuredAgeRange,
10707
10873
  getNumberFromYear: getNumberFromYear,
@@ -11253,16 +11419,20 @@
11253
11419
  exports.checkInsureCalculate = checkInsureCalculate;
11254
11420
  exports.checkInsureCalculateIn = checkInsureCalculateIn;
11255
11421
  exports.clearAddAndTakeAndAdjustBaoeData = clearAddAndTakeAndAdjustBaoeData;
11422
+ exports.consoleLogWhenEnable = consoleLogWhenEnable;
11256
11423
  exports.converUnit10000 = converUnit10000;
11257
11424
  exports.convertEleOrderListToObj = convertEleOrderListToObj;
11258
11425
  exports.convertPersonData = convertPersonData;
11259
11426
  exports.convertProductData = convertProductData;
11260
11427
  exports.deepCopy = deepCopy;
11261
11428
  exports.default = index;
11429
+ exports.enableLizhaoDebug = enableLizhaoDebug;
11430
+ exports.executeElementRule = executeElementRule;
11262
11431
  exports.formatNumberToThousand = formatNumberToThousand;
11263
11432
  exports.getAddress = getAddress;
11264
11433
  exports.getAgeFromBirth = getAgeFromBirth;
11265
11434
  exports.getElementVerifyFromProductVerify = getElementVerifyFromProductVerify;
11435
+ exports.getExpressionParamMap = getExpressionParamMap;
11266
11436
  exports.getHuomianPeriodValue = getHuomianPeriodValue;
11267
11437
  exports.getInsuredAgeRange = getInsuredAgeRange;
11268
11438
  exports.getNumberFromYear = getNumberFromYear;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bxs-tools-ui",
3
- "version": "3.1.3",
3
+ "version": "3.2.0-0",
4
4
  "description": "微易前端业务组件",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -90,7 +90,7 @@ import QS from 'qs';
90
90
  import { get as _get } from 'lodash';
91
91
  import { getPlanbookData } from 'packages/planbook-input/api.js';
92
92
  import { convertPersonData, convertProductData } from 'packages/bxs-utils/planbook/index.ts';
93
- import { initPageData, setPageDataBaseOnResult, calculateProductData } from 'packages/planbook-input/helper.js';
93
+ import { initPageData, setPageDataBaseOnResult, doubleCalcProductData } from 'packages/planbook-input/helper.js';
94
94
  import { convertInputDataToResultData } from 'packages/planbook-input/components/handler.js';
95
95
  import { initAddAndTakePopupConfig } from 'packages/add-and-take/handler.ts';
96
96
  import { ADD_AND_TAKE_TITLE_MAP } from 'packages/add-and-take/constant.ts';
@@ -177,7 +177,7 @@ export default {
177
177
  .filter(g => g.prodOrderList)
178
178
  .map(g => {
179
179
  const pPromises = g.prodOrderList.map(p => {
180
- return calculateProductData(inputData, {
180
+ return doubleCalcProductData(inputData, {
181
181
  planbookId: Number(planbookId) || 13767,
182
182
  publicPbUuid,
183
183
  groupKey: g.key,
@@ -1,3 +1,11 @@
1
+ export const enableLizhaoDebug = document && document.cookie && document.cookie.match('ENABLE_LIZHAO_DEBUG=1')
2
+
3
+ export function consoleLogWhenEnable(...args: any[]) {
4
+ if (enableLizhaoDebug) {
5
+ console.log(...args)
6
+ }
7
+ }
8
+
1
9
  /**
2
10
  * **将对象下的 eleOrderList 数组中的子元素下的 value,转换为 key-value 键值对**
3
11
  * @author Lizhao <lz@winbaoxian.com>
@@ -256,3 +264,139 @@ export function textOverflowEllipsis (str, n) {
256
264
  return text
257
265
  }
258
266
 
267
+ export function getExpressionParamMap (personData : IPbPersons, product : IPbProduct, ins : IProdInsurance, options : any) : any {
268
+ const map : any = {
269
+ planbookId: null, // 计划书id
270
+ productId: null, // 产品id
271
+ insured: {}, // 被保人
272
+ insured2: {}, // 第二被保人
273
+ applicant: {}, // 投保人
274
+ recipient: {}, // 收件人
275
+ p: {}, // 当前产品
276
+ m: {}, // 主险
277
+ me: {}, // 当前险种
278
+ common: {}, // 通用信息
279
+ customVariable: null, // 自定义变量
280
+ cv: null, // 简写,自定义变量
281
+ }
282
+
283
+ if (personData) {
284
+ const insuredInfo = (personData.personOrderList || []).find(p => p.key === 'insuredInfo')
285
+ const insured2Info = (personData.personOrderList || []).find(p => p.key === 'insured2Info')
286
+ const applicantInfo = (personData.personOrderList || []).find(p => p.key === 'applicantInfo')
287
+ const recipientInfo = personData?.recipientInfo ? personData.recipientInfo : null
288
+ map.insured = insuredInfo ? convertEleOrderListToObj(insuredInfo) : {}
289
+ map.insured2 = insured2Info ? convertEleOrderListToObj(insured2Info) : {}
290
+ map.applicant = applicantInfo ? convertEleOrderListToObj(applicantInfo) : {}
291
+ map.recipient = recipientInfo ? convertEleOrderListToObj(recipientInfo) : {}
292
+ }
293
+
294
+ if (ins) {
295
+ map.me = ins ? convertEleOrderListToObj(ins) : {}
296
+ map[`i${ins.key}`] = ins
297
+ }
298
+
299
+ if (product) {
300
+ map.productId = product.key
301
+ Object.keys(product)
302
+ .filter(k => !['mulInsOrderList'].includes(k))
303
+ .forEach(k => {
304
+ map.p[k] = product[k]
305
+ })
306
+ if (Array.isArray(product.mulInsOrderList)) {
307
+ const common = product.mulInsOrderList.find(item => item.key === 'common')
308
+ const insuranceList = product.mulInsOrderList.filter((item : any) => !['common'].includes(item.key)).map(item => convertEleOrderListToObj(item))
309
+ map.m = insuranceList[0] ? insuranceList[0] : {}
310
+ map.me = ins && ins.key ? insuranceList.find(e => e.key === ins.key) || {} : {}
311
+ map.common = common ? convertEleOrderListToObj(common) : {}
312
+ insuranceList.forEach(item => {
313
+ map[`i${item.key}`] = item
314
+ })
315
+ }
316
+ }
317
+
318
+ if (options && options.planbookId) {
319
+ map.planbookId = options.planbookId
320
+ }
321
+
322
+ if (ins && ins.customVariableExp) {
323
+ const exp = ins.customVariableExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'map.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'map.$2')
324
+ map.customVariable = eval(exp)
325
+ map.cv = map.customVariable
326
+ }
327
+
328
+ return map
329
+ }
330
+
331
+ export function executeElementRule (personData : IPbPersons, product : IPbProduct, ins : IProdInsurance, ele : IInsElement, options : any = {}) : any {
332
+ const paramMap = getExpressionParamMap(personData, product, ins, options)
333
+ const newEleMap : any = {}
334
+ if (paramMap) {
335
+ if (['cmCommonTitle'].includes(ele.componentName!)) {
336
+ if (ele.underwriteExp) {
337
+ const exp = ele.underwriteExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2')
338
+ const evalValue : Array<number> = eval(exp)
339
+ if (Array.isArray(evalValue)) {
340
+ if ([0, 1].includes(evalValue[0])) {
341
+ newEleMap.value = evalValue[0] === 1
342
+ }
343
+ if ([0, 1].includes(evalValue[1])) {
344
+ newEleMap.isDisabled = evalValue[1] === 0
345
+ }
346
+ }
347
+ consoleLogWhenEnable(`${ele.key}: underwriteExp`, exp, evalValue)
348
+ }
349
+ }
350
+ if (['cmCommonSelect', 'cmCommonRadioBtn', 'cmCommonRadio', 'cmCommonCheckbox'].includes(ele.componentName!)) {
351
+ if (ele.defaultValueExp) {
352
+ if (ele.value !== 0 && !ele.value) {
353
+ const exp = ele.defaultValueExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2')
354
+ newEleMap.value = eval(exp)
355
+ consoleLogWhenEnable(`${ele.key}: defaultValueExp`, exp, newEleMap.value)
356
+ }
357
+ }
358
+ if (ele.underwriteExp) {
359
+ const exp = ele.underwriteExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2')
360
+ const evalValue : Array<number> = eval(exp)
361
+ if (Array.isArray(evalValue) && Array.isArray(ele.opts)) {
362
+ if (evalValue.length === 2) {
363
+ newEleMap.opts = (ele.opts || []).filter((o : any) => o.val >= evalValue[0] && o.val <= evalValue[1])
364
+ } else {
365
+ newEleMap.opts = (ele.opts || []).filter((o : any) => evalValue.includes(o.val))
366
+ }
367
+ }
368
+ if (Array.isArray(newEleMap.opts)) {
369
+ if (newEleMap.opts.length && !newEleMap.opts.some((o : any) => o.val === ele.value)) {
370
+ newEleMap.value = newEleMap.opts[0].val
371
+ }
372
+ }
373
+ consoleLogWhenEnable(`${ele.key}: underwriteExp`, exp, evalValue)
374
+ }
375
+ }
376
+ if (['cmCommonInput'].includes(ele.componentName!)) {
377
+ if (ele.defaultValueExp) {
378
+ if (!ele.value) {
379
+ const exp = ele.defaultValueExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2')
380
+ newEleMap.value = eval(exp)
381
+ consoleLogWhenEnable(`${ele.key}: defaultValueExp`, exp, newEleMap.value)
382
+ }
383
+ }
384
+ if (ele.minExp) {
385
+ const exp = ele.minExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2')
386
+ newEleMap.min = eval(exp)
387
+ consoleLogWhenEnable(`${ele.key}: minExp`, exp, newEleMap.min)
388
+ }
389
+ if (ele.maxExp) {
390
+ const exp = ele.maxExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2')
391
+ newEleMap.max = eval(exp)
392
+ consoleLogWhenEnable(`${ele.key}: maxExp`, exp, newEleMap.max)
393
+ }
394
+ if (ele.multiExp) {
395
+ const exp = ele.multiExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2')
396
+ newEleMap.multi = eval(exp)
397
+ consoleLogWhenEnable(`${ele.key}: multiExp`, exp, newEleMap.multi)
398
+ }
399
+ }
400
+ }
401
+ return newEleMap
402
+ }
@@ -1,7 +1,4 @@
1
1
  export * from './common';
2
2
  export * from './person';
3
3
  export * from './product';
4
- export * from './insurance';
5
- if (document && document.cookie && document.cookie.match('LIZHAO_DEBUG_CONSOLE_FLAG=1')) {
6
- window.DEBUG_TEMP_CONSOLE_FLAG = true;
7
- }
4
+ export * from './insurance';
@@ -1,4 +1,4 @@
1
- import { convertEleOrderListToObj } from './common';
1
+ import { consoleLogWhenEnable, convertEleOrderListToObj } from './common';
2
2
 
3
3
  /**
4
4
  * **初始化人员数据**
@@ -271,9 +271,7 @@ export function getInsuredAgeRange(inputData : IPbInput, verifyData : any) : any
271
271
  prod.mulInsOrderList.forEach((ins : IProdInsurance) => {
272
272
  // 险种是否有费率
273
273
  if (!verifyData[prod.key][ins.key]) {
274
- if (window.DEBUG_TEMP_CONSOLE_FLAG) {
275
- console.log(`${prod.titleName}-${prod.key} -> ${ins.name}-${ins.key}: 当前险种没有费率表`);
276
- }
274
+ consoleLogWhenEnable(`${prod.titleName}-${prod.key} -> ${ins.name}-${ins.key}: 当前险种没有费率表`);
277
275
  return;
278
276
  }
279
277
  // 产品中是否有必选险种
@@ -2,11 +2,13 @@ import QS from 'qs';
2
2
  import { memoize, cloneDeep } from 'lodash'
3
3
  import { APP_HOSTNAME } from '@src/js/variables.js';
4
4
  import {
5
+ consoleLogWhenEnable,
5
6
  convertEleOrderListToObj,
6
7
  converUnit10000,
7
8
  getHuomianPeriodValue,
8
9
  getNumberFromYear,
9
- deepCopy
10
+ deepCopy,
11
+ executeElementRule
10
12
  } from './common';
11
13
  import { convertPersonData } from './person';
12
14
  import { initInsuranceData, insuranceDataHandler, restrictElementsInInsurance } from './insurance';
@@ -66,7 +68,7 @@ export async function productDataHandler(prodData : IPbProduct, prodVerifyData :
66
68
  } else {
67
69
  productVerifyData = prodVerifyData
68
70
  }
69
-
71
+
70
72
  const hasProduct = prodData.mulInsOrderList
71
73
  const hasVerifyData = productVerifyData && Object.keys(productVerifyData).length
72
74
  const hasPersonData = personData && personData.personOrderList
@@ -81,8 +83,8 @@ export async function productDataHandler(prodData : IPbProduct, prodVerifyData :
81
83
  insuranceDataHandler(ins, prodData);
82
84
  const insuranceVerifyData = productVerifyData[ins.key];
83
85
  if (!insuranceVerifyData) {
84
- if (window.DEBUG_TEMP_CONSOLE_FLAG) {
85
- console.log(`${prodData.titleName}-${prodData.key} -> ${ins.name}-${ins.key}: 当前险种没有费率表`);
86
+ if (ins.key !== 'common') {
87
+ consoleLogWhenEnable(`${prodData.titleName}-${prodData.key} -> ${ins.name}-${ins.key}: 当前险种没有费率表`);
86
88
  }
87
89
  return;
88
90
  }
@@ -127,9 +129,7 @@ export async function productDataHandler(prodData : IPbProduct, prodVerifyData :
127
129
  if (isNotAllowSelect) {
128
130
  eleTitle.isDisabled = true;
129
131
  eleTitle.value = false;
130
- if (window.DEBUG_TEMP_CONSOLE_FLAG) {
131
- console.log(curCondition ? `${eleTitle.labelName}-${ins.key}: 费率存在!但投保人未选中或投被保人为同一人,该豁免险(不能附加到被保人)不可选`:`${eleTitle.labelName}-${ins.key}: 费率不存在!`);
132
- }
132
+ consoleLogWhenEnable(curCondition ? `${eleTitle.labelName}-${ins.key}: 费率存在!但投保人未选中或投被保人为同一人,该豁免险(不能附加到被保人)不可选`:`${eleTitle.labelName}-${ins.key}: 费率不存在!`);
133
133
  } else {
134
134
  // 存在费率,险种可选
135
135
  eleTitle.isDisabled = false;
@@ -137,9 +137,7 @@ export async function productDataHandler(prodData : IPbProduct, prodVerifyData :
137
137
  if (ins.required && (!ins.groupKey || ins.isCheckbox)) {
138
138
  eleTitle.value = true;
139
139
  eleTitle.isDisabled = true;
140
- if (window.DEBUG_TEMP_CONSOLE_FLAG) {
141
- console.log(`${eleTitle.labelName}-${ins.key}: 费率存在,险种为必选险且(为非组合险或为多选一险种)`);
142
- }
140
+ consoleLogWhenEnable(`${eleTitle.labelName}-${ins.key}: 费率存在,险种为必选险且(为非组合险或为多选一险种)`);
143
141
  }
144
142
  }
145
143
  if (!curCondition) {
@@ -152,9 +150,7 @@ export async function productDataHandler(prodData : IPbProduct, prodVerifyData :
152
150
  eleData = commonData.eleOrderList.find((e : IInsElement) => e.key === curCondition.key) as IInsElement;
153
151
  }
154
152
  if (!eleData) {
155
- if (window.DEBUG_TEMP_CONSOLE_FLAG) {
156
- console.log(`${ins.name} - ${curCondition && curCondition.key}元素不存在:`);
157
- }
153
+ consoleLogWhenEnable(`${ins.name} - ${curCondition && curCondition.key}元素不存在:`);
158
154
  curCondition = null;
159
155
  break
160
156
  }
@@ -183,9 +179,7 @@ export async function productDataHandler(prodData : IPbProduct, prodVerifyData :
183
179
  eleData.value = refEleData.value;
184
180
  }
185
181
  } else {
186
- if (window.DEBUG_TEMP_CONSOLE_FLAG) {
187
- console.log(`${ins.name}-${ins.key}:关联险种${ins.refInsuranceId}不存在`);
188
- }
182
+ consoleLogWhenEnable(`${ins.name}-${ins.key}:关联险种${ins.refInsuranceId}不存在`);
189
183
  }
190
184
  } else {
191
185
  const backupOpts : any [] = eleData.opts && eleData.opts.length ? eleData.opts.slice(0) : []
@@ -216,7 +210,6 @@ export async function productDataHandler(prodData : IPbProduct, prodVerifyData :
216
210
  }
217
211
  // 提定下一个元素的限制条件
218
212
  curCondition = eleCondi.find(eleCondi => eleCondi.value == eleData.value);
219
-
220
213
  const eleIndex = (<IInsElement []>ins.eleOrderList).findIndex(ele => ele.key === eleData.key);
221
214
  let prevElement
222
215
  if (eleIndex >= 1) {
@@ -237,9 +230,7 @@ export async function productDataHandler(prodData : IPbProduct, prodVerifyData :
237
230
  if (!curCondition) {
238
231
  eleTitle.isDisabled = true;
239
232
  eleTitle.value = false;
240
- if (window.DEBUG_TEMP_CONSOLE_FLAG) {
241
- console.log(`${eleTitle.labelName}-${ins.key}: 费率不存在!`);
242
- }
233
+ consoleLogWhenEnable(`${eleTitle.labelName}-${ins.key}: 费率不存在!`);
243
234
  }
244
235
 
245
236
  // 如果当前元素是隐藏的且不可修改,则过滤上一元素的选项,即,删除上一元素中不包含当前元素值的选项。
@@ -269,6 +260,16 @@ export async function productDataHandler(prodData : IPbProduct, prodVerifyData :
269
260
  }
270
261
  }
271
262
  } while (curCondition && curCondition.key && curCondition[curCondition.key]);
263
+
264
+ if (Array.isArray(ins.eleOrderList)) {
265
+ ins.eleOrderList.forEach((ele : IInsElement) => {
266
+ const newEleMap = executeElementRule(personData, prodData, ins, ele, parmas)
267
+ for (const k in newEleMap) {
268
+ ele[k] = newEleMap[k]
269
+ }
270
+ })
271
+ insuranceDataHandler(ins, prodData);
272
+ }
272
273
  });
273
274
  }
274
275
  setGroupInsurance(prodData);
package/packages/index.ts CHANGED
@@ -50,6 +50,6 @@ export {
50
50
  }
51
51
 
52
52
  export default {
53
- version: '3.1.3',
53
+ version: '3.2.0-0',
54
54
  install
55
55
  }