general-basic-form 2.1.6 → 2.1.8
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 +81 -236
- package/dist/index.d.ts +12 -0
- package/dist/index.js +9356 -0
- package/dist/index.umd.cjs +152 -0
- package/package.json +4 -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
|
在单纯作为表单的时候可以这样使用:
|
|
@@ -151,28 +172,18 @@ parametersType 类型介绍
|
|
|
151
172
|
defPageSize:10, //默认的每页显示个数
|
|
152
173
|
queryWhenReady:false,//初始化完成后自动触发查找数据函数
|
|
153
174
|
formItem: [
|
|
154
|
-
|
|
155
|
-
label: '',
|
|
156
|
-
prop: 'bsName35',
|
|
157
|
-
type: 'divider',
|
|
158
|
-
setting: {
|
|
159
|
-
},
|
|
160
|
-
template: {
|
|
161
|
-
default: () => {
|
|
162
|
-
return "123123123";
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
},
|
|
175
|
+
|
|
166
176
|
{ label: "款式名称",
|
|
167
177
|
prop: "bsName",
|
|
168
178
|
type: "input",
|
|
179
|
+
legend: '这是一个可选的标题',
|
|
169
180
|
setting: {
|
|
170
181
|
placeholder: '请输入手机验证码',
|
|
171
182
|
style: 'width: 100%',
|
|
172
183
|
required: true,
|
|
173
184
|
},
|
|
174
185
|
fieldSetting: {
|
|
175
|
-
orientation: 'responsive'
|
|
186
|
+
orientation: 'responsive',//表单布局-响应式
|
|
176
187
|
},
|
|
177
188
|
rules: [
|
|
178
189
|
{
|
|
@@ -189,6 +200,8 @@ parametersType 类型介绍
|
|
|
189
200
|
},
|
|
190
201
|
},
|
|
191
202
|
],
|
|
203
|
+
separator: true, //分割线
|
|
204
|
+
|
|
192
205
|
//template: {
|
|
193
206
|
// suffix: () => {
|
|
194
207
|
// return <svg-icon icon-class="baifenbi" />;
|
|
@@ -199,6 +212,11 @@ parametersType 类型介绍
|
|
|
199
212
|
label: '天数-价格配置',
|
|
200
213
|
prop: 'prices',
|
|
201
214
|
type: 'form-list',
|
|
215
|
+
description: [
|
|
216
|
+
'段落1',
|
|
217
|
+
'段落2',
|
|
218
|
+
],
|
|
219
|
+
separator: "text", //文字分割线
|
|
202
220
|
setting: {
|
|
203
221
|
ndim: 3, // 多维数组,注意要和columns的长度相等,输出为对象数组
|
|
204
222
|
columns: [
|
|
@@ -213,12 +231,13 @@ parametersType 类型介绍
|
|
|
213
231
|
},
|
|
214
232
|
},
|
|
215
233
|
{
|
|
216
|
-
prop: '
|
|
234
|
+
prop: 'days',
|
|
217
235
|
label: '套餐名称',
|
|
218
236
|
type: 'input',
|
|
219
237
|
setting: {
|
|
220
238
|
required: true,
|
|
221
239
|
placeholder: '请输入套餐名称',
|
|
240
|
+
type: 'number'
|
|
222
241
|
},
|
|
223
242
|
},
|
|
224
243
|
{
|
|
@@ -237,7 +256,7 @@ parametersType 类型介绍
|
|
|
237
256
|
],
|
|
238
257
|
},
|
|
239
258
|
fieldSetting: {
|
|
240
|
-
className: 'col-span-4
|
|
259
|
+
className: 'col-span-4',
|
|
241
260
|
},
|
|
242
261
|
rules: [
|
|
243
262
|
{
|
|
@@ -245,7 +264,7 @@ parametersType 类型介绍
|
|
|
245
264
|
console.log(value);
|
|
246
265
|
for (let i = 0; i < value.length; i++) {
|
|
247
266
|
const element = value[i];
|
|
248
|
-
if (!Number(element.days)
|
|
267
|
+
if (!Number(element.days)) {
|
|
249
268
|
callback(new Error('请输入数字'));
|
|
250
269
|
return;
|
|
251
270
|
}
|
|
@@ -274,7 +293,6 @@ parametersType 类型介绍
|
|
|
274
293
|
rules: [
|
|
275
294
|
{
|
|
276
295
|
validator: (rule, value, callback) => {
|
|
277
|
-
console.log(value);
|
|
278
296
|
for (let i = 0; i < value.length; i++) {
|
|
279
297
|
const element = value[i];
|
|
280
298
|
if (!element) {
|
|
@@ -287,17 +305,21 @@ parametersType 类型介绍
|
|
|
287
305
|
},
|
|
288
306
|
],
|
|
289
307
|
},
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
308
|
+
{
|
|
309
|
+
prop: 'level',
|
|
310
|
+
label: '等级',
|
|
311
|
+
type: 'select',
|
|
312
|
+
option: [
|
|
313
|
+
{ label: 'Y3', value: 'Y3' },
|
|
314
|
+
{ label: 'Y4', value: 'Y4' },
|
|
315
|
+
{ label: 'Y5', value: 'Y5' },
|
|
316
|
+
],
|
|
317
|
+
setting: {
|
|
318
|
+
placeholder: '请选择等级',
|
|
319
|
+
required: true,
|
|
320
|
+
multiple: true,
|
|
321
|
+
},
|
|
322
|
+
},
|
|
301
323
|
{
|
|
302
324
|
label: "创建时间",
|
|
303
325
|
prop: "create_time",
|
|
@@ -306,20 +328,6 @@ parametersType 类型介绍
|
|
|
306
328
|
"range-separator": "至",
|
|
307
329
|
}
|
|
308
330
|
},
|
|
309
|
-
{
|
|
310
|
-
label: "二次工艺成本价格(人民币分)",
|
|
311
|
-
prop: "spCost",
|
|
312
|
-
type: "input-number",
|
|
313
|
-
"controls-position": "right",
|
|
314
|
-
min: 0,
|
|
315
|
-
rules: [
|
|
316
|
-
{
|
|
317
|
-
required: true,
|
|
318
|
-
message: "请输入二次工艺成本价格",
|
|
319
|
-
trigger: "blur",
|
|
320
|
-
},
|
|
321
|
-
],
|
|
322
|
-
},
|
|
323
331
|
{
|
|
324
332
|
label: '',
|
|
325
333
|
prop: 'bsName2',
|
|
@@ -377,18 +385,24 @@ parametersType 类型介绍
|
|
|
377
385
|
}
|
|
378
386
|
]
|
|
379
387
|
},
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
388
|
+
{
|
|
389
|
+
prop: 'level',
|
|
390
|
+
label: '多选',
|
|
391
|
+
legend: 标题',
|
|
392
|
+
type: 'checkbox',
|
|
393
|
+
gap: 3,
|
|
394
|
+
option: [
|
|
395
|
+
{ label: 'Y3', value: 'Y3' },
|
|
396
|
+
{ label: 'Y4', value: 'Y4' },
|
|
397
|
+
{ label: 'Y5', value: 'Y5' },
|
|
398
|
+
],
|
|
399
|
+
fieldSetting: {
|
|
400
|
+
className: 'col-span-4',
|
|
401
|
+
},
|
|
402
|
+
setting: {
|
|
403
|
+
placeholder: '请选择等级',
|
|
404
|
+
},
|
|
385
405
|
},
|
|
386
|
-
option: [
|
|
387
|
-
{ value: '是', label: 'true' },
|
|
388
|
-
{ value: '否', label: 'false' }
|
|
389
|
-
],
|
|
390
|
-
rules: []
|
|
391
|
-
},
|
|
392
406
|
{
|
|
393
407
|
label: '受访人',
|
|
394
408
|
prop: 'contactors',
|
|
@@ -519,10 +533,7 @@ parametersType 类型介绍
|
|
|
519
533
|
_/
|
|
520
534
|
"date-picker" = "date-picker",
|
|
521
535
|
/\*\*
|
|
522
|
-
|
|
523
|
-
- @return {_}
|
|
524
|
-
_/
|
|
525
|
-
"input-number" = "input-number",
|
|
536
|
+
|
|
526
537
|
/\*\*
|
|
527
538
|
- @description: 单选框
|
|
528
539
|
- @return {_}
|
|
@@ -536,169 +547,3 @@ parametersType 类型介绍
|
|
|
536
547
|
_/
|
|
537
548
|
"checkbox" = "checkbox",
|
|
538
549
|
|
|
539
|
-
# VInfiniteScrollList 对虚拟滚动列表+接口的封装
|
|
540
|
-
|
|
541
|
-

|
|
542
|
-
|
|
543
|
-
```
|
|
544
|
-
import { VInfiniteScrollList } from 'general-basic-form'
|
|
545
|
-
import 'general-basic-form/style'
|
|
546
|
-
<VInfiniteScrollList
|
|
547
|
-
:search="search"
|
|
548
|
-
id="user_id"
|
|
549
|
-
name="name"
|
|
550
|
-
ref="InfiniteScrollListRef"
|
|
551
|
-
checkbox
|
|
552
|
-
:extra="extraRender"
|
|
553
|
-
:max="1"
|
|
554
|
-
/>
|
|
555
|
-
```
|
|
556
|
-
|
|
557
|
-
```
|
|
558
|
-
移动端配合下拉刷新使用
|
|
559
|
-
import { getOrderItem } from "../orderItem/functional"
|
|
560
|
-
// getOrderItem为JSX函数,返回一个VUE组件
|
|
561
|
-
|
|
562
|
-
<t-pull-down-refresh v-model="refreshing" @refresh="onRefresh" class="refresh-content">
|
|
563
|
-
<VInfiniteScrollList :search="loadData" :checkbox="false" id="cancelId" ref="InfiniteScrollListRef" checkbox
|
|
564
|
-
:extra="getOrderItem" height="100%" infinite-scroll-distance="50"/>
|
|
565
|
-
</t-pull-down-refresh>
|
|
566
|
-
```
|
|
567
|
-
|
|
568
|
-
```
|
|
569
|
-
search:数据接口 (page: Number) => Promise<[]>
|
|
570
|
-
id:数据key值(唯一和选择值)
|
|
571
|
-
name:显示名字
|
|
572
|
-
checkbox:是否有多选功能,不传的话就是单纯的虚拟滚动列表
|
|
573
|
-
extra:同行额外显示的内容,(item: any) => VNode | String;
|
|
574
|
-
//el-checkbox有固定高度,如果需要配置高度比较高,例如有换行的自定义extra,最好处理一下样式,例子:
|
|
575
|
-
//:deep(.el-checkbox) {
|
|
576
|
-
// padding: 6px 16px !important;
|
|
577
|
-
// display: flex;
|
|
578
|
-
// align-items: baseline;
|
|
579
|
-
// height: auto;
|
|
580
|
-
//}
|
|
581
|
-
defaultSelection:包含数据key值的对象数组或者直接传入key值数组
|
|
582
|
-
height:默认272px String
|
|
583
|
-
```
|
|
584
|
-
|
|
585
|
-
```
|
|
586
|
-
defineExpose({ reset, loadList, selectInfo, list, ifbottom });
|
|
587
|
-
InfiniteScrollListRef?.value?.reset():重置列表内容
|
|
588
|
-
InfiniteScrollListRef?.value?.lowReset():重置列表内容,但保留已选择的选项
|
|
589
|
-
InfiniteScrollListRef?.value?.loadList():向下滚动列表内容,受到loading和ifbottom的影响
|
|
590
|
-
InfiniteScrollListRef?.value?.refreshList():刷新列表,滚动列表会对整个内容重新请求数据,已选择的内容会自动选择
|
|
591
|
-
InfiniteScrollListRef?.value?.selectInfo:选择的内容
|
|
592
|
-
InfiniteScrollListRef?.value?.list:列表的内容
|
|
593
|
-
InfiniteScrollListRef?.value?.ifbottom:是否到底部
|
|
594
|
-
InfiniteScrollListRef?.value?.loading:加载中
|
|
595
|
-
```
|
|
596
|
-
|
|
597
|
-
# VDescriptions 对展示描述列表的封装
|
|
598
|
-
|
|
599
|
-

|
|
600
|
-
|
|
601
|
-
```
|
|
602
|
-
import { VDescriptions } from 'general-basic-form'
|
|
603
|
-
<VDescriptions
|
|
604
|
-
:formData="props.formData"
|
|
605
|
-
:formItem="formItem"
|
|
606
|
-
componentType="Ant Design Vue"
|
|
607
|
-
...其他el-descriptions的配置
|
|
608
|
-
/>
|
|
609
|
-
```
|
|
610
|
-
|
|
611
|
-
```
|
|
612
|
-
formData:Object
|
|
613
|
-
formItem:[ {
|
|
614
|
-
label: '受访人',
|
|
615
|
-
prop: 'contactors',
|
|
616
|
-
render: (scope: any) => {
|
|
617
|
-
const { $index, row = {} } = scope
|
|
618
|
-
const { contactors = [] } = row
|
|
619
|
-
const ele = (contactors.length > 0 ? <span>{contactors.map((item: any) => item.name).join(",")} </span> : null)
|
|
620
|
-
return ele
|
|
621
|
-
}
|
|
622
|
-
},
|
|
623
|
-
{
|
|
624
|
-
label: '拜访详情',
|
|
625
|
-
prop: 'detail',
|
|
626
|
-
descriptionsItemProps:{
|
|
627
|
-
'label-class-name': 'label-class-name'
|
|
628
|
-
}
|
|
629
|
-
}]
|
|
630
|
-
componentType:"Ant Design Vue"|"Element Plus"(默认)
|
|
631
|
-
strict:Boolean //使用strict参数后,如果formData内的某个字段没有值,对应的描述元素将不会展示(包括标签文字),但有render的字段仍然会展示
|
|
632
|
-
descriptionsItemProps:a-descriptions-item|el-descriptions-item的配置
|
|
633
|
-
```
|
|
634
|
-
|
|
635
|
-
# VInputMobilecVerification,VInputGraphicVerification 表单里的图形验证码、手机验证码组件,可以单独引入
|
|
636
|
-
|
|
637
|
-
```
|
|
638
|
-
<VInputGraphicVerification :item="{同表单,可忽略label和rules字段}" :loading="loading"></VInputGraphicVerification>
|
|
639
|
-
|
|
640
|
-
<VInputMobilecVerification :item="{同表单,可忽略label和rules字段}" componentType="Ant Design Vue" ref="VInputMobilecVerificationRef"></VInputMobilecVerification>
|
|
641
|
-
```
|
|
642
|
-
|
|
643
|
-
```
|
|
644
|
-
componentType:"Ant Design Vue"|"Element Plus"(默认)
|
|
645
|
-
```
|
|
646
|
-
|
|
647
|
-
```
|
|
648
|
-
此用法下必须提供:
|
|
649
|
-
provide(/* 注入名 */ "queryParams", /* 表单值对象 */ queryParams);
|
|
650
|
-
|
|
651
|
-
componentType为Ant Design Vue需要提供:
|
|
652
|
-
import { Form } from 'ant-design-vue';
|
|
653
|
-
provide(/* 注入名 */ "Form", /* Ant Design Vue Form实例,用于表单数据更新等 */ Form);
|
|
654
|
-
|
|
655
|
-
可选:
|
|
656
|
-
provide("size", size); // 同组件size
|
|
657
|
-
provide("getList", getList); // 输入框回车触发
|
|
658
|
-
|
|
659
|
-
调用发送短信验证码和重置的方法
|
|
660
|
-
VInputMobilecVerificationRef.value.VerificationButtonRef.buttonClick()
|
|
661
|
-
VInputMobilecVerificationRef.value.VerificationButtonRef.reset()
|
|
662
|
-
```
|
|
663
|
-
|
|
664
|
-
# VTreeTransfer 树形数据穿梭框
|
|
665
|
-
|
|
666
|
-

|
|
667
|
-
|
|
668
|
-
```
|
|
669
|
-
<VTreeTransfer :dataSource="classmate" :treeAttributes="{
|
|
670
|
-
'node-key': 'user_id', props: { label: 'user_name' }, 'default-expand-all': false
|
|
671
|
-
}" transferTitleRight="白名单(不会被选中)" transferTitleLeft="普通名单" filterable :checkedKeys="checkedKeys">
|
|
672
|
-
</VTreeTransfer>
|
|
673
|
-
|
|
674
|
-
import { VTreeTransfer } from 'general-basic-form';
|
|
675
|
-
const VTreeTransferRef = ref([])
|
|
676
|
-
```
|
|
677
|
-
|
|
678
|
-
```
|
|
679
|
-
dataSource:[
|
|
680
|
-
{
|
|
681
|
-
label: 'Level one 1',
|
|
682
|
-
id:1,
|
|
683
|
-
children: [
|
|
684
|
-
{
|
|
685
|
-
label: 'Level two 1-1',
|
|
686
|
-
id:2,
|
|
687
|
-
children: [
|
|
688
|
-
{
|
|
689
|
-
label: 'Level three 1-1-1',
|
|
690
|
-
id:3,
|
|
691
|
-
},
|
|
692
|
-
],
|
|
693
|
-
},
|
|
694
|
-
],
|
|
695
|
-
},] 树状结构数据
|
|
696
|
-
treeAttributes:{} 树形控件的属性,见https://element-plus.org/zh-CN/component/tree.html
|
|
697
|
-
transferTitleLeft:"" 左标题
|
|
698
|
-
transferTitleRight:"" 右标题
|
|
699
|
-
filterable:false 是否显示搜索框
|
|
700
|
-
checkedKeys:[1,2] 选中的值
|
|
701
|
-
|
|
702
|
-
获取选中的数组详情:
|
|
703
|
-
VTreeTransferRef.value["selectedList"].map((item) => {}))
|
|
704
|
-
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: 陈德立*******419287484@qq.com
|
|
3
|
+
* @Date: 2023-11-07 17:55:59
|
|
4
|
+
* @LastEditTime: 2025-10-24 20:47:29
|
|
5
|
+
* @LastEditors: 陈德立*******419287484@qq.com
|
|
6
|
+
* @Github: https://github.com/Alan1034
|
|
7
|
+
* @Description:
|
|
8
|
+
* @FilePath: /GeneralBasicForm/public/index.d.ts
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
/// <reference types="vite/client" />
|
|
12
|
+
declare module "general-basic-form";
|