general-basic-form 2.1.1 → 2.1.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.
- package/README.md +171 -136
- package/dist/index.js +1156 -1042
- package/dist/index.umd.cjs +25 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
+
<!-- @format -->
|
|
2
|
+
|
|
1
3
|
# GeneralBasicForm
|
|
2
4
|
|
|
3
|
-
## 一个兼容 Vue2 、Vue3 和 React(未来实现)
|
|
5
|
+
## 一个兼容 Vue2 、Vue3 和 React(未来实现) 的表单组件,支持 typescript,vue2 请使用@1 版本,Vue3 请使用@2 版本
|
|
4
6
|
|
|
5
|
-
| 组件\兼容性
|
|
6
|
-
|
|
|
7
|
-
| VGeneralBasicForm
|
|
8
|
-
| VSearchBox
|
|
9
|
-
| VInfiniteScrollList
|
|
10
|
-
| VDescriptions
|
|
11
|
-
| VInputMobilecVerification |
|
|
12
|
-
| VInputGraphicVerification |
|
|
13
|
-
| VTreeTransfer
|
|
14
|
-
| VTabs
|
|
7
|
+
| 组件\兼容性 | vue2 | vue3 | Ant Design Vue(next) | Element Plus | Element(ui) |
|
|
8
|
+
| ------------------------- | ---- | ---- | ---------------------- | ------------ | ------------- |
|
|
9
|
+
| VGeneralBasicForm | √ | √ | | √ | √ |
|
|
10
|
+
| VSearchBox | √ | | | | √ |
|
|
11
|
+
| VInfiniteScrollList | | √ | | √ | |
|
|
12
|
+
| VDescriptions | √ | √ | √ | √ | √ |
|
|
13
|
+
| VInputMobilecVerification | | √ | √ | √ | |
|
|
14
|
+
| VInputGraphicVerification | | √ | √ | √ | |
|
|
15
|
+
| VTreeTransfer | √ | √ | | √ | √ |
|
|
16
|
+
| VTabs | √ | | | | √ |
|
|
15
17
|
|
|
16
18
|
安装:npm i general-basic-form<br/>
|
|
17
19
|
install: npm i general-basic-form
|
|
18
20
|
|
|
19
|
-
webpack4兼容:
|
|
21
|
+
webpack4 兼容:
|
|
20
22
|
加入配置:module.exports = {
|
|
21
|
-
|
|
23
|
+
transpileDependencies: ['general-basic-form'],
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
示例:
|
|
@@ -34,7 +36,16 @@ app.use(ElementPlus)
|
|
|
34
36
|
```
|
|
35
37
|
import { RGeneralBasicForm } from 'general-basic-form';
|
|
36
38
|
```
|
|
37
|
-
|
|
39
|
+
|
|
40
|
+
<RGeneralBasicForm
|
|
41
|
+
formItem={formItem}
|
|
42
|
+
getList={getList}
|
|
43
|
+
parametersType="data"
|
|
44
|
+
noInputBlank
|
|
45
|
+
formData={detail}
|
|
46
|
+
fieldGroupSetting={{ className: 'grid grid-cols-4 gap-4' }}
|
|
47
|
+
|
|
48
|
+
> </RGeneralBasicForm>
|
|
38
49
|
|
|
39
50
|

|
|
40
51
|
|
|
@@ -53,7 +64,7 @@ import { RGeneralBasicForm } from 'general-basic-form';
|
|
|
53
64
|
:afterReset="afterReset"
|
|
54
65
|
v-model:loading="loading"
|
|
55
66
|
/>
|
|
56
|
-
|
|
67
|
+
|
|
57
68
|
<style lang="scss" scoped>
|
|
58
69
|
:deep(.el-form-item) {
|
|
59
70
|
margin-bottom: 16px;
|
|
@@ -63,7 +74,7 @@ import { RGeneralBasicForm } from 'general-basic-form';
|
|
|
63
74
|
}
|
|
64
75
|
</style>
|
|
65
76
|
|
|
66
|
-
getList会传出默认的参数,首次请求时会有页数和分页大小,重置后会传出默认页数1
|
|
77
|
+
getList 会传出默认的参数,首次请求时会有页数和分页大小,重置后会传出默认页数 1
|
|
67
78
|
|
|
68
79
|
async getList(
|
|
69
80
|
params = {
|
|
@@ -72,7 +83,7 @@ getList会传出默认的参数,首次请求时会有页数和分页大小,重
|
|
|
72
83
|
}
|
|
73
84
|
) {}
|
|
74
85
|
|
|
75
|
-
表单数据校验需要拿到内部表单的ref
|
|
86
|
+
表单数据校验需要拿到内部表单的 ref
|
|
76
87
|
|
|
77
88
|
async getSmscode() {
|
|
78
89
|
const VGeneralBasicFormRef = this.$refs['VGeneralBasicFormRef'] as any
|
|
@@ -97,7 +108,7 @@ getList会传出默认的参数,首次请求时会有页数和分页大小,重
|
|
|
97
108
|
})
|
|
98
109
|
return state
|
|
99
110
|
},
|
|
100
|
-
|
|
111
|
+
|
|
101
112
|
setup写法:
|
|
102
113
|
const VGeneralBasicFormRef = ref()
|
|
103
114
|
const params = await new Promise<any>((resolve, reject) => {
|
|
@@ -113,16 +124,15 @@ getList会传出默认的参数,首次请求时会有页数和分页大小,重
|
|
|
113
124
|
)
|
|
114
125
|
})
|
|
115
126
|
|
|
116
|
-
|
|
117
127
|

