general-basic-form 2.1.4 → 2.1.7
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/README.md +117 -222
- package/dist/index.js +4282 -3469
- package/dist/index.umd.cjs +43 -43
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -2,18 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
# GeneralBasicForm
|
|
4
4
|
|
|
5
|
-
## 一个兼容 Vue2 、Vue3 和 React(未来实现) 的表单组件,支持 typescript,vue2 请使用@1 版本,Vue3 请使用@2
|
|
6
|
-
|
|
7
|
-
| 组件\兼容性
|
|
8
|
-
|
|
|
9
|
-
| VGeneralBasicForm
|
|
10
|
-
| VSearchBox
|
|
11
|
-
| VInfiniteScrollList
|
|
12
|
-
| VDescriptions
|
|
13
|
-
| VInputMobilecVerification |
|
|
14
|
-
| VInputGraphicVerification |
|
|
15
|
-
| VTreeTransfer
|
|
16
|
-
| VTabs
|
|
5
|
+
## 一个兼容 Vue2 、Vue3 和 React(未来实现) 的表单组件,支持 typescript,vue2 请使用@1 版本,Vue3 请使用@2 版本,React19请使用@3 版本。
|
|
6
|
+
|
|
7
|
+
| 组件\兼容性 | vue2 | vue3 | Ant Design Vue(next) | Element Plus | Element(ui) | React19 | shadcn/ui |
|
|
8
|
+
| ------------------- | ---- | ---- | ---- | ---- | ---- | ------------------- | ------------------- |
|
|
9
|
+
| VGeneralBasicForm | √ | √ | | √ | √ | | |
|
|
10
|
+
| VSearchBox | √ | | | | √ | | |
|
|
11
|
+
| VInfiniteScrollList | | √ | | √ | | | |
|
|
12
|
+
| VDescriptions | √ | √ | √ | √ | √ | | |
|
|
13
|
+
| VInputMobilecVerification | | √ | √ | √ | | | |
|
|
14
|
+
| VInputGraphicVerification | | √ | √ | √ | | | |
|
|
15
|
+
| VTreeTransfer | √ | √ | | √ | √ | | |
|
|
16
|
+
| VTabs | √ | | | | √ | | |
|
|
17
|
+
| RGeneralBasicForm | | | | | | √ | √ |
|
|
18
|
+
| RFormList | | | | | | √ | √ |
|
|
19
|
+
| RTabs | | | | | | √ | √ |
|
|
17
20
|
|
|
18
21
|
安装:npm i general-basic-form<br/>
|
|
19
22
|
install: npm i general-basic-form
|
|
@@ -34,7 +37,7 @@ app.use(ElementPlus)
|
|
|
34
37
|
```
|
|
35
38
|
|
|
36
39
|
```
|
|
37
|
-
import { RGeneralBasicForm } from 'general-basic-form';
|
|
40
|
+
import { RGeneralBasicForm,RBasicForm } from 'general-basic-form';
|
|
38
41
|
```
|
|
39
42
|
|
|
40
43
|
<RGeneralBasicForm
|
|
@@ -47,6 +50,24 @@ fieldGroupSetting={{ className: 'grid grid-cols-4 gap-4' }}
|
|
|
47
50
|
|
|
48
51
|
> </RGeneralBasicForm>
|
|
49
52
|
|
|
53
|
+
<RBasicForm
|
|
54
|
+
formItem={formItem}
|
|
55
|
+
getList={getList}
|
|
56
|
+
parametersType="data"
|
|
57
|
+
noInputBlank
|
|
58
|
+
formData={detail}
|
|
59
|
+
fieldGroupSetting={{ className: 'grid grid-cols-4 gap-4' }}
|
|
60
|
+
coms={{
|
|
61
|
+
Input,
|
|
62
|
+
Button,
|
|
63
|
+
Select,
|
|
64
|
+
SelectContent,
|
|
65
|
+
SelectItem,
|
|
66
|
+
SelectTrigger,
|
|
67
|
+
SelectValue,
|
|
68
|
+
SelectGroup,
|
|
69
|
+
}}
|
|
70
|
+
></RBasicForm>
|
|
50
71
|

|
|
51
72
|
|
|
52
73
|
在单纯作为表单的时候可以这样使用:
|
|
@@ -199,15 +220,49 @@ parametersType 类型介绍
|
|
|
199
220
|
label: '天数-价格配置',
|
|
200
221
|
prop: 'prices',
|
|
201
222
|
type: 'form-list',
|
|
223
|
+
description: [
|
|
224
|
+
'段落1',
|
|
225
|
+
'段落2',
|
|
226
|
+
],
|
|
202
227
|
setting: {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
228
|
+
ndim: 3, // 多维数组,注意要和columns的长度相等,输出为对象数组
|
|
229
|
+
columns: [
|
|
230
|
+
{
|
|
231
|
+
prop: 'id',
|
|
232
|
+
label: '套餐ID',
|
|
233
|
+
type: 'input',
|
|
234
|
+
setting: {
|
|
235
|
+
placeholder: '请输入套餐ID',
|
|
236
|
+
disabled: true,
|
|
237
|
+
className: 'hidden',
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
prop: 'packageCode',
|
|
242
|
+
label: '套餐名称',
|
|
243
|
+
type: 'input',
|
|
244
|
+
setting: {
|
|
245
|
+
required: true,
|
|
246
|
+
placeholder: '请输入套餐名称',
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
prop: 'serviceType',
|
|
251
|
+
label: '服务类型',
|
|
252
|
+
type: 'select',
|
|
253
|
+
option: [
|
|
254
|
+
{ label: '到家服务', value: 'home_service' },
|
|
255
|
+
{ label: '医院陪护', value: 'hospital_care' },
|
|
256
|
+
],
|
|
257
|
+
setting: {
|
|
258
|
+
placeholder: '请选择服务类型',
|
|
259
|
+
required: true,
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
],
|
|
208
263
|
},
|
|
209
264
|
fieldSetting: {
|
|
210
|
-
className: 'col-span-
|
|
265
|
+
className: 'col-span-4 overflow-auto',
|
|
211
266
|
},
|
|
212
267
|
rules: [
|
|
213
268
|
{
|
|
@@ -224,6 +279,10 @@ parametersType 类型介绍
|
|
|
224
279
|
},
|
|
225
280
|
},
|
|
226
281
|
],
|
|
282
|
+
removeItemAction: (item, index) => {
|
|
283
|
+
// 删除项会触发此函数
|
|
284
|
+
console.log(item, index);
|
|
285
|
+
},
|
|
227
286
|
},
|
|
228
287
|
{
|
|
229
288
|
label: '护士在线增值服务内容',
|
|
@@ -232,7 +291,7 @@ parametersType 类型介绍
|
|
|
232
291
|
setting: {
|
|
233
292
|
placeholder: ['请输入服务内容'],
|
|
234
293
|
required: true,
|
|
235
|
-
ndim: 1, // 1
|
|
294
|
+
ndim: 1, // 1维数组,输出为字符串数组
|
|
236
295
|
},
|
|
237
296
|
fieldSetting: {
|
|
238
297
|
className: 'col-span-2',
|
|
@@ -453,216 +512,52 @@ parametersType 类型介绍
|
|
|
453
512
|
|
|
454
513
|
支持组件 type:
|
|
455
514
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
515
|
+
/\*\*
|
|
516
|
+
|
|
517
|
+
- @description: 输入框
|
|
518
|
+
- @return {_}
|
|
519
|
+
_/
|
|
460
520
|
"input" = "input",
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
521
|
+
/\*\*
|
|
522
|
+
- @description: 表单中的多维列表,可增减元素
|
|
523
|
+
- @return {_}
|
|
524
|
+
_/
|
|
465
525
|
"form-list" = "form-list",
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
526
|
+
/\*\*
|
|
527
|
+
- @description: 分割线
|
|
528
|
+
- @return {_}
|
|
529
|
+
_/
|
|
470
530
|
"divider" = "divider",
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
531
|
+
/\*\*
|
|
532
|
+
- @description: 选择器
|
|
533
|
+
- @return {_}
|
|
534
|
+
_/
|
|
475
535
|
"select" = "select",
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
536
|
+
/\*\*
|
|
537
|
+
- @description: 级联选择器
|
|
538
|
+
- @return {_}
|
|
539
|
+
_/
|
|
480
540
|
"cascader" = "cascader",
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
541
|
+
/\*\*
|
|
542
|
+
- @description: 日期选择器
|
|
543
|
+
- @return {_}
|
|
544
|
+
_/
|
|
485
545
|
"date-picker" = "date-picker",
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
546
|
+
/\*\*
|
|
547
|
+
- @description: 数字输入框
|
|
548
|
+
- @return {_}
|
|
549
|
+
_/
|
|
490
550
|
"input-number" = "input-number",
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
551
|
+
/\*\*
|
|
552
|
+
- @description: 单选框
|
|
553
|
+
- @return {_}
|
|
554
|
+
_/
|
|
495
555
|
"radio" = "radio",
|
|
496
556
|
|
|
497
|
-
|
|
498
|
-
* @description: 多选框
|
|
499
|
-
* @return {*}
|
|
500
|
-
*/
|
|
501
|
-
"checkbox" = "checkbox",
|
|
502
|
-
|
|
503
|
-
# VInfiniteScrollList 对虚拟滚动列表+接口的封装
|
|
504
|
-
|
|
505
|
-

|
|
506
|
-
|
|
507
|
-
```
|
|
508
|
-
import { VInfiniteScrollList } from 'general-basic-form'
|
|
509
|
-
import 'general-basic-form/style'
|
|
510
|
-
<VInfiniteScrollList
|
|
511
|
-
:search="search"
|
|
512
|
-
id="user_id"
|
|
513
|
-
name="name"
|
|
514
|
-
ref="InfiniteScrollListRef"
|
|
515
|
-
checkbox
|
|
516
|
-
:extra="extraRender"
|
|
517
|
-
:max="1"
|
|
518
|
-
/>
|
|
519
|
-
```
|
|
520
|
-
|
|
521
|
-
```
|
|
522
|
-
移动端配合下拉刷新使用
|
|
523
|
-
import { getOrderItem } from "../orderItem/functional"
|
|
524
|
-
// getOrderItem为JSX函数,返回一个VUE组件
|
|
525
|
-
|
|
526
|
-
<t-pull-down-refresh v-model="refreshing" @refresh="onRefresh" class="refresh-content">
|
|
527
|
-
<VInfiniteScrollList :search="loadData" :checkbox="false" id="cancelId" ref="InfiniteScrollListRef" checkbox
|
|
528
|
-
:extra="getOrderItem" height="100%" infinite-scroll-distance="50"/>
|
|
529
|
-
</t-pull-down-refresh>
|
|
530
|
-
```
|
|
531
|
-
|
|
532
|
-
```
|
|
533
|
-
search:数据接口 (page: Number) => Promise<[]>
|
|
534
|
-
id:数据key值(唯一和选择值)
|
|
535
|
-
name:显示名字
|
|
536
|
-
checkbox:是否有多选功能,不传的话就是单纯的虚拟滚动列表
|
|
537
|
-
extra:同行额外显示的内容,(item: any) => VNode | String;
|
|
538
|
-
//el-checkbox有固定高度,如果需要配置高度比较高,例如有换行的自定义extra,最好处理一下样式,例子:
|
|
539
|
-
//:deep(.el-checkbox) {
|
|
540
|
-
// padding: 6px 16px !important;
|
|
541
|
-
// display: flex;
|
|
542
|
-
// align-items: baseline;
|
|
543
|
-
// height: auto;
|
|
544
|
-
//}
|
|
545
|
-
defaultSelection:包含数据key值的对象数组或者直接传入key值数组
|
|
546
|
-
height:默认272px String
|
|
547
|
-
```
|
|
548
|
-
|
|
549
|
-
```
|
|
550
|
-
defineExpose({ reset, loadList, selectInfo, list, ifbottom });
|
|
551
|
-
InfiniteScrollListRef?.value?.reset():重置列表内容
|
|
552
|
-
InfiniteScrollListRef?.value?.lowReset():重置列表内容,但保留已选择的选项
|
|
553
|
-
InfiniteScrollListRef?.value?.loadList():向下滚动列表内容,受到loading和ifbottom的影响
|
|
554
|
-
InfiniteScrollListRef?.value?.refreshList():刷新列表,滚动列表会对整个内容重新请求数据,已选择的内容会自动选择
|
|
555
|
-
InfiniteScrollListRef?.value?.selectInfo:选择的内容
|
|
556
|
-
InfiniteScrollListRef?.value?.list:列表的内容
|
|
557
|
-
InfiniteScrollListRef?.value?.ifbottom:是否到底部
|
|
558
|
-
InfiniteScrollListRef?.value?.loading:加载中
|
|
559
|
-
```
|
|
560
|
-
|
|
561
|
-
# VDescriptions 对展示描述列表的封装
|
|
562
|
-
|
|
563
|
-

|
|
564
|
-
|
|
565
|
-
```
|
|
566
|
-
import { VDescriptions } from 'general-basic-form'
|
|
567
|
-
<VDescriptions
|
|
568
|
-
:formData="props.formData"
|
|
569
|
-
:formItem="formItem"
|
|
570
|
-
componentType="Ant Design Vue"
|
|
571
|
-
...其他el-descriptions的配置
|
|
572
|
-
/>
|
|
573
|
-
```
|
|
557
|
+
/\*\*
|
|
574
558
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
prop: 'contactors',
|
|
580
|
-
render: (scope: any) => {
|
|
581
|
-
const { $index, row = {} } = scope
|
|
582
|
-
const { contactors = [] } = row
|
|
583
|
-
const ele = (contactors.length > 0 ? <span>{contactors.map((item: any) => item.name).join(",")} </span> : null)
|
|
584
|
-
return ele
|
|
585
|
-
}
|
|
586
|
-
},
|
|
587
|
-
{
|
|
588
|
-
label: '拜访详情',
|
|
589
|
-
prop: 'detail',
|
|
590
|
-
descriptionsItemProps:{
|
|
591
|
-
'label-class-name': 'label-class-name'
|
|
592
|
-
}
|
|
593
|
-
}]
|
|
594
|
-
componentType:"Ant Design Vue"|"Element Plus"(默认)
|
|
595
|
-
strict:Boolean //使用strict参数后,如果formData内的某个字段没有值,对应的描述元素将不会展示(包括标签文字),但有render的字段仍然会展示
|
|
596
|
-
descriptionsItemProps:a-descriptions-item|el-descriptions-item的配置
|
|
597
|
-
```
|
|
598
|
-
|
|
599
|
-
# VInputMobilecVerification,VInputGraphicVerification 表单里的图形验证码、手机验证码组件,可以单独引入
|
|
600
|
-
|
|
601
|
-
```
|
|
602
|
-
<VInputGraphicVerification :item="{同表单,可忽略label和rules字段}" :loading="loading"></VInputGraphicVerification>
|
|
603
|
-
|
|
604
|
-
<VInputMobilecVerification :item="{同表单,可忽略label和rules字段}" componentType="Ant Design Vue" ref="VInputMobilecVerificationRef"></VInputMobilecVerification>
|
|
605
|
-
```
|
|
606
|
-
|
|
607
|
-
```
|
|
608
|
-
componentType:"Ant Design Vue"|"Element Plus"(默认)
|
|
609
|
-
```
|
|
610
|
-
|
|
611
|
-
```
|
|
612
|
-
此用法下必须提供:
|
|
613
|
-
provide(/* 注入名 */ "queryParams", /* 表单值对象 */ queryParams);
|
|
614
|
-
|
|
615
|
-
componentType为Ant Design Vue需要提供:
|
|
616
|
-
import { Form } from 'ant-design-vue';
|
|
617
|
-
provide(/* 注入名 */ "Form", /* Ant Design Vue Form实例,用于表单数据更新等 */ Form);
|
|
618
|
-
|
|
619
|
-
可选:
|
|
620
|
-
provide("size", size); // 同组件size
|
|
621
|
-
provide("getList", getList); // 输入框回车触发
|
|
622
|
-
|
|
623
|
-
调用发送短信验证码和重置的方法
|
|
624
|
-
VInputMobilecVerificationRef.value.VerificationButtonRef.buttonClick()
|
|
625
|
-
VInputMobilecVerificationRef.value.VerificationButtonRef.reset()
|
|
626
|
-
```
|
|
627
|
-
|
|
628
|
-
# VTreeTransfer 树形数据穿梭框
|
|
629
|
-
|
|
630
|
-

