general-basic-form 2.0.64 → 2.1.1

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 CHANGED
@@ -1,605 +1,633 @@
1
- # GeneralBasicForm
2
-
3
- ## 一个兼容 Vue2 、Vue3 和 React(未来实现) 的表单组件,支持typescript,vue2请使用@1版本,Vue3请使用@2版本
4
-
5
- | 组件\兼容性 | vue2 | vue3 | Ant Design Vue(next) | Element Plus | Element(ui) |
6
- | ------------------- | ---- | ---- | ---- | ---- | ---- |
7
- | VGeneralBasicForm | √ | √ | | √ | √ |
8
- | VSearchBox | √ | | | | √ |
9
- | VInfiniteScrollList | | √ | | √ | |
10
- | VDescriptions | √ | √ | √ | √ | √ |
11
- | VInputMobilecVerification | | √ | √ | √ | |
12
- | VInputGraphicVerification | | √ | √ | √ | |
13
- | VTreeTransfer | √ | | | | √ |
14
- | VTabs | √ | | | | √ |
15
-
16
- 示例:
17
-
18
- 因为兼容性问题,目前只能使用完整引入
19
-
20
- ```
21
- import ElementPlus from 'element-plus'
22
- import 'element-plus/dist/index.css'
23
- app.use(ElementPlus)
24
- ```
25
-
26
- ```
27
- import { VGeneralBasicForm } from 'general-basic-form'
28
- import 'general-basic-form/style'
29
- ```
30
-
31
- <VGeneralBasicForm
32
- :showSearch="showSearch"
33
- :getList="getList"
34
- :formItem="formItem"
35
- :size="size"
36
- ref="VGeneralBasicFormRef"
37
- labelWidth="90px"
38
- :noInputBlank="true"
39
- >
40
- <template v-slot:default>
41
- ...一些传入插槽的内容
42
- </template>
43
- <template v-slot:behind-the-button>
44
- <el-form-item>
45
- <div>上次同步时间:</div>
46
- </el-form-item>
47
- </template>
48
- </VGeneralBasicForm>
49
-
50
- ![image-20210903165502942](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202109031655830.png)
51
-
52
- 在单纯作为表单的时候可以这样使用:
53
-
54
- <VGeneralBasicForm
55
- formOnly
56
- :formItem="formItem"
57
- size="small"
58
- ref="VGeneralBasicFormRef"
59
- :labelWidth="formLabelWidth"
60
- :formData: {
61
- // 外部传入的表单数据,用于回填
62
- }
63
- noUrlParameters
64
- :afterReset="afterReset"
65
- v-model:loading="loading"
66
- />
67
-
68
- <style lang="scss" scoped>
69
- :deep(.el-form-item) {
70
- margin-bottom: 16px;
71
- }
72
- :deep(.el-divider--horizontal) {
73
- margin: 8px 0px;
74
- }
75
- </style>
76
-
77
- getList会传出默认的参数,首次请求时会有页数和分页大小,重置后会传出默认页数1
78
-
79
- async getList(
80
- params = {
81
- page: Number(this.$route.query.page) || 1,
82
- limit: Number(this.$route.query.limit) || 10,
83
- }
84
- ) {}
85
-
86
- 表单数据校验需要拿到内部表单的ref
87
-
88
- async getSmscode() {
89
- const VGeneralBasicFormRef = this.$refs['VGeneralBasicFormRef'] as any
90
- const state = await new Promise<boolean>((resolve, reject) => {
91
- VGeneralBasicFormRef.$refs['queryFormRef']?.validateField(
92
- 'user_phone',
93
- async (valid: boolean, props?: FormItemProp[] | undefined) => {
94
- if (valid) {
95
- const { user_phone } = VGeneralBasicFormRef['queryParams']
96
- const res: any = await SmscodeList({ user_phone })
97
- if (res) {
98
- console.log(res)
99
- resolve(true)
100
- } else {
101
- resolve(false)
102
- }
103
- } else {
104
- resolve(false)
105
- }
106
- }
107
- )
108
- })
109
- return state
110
- },
111
-
112
- setup写法:
113
- const VGeneralBasicFormRef = ref()
114
- const params = await new Promise<any>((resolve, reject) => {
115
- VGeneralBasicFormRef.value.$refs['queryFormRef']?.validate(
116
- async (valid: boolean, props?: FormItemProp[] | undefined) => {
117
- if (valid) {
118
- const params = VGeneralBasicFormRef.value['queryParams']
119
- resolve(params)
120
- } else {
121
- reject()
122
- }
123
- }
124
- )
125
- })
126
-
127
-
128
- ![image-20211014191532067](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202110141915657.png)
129
-
130
- parametersType类型介绍
131
-
132
- | parametersType形式 | 支持页面刷新 | 参数改变引起路由跳转 | 组件间共享数据 | 存储上限 | 浏览器兼容性 |
133
- | ------------------ | ------------ | -------------------- | -------------- | -------- | ------------ |
134
- | url | 是 | 是 | 是 | 中 | 高 |
135
- | data | 否 | 否 | 否 | 高 | 高 |
136
- | indexDB | 是 | 否 | 是 | 高 | 中 |
137
-
138
- 数据示例:
139
-
140
- showSearch: true, // 显示搜索条件
141
- getList(); // 请求数据的函数
142
- afterReset(); // 在重置按钮点击完后但还没重新请求时触发的的函数
143
- formOnly:true // 只展示表单不展示按钮
144
- parametersType:"url" // 见parametersType类型介绍
145
- loading:false // 加载动画
146
- formData:{} // 注意,因为可能出现的性能问题在组件watch formData的变化时没有使用deep,所以有时候深度的修改会不生效,导致表单数据不完整
147
- noInputBlank: true //校验input框不能仅输入空格
148
- //例子:formData.value.x=y ✘ | formData.value={...formData.value,x:y} ✔
149
- currentPageKey:"page", //当前页数key
150
- pageSizeKey:"limit", //每页显示个数key
151
- defCurrentPage:1, //默认的页数
152
- defPageSize:10, //默认的每页显示个数
153
- queryWhenReady:false,//初始化完成后自动触发查找数据函数,建议用这个this.$refs["VGeneralBasicFormRef"].handleQuery({ defaultPageFirst: false })
154
- formItem: [
155
- {
156
- label: '',
157
- prop: 'bsName35',
158
- type: 'divider',
159
- setting: {
160
- },
161
- template: {
162
- default: () => {
163
- return "123123123";
164
- },
165
- },
166
- },
167
- { label: "款式名称",
168
- prop: "bsName",
169
- type: "input",
170
- setting: {
171
- placeholder: '请输入手机验证码',
172
- style: 'width: 100%'
173
- },
174
- rules: [
175
- {
176
- message: "请输入信息"
177
- },
178
- {
179
- pattern: /^\w+[\,\,\-\w' '#]+$/,
180
- message: "请输入正确的Invoice单号"
181
- }
182
- ],
183
- template: {
184
- suffix: () => {
185
- return <svg-icon icon-class="baifenbi" />;
186
- },
187
- },
188
- },
189
- {
190
- label: "二次工艺",
191
- prop: "spName",
192
- type: "select",
193
- setting:{ multiple:true, //多选},
194
- option: [
195
- { value: "3", label: "满印" },
196
- { value: "1", label: "区域印花" },
197
- { value: "2", label: "绣花" },
198
- ],
199
- },
200
- {
201
- label: "创建时间",
202
- prop: "create_time",
203
- type: "date-picker",
204
- setting: {
205
- "range-separator": "至",
206
- }
207
- },
208
- {
209
- label: "二次工艺成本价格(人民币分)",
210
- prop: "spCost",
211
- type: "input-number",
212
- "controls-position": "right",
213
- min: 0,
214
- rules: [
215
- {
216
- required: true,
217
- message: "请输入二次工艺成本价格",
218
- trigger: "blur",
219
- },
220
- ],
221
- },
222
- {
223
- label: '',
224
- prop: 'bsName2',
225
- type: 'input-graphic-verification',
226
- setting: {
227
- placeholder: '请输入图形验证码',
228
- style: 'width: 100%'
229
- },
230
- rules: [
231
- {
232
- message: '请输入图形验证码',
233
- trigger: 'blur'
234
- }
235
- ],
236
- graphicSrc, // 请求图像的URL
237
- getGraphic, // 重新请求图像的函数
238
- key:Math.random(), // 必传,图像更新后必须更新。如果URL会变化也可以用URL代替
239
- },
240
- {
241
- label: '',
242
- prop: 'bsName3',
243
- type: 'input-mobile-verification',
244
- inputSetting: {
245
- placeholder: '请输入手机验证码',
246
- style: 'width: 100%'
247
- },
248
- buttonSetting: {
249
- type: "text",
250
- style: 'text-align: end',
251
- },
252
- rules: [
253
- {
254
- message: '请输入手机验证码',
255
- trigger: 'blur'
256
- }
257
- ],
258
- getSmscode,// 获取验证码的回调函数,获取失败必须返回false,否则计时器不会重新计算
259
- },
260
- {
261
- label: '是否必填',
262
- prop: 'is_optional',
263
- type: 'radio',
264
- setting: {
265
- disabled: true
266
- },
267
- option: [
268
- { value: '是', label: 'true',border: true },
269
- { value: '', label: 'false' }
270
- ],
271
- rules: [
272
- {
273
- required: true,
274
- message: '请输入标签项名称',
275
- trigger: 'blur'
276
- }
277
- ]
278
- },
279
- {
280
- label: '多选',
281
- prop: 'is_multi',
282
- type: 'checkbox',
283
- setting: {
284
- },
285
- option: [
286
- { value: '是', label: 'true' },
287
- { value: '否', label: 'false' }
288
- ],
289
- rules: []
290
- },
291
- {
292
- label: '受访人',
293
- prop: 'contactors',
294
- type: 'form-item-slot',
295
- name: "contactors"
296
- // 插槽组件使用:
297
- // <VGeneralBasicForm ...>
298
- // <template #contactors>
299
- // <div>一些组件
300
- // 一些组件
301
- // <el-form-item prop="contactors">...</el-form-item>
302
- // </div>
303
- // </template>
304
- // </VGeneralBasicForm>
305
- },
306
- {
307
- label: "分类",
308
- prop: "分类",
309
- type: "cascader",
310
- setting:{},
311
- options: [
312
- {
313
- value: "zhinan",
314
- label: "指南",
315
- children: [
316
- {
317
- value: "shejiyuanze",
318
- label: "设计原则",
319
- children: [
320
- {
321
- value: "yizhi",
322
- label: "一致",
323
- },
324
- {
325
- value: "fankui",
326
- label: "反馈",
327
- },
328
- {
329
- value: "xiaolv",
330
- label: "效率",
331
- },
332
- {
333
- value: "kekong",
334
- label: "可控",
335
- },
336
- ],
337
- },
338
- {
339
- value: "daohang",
340
- label: "导航",
341
- children: [
342
- {
343
- value: "cexiangdaohang",
344
- label: "侧向导航",
345
- },
346
- {
347
- value: "dingbudaohang",
348
- label: "顶部导航",
349
- },
350
- ],
351
- },
352
- ],
353
- },
354
- {
355
- value: "ziyuan",
356
- label: "资源",
357
- children: [
358
- {
359
- value: "axure",
360
- label: "Axure Components",
361
- },
362
- {
363
- value: "sketch",
364
- label: "Sketch Templates",
365
- },
366
- {
367
- value: "jiaohu",
368
- label: "组件交互文档",
369
- },
370
- ],
371
- },
372
- ],
373
- },
374
- ],
375
-
376
- //rules为表单校验规则,每个组件都可以传入
377
-
378
- //input支持template,支持以下几个属性:
379
- //prefix 输入框头部内容,只对 type="text"(默认) 有效
380
- //suffix 输入框尾部内容,只对 type="text" 有效
381
- //prepend 输入框前置内容,只对 type="text" 有效
382
- //append 输入框后置内容,只对 type="text" 有效
383
-
384
- //divider支持template:
385
- //default
386
- 支持组件type:
387
-
388
- /**
389
-
390
- \* @description: 输入框
391
-
392
- */
393
-
394
- 'input' = 'input',
395
-
396
- /**
397
-
398
- \* @description: 输入框/图像验证码
399
-
400
- */
401
-
402
- 'input-graphic-verification' = 'input-graphic-verification',
403
-
404
- /**
405
-
406
- \* @description: 输入框/手机验证码
407
-
408
- */
409
-
410
- 'input-mobile-verification' = 'input-mobile-verification',
411
-
412
- /**
413
-
414
- \* @description: 分割线
415
-
416
- */
417
-
418
- 'divider' = 'divider',
419
-
420
- /**
421
-
422
- \* @description: 选择器
423
-
424
- */
425
-
426
- 'select' = 'select',
427
-
428
- /**
429
-
430
- \* @description: 级联选择器
431
-
432
- */
433
-
434
- 'cascader' = 'cascader',
435
-
436
- /**
437
-
438
- \* @description: 日期选择器
439
-
440
- */
441
-
442
- 'date-picker' = 'date-picker',
443
-
444
- /**
445
-
446
- \* @description: 数字输入框
447
-
448
- */
449
-
450
- 'input-number' = 'input-number',
451
-
452
- /**
453
-
454
- \* @description: 单选框
455
-
456
- */
457
-
458
- 'radio' = 'radio',
459
-
460
- /**
461
-
462
- \* @description: 自定义元素,插槽组件
463
-
464
- */
465
-
466
- 'form-item-slot'='form-item-slot',
467
-
468
- /**
469
-
470
- \* @description: 多选框
471
-
472
- */
473
-
474
- 'checkbox'='checkbox',
475
-
476
-
477
-
478
- # VInfiniteScrollList对虚拟滚动列表+接口的封装
479
-
480
-
481
-
482
- ![image-20231208165229296](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202312081652392.png)
483
-
484
- ```
485
- import { VInfiniteScrollList } from 'general-basic-form'
486
- import 'general-basic-form/style'
487
- <VInfiniteScrollList
488
- :search="search"
489
- id="user_id"
490
- name="name"
491
- ref="InfiniteScrollListRef"
492
- checkbox
493
- :extra="extraRender"
494
- :max="1"
495
- />
496
- ```
497
- ```
498
- 移动端配合下拉刷新使用
499
- import { getOrderItem } from "../orderItem/functional"
500
- // getOrderItem为JSX函数,返回一个VUE组件
501
-
502
- <t-pull-down-refresh v-model="refreshing" @refresh="onRefresh" class="refresh-content">
503
- <VInfiniteScrollList :search="loadData" :checkbox="false" id="cancelId" ref="InfiniteScrollListRef" checkbox
504
- :extra="getOrderItem" height="100%" infinite-scroll-distance="50"/>
505
- </t-pull-down-refresh>
506
- ```
507
- ```
508
- search:数据接口 (page: Number) => Promise<[]>
509
- id:数据key值(唯一和选择值)
510
- name:显示名字
511
- checkbox:是否有多选功能,不传的话就是单纯的虚拟滚动列表
512
- extra:同行额外显示的内容,(item: any) => VNode | String;
513
- //el-checkbox有固定高度,如果需要配置高度比较高,例如有换行的自定义extra,最好处理一下样式,例子:
514
- //:deep(.el-checkbox) {
515
- // padding: 6px 16px !important;
516
- // display: flex;
517
- // align-items: baseline;
518
- // height: auto;
519
- //}
520
- defaultSelection:包含数据key值的对象数组或者直接传入key值数组
521
- height:默认272px String
522
- ```
523
-
524
- ```
525
- defineExpose({ reset, loadList, selectInfo, list, ifbottom });
526
- InfiniteScrollListRef?.value?.reset():重置列表内容
527
- InfiniteScrollListRef?.value?.lowReset():重置列表内容,但保留已选择的选项
528
- InfiniteScrollListRef?.value?.loadList():向下滚动列表内容,受到loading和ifbottom的影响
529
- InfiniteScrollListRef?.value?.refreshList():刷新列表,滚动列表会对整个内容重新请求数据,已选择的内容会自动选择
530
- InfiniteScrollListRef?.value?.selectInfo:选择的内容
531
- InfiniteScrollListRef?.value?.list:列表的内容
532
- InfiniteScrollListRef?.value?.ifbottom:是否到底部
533
- InfiniteScrollListRef?.value?.loading:加载中
534
- ```
535
-
536
- # VDescriptions对展示描述列表的封装
537
-
538
- ![image-20231208182455415](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202312081824708.png)
539
-
540
- ```
541
- import { VDescriptions } from 'general-basic-form'
542
- <VDescriptions
543
- :formData="props.formData"
544
- :formItem="formItem"
545
- componentType="Ant Design Vue"
546
- ...其他el-descriptions的配置
547
- />
548
- ```
549
-
550
- ```
551
- formData:Object
552
- formItem:[ {
553
- label: '受访人',
554
- prop: 'contactors',
555
- render: (scope: any) => {
556
- const { $index, row = {} } = scope
557
- const { contactors = [] } = row
558
- const ele = (contactors.length > 0 ? <span>{contactors.map((item: any) => item.name).join("")} </span> : null)
559
- return ele
560
- }
561
- },
562
- {
563
- label: '拜访详情',
564
- prop: 'detail',
565
- descriptionsItemProps:{
566
- 'label-class-name': 'label-class-name'
567
- }
568
- }]
569
- componentType:"Ant Design Vue"|"Element Plus"(默认)
570
- strict:Boolean //使用strict参数后,如果formData内的某个字段没有值,对应的描述元素将不会展示(包括标签文字),但有render的字段仍然会展示
571
- descriptionsItemProps:a-descriptions-item|el-descriptions-item的配置
572
- ```
573
-
574
- # VInputMobilecVerification,VInputGraphicVerification表单里的图形验证码、手机验证码组件,可以单独引入
575
-
576
- ```
577
- <VInputGraphicVerification :item="{同表单,可忽略label和rules字段}" :loading="loading"></VInputGraphicVerification>
578
-
579
- <VInputMobilecVerification :item="{同表单,可忽略label和rules字段}" componentType="Ant Design Vue" ref="VInputMobilecVerificationRef"></VInputMobilecVerification>
580
- ```
581
-
582
- ```
583
- componentType:"Ant Design Vue"|"Element Plus"(默认)
584
- ```
585
-
586
- ```
587
- 此用法下必须提供:
588
- provide(/* 注入名 */ "queryParams", /* 表单值对象 */ queryParams);
589
-
590
- componentType为Ant Design Vue需要提供:
591
- import { Form } from 'ant-design-vue';
592
- provide(/* 注入名 */ "Form", /* Ant Design Vue Form实例,用于表单数据更新等 */ Form);
593
-
594
- 可选:
595
- provide("size", size); // 同组件size
596
- provide("getList", getList); // 输入框回车触发
597
-
598
- 调用发送短信验证码和重置的方法
599
- VInputMobilecVerificationRef.value.VerificationButtonRef.buttonClick()
600
- VInputMobilecVerificationRef.value.VerificationButtonRef.reset()
601
- ```
602
-
603
- 安装:npm i general-basic-form<br/>
604
- install: npm i general-basic-form
605
-
1
+ # GeneralBasicForm
2
+
3
+ ## 一个兼容 Vue2 、Vue3 和 React(未来实现) 的表单组件,支持typescript,vue2请使用@1版本,Vue3请使用@2版本
4
+
5
+ | 组件\兼容性 | vue2 | vue3 | Ant Design Vue(next) | Element Plus | Element(ui) |
6
+ | ------------------- | ---- | ---- | ---- | ---- | ---- |
7
+ | VGeneralBasicForm | √ | √ | | √ | √ |
8
+ | VSearchBox | √ | | | | √ |
9
+ | VInfiniteScrollList | | √ | | √ | |
10
+ | VDescriptions | √ | √ | √ | √ | √ |
11
+ | VInputMobilecVerification | | √ | √ | √ | |
12
+ | VInputGraphicVerification | | √ | √ | √ | |
13
+ | VTreeTransfer | √ || || √ |
14
+ | VTabs | √ | | | | √ |
15
+
16
+ 安装:npm i general-basic-form<br/>
17
+ install: npm i general-basic-form
18
+
19
+ webpack4兼容:
20
+ 加入配置:module.exports = {
21
+ transpileDependencies: ['general-basic-form'],
22
+ }
23
+
24
+ 示例:
25
+
26
+ 因为兼容性问题,目前只能使用完整引入
27
+
28
+ ```
29
+ import ElementPlus from 'element-plus'
30
+ import 'element-plus/dist/index.css'
31
+ app.use(ElementPlus)
32
+ ```
33
+
34
+ ```
35
+ import { RGeneralBasicForm } from 'general-basic-form';
36
+ ```
37
+ <RGeneralBasicForm formItem={formItem} getList={getList} parametersType="data" noInputBlank></RGeneralBasicForm>
38
+
39
+ ![image-20210903165502942](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202109031655830.png)
40
+
41
+ 在单纯作为表单的时候可以这样使用:
42
+
43
+ <VGeneralBasicForm
44
+ formOnly
45
+ :formItem="formItem"
46
+ size="small"
47
+ ref="VGeneralBasicFormRef"
48
+ :labelWidth="formLabelWidth"
49
+ :formData: {
50
+ // 外部传入的表单数据,用于回填
51
+ }
52
+ noUrlParameters
53
+ :afterReset="afterReset"
54
+ v-model:loading="loading"
55
+ />
56
+
57
+ <style lang="scss" scoped>
58
+ :deep(.el-form-item) {
59
+ margin-bottom: 16px;
60
+ }
61
+ :deep(.el-divider--horizontal) {
62
+ margin: 8px 0px;
63
+ }
64
+ </style>
65
+
66
+ getList会传出默认的参数,首次请求时会有页数和分页大小,重置后会传出默认页数1
67
+
68
+ async getList(
69
+ params = {
70
+ page: Number(this.$route.query.page) || 1,
71
+ limit: Number(this.$route.query.limit) || 10,
72
+ }
73
+ ) {}
74
+
75
+ 表单数据校验需要拿到内部表单的ref
76
+
77
+ async getSmscode() {
78
+ const VGeneralBasicFormRef = this.$refs['VGeneralBasicFormRef'] as any
79
+ const state = await new Promise<boolean>((resolve, reject) => {
80
+ VGeneralBasicFormRef.$refs['queryFormRef']?.validateField(
81
+ 'user_phone',
82
+ async (valid: boolean, props?: FormItemProp[] | undefined) => {
83
+ if (valid) {
84
+ const { user_phone } = VGeneralBasicFormRef['queryParams']
85
+ const res: any = await SmscodeList({ user_phone })
86
+ if (res) {
87
+ console.log(res)
88
+ resolve(true)
89
+ } else {
90
+ resolve(false)
91
+ }
92
+ } else {
93
+ resolve(false)
94
+ }
95
+ }
96
+ )
97
+ })
98
+ return state
99
+ },
100
+
101
+ setup写法:
102
+ const VGeneralBasicFormRef = ref()
103
+ const params = await new Promise<any>((resolve, reject) => {
104
+ VGeneralBasicFormRef.value.$refs['queryFormRef']?.validate(
105
+ async (valid: boolean, props?: FormItemProp[] | undefined) => {
106
+ if (valid) {
107
+ const params = VGeneralBasicFormRef.value['queryParams']
108
+ resolve(params)
109
+ } else {
110
+ reject()
111
+ }
112
+ }
113
+ )
114
+ })
115
+
116
+
117
+ ![image-20211014191532067](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202110141915657.png)
118
+
119
+ parametersType类型介绍
120
+
121
+ | parametersType形式 | 支持页面刷新 | 参数改变引起路由跳转 | 组件间共享数据 | 存储上限 | 浏览器兼容性 |
122
+ | ------------------ | ------------ | -------------------- | -------------- | -------- | ------------ |
123
+ | url | 是 | 是 | 是 | 中 | 高 |
124
+ | data | 否 | 否 | 否 | 高 | 高 |
125
+ | indexDB | 是 | 否 | 是 | 高 | 中 |
126
+
127
+ 数据示例:
128
+
129
+ showSearch: true, // 显示搜索条件
130
+ getList(); // 请求数据的函数
131
+ afterReset(); // 在重置按钮点击完后但还没重新请求时触发的的函数
132
+ formOnly:true // 只展示表单不展示按钮
133
+ parametersType:"url" // 见parametersType类型介绍
134
+ loading:false // 加载动画
135
+ formData:{} // 注意,因为可能出现的性能问题在组件watch formData的变化时没有使用deep,所以有时候深度的修改会不生效,导致表单数据不完整
136
+ noInputBlank: true //校验input框不能仅输入空格
137
+ //例子:formData.value.x=y ✘ | formData.value={...formData.value,x:y} ✔
138
+ currentPageKey:"page", //当前页数key
139
+ pageSizeKey:"limit", //每页显示个数key
140
+ defCurrentPage:1, //默认的页数
141
+ defPageSize:10, //默认的每页显示个数
142
+ queryWhenReady:false,//初始化完成后自动触发查找数据函数,建议用这个this.$refs["VGeneralBasicFormRef"].handleQuery({ defaultPageFirst: false })
143
+ formItem: [
144
+ {
145
+ label: '',
146
+ prop: 'bsName35',
147
+ type: 'divider',
148
+ setting: {
149
+ },
150
+ template: {
151
+ default: () => {
152
+ return "123123123";
153
+ },
154
+ },
155
+ },
156
+ { label: "款式名称",
157
+ prop: "bsName",
158
+ type: "input",
159
+ setting: {
160
+ placeholder: '请输入手机验证码',
161
+ style: 'width: 100%'
162
+ },
163
+ rules: [
164
+ {
165
+ message: "请输入信息"
166
+ },
167
+ {
168
+ pattern: /^\w+[\,\,\-\w' '#]+$/,
169
+ message: "请输入正确的Invoice单号"
170
+ }
171
+ ],
172
+ template: {
173
+ suffix: () => {
174
+ return <svg-icon icon-class="baifenbi" />;
175
+ },
176
+ },
177
+ },
178
+ {
179
+ label: "二次工艺",
180
+ prop: "spName",
181
+ type: "select",
182
+ setting:{ multiple:true, //多选},
183
+ option: [
184
+ { value: "3", label: "满印" },
185
+ { value: "1", label: "区域印花" },
186
+ { value: "2", label: "绣花" },
187
+ ],
188
+ },
189
+ {
190
+ label: "创建时间",
191
+ prop: "create_time",
192
+ type: "date-picker",
193
+ setting: {
194
+ "range-separator": "至",
195
+ }
196
+ },
197
+ {
198
+ label: "二次工艺成本价格(人民币分)",
199
+ prop: "spCost",
200
+ type: "input-number",
201
+ "controls-position": "right",
202
+ min: 0,
203
+ rules: [
204
+ {
205
+ required: true,
206
+ message: "请输入二次工艺成本价格",
207
+ trigger: "blur",
208
+ },
209
+ ],
210
+ },
211
+ {
212
+ label: '',
213
+ prop: 'bsName2',
214
+ type: 'input-graphic-verification',
215
+ setting: {
216
+ placeholder: '请输入图形验证码',
217
+ style: 'width: 100%'
218
+ },
219
+ rules: [
220
+ {
221
+ message: '请输入图形验证码',
222
+ trigger: 'blur'
223
+ }
224
+ ],
225
+ graphicSrc, // 请求图像的URL
226
+ getGraphic, // 重新请求图像的函数
227
+ key:Math.random(), // 必传,图像更新后必须更新。如果URL会变化也可以用URL代替
228
+ },
229
+ {
230
+ label: '',
231
+ prop: 'bsName3',
232
+ type: 'input-mobile-verification',
233
+ inputSetting: {
234
+ placeholder: '请输入手机验证码',
235
+ style: 'width: 100%'
236
+ },
237
+ buttonSetting: {
238
+ type: "text",
239
+ style: 'text-align: end',
240
+ },
241
+ rules: [
242
+ {
243
+ message: '请输入手机验证码',
244
+ trigger: 'blur'
245
+ }
246
+ ],
247
+ getSmscode,// 获取验证码的回调函数,获取失败必须返回false,否则计时器不会重新计算
248
+ },
249
+ {
250
+ label: '是否必填',
251
+ prop: 'is_optional',
252
+ type: 'radio',
253
+ setting: {
254
+ disabled: true
255
+ },
256
+ option: [
257
+ { value: '是', label: 'true',border: true },
258
+ { value: '否', label: 'false' }
259
+ ],
260
+ rules: [
261
+ {
262
+ required: true,
263
+ message: '请输入标签项名称',
264
+ trigger: 'blur'
265
+ }
266
+ ]
267
+ },
268
+ {
269
+ label: '多选',
270
+ prop: 'is_multi',
271
+ type: 'checkbox',
272
+ setting: {
273
+ },
274
+ option: [
275
+ { value: '', label: 'true' },
276
+ { value: '否', label: 'false' }
277
+ ],
278
+ rules: []
279
+ },
280
+ {
281
+ label: '受访人',
282
+ prop: 'contactors',
283
+ type: 'form-item-slot',
284
+ name: "contactors"
285
+ // 插槽组件使用:
286
+ // <VGeneralBasicForm ...>
287
+ // <template #contactors>
288
+ // <div>一些组件
289
+ // 一些组件
290
+ // <el-form-item prop="contactors">...</el-form-item>
291
+ // </div>
292
+ // </template>
293
+ // </VGeneralBasicForm>
294
+ },
295
+ {
296
+ label: "分类",
297
+ prop: "分类",
298
+ type: "cascader",
299
+ setting:{},
300
+ options: [
301
+ {
302
+ value: "zhinan",
303
+ label: "指南",
304
+ children: [
305
+ {
306
+ value: "shejiyuanze",
307
+ label: "设计原则",
308
+ children: [
309
+ {
310
+ value: "yizhi",
311
+ label: "一致",
312
+ },
313
+ {
314
+ value: "fankui",
315
+ label: "反馈",
316
+ },
317
+ {
318
+ value: "xiaolv",
319
+ label: "效率",
320
+ },
321
+ {
322
+ value: "kekong",
323
+ label: "可控",
324
+ },
325
+ ],
326
+ },
327
+ {
328
+ value: "daohang",
329
+ label: "导航",
330
+ children: [
331
+ {
332
+ value: "cexiangdaohang",
333
+ label: "侧向导航",
334
+ },
335
+ {
336
+ value: "dingbudaohang",
337
+ label: "顶部导航",
338
+ },
339
+ ],
340
+ },
341
+ ],
342
+ },
343
+ {
344
+ value: "ziyuan",
345
+ label: "资源",
346
+ children: [
347
+ {
348
+ value: "axure",
349
+ label: "Axure Components",
350
+ },
351
+ {
352
+ value: "sketch",
353
+ label: "Sketch Templates",
354
+ },
355
+ {
356
+ value: "jiaohu",
357
+ label: "组件交互文档",
358
+ },
359
+ ],
360
+ },
361
+ ],
362
+ },
363
+ ],
364
+
365
+ //rules为表单校验规则,每个组件都可以传入
366
+
367
+ //input支持template,支持以下几个属性:
368
+ //prefix 输入框头部内容,只对 type="text"(默认) 有效
369
+ //suffix 输入框尾部内容,只对 type="text" 有效
370
+ //prepend 输入框前置内容,只对 type="text" 有效
371
+ //append 输入框后置内容,只对 type="text" 有效
372
+
373
+ //divider支持template:
374
+ //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
+
470
+
471
+ ![image-20231208165229296](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202312081652392.png)
472
+
473
+ ```
474
+ import { VInfiniteScrollList } from 'general-basic-form'
475
+ import 'general-basic-form/style'
476
+ <VInfiniteScrollList
477
+ :search="search"
478
+ id="user_id"
479
+ name="name"
480
+ ref="InfiniteScrollListRef"
481
+ checkbox
482
+ :extra="extraRender"
483
+ :max="1"
484
+ />
485
+ ```
486
+ ```
487
+ 移动端配合下拉刷新使用
488
+ import { getOrderItem } from "../orderItem/functional"
489
+ // getOrderItem为JSX函数,返回一个VUE组件
490
+
491
+ <t-pull-down-refresh v-model="refreshing" @refresh="onRefresh" class="refresh-content">
492
+ <VInfiniteScrollList :search="loadData" :checkbox="false" id="cancelId" ref="InfiniteScrollListRef" checkbox
493
+ :extra="getOrderItem" height="100%" infinite-scroll-distance="50"/>
494
+ </t-pull-down-refresh>
495
+ ```
496
+ ```
497
+ search:数据接口 (page: Number) => Promise<[]>
498
+ id:数据key值(唯一和选择值)
499
+ name:显示名字
500
+ checkbox:是否有多选功能,不传的话就是单纯的虚拟滚动列表
501
+ extra:同行额外显示的内容,(item: any) => VNode | String;
502
+ //el-checkbox有固定高度,如果需要配置高度比较高,例如有换行的自定义extra,最好处理一下样式,例子:
503
+ //:deep(.el-checkbox) {
504
+ // padding: 6px 16px !important;
505
+ // display: flex;
506
+ // align-items: baseline;
507
+ // height: auto;
508
+ //}
509
+ defaultSelection:包含数据key值的对象数组或者直接传入key值数组
510
+ height:默认272px String
511
+ ```
512
+
513
+ ```
514
+ defineExpose({ reset, loadList, selectInfo, list, ifbottom });
515
+ InfiniteScrollListRef?.value?.reset():重置列表内容
516
+ InfiniteScrollListRef?.value?.lowReset():重置列表内容,但保留已选择的选项
517
+ InfiniteScrollListRef?.value?.loadList():向下滚动列表内容,受到loading和ifbottom的影响
518
+ InfiniteScrollListRef?.value?.refreshList():刷新列表,滚动列表会对整个内容重新请求数据,已选择的内容会自动选择
519
+ InfiniteScrollListRef?.value?.selectInfo:选择的内容
520
+ InfiniteScrollListRef?.value?.list:列表的内容
521
+ InfiniteScrollListRef?.value?.ifbottom:是否到底部
522
+ InfiniteScrollListRef?.value?.loading:加载中
523
+ ```
524
+
525
+ # VDescriptions对展示描述列表的封装
526
+
527
+ ![image-20231208182455415](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202312081824708.png)
528
+
529
+ ```
530
+ import { VDescriptions } from 'general-basic-form'
531
+ <VDescriptions
532
+ :formData="props.formData"
533
+ :formItem="formItem"
534
+ componentType="Ant Design Vue"
535
+ ...其他el-descriptions的配置
536
+ />
537
+ ```
538
+
539
+ ```
540
+ formData:Object
541
+ formItem:[ {
542
+ label: '受访人',
543
+ prop: 'contactors',
544
+ render: (scope: any) => {
545
+ const { $index, row = {} } = scope
546
+ const { contactors = [] } = row
547
+ const ele = (contactors.length > 0 ? <span>{contactors.map((item: any) => item.name).join(",")} </span> : null)
548
+ return ele
549
+ }
550
+ },
551
+ {
552
+ label: '拜访详情',
553
+ prop: 'detail',
554
+ descriptionsItemProps:{
555
+ 'label-class-name': 'label-class-name'
556
+ }
557
+ }]
558
+ componentType:"Ant Design Vue"|"Element Plus"(默认)
559
+ strict:Boolean //使用strict参数后,如果formData内的某个字段没有值,对应的描述元素将不会展示(包括标签文字),但有render的字段仍然会展示
560
+ descriptionsItemProps:a-descriptions-item|el-descriptions-item的配置
561
+ ```
562
+
563
+ # VInputMobilecVerification,VInputGraphicVerification表单里的图形验证码、手机验证码组件,可以单独引入
564
+
565
+ ```
566
+ <VInputGraphicVerification :item="{同表单,可忽略label和rules字段}" :loading="loading"></VInputGraphicVerification>
567
+
568
+ <VInputMobilecVerification :item="{同表单,可忽略label和rules字段}" componentType="Ant Design Vue" ref="VInputMobilecVerificationRef"></VInputMobilecVerification>
569
+ ```
570
+
571
+ ```
572
+ componentType:"Ant Design Vue"|"Element Plus"(默认)
573
+ ```
574
+
575
+ ```
576
+ 此用法下必须提供:
577
+ provide(/* 注入名 */ "queryParams", /* 表单值对象 */ queryParams);
578
+
579
+ componentTypeAnt Design Vue需要提供:
580
+ import { Form } from 'ant-design-vue';
581
+ provide(/* 注入名 */ "Form", /* Ant Design Vue Form实例,用于表单数据更新等 */ Form);
582
+
583
+ 可选:
584
+ provide("size", size); // 同组件size
585
+ provide("getList", getList); // 输入框回车触发
586
+
587
+ 调用发送短信验证码和重置的方法
588
+ VInputMobilecVerificationRef.value.VerificationButtonRef.buttonClick()
589
+ VInputMobilecVerificationRef.value.VerificationButtonRef.reset()
590
+ ```
591
+
592
+ # VTreeTransfer 树形数据穿梭框
593
+
594
+ ![image-20250425183446375](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202504251834575.png)
595
+
596
+ ```
597
+ <VTreeTransfer :dataSource="classmate" :treeAttributes="{
598
+ 'node-key': 'user_id', props: { label: 'user_name' }, 'default-expand-all': false
599
+ }" transferTitleRight="白名单(不会被选中)" transferTitleLeft="普通名单" filterable :checkedKeys="checkedKeys">
600
+ </VTreeTransfer>
601
+
602
+ import { VTreeTransfer } from 'general-basic-form';
603
+ const VTreeTransferRef = ref([])
604
+ ```
605
+
606
+ ```
607
+ dataSource:[
608
+ {
609
+ label: 'Level one 1',
610
+ id:1,
611
+ children: [
612
+ {
613
+ label: 'Level two 1-1',
614
+ id:2,
615
+ children: [
616
+ {
617
+ label: 'Level three 1-1-1',
618
+ id:3,
619
+ },
620
+ ],
621
+ },
622
+ ],
623
+ },] 树状结构数据
624
+ treeAttributes:{} 树形控件的属性,见https://element-plus.org/zh-CN/component/tree.html
625
+ transferTitleLeft:"" 左标题
626
+ transferTitleRight:"" 右标题
627
+ filterable:false 是否显示搜索框
628
+ checkedKeys:[1,2] 选中的值
629
+
630
+ 获取选中的数组详情:
631
+ VTreeTransferRef.value["selectedList"].map((item) => {}))
632
+ ```
633
+