general-basic-form 2.0.30 → 2.0.32

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,522 +1,522 @@
1
- # GeneralBasicForm
2
-
3
- ## 一个兼容 Vue3 和 React(未来实现) 的表单组件
4
-
5
- 示例:
6
-
7
- 因为兼容性问题,目前只能使用完整引入
8
-
9
- ```
10
- import ElementPlus from 'element-plus'
11
- import 'element-plus/dist/index.css'
12
- app.use(ElementPlus)
13
- ```
14
-
15
- ```
16
- import { VGeneralBasicForm } from 'general-basic-form'
17
- import 'general-basic-form/style'
18
- ```
19
-
20
- <GeneralBasicForm
21
- :showSearch="showSearch"
22
- :getList="getList"
23
- :formItem="formItem"
24
- :size="size"
25
- ref="generalBasicForm"
26
- labelWidth="90px"
27
- >
28
- <template v-slot:default>
29
- ...一些传入插槽的内容
30
- </template>
31
- <template v-slot:behind-the-button>
32
- <el-form-item>
33
- <div>上次同步时间:</div>
34
- </el-form-item>
35
- </template>
36
- </GeneralBasicForm>
37
-
38
- ![image-20210903165502942](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202109031655830.png)
39
-
40
- 在单纯作为表单的时候可以这样使用:
41
-
42
- <GeneralBasicForm
43
- formOnly
44
- :formItem="formItem"
45
- size="small"
46
- ref="generalBasicForm"
47
- :labelWidth="formLabelWidth"
48
- :formData: {
49
- // 外部传入的表单数据,用于回填
50
- }
51
- noUrlParameters
52
- :afterReset="afterReset"
53
- v-model:loading="loading"
54
- />
55
-
56
- <style lang="scss" scoped>
57
- :deep(.el-form-item) {
58
- margin-bottom: 16px;
59
- }
60
- :deep(.el-divider--horizontal) {
61
- margin: 8px 0px;
62
- }
63
- </style>
64
-
65
- getList会传出默认的参数,首次请求时会有页数和分页大小,重置后会传出默认页数1
66
-
67
- async getList(
68
- params = {
69
- page: Number(this.$route.query.page) || 1,
70
- limit: Number(this.$route.query.limit) || 10,
71
- }
72
- ) {}
73
-
74
- 表单数据校验需要拿到内部表单的ref
75
-
76
- async getSmscode() {
77
- const VGeneralBasicFormRef = this.$refs['VGeneralBasicFormRef'] as any
78
- const state = await new Promise<boolean>((resolve, reject) => {
79
- VGeneralBasicFormRef.$refs['queryFormRef']?.validateField(
80
- 'user_phone',
81
- async (valid: boolean, props?: FormItemProp[] | undefined) => {
82
- if (valid) {
83
- const { user_phone } = VGeneralBasicFormRef['queryParams']
84
- const res: any = await SmscodeList({ user_phone })
85
- if (res) {
86
- console.log(res)
87
- resolve(true)
88
- } else {
89
- resolve(false)
90
- }
91
- } else {
92
- resolve(false)
93
- }
94
- }
95
- )
96
- })
97
- return state
98
- },
99
-
100
- setup写法:
101
- const VGeneralBasicFormRef = ref()
102
- const params = await new Promise<any>((resolve, reject) => {
103
- VGeneralBasicFormRef.value.$refs['queryFormRef']?.validate(
104
- async (valid: boolean, props?: FormItemProp[] | undefined) => {
105
- if (valid) {
106
- const params = VGeneralBasicFormRef.value['queryParams']
107
- resolve(params)
108
- } else {
109
- reject(false)
110
- }
111
- }
112
- )
113
- })
114
-
115
-
116
- ![image-20211014191532067](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202110141915657.png)
117
-
118
- 数据示例:
119
-
120
- showSearch: true, // 显示搜索条件
121
- getList(); // 请求数据的函数
122
- afterReset(); // 在重置按钮点击完后但还没重新请求时触发的的函数
123
- formOnly:true // 只展示表单不展示按钮
124
- noUrlParameters:true // 不接受和不改变url的参数
125
- loading:false // 加载动画
126
- formData:{} // 注意,因为可能出现的性能问题在组件watch formData的变化时没有使用deep,所以有时候深度的修改会不生效,导致表单数据不完整
127
- //例子:formData.value.x=y ✘ | formData.value={...formData.value,x:y} ✔
128
- formItem: [
129
- {
130
- label: '',
131
- prop: 'bsName35',
132
- type: 'divider',
133
- dividerSetting: {
134
- },
135
- template: {
136
- default: () => {
137
- return "123123123";
138
- },
139
- },
140
- },
141
- { label: "款式名称",
142
- prop: "bsName",
143
- type: "input",
144
- inputSetting: {
145
- placeholder: '请输入手机验证码',
146
- style: 'width: 100%'
147
- },
148
- rules: [
149
- {
150
- message: "请输入信息"
151
- },
152
- {
153
- pattern: /^\w+[\,\,\-\w' '#]+$/,
154
- message: "请输入正确的Invoice单号"
155
- }
156
- ],
157
- template: {
158
- suffix: () => {
159
- return <svg-icon icon-class="baifenbi" />;
160
- },
161
- },
162
- },
163
- {
164
- label: "二次工艺",
165
- prop: "spName",
166
- type: "select",
167
- multiple:true, //多选
168
- selectSetting:{},
169
- option: [
170
- { value: "3", label: "满印" },
171
- { value: "1", label: "区域印花" },
172
- { value: "2", label: "绣花" },
173
- ],
174
- },
175
- {
176
- label: "创建时间",
177
- prop: "create_time",
178
- type: "date-picker",
179
- datePackerSetting: {
180
- "range-separator": "至",
181
- }
182
- },
183
- {
184
- label: "二次工艺成本价格(人民币分)",
185
- prop: "spCost",
186
- type: "input-number",
187
- "controls-position": "right",
188
- min: 0,
189
- rules: [
190
- {
191
- required: true,
192
- message: "请输入二次工艺成本价格",
193
- trigger: "blur",
194
- },
195
- ],
196
- },
197
- {
198
- label: '',
199
- prop: 'bsName2',
200
- type: 'input-graphic-verification',
201
- inputSetting: {
202
- placeholder: '请输入图形验证码',
203
- style: 'width: 100%'
204
- },
205
- rules: [
206
- {
207
- message: '请输入图形验证码',
208
- trigger: 'blur'
209
- }
210
- ],
211
- graphicSrc, // 请求图像的URL
212
- getGraphic, // 重新请求图像的函数
213
- key:Math.random(), // 必传,图像更新后必须更新。如果URL会变化也可以用URL代替
214
- },
215
- {
216
- label: '',
217
- prop: 'bsName3',
218
- type: 'input-mobile-verification',
219
- inputSetting: {
220
- placeholder: '请输入手机验证码',
221
- style: 'width: 100%'
222
- },
223
- rules: [
224
- {
225
- message: '请输入手机验证码',
226
- trigger: 'blur'
227
- }
228
- ]
229
- getSmscode,// 获取验证码的回调函数,获取失败必须返回false,否则计时器不会重新计算
230
- },
231
- {
232
- label: '是否必填',
233
- prop: 'is_optional',
234
- type: 'radio',
235
- radioGroupSetting: {
236
- disabled: true
237
- },
238
- option: [
239
- { value: '是', label: 'true',border: true },
240
- { value: '否', label: 'false' }
241
- ],
242
- rules: [
243
- {
244
- required: true,
245
- message: '请输入标签项名称',
246
- trigger: 'blur'
247
- }
248
- ]
249
- },
250
- {
251
- label: '多选',
252
- prop: 'is_multi',
253
- type: 'checkbox',
254
- checkboxGroupSetting: {
255
- },
256
- option: [
257
- { value: '是', label: 'true' },
258
- { value: '否', label: 'false' }
259
- ],
260
- rules: []
261
- },
262
- {
263
- label: '受访人',
264
- prop: 'contactors',
265
- type: 'form-item-slot',
266
- name: "contactors"
267
- // 插槽组件使用:
268
- // <VGeneralBasicForm ...>
269
- // <template #contactors>
270
- // <div>一些组件
271
- // 一些组件
272
- // <el-form-item prop="contactors">...</el-form-item>
273
- // </div>
274
- // </template>
275
- // </VGeneralBasicForm>
276
- },
277
- {
278
- label: "分类",
279
- prop: "分类",
280
- type: "cascader",
281
- selectSetting:{},
282
- options: [
283
- {
284
- value: "zhinan",
285
- label: "指南",
286
- children: [
287
- {
288
- value: "shejiyuanze",
289
- label: "设计原则",
290
- children: [
291
- {
292
- value: "yizhi",
293
- label: "一致",
294
- },
295
- {
296
- value: "fankui",
297
- label: "反馈",
298
- },
299
- {
300
- value: "xiaolv",
301
- label: "效率",
302
- },
303
- {
304
- value: "kekong",
305
- label: "可控",
306
- },
307
- ],
308
- },
309
- {
310
- value: "daohang",
311
- label: "导航",
312
- children: [
313
- {
314
- value: "cexiangdaohang",
315
- label: "侧向导航",
316
- },
317
- {
318
- value: "dingbudaohang",
319
- label: "顶部导航",
320
- },
321
- ],
322
- },
323
- ],
324
- },
325
- {
326
- value: "ziyuan",
327
- label: "资源",
328
- children: [
329
- {
330
- value: "axure",
331
- label: "Axure Components",
332
- },
333
- {
334
- value: "sketch",
335
- label: "Sketch Templates",
336
- },
337
- {
338
- value: "jiaohu",
339
- label: "组件交互文档",
340
- },
341
- ],
342
- },
343
- ],
344
- },
345
- ],
346
-
347
- //rules为表单校验规则,每个组件都可以传入
348
-
349
- //input支持template,支持以下几个属性:
350
- //prefix 输入框头部内容,只对 type="text"(默认) 有效
351
- //suffix 输入框尾部内容,只对 type="text" 有效
352
- //prepend 输入框前置内容,只对 type="text" 有效
353
- //append 输入框后置内容,只对 type="text" 有效
354
-
355
- //divider支持template:
356
- //default
357
- 支持组件type:
358
-
359
- /**
360
-
361
- \* @description: 输入框
362
-
363
- */
364
-
365
- 'input' = 'input',
366
-
367
- /**
368
-
369
- \* @description: 输入框/图像验证码
370
-
371
- */
372
-
373
- 'input-graphic-verification' = 'input-graphic-verification',
374
-
375
- /**
376
-
377
- \* @description: 输入框/手机验证码
378
-
379
- */
380
-
381
- 'input-mobile-verification' = 'input-mobile-verification',
382
-
383
- /**
384
-
385
- \* @description: 分割线
386
-
387
- */
388
-
389
- 'divider' = 'divider',
390
-
391
- /**
392
-
393
- \* @description: 选择器
394
-
395
- */
396
-
397
- 'select' = 'select',
398
-
399
- /**
400
-
401
- \* @description: 级联选择器
402
-
403
- */
404
-
405
- 'cascader' = 'cascader',
406
-
407
- /**
408
-
409
- \* @description: 日期选择器
410
-
411
- */
412
-
413
- 'date-picker' = 'date-picker',
414
-
415
- /**
416
-
417
- \* @description: 数字输入框
418
-
419
- */
420
-
421
- 'input-number' = 'input-number',
422
-
423
- /**
424
-
425
- \* @description: 单选框
426
-
427
- */
428
-
429
- 'radio' = 'radio',
430
-
431
- /**
432
-
433
- \* @description: 自定义元素,插槽组件
434
-
435
- */
436
-
437
- 'form-item-slot'='form-item-slot',
438
-
439
- /**
440
-
441
- \* @description: 多选框
442
-
443
- */
444
-
445
- 'checkbox'='checkbox',
446
-
447
-
448
-
449
- ## 对虚拟滚动列表+接口的封装
450
-
451
-
452
-
453
- ![image-20231208165229296](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202312081652392.png)
454
-
455
- ```
456
- import { VInfiniteScrollList } from 'general-basic-form'
457
- <VInfiniteScrollList
458
- :search="search"
459
- id="user_id"
460
- name="name"
461
- ref="InfiniteScrollListRef"
462
- checkbox
463
- :extra="extraRender"
464
- :max="1"
465
- />
466
- ```
467
-
468
- ```
469
- search:数据接口 (page: Number) => Promise<[]>
470
- id:数据key值(唯一和选择值)
471
- name:显示名字
472
- checkbox:是否有多选功能,不传的话就是单纯的虚拟滚动列表
473
- extra:同行额外显示的内容,(item: any) => VNode | String;
474
- defaultSelection:包含数据key值的对象数组或者直接传入key值数组
475
- ```
476
-
477
- ```
478
- defineExpose({ reset, loadList, selectInfo, list, ifbottom });
479
- InfiniteScrollListRef.value.reset():重置列表内容
480
- InfiniteScrollListRef.value.loadList():重新请求列表内容
481
- InfiniteScrollListRef?.value?.selectInfo:选择的内容
482
- InfiniteScrollListRef?.value?.list:列表的内容
483
- InfiniteScrollListRef?.value?.ifbottom:是否到底部
484
- ```
485
-
486
- ## 对展示描述列表的封装
487
-
488
- ![image-20231208182455415](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202312081824708.png)
489
-
490
- ```
491
- import { VDescriptions } from 'general-basic-form'
492
- <VDescriptions
493
- :formData="props.formData"
494
- :formItem="formItem"
495
- ...其他el-descriptions的配置
496
- />
497
- ```
498
-
499
- ```
500
- formData:Object
501
- formItem:[ {
502
- label: '受访人',
503
- prop: 'contactors',
504
- render: (scope: any) => {
505
- const { $index, row = {} } = scope
506
- const { contactors = [] } = row
507
- const ele = (contactors.length > 0 ? <span>{contactors.map((item: any) => item.name).join(",")} </span> : null)
508
- return ele
509
- }
510
- },
511
- {
512
- label: '拜访详情',
513
- prop: 'detail',
514
- descriptionsItemProps:{
515
- 'label-class-name': 'label-class-name'
516
- }
517
- }]
518
- descriptionsItemProps:el-descriptions-item的配置
519
- ```
520
-
521
- 安装:npm i general-basic-form<br/>
522
- install: npm i general-basic-form
1
+ # GeneralBasicForm
2
+
3
+ ## 一个兼容 Vue3 和 React(未来实现) 的表单组件
4
+
5
+ 示例:
6
+
7
+ 因为兼容性问题,目前只能使用完整引入
8
+
9
+ ```
10
+ import ElementPlus from 'element-plus'
11
+ import 'element-plus/dist/index.css'
12
+ app.use(ElementPlus)
13
+ ```
14
+
15
+ ```
16
+ import { VGeneralBasicForm } from 'general-basic-form'
17
+ import 'general-basic-form/style'
18
+ ```
19
+
20
+ <GeneralBasicForm
21
+ :showSearch="showSearch"
22
+ :getList="getList"
23
+ :formItem="formItem"
24
+ :size="size"
25
+ ref="generalBasicForm"
26
+ labelWidth="90px"
27
+ >
28
+ <template v-slot:default>
29
+ ...一些传入插槽的内容
30
+ </template>
31
+ <template v-slot:behind-the-button>
32
+ <el-form-item>
33
+ <div>上次同步时间:</div>
34
+ </el-form-item>
35
+ </template>
36
+ </GeneralBasicForm>
37
+
38
+ ![image-20210903165502942](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202109031655830.png)
39
+
40
+ 在单纯作为表单的时候可以这样使用:
41
+
42
+ <GeneralBasicForm
43
+ formOnly
44
+ :formItem="formItem"
45
+ size="small"
46
+ ref="generalBasicForm"
47
+ :labelWidth="formLabelWidth"
48
+ :formData: {
49
+ // 外部传入的表单数据,用于回填
50
+ }
51
+ noUrlParameters
52
+ :afterReset="afterReset"
53
+ v-model:loading="loading"
54
+ />
55
+
56
+ <style lang="scss" scoped>
57
+ :deep(.el-form-item) {
58
+ margin-bottom: 16px;
59
+ }
60
+ :deep(.el-divider--horizontal) {
61
+ margin: 8px 0px;
62
+ }
63
+ </style>
64
+
65
+ getList会传出默认的参数,首次请求时会有页数和分页大小,重置后会传出默认页数1
66
+
67
+ async getList(
68
+ params = {
69
+ page: Number(this.$route.query.page) || 1,
70
+ limit: Number(this.$route.query.limit) || 10,
71
+ }
72
+ ) {}
73
+
74
+ 表单数据校验需要拿到内部表单的ref
75
+
76
+ async getSmscode() {
77
+ const VGeneralBasicFormRef = this.$refs['VGeneralBasicFormRef'] as any
78
+ const state = await new Promise<boolean>((resolve, reject) => {
79
+ VGeneralBasicFormRef.$refs['queryFormRef']?.validateField(
80
+ 'user_phone',
81
+ async (valid: boolean, props?: FormItemProp[] | undefined) => {
82
+ if (valid) {
83
+ const { user_phone } = VGeneralBasicFormRef['queryParams']
84
+ const res: any = await SmscodeList({ user_phone })
85
+ if (res) {
86
+ console.log(res)
87
+ resolve(true)
88
+ } else {
89
+ resolve(false)
90
+ }
91
+ } else {
92
+ resolve(false)
93
+ }
94
+ }
95
+ )
96
+ })
97
+ return state
98
+ },
99
+
100
+ setup写法:
101
+ const VGeneralBasicFormRef = ref()
102
+ const params = await new Promise<any>((resolve, reject) => {
103
+ VGeneralBasicFormRef.value.$refs['queryFormRef']?.validate(
104
+ async (valid: boolean, props?: FormItemProp[] | undefined) => {
105
+ if (valid) {
106
+ const params = VGeneralBasicFormRef.value['queryParams']
107
+ resolve(params)
108
+ } else {
109
+ reject(false)
110
+ }
111
+ }
112
+ )
113
+ })
114
+
115
+
116
+ ![image-20211014191532067](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202110141915657.png)
117
+
118
+ 数据示例:
119
+
120
+ showSearch: true, // 显示搜索条件
121
+ getList(); // 请求数据的函数
122
+ afterReset(); // 在重置按钮点击完后但还没重新请求时触发的的函数
123
+ formOnly:true // 只展示表单不展示按钮
124
+ noUrlParameters:true // 不接受和不改变url的参数
125
+ loading:false // 加载动画
126
+ formData:{} // 注意,因为可能出现的性能问题在组件watch formData的变化时没有使用deep,所以有时候深度的修改会不生效,导致表单数据不完整
127
+ //例子:formData.value.x=y ✘ | formData.value={...formData.value,x:y} ✔
128
+ formItem: [
129
+ {
130
+ label: '',
131
+ prop: 'bsName35',
132
+ type: 'divider',
133
+ dividerSetting: {
134
+ },
135
+ template: {
136
+ default: () => {
137
+ return "123123123";
138
+ },
139
+ },
140
+ },
141
+ { label: "款式名称",
142
+ prop: "bsName",
143
+ type: "input",
144
+ inputSetting: {
145
+ placeholder: '请输入手机验证码',
146
+ style: 'width: 100%'
147
+ },
148
+ rules: [
149
+ {
150
+ message: "请输入信息"
151
+ },
152
+ {
153
+ pattern: /^\w+[\,\,\-\w' '#]+$/,
154
+ message: "请输入正确的Invoice单号"
155
+ }
156
+ ],
157
+ template: {
158
+ suffix: () => {
159
+ return <svg-icon icon-class="baifenbi" />;
160
+ },
161
+ },
162
+ },
163
+ {
164
+ label: "二次工艺",
165
+ prop: "spName",
166
+ type: "select",
167
+ multiple:true, //多选
168
+ selectSetting:{},
169
+ option: [
170
+ { value: "3", label: "满印" },
171
+ { value: "1", label: "区域印花" },
172
+ { value: "2", label: "绣花" },
173
+ ],
174
+ },
175
+ {
176
+ label: "创建时间",
177
+ prop: "create_time",
178
+ type: "date-picker",
179
+ datePackerSetting: {
180
+ "range-separator": "至",
181
+ }
182
+ },
183
+ {
184
+ label: "二次工艺成本价格(人民币分)",
185
+ prop: "spCost",
186
+ type: "input-number",
187
+ "controls-position": "right",
188
+ min: 0,
189
+ rules: [
190
+ {
191
+ required: true,
192
+ message: "请输入二次工艺成本价格",
193
+ trigger: "blur",
194
+ },
195
+ ],
196
+ },
197
+ {
198
+ label: '',
199
+ prop: 'bsName2',
200
+ type: 'input-graphic-verification',
201
+ inputSetting: {
202
+ placeholder: '请输入图形验证码',
203
+ style: 'width: 100%'
204
+ },
205
+ rules: [
206
+ {
207
+ message: '请输入图形验证码',
208
+ trigger: 'blur'
209
+ }
210
+ ],
211
+ graphicSrc, // 请求图像的URL
212
+ getGraphic, // 重新请求图像的函数
213
+ key:Math.random(), // 必传,图像更新后必须更新。如果URL会变化也可以用URL代替
214
+ },
215
+ {
216
+ label: '',
217
+ prop: 'bsName3',
218
+ type: 'input-mobile-verification',
219
+ inputSetting: {
220
+ placeholder: '请输入手机验证码',
221
+ style: 'width: 100%'
222
+ },
223
+ rules: [
224
+ {
225
+ message: '请输入手机验证码',
226
+ trigger: 'blur'
227
+ }
228
+ ]
229
+ getSmscode,// 获取验证码的回调函数,获取失败必须返回false,否则计时器不会重新计算
230
+ },
231
+ {
232
+ label: '是否必填',
233
+ prop: 'is_optional',
234
+ type: 'radio',
235
+ radioGroupSetting: {
236
+ disabled: true
237
+ },
238
+ option: [
239
+ { value: '是', label: 'true',border: true },
240
+ { value: '否', label: 'false' }
241
+ ],
242
+ rules: [
243
+ {
244
+ required: true,
245
+ message: '请输入标签项名称',
246
+ trigger: 'blur'
247
+ }
248
+ ]
249
+ },
250
+ {
251
+ label: '多选',
252
+ prop: 'is_multi',
253
+ type: 'checkbox',
254
+ checkboxGroupSetting: {
255
+ },
256
+ option: [
257
+ { value: '是', label: 'true' },
258
+ { value: '否', label: 'false' }
259
+ ],
260
+ rules: []
261
+ },
262
+ {
263
+ label: '受访人',
264
+ prop: 'contactors',
265
+ type: 'form-item-slot',
266
+ name: "contactors"
267
+ // 插槽组件使用:
268
+ // <VGeneralBasicForm ...>
269
+ // <template #contactors>
270
+ // <div>一些组件
271
+ // 一些组件
272
+ // <el-form-item prop="contactors">...</el-form-item>
273
+ // </div>
274
+ // </template>
275
+ // </VGeneralBasicForm>
276
+ },
277
+ {
278
+ label: "分类",
279
+ prop: "分类",
280
+ type: "cascader",
281
+ selectSetting:{},
282
+ options: [
283
+ {
284
+ value: "zhinan",
285
+ label: "指南",
286
+ children: [
287
+ {
288
+ value: "shejiyuanze",
289
+ label: "设计原则",
290
+ children: [
291
+ {
292
+ value: "yizhi",
293
+ label: "一致",
294
+ },
295
+ {
296
+ value: "fankui",
297
+ label: "反馈",
298
+ },
299
+ {
300
+ value: "xiaolv",
301
+ label: "效率",
302
+ },
303
+ {
304
+ value: "kekong",
305
+ label: "可控",
306
+ },
307
+ ],
308
+ },
309
+ {
310
+ value: "daohang",
311
+ label: "导航",
312
+ children: [
313
+ {
314
+ value: "cexiangdaohang",
315
+ label: "侧向导航",
316
+ },
317
+ {
318
+ value: "dingbudaohang",
319
+ label: "顶部导航",
320
+ },
321
+ ],
322
+ },
323
+ ],
324
+ },
325
+ {
326
+ value: "ziyuan",
327
+ label: "资源",
328
+ children: [
329
+ {
330
+ value: "axure",
331
+ label: "Axure Components",
332
+ },
333
+ {
334
+ value: "sketch",
335
+ label: "Sketch Templates",
336
+ },
337
+ {
338
+ value: "jiaohu",
339
+ label: "组件交互文档",
340
+ },
341
+ ],
342
+ },
343
+ ],
344
+ },
345
+ ],
346
+
347
+ //rules为表单校验规则,每个组件都可以传入
348
+
349
+ //input支持template,支持以下几个属性:
350
+ //prefix 输入框头部内容,只对 type="text"(默认) 有效
351
+ //suffix 输入框尾部内容,只对 type="text" 有效
352
+ //prepend 输入框前置内容,只对 type="text" 有效
353
+ //append 输入框后置内容,只对 type="text" 有效
354
+
355
+ //divider支持template:
356
+ //default
357
+ 支持组件type:
358
+
359
+ /**
360
+
361
+ \* @description: 输入框
362
+
363
+ */
364
+
365
+ 'input' = 'input',
366
+
367
+ /**
368
+
369
+ \* @description: 输入框/图像验证码
370
+
371
+ */
372
+
373
+ 'input-graphic-verification' = 'input-graphic-verification',
374
+
375
+ /**
376
+
377
+ \* @description: 输入框/手机验证码
378
+
379
+ */
380
+
381
+ 'input-mobile-verification' = 'input-mobile-verification',
382
+
383
+ /**
384
+
385
+ \* @description: 分割线
386
+
387
+ */
388
+
389
+ 'divider' = 'divider',
390
+
391
+ /**
392
+
393
+ \* @description: 选择器
394
+
395
+ */
396
+
397
+ 'select' = 'select',
398
+
399
+ /**
400
+
401
+ \* @description: 级联选择器
402
+
403
+ */
404
+
405
+ 'cascader' = 'cascader',
406
+
407
+ /**
408
+
409
+ \* @description: 日期选择器
410
+
411
+ */
412
+
413
+ 'date-picker' = 'date-picker',
414
+
415
+ /**
416
+
417
+ \* @description: 数字输入框
418
+
419
+ */
420
+
421
+ 'input-number' = 'input-number',
422
+
423
+ /**
424
+
425
+ \* @description: 单选框
426
+
427
+ */
428
+
429
+ 'radio' = 'radio',
430
+
431
+ /**
432
+
433
+ \* @description: 自定义元素,插槽组件
434
+
435
+ */
436
+
437
+ 'form-item-slot'='form-item-slot',
438
+
439
+ /**
440
+
441
+ \* @description: 多选框
442
+
443
+ */
444
+
445
+ 'checkbox'='checkbox',
446
+
447
+
448
+
449
+ ## 对虚拟滚动列表+接口的封装
450
+
451
+
452
+
453
+ ![image-20231208165229296](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202312081652392.png)
454
+
455
+ ```
456
+ import { VInfiniteScrollList } from 'general-basic-form'
457
+ <VInfiniteScrollList
458
+ :search="search"
459
+ id="user_id"
460
+ name="name"
461
+ ref="InfiniteScrollListRef"
462
+ checkbox
463
+ :extra="extraRender"
464
+ :max="1"
465
+ />
466
+ ```
467
+
468
+ ```
469
+ search:数据接口 (page: Number) => Promise<[]>
470
+ id:数据key值(唯一和选择值)
471
+ name:显示名字
472
+ checkbox:是否有多选功能,不传的话就是单纯的虚拟滚动列表
473
+ extra:同行额外显示的内容,(item: any) => VNode | String;
474
+ defaultSelection:包含数据key值的对象数组或者直接传入key值数组
475
+ ```
476
+
477
+ ```
478
+ defineExpose({ reset, loadList, selectInfo, list, ifbottom });
479
+ InfiniteScrollListRef.value.reset():重置列表内容
480
+ InfiniteScrollListRef.value.loadList():重新请求列表内容
481
+ InfiniteScrollListRef?.value?.selectInfo:选择的内容
482
+ InfiniteScrollListRef?.value?.list:列表的内容
483
+ InfiniteScrollListRef?.value?.ifbottom:是否到底部
484
+ ```
485
+
486
+ ## 对展示描述列表的封装
487
+
488
+ ![image-20231208182455415](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202312081824708.png)
489
+
490
+ ```
491
+ import { VDescriptions } from 'general-basic-form'
492
+ <VDescriptions
493
+ :formData="props.formData"
494
+ :formItem="formItem"
495
+ ...其他el-descriptions的配置
496
+ />
497
+ ```
498
+
499
+ ```
500
+ formData:Object
501
+ formItem:[ {
502
+ label: '受访人',
503
+ prop: 'contactors',
504
+ render: (scope: any) => {
505
+ const { $index, row = {} } = scope
506
+ const { contactors = [] } = row
507
+ const ele = (contactors.length > 0 ? <span>{contactors.map((item: any) => item.name).join(",")} </span> : null)
508
+ return ele
509
+ }
510
+ },
511
+ {
512
+ label: '拜访详情',
513
+ prop: 'detail',
514
+ descriptionsItemProps:{
515
+ 'label-class-name': 'label-class-name'
516
+ }
517
+ }]
518
+ descriptionsItemProps:el-descriptions-item的配置
519
+ ```
520
+
521
+ 安装:npm i general-basic-form<br/>
522
+ install: npm i general-basic-form