|
|
631
|
-
|
|
632
|
-
```
|
|
633
|
-
<VTreeTransfer :dataSource="classmate" :treeAttributes="{
|
|
634
|
-
'node-key': 'user_id', props: { label: 'user_name' }, 'default-expand-all': false
|
|
635
|
-
}" transferTitleRight="白名单(不会被选中)" transferTitleLeft="普通名单" filterable :checkedKeys="checkedKeys">
|
|
636
|
-
</VTreeTransfer>
|
|
637
|
-
|
|
638
|
-
import { VTreeTransfer } from 'general-basic-form';
|
|
639
|
-
const VTreeTransferRef = ref([])
|
|
640
|
-
```
|
|
559
|
+
- @description: 多选框
|
|
560
|
+
- @return {_}
|
|
561
|
+
_/
|
|
562
|
+
"checkbox" = "checkbox",
|
|
641
563
|
|
|
642
|
-
```
|
|
643
|
-
dataSource:[
|
|
644
|
-
{
|
|
645
|
-
label: 'Level one 1',
|
|
646
|
-
id:1,
|
|
647
|
-
children: [
|
|
648
|
-
{
|
|
649
|
-
label: 'Level two 1-1',
|
|
650
|
-
id:2,
|
|
651
|
-
children: [
|
|
652
|
-
{
|
|
653
|
-
label: 'Level three 1-1-1',
|
|
654
|
-
id:3,
|
|
655
|
-
},
|
|
656
|
-
],
|
|
657
|
-
},
|
|
658
|
-
],
|
|
659
|
-
},] 树状结构数据
|
|
660
|
-
treeAttributes:{} 树形控件的属性,见https://element-plus.org/zh-CN/component/tree.html
|
|
661
|
-
transferTitleLeft:"" 左标题
|
|
662
|
-
transferTitleRight:"" 右标题
|
|
663
|
-
filterable:false 是否显示搜索框
|
|
664
|
-
checkedKeys:[1,2] 选中的值
|
|
665
|
-
|
|
666
|
-
获取选中的数组详情:
|
|
667
|
-
VTreeTransferRef.value["selectedList"].map((item) => {}))
|
|
668
|
-
```
|