bxs-tools-ui 3.2.0-1 → 3.2.0-2

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,110 +1,145 @@
1
- <!--仅用于绕过 eslint-loader 校验的错误信息:Parsing error: Invalid character-->
2
- <!--??以目前现象看,文档首字符不为 "<" 会报错??-->
3
1
  ## 调整保额(AdjustBaoe)
4
- **说明:** 计划书的调整保额模块,该模块跟随产品。显示该模块的必要条件是,产品下的至少有一个险种有 `adjustBaoe: true` 值。
5
- **内容:** 该模块包含两个子模块,一个展示数据的 Table 模块,一个用于编辑数据的 Form 模块,模块内部实现子模块的切换逻辑。
6
- **属性:** inputData、params、footer、submoduleName
7
- **方法:** goToTable、confirm
8
- **事件:** confirm
9
2
 
10
- ###
3
+ 计划书的调整保额模块,随产品展示。显示该模块的必要条件为:产品下至少有一个险种包含 `adjustBaoe: true` 字段。
4
+
5
+ **模块包含两个子模块**,内部自动处理子模块切换:
6
+
7
+ 1. **Table 模块**:以表格形式展示各险种保额数据
8
+ 2. **Form 模块**:编辑各险种保额数据
9
+
10
+ ---
11
+
11
12
  ### 模块引用(import)
13
+
12
14
  ```javascript
13
- import AdjustBaoe from 'bxs-tools-ui';
15
+ import { AdjustBaoe } from 'bxs-tools-ui';
14
16
  export default {
15
17
  components: {
16
18
  AdjustBaoe
17
19
  }
18
- }
20
+ };
19
21
  ```
20
22
 
21
- ###
22
- ### 数据示例
23
- ```json
24
- {
25
- "adjustBaoeData": [
26
- {
27
- "baoe_856": 1,
28
- "baoe_855": 2,
29
- "baoe_552": 33,
30
- "baoe_530": 4,
31
- "age": 32
32
- }
33
- ]
34
- }
23
+ ---
24
+
25
+ ### 示例(example)
26
+
27
+ **弹层模式:**
28
+
29
+ ```html
30
+ <template>
31
+ <CommonPopup
32
+ v-model="isShowAdjustBaoe"
33
+ title="调整保额"
34
+ height="90%"
35
+ closeable
36
+ position="bottom"
37
+ get-container="body"
38
+ :showFooter="false"
39
+ :z-index="100"
40
+ >
41
+ <AdjustBaoe
42
+ v-if="isShowAdjustBaoe"
43
+ ref="AdjustBaoe"
44
+ :submoduleName.sync="submoduleName"
45
+ :input-data="inputData"
46
+ :params="{
47
+ planbookId: URL_PARAM.planbookId,
48
+ groupKey: groupData.key,
49
+ productKey: productData.key
50
+ }"
51
+ @confirm="onConfirm"
52
+ />
53
+ </CommonPopup>
54
+ </template>
35
55
  ```
36
- ###
37
- ### 示例
38
- 两种使用模式的 DEMO:
39
-
40
- ###
41
- **弹层模式示例:**
56
+
57
+ **普通(内嵌)模式:**
58
+
42
59
  ```html
43
- <CommonPopup
44
- v-model="isShowAdjustBaoe"
45
- title="调整保额"
46
- height="90%"
47
- closeable
48
- position="bottom"
49
- get-container="body"
50
- :showFooter="false"
51
- :z-index="100"
52
- >
60
+ <template>
53
61
  <AdjustBaoe
54
- v-if="isShowAdjustBaoe"
55
62
  ref="AdjustBaoe"
56
- :submoduleName.sync="submoduleName1"
63
+ :submoduleName.sync="submoduleName"
57
64
  :input-data="inputData"
58
65
  :params="{
59
66
  planbookId: URL_PARAM.planbookId,
60
67
  groupKey: groupData.key,
61
68
  productKey: productData.key
62
69
  }"