|
|
118
128
|
|
|
119
|
-
parametersType类型介绍
|
|
129
|
+
parametersType 类型介绍
|
|
120
130
|
|
|
121
|
-
| parametersType形式 | 支持页面刷新 | 参数改变引起路由跳转 | 组件间共享数据 | 存储上限 | 浏览器兼容性 |
|
|
122
|
-
|
|
|
123
|
-
| url
|
|
124
|
-
| data
|
|
125
|
-
| indexDB
|
|
131
|
+
| parametersType 形式 | 支持页面刷新 | 参数改变引起路由跳转 | 组件间共享数据 | 存储上限 | 浏览器兼容性 |
|
|
132
|
+
| ------------------- | ------------ | -------------------- | -------------- | -------- | ------------ |
|
|
133
|
+
| url | 是 | 是 | 是 | 中 | 高 |
|
|
134
|
+
| data | 否 | 否 | 否 | 高 | 高 |
|
|
135
|
+
| indexDB | 是 | 否 | 是 | 高 | 中 |
|
|
126
136
|
|
|
127
137
|
数据示例:
|
|
128
138
|
|
|
@@ -139,7 +149,7 @@ parametersType类型介绍
|
|
|
139
149
|
pageSizeKey:"limit", //每页显示个数key
|
|
140
150
|
defCurrentPage:1, //默认的页数
|
|
141
151
|
defPageSize:10, //默认的每页显示个数
|
|
142
|
-
queryWhenReady:false
|
|
152
|
+
queryWhenReady:false,//初始化完成后自动触发查找数据函数
|
|
143
153
|
formItem: [
|
|
144
154
|
{
|
|
145
155
|
label: '',
|
|
@@ -158,23 +168,91 @@ parametersType类型介绍
|
|
|
158
168
|
type: "input",
|
|
159
169
|
setting: {
|
|
160
170
|
placeholder: '请输入手机验证码',
|
|
161
|
-
style: 'width: 100%'
|
|
171
|
+
style: 'width: 100%',
|
|
172
|
+
required: true,
|
|
162
173
|
},
|
|
174
|
+
fieldSetting: {
|
|
175
|
+
orientation: 'responsive',
|
|
176
|
+
},
|
|
163
177
|
rules: [
|
|
164
178
|
{
|
|
165
|
-
message: "请输入信息"
|
|
179
|
+
message: "请输入信息",
|
|
180
|
+
required: true,
|
|
166
181
|
},
|
|
167
182
|
{
|
|
168
183
|
pattern: /^\w+[\,\,\-\w' '#]+$/,
|
|
169
184
|
message: "请输入正确的Invoice单号"
|
|
170
|
-
}
|
|
171
|
-
],
|
|
172
|
-
template: {
|
|
173
|
-
suffix: () => {
|
|
174
|
-
return <svg-icon icon-class="baifenbi" />;
|
|
175
185
|
},
|
|
186
|
+
{
|
|
187
|
+
validator: (rule, value, callback) => {
|
|
188
|
+
callback();
|
|
176
189
|
},
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
//template: {
|
|
193
|
+
// suffix: () => {
|
|
194
|
+
// return <svg-icon icon-class="baifenbi" />;
|
|
195
|
+
// },
|
|
196
|
+
//},
|
|
177
197
|
},
|
|
198
|
+
{
|
|
199
|
+
label: '天数-价格配置',
|
|
200
|
+
prop: 'prices',
|
|
201
|
+
type: 'form-list',
|
|
202
|
+
setting: {
|
|
203
|
+
placeholder: ['请输入天数', '请输入价格'],
|
|
204
|
+
required: true,
|
|
205
|
+
type: 'number',
|
|
206
|
+
ndim: 2, // 多维数组
|
|
207
|
+
columns: ['days', 'price'],
|
|
208
|
+
},
|
|
209
|
+
fieldSetting: {
|
|
210
|
+
className: 'col-span-2',
|
|
211
|
+
},
|
|
212
|
+
rules: [
|
|
213
|
+
{
|
|
214
|
+
validator: (rule, value, callback) => {
|
|
215
|
+
console.log(value);
|
|
216
|
+
for (let i = 0; i < value.length; i++) {
|
|
217
|
+
const element = value[i];
|
|
218
|
+
if (!Number(element.days) || !Number(element.price)) {
|
|
219
|
+
callback(new Error('请输入数字'));
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
callback();
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
label: '护士在线增值服务内容',
|
|
230
|
+
prop: 'nursingCare',
|
|
231
|
+
type: 'form-list',
|
|
232
|
+
setting: {
|
|
233
|
+
placeholder: ['请输入服务内容'],
|
|
234
|
+
required: true,
|
|
235
|
+
ndim: 1, // 1维数组
|
|
236
|
+
},
|
|
237
|
+
fieldSetting: {
|
|
238
|
+
className: 'col-span-2',
|
|
239
|
+
},
|
|
240
|
+
rules: [
|
|
241
|
+
{
|
|
242
|
+
validator: (rule, value, callback) => {
|
|
243
|
+
console.log(value);
|
|
244
|
+
for (let i = 0; i < value.length; i++) {
|
|
245
|
+
const element = value[i];
|
|
246
|
+
if (!element) {
|
|
247
|
+
callback(new Error('请输入服务内容'));
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
callback();
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
},
|
|
178
256
|
{
|
|
179
257
|
label: "二次工艺",
|
|
180
258
|
prop: "spName",
|
|
@@ -186,7 +264,7 @@ parametersType类型介绍
|
|
|
186
264
|
{ value: "2", label: "绣花" },
|
|
187
265
|
],
|
|
188
266
|
},
|
|
189
|
-
{
|
|
267
|
+
{
|
|
190
268
|
label: "创建时间",
|
|
191
269
|
prop: "create_time",
|
|
192
270
|
type: "date-picker",
|
|
@@ -361,112 +439,68 @@ parametersType类型介绍
|
|
|
361
439
|
],
|
|
362
440
|
},
|
|
363
441
|
],
|
|
364
|
-
|
|
442
|
+
|
|
365
443
|
//rules为表单校验规则,每个组件都可以传入
|
|
366
|
-
|
|
444
|
+
|
|
367
445
|
//input支持template,支持以下几个属性:
|
|
368
446
|
//prefix 输入框头部内容,只对 type="text"(默认) 有效
|
|
369
447
|
//suffix 输入框尾部内容,只对 type="text" 有效
|
|
370
448
|
//prepend 输入框前置内容,只对 type="text" 有效
|
|
371
449
|
//append 输入框后置内容,只对 type="text" 有效
|
|
372
|
-
|
|
450
|
+
|
|
373
451
|
//divider支持template:
|
|
374
452
|
//default
|
|
375
|
-
支持组件type:
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
|
|
379
|
-
\* @description: 输入框
|
|
380
|
-
|
|
381
|
-
*/
|
|
382
|
-
|
|
383
|
-
'input' = 'input',
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
|
|
387
|
-
\* @description: 输入框/图像验证码
|
|
388
|
-
|
|
389
|
-
*/
|
|
390
|
-
|
|
391
|
-
'input-graphic-verification' = 'input-graphic-verification',
|
|
392
|
-
|
|
393
|
-
/**
|
|
394
|
-
|
|
395
|
-
\* @description: 输入框/手机验证码
|
|
396
|
-
|
|
397
|
-
*/
|
|
398
|
-
|
|
399
|
-
'input-mobile-verification' = 'input-mobile-verification',
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
|
|
403
|
-
\* @description: 分割线
|
|
404
|
-
|
|
405
|
-
*/
|
|
406
|
-
|
|
407
|
-
'divider' = 'divider',
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
|
|
411
|
-
\* @description: 选择器
|
|
412
|
-
|
|
413
|
-
*/
|
|
414
|
-
|
|
415
|
-
'select' = 'select',
|
|
416
|
-
|
|
417
|
-
/**
|
|
418
|
-
|
|
419
|
-
\* @description: 级联选择器
|
|
420
|
-
|
|
421
|
-
*/
|
|
422
|
-
|
|
423
|
-
'cascader' = 'cascader',
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
|
|
427
|
-
\* @description: 日期选择器
|
|
428
|
-
|
|
429
|
-
*/
|
|
430
|
-
|
|
431
|
-
'date-picker' = 'date-picker',
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
|
|
435
|
-
\* @description: 数字输入框
|
|
436
|
-
|
|
437
|
-
*/
|
|
438
|
-
|
|
439
|
-
'input-number' = 'input-number',
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
|
|
443
|
-
\* @description: 单选框
|
|
444
|
-
|
|
445
|
-
*/
|
|
446
|
-
|
|
447
|
-
'radio' = 'radio',
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
|
|
451
|
-
\* @description: 自定义元素,插槽组件
|
|
452
|
-
|
|
453
|
-
*/
|
|
454
|
-
|
|
455
|
-
'form-item-slot'='form-item-slot',
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
|
|
459
|
-
\* @description: 多选框
|
|
460
|
-
|
|
461
|
-
*/
|
|
462
|
-
|
|
463
|
-
'checkbox'='checkbox',
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
# VInfiniteScrollList对虚拟滚动列表+接口的封装
|
|
468
|
-
|
|
469
453
|
|
|
454
|
+
支持组件 type:
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* @description: 输入框
|
|
458
|
+
* @return {*}
|
|
459
|
+
*/
|
|
460
|
+
"input" = "input",
|
|
461
|
+
/**
|
|
462
|
+
* @description: 表单中的多维列表,可增减元素
|
|
463
|
+
* @return {*}
|
|
464
|
+
*/
|
|
465
|
+
"form-list" = "form-list",
|
|
466
|
+
/**
|
|
467
|
+
* @description: 分割线
|
|
468
|
+
* @return {*}
|
|
469
|
+
*/
|
|
470
|
+
"divider" = "divider",
|
|
471
|
+
/**
|
|
472
|
+
* @description: 选择器
|
|
473
|
+
* @return {*}
|
|
474
|
+
*/
|
|
475
|
+
"select" = "select",
|
|
476
|
+
/**
|
|
477
|
+
* @description: 级联选择器
|
|
478
|
+
* @return {*}
|
|
479
|
+
*/
|
|
480
|
+
"cascader" = "cascader",
|
|
481
|
+
/**
|
|
482
|
+
* @description: 日期选择器
|
|
483
|
+
* @return {*}
|
|
484
|
+
*/
|
|
485
|
+
"date-picker" = "date-picker",
|
|
486
|
+
/**
|
|
487
|
+
* @description: 数字输入框
|
|
488
|
+
* @return {*}
|
|
489
|
+
*/
|
|
490
|
+
"input-number" = "input-number",
|
|
491
|
+
/**
|
|
492
|
+
* @description: 单选框
|
|
493
|
+
* @return {*}
|
|
494
|
+
*/
|
|
495
|
+
"radio" = "radio",
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* @description: 多选框
|
|
499
|
+
* @return {*}
|
|
500
|
+
*/
|
|
501
|
+
"checkbox" = "checkbox",
|
|
502
|
+
|
|
503
|
+
# VInfiniteScrollList 对虚拟滚动列表+接口的封装
|
|
470
504
|
|
|
471
505
|

|
|
472
506
|
|
|
@@ -483,6 +517,7 @@ import 'general-basic-form/style'
|
|
|
483
517
|
:max="1"
|
|
484
518
|
/>
|
|
485
519
|
```
|
|
520
|
+
|
|
486
521
|
```
|
|
487
522
|
移动端配合下拉刷新使用
|
|
488
523
|
import { getOrderItem } from "../orderItem/functional"
|
|
@@ -493,6 +528,7 @@ import { getOrderItem } from "../orderItem/functional"
|
|
|
493
528
|
:extra="getOrderItem" height="100%" infinite-scroll-distance="50"/>
|
|
494
529
|
</t-pull-down-refresh>
|
|
495
530
|
```
|
|
531
|
+
|
|
496
532
|
```
|
|
497
533
|
search:数据接口 (page: Number) => Promise<[]>
|
|
498
534
|
id:数据key值(唯一和选择值)
|
|
@@ -522,7 +558,7 @@ height:默认272px String
|
|
|
522
558
|
InfiniteScrollListRef?.value?.loading:加载中
|
|
523
559
|
```
|
|
524
560
|
|
|
525
|
-
# VDescriptions对展示描述列表的封装
|
|
561
|
+
# VDescriptions 对展示描述列表的封装
|
|
526
562
|
|
|
527
563
|

|
|
528
564
|
|
|
@@ -560,7 +596,7 @@ strict:Boolean //使用strict参数后,如果formData内的某个字段没有
|
|
|
560
596
|
descriptionsItemProps:a-descriptions-item|el-descriptions-item的配置
|
|
561
597
|
```
|
|
562
598
|
|
|
563
|
-
# VInputMobilecVerification,VInputGraphicVerification表单里的图形验证码、手机验证码组件,可以单独引入
|
|
599
|
+
# VInputMobilecVerification,VInputGraphicVerification 表单里的图形验证码、手机验证码组件,可以单独引入
|
|
564
600
|
|
|
565
601
|
```
|
|
566
602
|
<VInputGraphicVerification :item="{同表单,可忽略label和rules字段}" :loading="loading"></VInputGraphicVerification>
|
|
@@ -598,8 +634,8 @@ VInputMobilecVerificationRef.value.VerificationButtonRef.reset()
|
|
|
598
634
|
'node-key': 'user_id', props: { label: 'user_name' }, 'default-expand-all': false
|
|
599
635
|
}" transferTitleRight="白名单(不会被选中)" transferTitleLeft="普通名单" filterable :checkedKeys="checkedKeys">
|
|
600
636
|
</VTreeTransfer>
|
|
601
|
-
|
|
602
|
-
import { VTreeTransfer } from 'general-basic-form';
|
|
637
|
+
|
|
638
|
+
import { VTreeTransfer } from 'general-basic-form';
|
|
603
639
|
const VTreeTransferRef = ref([])
|
|
604
640
|
```
|
|
605
641
|
|
|
@@ -630,4 +666,3 @@ checkedKeys:[1,2] 选中的值
|
|
|
630
666
|
获取选中的数组详情:
|
|
631
667
|
VTreeTransferRef.value["selectedList"].map((item) => {}))
|
|
632
668
|
```
|
|
633
|
-
|