63
- @confirm="onClickPopupConfirm"
70
+ :footer="false"
71
+ @confirm="onConfirm"
64
72
  />
65
- </CommonPopup>
73
+ </template>
74
+
75
+ <script>
76
+ import { AdjustBaoe } from 'bxs-tools-ui';
77
+
78
+ export default {
79
+ components: { AdjustBaoe },
80
+ data() {
81
+ return {
82
+ submoduleName: 'Table'
83
+ };
84
+ },
85
+ methods: {
86
+ onConfirm(adjustBaoeData, inst) {
87
+ console.log(adjustBaoeData);
88
+ }
89
+ }
90
+ };
91
+ </script>
66
92
  ```
67
-
68
- ###
69
- **普通模式示例:**
70
- ```html
71
- <AdjustBaoe
72
- ref="AdjustBaoe2"
73
- :submoduleName.sync="submoduleName2"
74
- :input-data="inputData"
75
- :params="{
76
- planbookId: URL_PARAM.planbookId,
77
- groupKey: groupData.key,
78
- productKey: productData.key
79
- }"
80
- :footer="false"
81
- @confirm="onClickPopupConfirm"
82
- />
93
+
94
+ `confirm` 回调中 `adjustBaoeData` 是直接的数组(非对象包装):
95
+
96
+ ```json
97
+ [
98
+ {
99
+ "baoe_856": 1,
100
+ "baoe_855": 2,
101
+ "baoe_552": 33,
102
+ "baoe_530": 4,
103
+ "age": 32
104
+ }
105
+ ]
83
106
  ```
84
107
 
85
- ###
108
+ ---
109
+
86
110
  ### Attributes
87
- | 参数| 说明 | 类型 | 默认值 | 备注 |
88
- | --- | --- | --- | --- | --- |
89
- | inputData | 必传。计划书数据,需要符合计划书的数据结构 | Object | {} | - |
90
- | params | 必传。其他参数,参考下方 Params 对象 | Object | {} | - |
91
- | submoduleName | 可不传,只读属性。仅用于需要获取子模块名称的场景 | String | Table | 可选值:Table、Form |
92
- | footer | 可不传,有默认值。表示是否显示底部按钮 | Boolean | true | - |
93
- ###
94
- ### Params 对象
95
- | 参数| 说明 | 类型 | 备注 |
96
- | --- | --- | --- | --- |
97
- | planbookId | 计划书的 ID | Number | - |
98
- | groupKey | 组合产品的 Key | String、Number | - |
99
- | productKey | 产品的 Key | Number | - |
100
- ###
111
+
112
+ | 参数 | 说明 | 类型 | 默认值 | 备注 |
113
+ | --- | --- | --- | --- | --- |
114
+ | `inputData` | 必传,计划书数据,需符合计划书数据结构 | Object | `{}` | — |
115
+ | `params` | 必传,需有 `groupKey` / `productKey` 才能正常定位产品 | Object | `{}` | 见 Params 对象 |
116
+ | `submoduleName` | 可选,当前子模块名称,支持 `.sync` 双向绑定 | String | `Table` | `Table` / `Form` |
117
+ | `footer` | 可选,是否显示底部按钮 | Boolean | `true` | — |
118
+
119
+
120
+ #### Params 对象
121
+
122
+ | 参数 | 说明 | 类型 |
123
+ | --- | --- | --- |
124
+ | `planbookId` | 计划书 ID | Number |
125
+ | `groupKey` | 产品组的 key | String / Number |
126
+ | `productKey` | 产品的 key | Number |
127
+ | `publicPbUuid` | 公开计划书的 uuid;传入时调用 public 接口进行保额校验 | String |
128
+
129
+ ---
130
+
101
131
  ### Methods
102
- | 方法名 | 说明 | 参数 | 备注 |
103
- | --- | --- | --- | --- |
104
- | goToTable | 用于从 Form 子模块,返回 Table 子模块 | - | - |
105
- | confirm | 自动调用 Table、Form 的确定事件。如果当前是 Table 模块,返回调整保额的数据 | - | - |
106
- ###
132
+
133
+ | 方法名 | 说明 | 参数 |
134
+ | --- | --- | --- |
135
+ | `goToTable` | 从 Form 子模块返回 Table 子模块 | — |
136
+ | `confirm` | 自动触发 Table / Form 的确定事件;当前为 Table 时返回调整保额数据 | — |
137
+
138
+ ---
139
+
107
140
  ### Events
108
- | 方法名 | 说明 | 参数 | 备注 |
109
- | --- | --- | --- | --- |
110
- | confirm | 确定事件。仅用于 footer 属性为 true 时,Table 子模块底部确定按钮的回调 | (调整保额数据, 模块实例) | - |
141
+
142
+ | 事件名 | 说明 | 回调参数 |
143
+ | --- | --- | --- |
144
+ | `confirm` | 确定事件;`footer` 为 `true` 时,Table 子模块底部确定按钮的回调(Form 子模块的确定不触发此事件,仅切回 Table) | `Function(adjustBaoeData, 模块实例)` |
145
+ | `update:submoduleName` | 子模块切换时触发,配合 `:submoduleName.sync` 使用 | 当前子模块名称(`'Table'` / `'Form'`) |
@@ -1,54 +1,117 @@
1
- <!--仅用于绕过 eslint-loader 校验的错误信息:Parsing error: Invalid character-->
2
- <!--??以目前现象看,文档首字符不为 "<" 会报错??-->
3
1
  ## 名片(BusinessCard)
4
- 说明:前端工具组,名片模块。
5
- 内容:头像、姓名、手机号、按钮
6
- 属性:名片信息(头像、姓名、手机号)、位置(bottom) 、按钮文案、按钮背景色
7
- 方法:单击头像、单击按钮
8
2
 
3
+ 展示个人名片信息的业务组件,适用于代理人名片场景。
4
+
5
+ **自上而下展示顺序**:
6
+
7
+ 1. 头像(可点击)
8
+ 2. 姓名 + 职级图标(可点击,与头像同事件)
9
+ 3. 职级文案(可选)
10
+ 4. 手机号(可选,点击触发系统拨号)
11
+ 5. 操作按钮(可选,可自定义文案与颜色)
12
+
13
+ ---
9
14
 
10
- ###
11
15
  ### 模块引用(import)
16
+
12
17
  ```javascript
13
- import BusinessCard from 'bxs-tools-ui';
18
+ import { BusinessCard } from 'bxs-tools-ui';
14
19
  export default {
15
20
  components: {
16
21
  BusinessCard
17
22
  }
18
- }
23
+ };
19
24
  ```
20
25
 
21
- ### 示例
22
- ``` html
26
+ ---
27
+
28
+ ### 示例(example)
29
+
30
+ ```html
23
31
  <template>
24
32
  <BusinessCard
25
33
  :card-data="cardData"
26
34
  :button-data="buttonData"
27
35
  @click="avatarHandler"
28
36
  @clickBtn="buttonHandler"
29
- ></BusinessCard>
37
+ />
30
38
  </template>
31
39
 
32
- <scripte>
40
+ <script>
41
+ import { BusinessCard } from 'bxs-tools-ui';
42
+
33
43
  export default {
34
- data () {
44
+ components: { BusinessCard },
45
+ data() {
35
46
  return {
36
47
  cardData: {
37
- avatar:
38
- '//media.winbaoxian.com/autoUpload/activity/2b3511574077482e0893c816eb56c8019b142d42f3639-CUzkUL_fw658_478c0884c573f5a.jpeg',
39
- name: 'lizhao11',
48
+ avatar: '//media.winbaoxian.com/autoUpload/activity/xxx.jpeg',
49
+ name: '张三',
40
50
  rank: '三联钻代理人',
41
- rankIcon:
42
- '//media.winbaoxian.com/autoUpload/activity/diamond_362dcf9f4453ded.png',
43
- mobile: '13023690000'
44
- };
45
- buttonData = {
46
- tx: '编辑名片11'
47
- // bg: '#0dd',
48
- // color: '#d0d'
49
- };
51
+ rankIcon: '//media.winbaoxian.com/autoUpload/activity/diamond_xxx.png',
52
+ mobile: '13800138000'
53
+ },
54
+ buttonData: {
55
+ tx: '编辑名片',
56
+ bg: '#ED9E14',
57
+ color: '#fff'
58
+ }
59
+ };
60
+ },
61
+ methods: {
62
+ avatarHandler() {
63
+ console.log('点击头像或姓名');
64
+ },
65
+ buttonHandler() {
66
+ console.log('点击操作按钮');
50
67
  }
51
68
  }
52
- }
53
- </scripte>
69
+ };
70
+ </script>
54
71
  ```
72
+
73
+ ---
74
+
75
+ ### Attributes
76
+
77
+ #### 根级 props
78
+
79
+ | 参数 | 说明 | 类型 | 默认值 |
80
+ | --- | --- | --- | --- |
81
+ | `cardData` | 必传,名片信息 | Object | 见 CardData 对象 |
82
+ | `buttonData` | 可选,按钮配置 | Object | 见 ButtonData 对象 |
83
+
84
+
85
+ #### CardData 对象
86
+
87
+ | 参数 | 说明 | 类型 | 默认值 |
88
+ | --- | --- | --- | --- |
89
+ | `avatar` | 头像图片地址 | String | `''` |
90
+ | `name` | 姓名 | String | `''` |
91
+ | `rank` | 职级文案 | String | `''` |
92
+ | `rankIcon` | 职级图标地址 | String | `''` |
93
+ | `mobile` | 手机号(点击触发系统拨号) | String | `''` |
94
+
95
+
96
+ #### ButtonData 对象
97
+
98
+ | 参数 | 说明 | 类型 | 默认值 |
99
+ | --- | --- | --- | --- |
100
+ | `tx` | 按钮文案;为空时不渲染按钮 | String | `'编辑名片'` |
101
+ | `bg` | 按钮背景色 | String | `'#ED9E14'` |
102
+ | `color` | 按钮文字颜色 | String | `'#fff'` |
103
+
104
+ ---
105
+
106
+ ### Methods
107
+
108
+ -
109
+
110
+ ---
111
+
112
+ ### Events
113
+
114
+ | 事件名 | 说明 | 参数 |
115
+ | --- | --- | --- |
116
+ | `click` | 点击头像或姓名区域时触发 | — |
117
+ | `clickBtn` | 点击操作按钮时触发 | — |
@@ -111,7 +111,7 @@ export function getHuomianPeriodValue(val = '', pMinus = 0, age = 0) : string {
111
111
  * **将交费期间或者保险期间的值,转换成数值**
112
112
  * @author Lizhao <lz@winbaoxian.com>
113
113
  * @date 2022-04-25
114
- * @param {string} value 必传。需要转换的值
114
+ * @param {string|number} value 必传。需要转换的值
115
115
  * @param {number} age 0 可不传。被保人年龄
116
116
  * @returns {number} 数值
117
117
  * @example
@@ -142,7 +142,7 @@ export function getNumberFromYear(value : string | number, age = 0) : number {
142
142
  * @author Lizhao <lz@winbaoxian.com>
143
143
  * @date 2022-04-25
144
144
  * @param {number} value 必传
145
- * @returns {string} 单位为万的字符串
145
+ * @returns {number|string} 满足条件时返回单位为万的字符串,否则返回原数值
146
146
  * @example
147
147
  * converUnit10000(1000)
148
148
  * // returns 1000
@@ -201,7 +201,7 @@ export function deepCopy(obj : any, hash = new WeakMap()) : any {
201
201
  * **根据生日算年龄**
202
202
  * @author Lizhao <lz@winbaoxian.com>
203
203
  * @date 2022-04-25
204
- * @param {Date|timestamp|dateStr} birth 必传。时间字符串或时间翟
204
+ * @param {Date|timestamp|dateStr} birth 必传。时间字符串或时间戳
205
205
  * @param {Date|timestamp|dateStr} cDate 可不传。指定时间,不传默认为当前时间
206
206
  * @returns {number} 年龄
207
207
  * @example
@@ -228,11 +228,20 @@ export function getAgeFromBirth(birth : Date | number | string, cDate? : Date |
228
228
  }
229
229
 
230
230
  /**
231
- * 将数值转换为千分位
231
+ * **将数值转换为千分位格式的字符串**
232
232
  * @author Lizhao <lz@winbaoxian.com>
233
233
  * @date 2024-09-10
234
- * @param {*} n 数值
235
- * @returns 千分位字符串
234
+ * @param {number|string} n 必传。需要转换的数值
235
+ * @returns {string} 千分位字符串;空值返回空字符串;非数值返回原值
236
+ * @example
237
+ * formatNumberToThousand(1234567)
238
+ * // returns '1,234,567'
239
+ *
240
+ * formatNumberToThousand(0)
241
+ * // returns '0'
242
+ *
243
+ * formatNumberToThousand(null)
244
+ * // returns ''
236
245
  */
237
246
  export function formatNumberToThousand(n) {
238
247
  if (n !== 0 && !n) {
@@ -246,10 +255,21 @@ export function formatNumberToThousand(n) {
246
255
  }
247
256
 
248
257
  /**
249
- * 截取指定字数字符串
250
- * @param str
251
- * @param n
252
- * @returns
258
+ * **截取字符串到指定字数**
259
+ * - 中文字符(及非 `[0-9a-z.()]` 的字符)计为 1 个字符
260
+ * - 数字、小写字母及 `.()` 计为 0.5 个字符
261
+ * - 超出长度时,截取前 n-2 个字符并追加 `...`
262
+ * @author Lizhao <lz@winbaoxian.com>
263
+ * @date 2024-09-10
264
+ * @param {string} str 必传。需要截取的字符串
265
+ * @param {number} n 必传。最大字符数(需大于 2)
266
+ * @returns {string} 截取后的字符串
267
+ * @example
268
+ * textOverflowEllipsis('你好world', 4)
269
+ * // returns 你好...
270
+ *
271
+ * textOverflowEllipsis('hello world', 4)
272
+ * // returns hello world
253
273
  */
254
274
  export function textOverflowEllipsis (str, n) {
255
275
  let text = String(str)
@@ -355,11 +375,12 @@ export function executeElementRule (personData : IPbPersons, product : IPbProduc
355
375
  }
356
376
  if (['cmCommonSelect', 'cmCommonRadioBtn', 'cmCommonRadio', 'cmCommonCheckbox'].includes(ele.componentName!)) {
357
377
  if (ele.defaultValueExp) {
358
- if (ele.value !== 0 && !ele.value && paramMap.t.elementKey !== ele.key) {
359
- const exp = ele.defaultValueExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2')
360
- newEleMap.value = eval(exp)
361
- consoleLogWhenEnable(`${ele.key}: defaultValueExp`, exp, newEleMap.value)
378
+ const exp = ele.defaultValueExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2')
379
+ const expValue = eval(exp)
380
+ if (!['', null, undefined].includes(expValue)) {
381
+ newEleMap.value = expValue
362
382
  }
383
+ consoleLogWhenEnable(`${ele.key}: defaultValueExp`, exp, newEleMap.value)
363
384
  }
364
385
  if (ele.underwriteExp) {
365
386
  const exp = ele.underwriteExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2')
@@ -381,11 +402,12 @@ export function executeElementRule (personData : IPbPersons, product : IPbProduc
381
402
  }
382
403
  if (['cmCommonInput'].includes(ele.componentName!)) {
383
404
  if (ele.defaultValueExp) {
384
- if (ele.value !== 0 && !ele.value && paramMap.t.elementKey !== ele.key) {
385
- const exp = ele.defaultValueExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2')
386
- newEleMap.value = eval(exp)
387
- consoleLogWhenEnable(`${ele.key}: defaultValueExp`, exp, newEleMap.value)
405
+ const exp = ele.defaultValueExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2')
406
+ const expValue = eval(exp)
407
+ if (!['', null, undefined].includes(expValue)) {
408
+ newEleMap.value = expValue
388
409
  }
410
+ consoleLogWhenEnable(`${ele.key}: defaultValueExp`, exp, newEleMap.value)
389
411
  }
390
412
  if (ele.minExp) {
391
413
  const exp = ele.minExp.replace(/(%)(\d+)(\.*\w*)(%)/g, 'paramMap.i$2$3').replace(/(%)(\w*\.*\w*)(%)/g, 'paramMap.$2')
@@ -355,7 +355,7 @@ export function setPersonAgeOptions(personData : IPbPerson) : IPbPerson {
355
355
  * @author Lizhao <lz@winbaoxian.com>
356
356
  * @date 2022-04-26
357
357
  * @param {IPbPersons} allPersonsData 必传。所有人员数据
358
- * @param {null|string} type 可不传。
358
+ * @param {null|string|string[]} type 可不传。
359
359
  * 不传,人员数据按原结构返回;
360
360
  * 字符串,返回指定的人员数据;
361
361
  * 数组,以数组形式,返回多个人员数据。
@@ -50,10 +50,10 @@ export function initProductData(prodData : IPbProduct) : IPbProduct {
50
50
  * @author Lizhao <lz@winbaoxian.com>
51
51
  * @date 2022-04-26
52
52
  * @param {IPbProduct} prodData 必传。产品数据(单个)
53
- * @param {object} productVerifyData 必传。产品校验条件(单个)
53
+ * @param {object} prodVerifyData 必传。产品校验条件(单个)
54
54
  * @param {IPbPersons} personData 必传。人员信息,包括被保人、投保人、投保人配偶
55
- * @param {object} parmas 补充参数,目前只有 planbookId
56
- * @returns {IPbProduct} 产品数据(单个)
55
+ * @param {object} [parmas] 可不传。补充参数,目前只有 planbookId
56
+ * @returns {Promise<IPbProduct>} 产品数据(单个)
57
57
  */
58
58
  export async function productDataHandler(prodData : IPbProduct, prodVerifyData : any, personData : IPbPersons, parmas?: any) : Promise<IPbProduct> {
59
59
  if (!prodData) {
@@ -295,6 +295,7 @@ export async function productDataHandler(prodData : IPbProduct, prodVerifyData :
295
295
 
296
296
  /**
297
297
  * **处理多被保人**
298
+ * @ignore
298
299
  * @author Lizhao <lz@winbaoxian.com>
299
300
  * @date 2024-02-28
300
301
  * @param {IPbPersons} personData 必传。人员信息,包括被保人、投保人、投保人配偶
@@ -327,6 +328,7 @@ function multipleInsuredHandler (personData : IPbPersons) {
327
328
 
328
329
  /**
329
330
  * 请求返回当前产品、当前条件的费率数据
331
+ * @ignore
330
332
  * @author Lizhao <lz@winbaoxian.com>
331
333
  * @date 2024-02-28
332
334
  * @param {IPbProduct} prodData 必传。产品数据(单个)
@@ -384,6 +386,7 @@ function getSingleInsurancesVerifyData (prodData : IPbProduct, personData : IPbP
384
386
 
385
387
  /**
386
388
  * **多被保人,获取并缓存多个险种信息的费率信息**
389
+ * @ignore
387
390
  * @author Lizhao <lz@winbaoxian.com>
388
391
  * @date 2023-12-28
389
392
  * @param { any } params 必传。接口请求信息