general-basic-form 2.4.2 → 2.4.4

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,30 +1,27 @@
1
- <!-- @format -->
2
-
3
1
  # GeneralBasicForm
4
2
 
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
- | RBaseTabs | | | | | | √ | √ |
20
- | RBaseCombobox | | | | | | √ | √ |
3
+ ## 一个兼容 Vue2 、Vue3 和 React(未来实现) 的表单组件,支持 typescript,vue2 请使用@1 版本,Vue3 请使用@2 版本,React19请使用@3 版本。
4
+
5
+ | 组件\兼容性 | vue2 | vue3 | Ant Design Vue(next) | Element Plus | Element(ui) | React19 | shadcn/ui |
6
+ | ------------------- | ---- | ---- | ---- | ---- | ---- | ------------------- | ------------------- |
7
+ | VGeneralBasicForm | √ | √ | | √ | √ | | |
8
+ | VSearchBox | √ | | | | √ | | |
9
+ | VInfiniteScrollList | | √ | | √ | | | |
10
+ | VDescriptions | √ | √ | √ | √ | √ | | |
11
+ | VInputMobilecVerification | | √ | √ | √ | | | |
12
+ | VInputGraphicVerification | | √ | √ | √ | | | |
13
+ | VTreeTransfer | √ | √ | | √ | √ | | |
14
+ | VTabs | √ | | | | √ | | |
15
+ | RGeneralBasicForm | | | | | | √ | √ |
16
+ | RFormList | | | | | | √ | √ |
17
+ | RTabs | | | | | | √ | √ |
21
18
 
22
19
  安装:npm i general-basic-form<br/>
23
20
  install: npm i general-basic-form
24
21
 
25
- webpack4 兼容:
22
+ webpack4兼容:
26
23
  加入配置:module.exports = {
27
- transpileDependencies: ['general-basic-form'],
24
+ transpileDependencies: ['general-basic-form'],
28
25
  }
29
26
 
30
27
  示例:
@@ -32,62 +29,63 @@ transpileDependencies: ['general-basic-form'],
32
29
  因为兼容性问题,目前只能使用完整引入
33
30
 
34
31
  ```
35
- import { RGeneralBasicForm,RBasicForm } from 'general-basic-form';
32
+ import ElementPlus from 'element-plus'
33
+ import 'element-plus/dist/index.css'
34
+ app.use(ElementPlus)
36
35
  ```
37
36
 
38
37
  ```
39
- <RGeneralBasicForm
40
- formItem={formItem}
41
- getList={getList}
42
- parametersType="data"
43
- noInputBlank
44
- formData={detail}
45
- fieldGroupSetting={{ className: 'grid grid-cols-4 gap-4' }}
46
- > </RGeneralBasicForm>
47
-
48
- <RBasicForm
49
- formItem={formItem}
50
- getList={getList}
51
- parametersType="data"
52
- noInputBlank
53
- formData={detail}
54
- fieldGroupSetting={{ className: 'grid grid-cols-4 gap-4' }}
55
- footFieldSetting={{ className: 'col-start-1 col-span-4 col-end-3 mb-8' }}
56
- fieldLabelSetting={{ className: "text-lg" }}
57
- coms={{
58
- Input,
59
- Button,
60
- Select,
61
- SelectContent,
62
- SelectItem,
63
- SelectTrigger,
64
- SelectValue,
65
- SelectGroup,
66
- }} >
67
- </RBasicForm>
38
+ import { VGeneralBasicForm } from 'general-basic-form'
39
+ import 'general-basic-form/style'
68
40
  ```
69
41
 
42
+ <VGeneralBasicForm
43
+ :showSearch="showSearch"
44
+ :getList="getList"
45
+ :formItem="formItem"
46
+ :size="size"
47
+ ref="VGeneralBasicFormRef"
48
+ labelWidth="90px"
49
+ :noInputBlank="true"
50
+ >
51
+ <template v-slot:default>
52
+ ...一些传入插槽的内容
53
+ </template>
54
+ <template v-slot:behind-the-button>
55
+ <el-form-item>
56
+ <div>上次同步时间:</div>
57
+ </el-form-item>
58
+ </template>
59
+ </VGeneralBasicForm>
60
+
70
61
  ![image-20210903165502942](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202109031655830.png)
71
62
 
72
63
  在单纯作为表单的时候可以这样使用:
73
64
 
74
- const RGeneralBasicFormRef = useRef(null);
75
-
76
- <RGeneralBasicForm
77
- formOnly
78
- ref={RGeneralBasicFormRef}
79
- className="py-4"
80
- formItem={formItem}
81
- getList={getList}
82
- parametersType="data"
83
- noInputBlank
84
- formData={formData}
85
- fieldGroupSetting={{ className: 'grid grid-cols-2 gap-4' }}
86
- >
87
- //自定义组件
88
- </RGeneralBasicForm>
65
+ <VGeneralBasicForm
66
+ formOnly
67
+ :formItem="formItem"
68
+ size="small"
69
+ ref="VGeneralBasicFormRef"
70
+ :labelWidth="formLabelWidth"
71
+ :formData: {
72
+ // 外部传入的表单数据,用于回填
73
+ }
74
+ noUrlParameters
75
+ :afterReset="afterReset"
76
+ v-model:loading="loading"
77
+ />
78
+
79
+ <style lang="scss" scoped>
80
+ :deep(.el-form-item) {
81
+ margin-bottom: 16px;
82
+ }
83
+ :deep(.el-divider--horizontal) {
84
+ margin: 8px 0px;
85
+ }
86
+ </style>
89
87
 
90
- getList 会传出默认的参数,首次请求时会有页数和分页大小,重置后会传出默认页数 1
88
+ getList会传出默认的参数,首次请求时会有页数和分页大小,重置后会传出默认页数1
91
89
 
92
90
  async getList(
93
91
  params = {
@@ -96,548 +94,296 @@ getList 会传出默认的参数,首次请求时会有页数和分页大小,重
96
94
  }
97
95
  ) {}
98
96
 
99
- 表单数据校验需要拿到内部表单的 ref
97
+ 表单数据校验需要拿到内部表单的ref
98
+
99
+ async getSmscode() {
100
+ const VGeneralBasicFormRef = this.$refs['VGeneralBasicFormRef'] as any
101
+ const state = await new Promise<boolean>((resolve, reject) => {
102
+ VGeneralBasicFormRef.$refs['queryFormRef']?.validateField(
103
+ 'user_phone',
104
+ async (valid: boolean, props?: FormItemProp[] | undefined) => {
105
+ if (valid) {
106
+ const { user_phone } = VGeneralBasicFormRef['queryParams']
107
+ const res: any = await SmscodeList({ user_phone })
108
+ if (res) {
109
+ console.log(res)
110
+ resolve(true)
111
+ } else {
112
+ resolve(false)
113
+ }
114
+ } else {
115
+ resolve(false)
116
+ }
117
+ }
118
+ )
119
+ })
120
+ return state
121
+ },
122
+
123
+ setup写法:
124
+ const VGeneralBasicFormRef = ref()
125
+ const params = await new Promise<any>((resolve, reject) => {
126
+ VGeneralBasicFormRef.value.$refs['queryFormRef']?.validate(
127
+ async (valid: boolean, props?: FormItemProp[] | undefined) => {
128
+ if (valid) {
129
+ const params = VGeneralBasicFormRef.value['queryParams']
130
+ resolve(params)
131
+ } else {
132
+ reject()
133
+ }
134
+ }
135
+ )
136
+ })
100
137
 
101
- RGeneralBasicFormRef.current.formAction(); // 触发表单校验和getList
102
138
 
103
139
  ![image-20211014191532067](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202110141915657.png)
104
140
 
105
- parametersType 类型介绍
141
+ parametersType类型介绍
106
142
 
107
- | parametersType 形式 | 支持页面刷新 | 参数改变引起路由跳转 | 组件间共享数据 | 存储上限 | 浏览器兼容性 |
108
- | ------------------- | ------------ | -------------------- | -------------- | -------- | ------------ |
109
- | url | 是 | 是 | 是 | 中 | 高 |
110
- | data | 否 | 否 | 否 | 高 | 高 |
111
- | indexDB | 是 | 否 | 是 | 高 | 中 |
143
+ | parametersType形式 | 支持页面刷新 | 参数改变引起路由跳转 | 组件间共享数据 | 存储上限 | 浏览器兼容性 |
144
+ | ------------------ | ------------ | -------------------- | -------------- | -------- | ------------ |
145
+ | url | 是 | 是 | 是 | 中 | 高 |
146
+ | data | 否 | 否 | 否 | 高 | 高 |
147
+ | indexDB | 是 | 否 | 是 | 高 | 中 |
112
148
 
113
149
  数据示例:
114
150
 
115
- formOnly:true // 只展示表单不展示按钮
116
- getList(queryParams); // 请求数据的函数
117
- afterReset(queryParams); // 在重置按钮点击完后但还没重新请求时触发的的函数
151
+ showSearch: true, // 显示搜索条件
152
+ getList(); // 请求数据的函数
153
+ afterReset(); // 在重置按钮点击完后但还没重新请求时触发的的函数
118
154
  formOnly:true // 只展示表单不展示按钮
119
155
  parametersType:"url" // 见parametersType类型介绍
120
- DBPrimaryKey: user_id // indexDB主键,配合indexDB使用
121
156
  loading:false // 加载动画
122
- formData:{} // 表单数据不完整
157
+ formData:{} // 注意,因为可能出现的性能问题在组件watch formData的变化时没有使用deep,所以有时候深度的修改会不生效,导致表单数据不完整
123
158
  noInputBlank: true //校验input框不能仅输入空格
124
159
  //例子:formData.value.x=y ✘ | formData.value={...formData.value,x:y} ✔
125
160
  currentPageKey:"page", //当前页数key
126
161
  pageSizeKey:"limit", //每页显示个数key
127
162
  defCurrentPage:1, //默认的页数
128
163
  defPageSize:10, //默认的每页显示个数
129
- queryWhenReady:false,//初始化完成后自动触发查找数据函数
130
- footFieldSetting: {} // 表单底部按钮设置
131
- fieldGroupSetting: {} // 表单分组设置
132
- fieldLabelSetting: {} // 表单字段label设置
133
- onFormChange(queryParams):表单数据变化时触发的函数
134
- <!--formItem的fieldSetting加入gap-0以避免表单内元素间隔 -->
164
+ queryWhenReady:false,//初始化完成后自动触发查找数据函数,建议用这个this.$refs["VGeneralBasicFormRef"].handleQuery({ defaultPageFirst: false })
135
165
  formItem: [
136
-
137
- {
138
- label: "普通输入框",
139
- prop: "bsName",
140
- type: "input",
141
- legend: '这是一个可选的标题',
142
- setting: {
143
- placeholder: '请输入手机验证码',
144
- // style: 'width: 100%',
145
- required: true,
146
- // type: 'number',
147
- // min: 1,
148
- // max: 100,
149
- },
150
- fieldSetting: {
151
- className: fieldClassName,
152
- },
153
- rules: [
154
- {
155
- message: "请输入信息",
156
- required: true,
157
- },
158
- {
159
- pattern: /^\w+[\,\,\-\w' '#]+$/,
160
- message: "请输入正确的Invoice单号"
161
- },
162
- {
163
- validator: (rule, value, callback) => {
164
- callback();
166
+ {
167
+ label: '',
168
+ prop: 'bsName35',
169
+ type: 'divider',
170
+ setting: {
165
171
  },
166
- },
167
- ],
168
- separator: true, //分割线
169
- },
170
- {
171
- label: "文本区域",
172
- prop: "Textarea",
173
- type: "textarea",
174
- setting: {
175
- placeholder: '请输入文本区域',
176
- },
177
- fieldSetting: {
178
- className: fieldClassName,
179
- }
180
- },
181
- {
182
- label: "复杂输入框",
183
- prop: "input-group",
184
- type: "input-group",
185
- setting: {
186
- placeholder: '请输入手机验证码',
187
- // style: 'width: 100%',
188
- addons: [
189
- {
190
- text: '前缀,一般和type: input 配合使用',
191
- align: "inline-start",
192
- render: (props) => {
193
- return (
194
- <div className="flex items-center">
195
- <span>{props}</span>
196
- </div>
197
- );
172
+ template: {
173
+ default: () => {
174
+ return "123123123";
198
175
  },
199
176
  },
200
- {
201
- text: '后缀,一般和type: input 配合使用',
202
- align: "inline-end"
203
- },
204
- // {
205
- // text: '底部盒子,一般和type: 'textarea'配合使用',
206
- // align: "block-end"
207
- // },
208
- ],
209
- // type: 'textarea',//input|textarea
210
- },
211
- fieldSetting: {
212
- className: fieldClassName,
213
- },
214
- },
215
- {
216
- label: '',
217
- prop: 'description',
218
- type: 'description',
219
- fieldSetting: {
220
- className: fieldClassName,
221
- },
222
- description: [
223
- 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
224
- '段落2',
225
- 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
226
- ],
227
- },
228
- {
229
- label: '多维数组',
230
- prop: 'prices',
231
- type: 'form-list',
232
- description: [
233
- '段落1',
234
- '段落2',
235
- ],
236
- separator: "text", //文字分割线
237
- setting: {
238
- heading: true, //是否显示标题
239
- dim: 5, // 多维数组,注意要和columns的长度相等,输出为对象数组
240
- itemWidth: 'mean',//itemWidth: 'auto' | 'mean' 自动宽度(满行) | 平均分配宽度
241
- onChange: (value) => {
242
- console.log(value);
243
- setDetail({ ...detail, prices: value })
244
177
  },
245
- columns: [
246
- {
247
- prop: 'id',
248
- label: '套餐ID',
249
- type: 'input',
250
- setting: {
251
- placeholder: '请输入套餐ID',
252
- disabled: true,
253
- className: 'hidden',
254
- },
255
- },
256
- {
257
- prop: 'days',
258
- label: '套餐名称',
259
- type: 'input',
260
- setting: {
261
- required: true,
262
- placeholder: '请输入套餐名称',
263
- type: 'number'
264
- },
178
+ { label: "款式名称",
179
+ prop: "bsName",
180
+ type: "input",
181
+ setting: {
182
+ placeholder: '请输入手机验证码',
183
+ style: 'width: 100%'
265
184
  },
266
- {
267
- prop: 'serviceType',
268
- label: '服务类型',
269
- type: 'select',
270
- option: [
271
- { label: '到家服务', value: 'home_service' },
272
- { label: '医院陪护', value: 'hospital_care' },
273
- ],
274
- setting: {
275
- placeholder: '请选择服务类型',
276
- required: true,
277
- className: 'w-full',
278
- },
279
- },
280
- {
281
- label: '组合分类',
282
- prop: 'expense_category_id',
283
- type: 'combobox',
284
- setting: {
285
- placeholder: '请输入分类',
185
+ rules: [
186
+ {
187
+ message: "请输入信息"
286
188
  },
287
- options: [
288
- {
289
- label: '指南',
290
- value: '指南',
291
- separator: true, //分割线
292
- children: [
293
- {
294
- value: 'shejiyuanze',
295
- label: '设计原则',
296
- shortcut: 'ctrl+z', //选项右侧的内容
297
- },
298
- ],
299
- },
300
- {
301
- label: '资源',
302
- value: 'resource',
303
- children: [
304
- {
305
- value: 'axure',
306
- label: 'Axure Components',
307
- },
308
- ],
309
- },
310
- ],
311
- },
312
- {
313
- label: '组合分类-多选',
314
- prop: 'expense_multiple_checkbox_test',
315
- type: 'combobox',
316
- setting: {
317
- placeholder: '请选择等级',
318
- type: 'checkbox-list',
189
+ {
190
+ pattern: /^\w+[\,\,\-\w' '#]+$/,
191
+ message: "请输入正确的Invoice单号"
192
+ }
193
+ ],
194
+ template: {
195
+ suffix: () => {
196
+ return <svg-icon icon-class="baifenbi" />;
319
197
  },
320
- option: [
321
- { label: 'Yysyayayasuydsaiewqnkerwjrklwjlwerjwlejrlj3', value: 'Y3' },
322
- { label: 'Yysyayayasuydsaiewqnkerwjrklwjlwerjwlejrlj4', value: 'Y4' },
323
-
324
- ],
325
198
  },
326
- ],
327
- },
328
- fieldSetting: {
329
- className: fieldClassName,
330
- },
331
- rules: [
199
+ },
332
200
  {
333
- validator: (rule, value, callback) => {
334
- console.log(value);
335
- if (!value) {
336
- callback();
337
- return;
338
- }
339
- for (let i = 0; i < value.length; i++) {
340
- const element = value[i];
341
- if (!Number(element.days)) {
342
- callback(new Error('请输入数字'));
343
- return;
344
- }
345
- }
346
- callback();
347
- },
201
+ label: "二次工艺",
202
+ prop: "spName",
203
+ type: "select",
204
+ setting:{ multiple:true, //多选},
205
+ option: [
206
+ { value: "3", label: "满印" },
207
+ { value: "1", label: "区域印花" },
208
+ { value: "2", label: "绣花" },
209
+ ],
348
210
  },
349
- ],
350
- removeItemAction: (item, index) => {
351
- // 删除项会触发此函数
352
- console.log(item, index);
353
- },
354
- },
355
- {
356
- label: '1维数组',
357
- prop: 'nursingCare',
358
- type: 'form-list',
359
- setting: {
360
- placeholder: ['请输入服务内容'],
361
- required: true,
362
- dim: 1, // 1维数组,输出为字符串数组
363
- },
364
- fieldSetting: {
365
- className: fieldClassName,
366
- },
367
- rules: [
368
- {
369
- validator: (rule, value, callback) => {
370
- if (!value) {
371
- callback();
372
- return;
373
- }
374
- for (let i = 0; i < value.length; i++) {
375
- const element = value[i];
376
- if (!element) {
377
- callback(new Error('请输入服务内容'));
378
- return;
379
- }
380
- }
381
- callback();
382
- },
211
+ {
212
+ label: "创建时间",
213
+ prop: "create_time",
214
+ type: "date-picker",
215
+ setting: {
216
+ "range-separator": "至",
217
+ }
383
218
  },
384
- ],
385
- },
386
- {
387
- prop: 'level1',
388
- label: '选择框',
389
- type: 'select',
390
- option: [
391
- { label: 'Y3', value: 'Y3' },
392
- { label: 'Y4', value: 'Y4' },
393
- { label: 'Y5', value: 'Y5' },
394
- ],
395
- setting: {
396
- placeholder: '请选择等级',
397
- required: true,
398
- },
399
- fieldSetting: {
400
- className: fieldClassName,
401
- },
402
- },
403
- {
404
- label: "开关",
405
- prop: "switch_test",
406
- type: "switch",
407
- setting: {
408
- },
409
- fieldSetting: {
410
- className: 'col-start-2 col-span-2 mb-8',
411
- },
412
- },
413
- {
414
- label: "创建时间",
415
- prop: "create_time",
416
- type: "date-picker",
417
- setting: {
418
- placeholder: '请选择创建时间',
419
- },
420
- dataPickerType: "month",//day|month
421
- fieldSetting: {
422
- className: fieldClassName,
423
- },
424
- // rules: [
425
- // {
426
- // message: "请输入信息",
427
- // required: true,
428
- // }
429
- // ],
430
- },
431
-
432
- // {
433
- // label: '是否必填',
434
- // prop: 'is_optional',
435
- // type: 'radio',
436
- // setting: {
437
- // disabled: true
438
- // },
439
- // option: [
440
- // { value: '是', label: 'true', border: true },
441
- // { value: '否', label: 'false' }
442
- // ],
443
- // fieldSetting: {
444
- // className: fieldClassName,
445
- // },
446
- // rules: [
447
- // {
448
- // required: true,
449
- // message: '请输入标签项名称',
450
- // trigger: 'blur'
451
- // }
452
- // ]
453
- // },
454
- {
455
- prop: 'level',
456
- label: '多选列表',
457
- legend: '标题',
458
- type: 'checkbox-list',
459
- gap: 3,
460
- option: [
461
- { label: 'Y3', value: 'Y3' },
462
- { label: 'Y4', value: 'Y4' },
463
- { label: 'Y5', value: 'Y5' },
464
- ],
465
- fieldSetting: {
466
- className: 'col-start-2 col-span-2 mb-8',
467
- },
468
- setting: {
469
- placeholder: '请选择等级',
470
- },
471
- },
472
- {
473
- prop: 'test1',
474
- label: '选择框',
475
- type: 'checkbox',
476
- fieldSetting: {
477
- className: 'col-start-4 col-span-2 mb-8',
478
- },
479
- setting: {
480
- placeholder: '请选择套餐',
481
- },
482
- },
483
- // enum ComTypes {
484
- // "command" = "command",
485
- // "rc-tree" = "rc-tree",
486
- // "ant-tree" = "ant-tree",
487
- // "checkbox-list" = "checkbox-list",
488
- // }
489
-
490
- // enum ContainerTypes {
491
- // "Popover" = "Popover",
492
- // "Drawer" = "Drawer",
493
- // "Dialog" = "Dialog",
494
- // }
495
- {
496
- label: "分类",
497
- prop: "分类",
498
- type: "command",
499
- setting: {
500
- placeholder: "请输入分类",
501
- empty: "搜索内容为空的提示",
502
- },
503
- fieldSetting: {
504
- className: fieldClassName,
505
- },
506
- options: [
507
219
  {
508
- label: "指南",
509
- value: "guide",
510
- separator: true, //分割线
511
- children: [
220
+ label: "二次工艺成本价格(人民币分)",
221
+ prop: "spCost",
222
+ type: "input-number",
223
+ "controls-position": "right",
224
+ min: 0,
225
+ rules: [
512
226
  {
513
- value: 'shejiyuanze',
514
- label: '设计原则',
515
- onSelect: (value) => {
516
- console.log('Selected', value);
517
- },
518
- shortcut: 'ctrl+z', //选项右侧的内容
227
+ required: true,
228
+ message: "请输入二次工艺成本价格",
229
+ trigger: "blur",
519
230
  },
520
-
521
231
  ],
522
232
  },
523
233
  {
524
- label: "资源",
525
- value: "resource",
526
- children: [
234
+ label: '',
235
+ prop: 'bsName2',
236
+ type: 'input-graphic-verification',
237
+ setting: {
238
+ placeholder: '请输入图形验证码',
239
+ style: 'width: 100%'
240
+ },
241
+ rules: [
527
242
  {
528
- value: "axure",
529
- label: "Axure Components",
243
+ message: '请输入图形验证码',
244
+ trigger: 'blur'
530
245
  }
531
246
  ],
247
+ graphicSrc, // 请求图像的URL
248
+ getGraphic, // 重新请求图像的函数
249
+ key:Math.random(), // 必传,图像更新后必须更新。如果URL会变化也可以用URL代替
532
250
  },
533
- ],
534
- },
535
- {
536
- label: '组合分类-多选',
537
- prop: 'expense_multiple_checkbox',
538
- type: 'combobox',
539
- setting: {
540
- placeholder: '请选择等级',
541
- type: 'checkbox-list',
542
- },
543
- fieldSetting: {
544
- className: fieldClassName,
545
- },
546
- option: [
547
- { label: 'Y3', value: 'Y3' },
548
- { label: 'Y4', value: 'Y4' },
549
- { label: 'Y5', value: 'Y5' },
550
- ],
551
- },
552
- {
553
- label: '组合分类',
554
- prop: 'expense_category_id',
555
- type: 'combobox',
556
- setting: {
557
- placeholder: '请输入分类',
558
- empty: '搜索内容为空的提示',
559
- },
560
- fieldSetting: {
561
- className: fieldClassName,
562
- },
563
- options: [
564
251
  {
565
- label: '指南',
566
- value: '指南',
567
- separator: true, //分割线
568
- children: [
252
+ label: '',
253
+ prop: 'bsName3',
254
+ type: 'input-mobile-verification',
255
+ inputSetting: {
256
+ placeholder: '请输入手机验证码',
257
+ style: 'width: 100%'
258
+ },
259
+ buttonSetting: {
260
+ type: "text",
261
+ style: 'text-align: end',
262
+ },
263
+ rules: [
569
264
  {
570
- value: 'shejiyuanze',
571
- label: '设计原则',
572
- shortcut: 'ctrl+z', //选项右侧的内容
573
- },
265
+ message: '请输入手机验证码',
266
+ trigger: 'blur'
267
+ }
574
268
  ],
269
+ getSmscode,// 获取验证码的回调函数,获取失败必须返回false,否则计时器不会重新计算
575
270
  },
576
271
  {
577
- label: '资源',
578
- value: 'resource',
579
-
272
+ label: '是否必填',
273
+ prop: 'is_optional',
274
+ type: 'radio',
275
+ setting: {
276
+ disabled: true
277
+ },
278
+ option: [
279
+ { value: '是', label: 'true',border: true },
280
+ { value: '否', label: 'false' }
281
+ ],
282
+ rules: [
283
+ {
284
+ required: true,
285
+ message: '请输入标签项名称',
286
+ trigger: 'blur'
287
+ }
288
+ ]
289
+ },
290
+ {
291
+ label: '多选',
292
+ prop: 'is_multi',
293
+ type: 'checkbox',
294
+ setting: {
295
+ },
296
+ option: [
297
+ { value: '是', label: 'true' },
298
+ { value: '否', label: 'false' }
299
+ ],
300
+ rules: []
301
+ },
302
+ {
303
+ label: '受访人',
304
+ prop: 'contactors',
305
+ type: 'form-item-slot',
306
+ name: "contactors"
307
+ // 插槽组件使用:
308
+ // <VGeneralBasicForm ...>
309
+ // <template #contactors>
310
+ // <div>一些组件
311
+ // 一些组件
312
+ // <el-form-item prop="contactors">...</el-form-item>
313
+ // </div>
314
+ // </template>
315
+ // </VGeneralBasicForm>
580
316
  },
581
- ],
582
- },
583
- {
584
- label: '树形选择',
585
- prop: 'select_tree',
586
- type: 'combobox',
587
- setting: {
588
- placeholder: '请输入分类',
589
- empty: '搜索内容为空的提示',
590
- type: 'ant-tree',
591
- width: `300px`,//控制组件宽度
592
- // checkable: true,
593
- // selectable: false
594
- },
595
- container: "Dialog",
596
- fieldSetting: {
597
- className: fieldClassName,
598
- },
599
- options: [
600
317
  {
601
- label: '指南',
602
- value: '指南',
603
- children: [
318
+ label: "分类",
319
+ prop: "分类",
320
+ type: "cascader",
321
+ setting:{},
322
+ options: [
604
323
  {
605
- value: 'shejiyuanze',
606
- label: '设计原则',
607
- setting: {
608
- icon: () => {
609
- return <div>ID</div>
610
- }
611
- },
324
+ value: "zhinan",
325
+ label: "指南",
612
326
  children: [
613
327
  {
614
- value: 'leaf',
615
- label: '叶子节点',
616
- shortcut: 'ctrl+z', //选项右侧的内容
328
+ value: "shejiyuanze",
329
+ label: "设计原则",
330
+ children: [
331
+ {
332
+ value: "yizhi",
333
+ label: "一致",
334
+ },
335
+ {
336
+ value: "fankui",
337
+ label: "反馈",
338
+ },
339
+ {
340
+ value: "xiaolv",
341
+ label: "效率",
342
+ },
343
+ {
344
+ value: "kekong",
345
+ label: "可控",
346
+ },
347
+ ],
617
348
  },
618
349
  {
619
- value: 'leaf1',
620
- label: '叶子节点1',
621
- shortcut: 'ctrl+z', //选项右侧的内容
350
+ value: "daohang",
351
+ label: "导航",
352
+ children: [
353
+ {
354
+ value: "cexiangdaohang",
355
+ label: "侧向导航",
356
+ },
357
+ {
358
+ value: "dingbudaohang",
359
+ label: "顶部导航",
360
+ },
361
+ ],
622
362
  },
623
363
  ],
624
364
  },
625
- ],
626
- },
627
- {
628
- label: '资源',
629
- value: 'resource',
630
- children: [
631
365
  {
632
- value: 'axure',
633
- label: 'Axure Components',
366
+ value: "ziyuan",
367
+ label: "资源",
368
+ children: [
369
+ {
370
+ value: "axure",
371
+ label: "Axure Components",
372
+ },
373
+ {
374
+ value: "sketch",
375
+ label: "Sketch Templates",
376
+ },
377
+ {
378
+ value: "jiaohu",
379
+ label: "组件交互文档",
380
+ },
381
+ ],
634
382
  },
635
383
  ],
636
384
  },
637
385
  ],
638
- },
639
- ]
640
-
386
+
641
387
  //rules为表单校验规则,每个组件都可以传入
642
388
 
643
389
  //input支持template,支持以下几个属性:
@@ -645,165 +391,265 @@ parametersType 类型介绍
645
391
  //suffix 输入框尾部内容,只对 type="text" 有效
646
392
  //prepend 输入框前置内容,只对 type="text" 有效
647
393
  //append 输入框后置内容,只对 type="text" 有效
648
-
394
+
649
395
  //divider支持template:
650
396
  //default
397
+ 支持组件type:
398
+
399
+ /**
400
+
401
+ \* @description: 输入框
402
+
403
+ */
404
+
405
+ 'input' = 'input',
406
+
407
+ /**
408
+
409
+ \* @description: 输入框/图像验证码
410
+
411
+ */
412
+
413
+ 'input-graphic-verification' = 'input-graphic-verification',
414
+
415
+ /**
416
+
417
+ \* @description: 输入框/手机验证码
418
+
419
+ */
420
+
421
+ 'input-mobile-verification' = 'input-mobile-verification',
422
+
423
+ /**
424
+
425
+ \* @description: 分割线
426
+
427
+ */
428
+
429
+ 'divider' = 'divider',
430
+
431
+ /**
432
+
433
+ \* @description: 选择器
434
+
435
+ */
436
+
437
+ 'select' = 'select',
438
+
439
+ /**
440
+
441
+ \* @description: 级联选择器
442
+
443
+ */
444
+
445
+ 'cascader' = 'cascader',
446
+
447
+ /**
448
+
449
+ \* @description: 日期选择器
450
+
451
+ */
452
+
453
+ 'date-picker' = 'date-picker',
454
+
455
+ /**
456
+
457
+ \* @description: 数字输入框
458
+
459
+ */
460
+
461
+ 'input-number' = 'input-number',
651
462
 
652
- 支持组件 type:
653
-
654
- export enum FormType {
655
- /\*\*
656
-
657
- - @description: 输入框
658
- - @return {_}
659
- _/
660
- "input" = "input",
661
- /\*\*
662
- - @description: 文本区域
663
- - @return {_}
664
- _/
665
- "textarea" = "textarea",
666
- /\*\*
667
- - @description: 复杂输入框,可自定义前后缀和大小
668
- - @return {_}
669
- _/
670
- "input-group" = "input-group",
671
- /\*\*
672
- - @description: 表单中的多维列表,可增减元素,内部可以使用的数据类型除自身 form-list 外同 FormType
673
- - @return {_}
674
- _/
675
- "form-list" = "form-list",
676
- /\*\*
677
- - @description: 选择器
678
- - @return {_}
679
- _/
680
- "select" = "select",
681
- /\*\*
682
- - @description: 开关
683
- - @return {_}
684
- _/
685
- "switch" = "switch",
686
- /\*\*
687
- - @description: 带搜索的二级菜单
688
- - @return {_}
689
- _/
690
- "command" = "command",
691
- /\*\*
692
- - @description: 响应式下拉框+带搜索的二级菜单/多选
693
- - @return {_}
694
- _/
695
- "combobox" = "combobox",
696
- /\*\*
697
- - @description: 日期选择器
698
- - @return {_}
699
- _/
700
- "date-picker" = "date-picker",
701
-
702
- /\*\*
703
-
704
- - @description: 单选框
705
- - @return {_}
706
- _/
707
- "radio" = "radio",
708
- // /**
709
- // _ @description: 自定义元素,插槽组件
710
- // _ @return {_}
711
- // _/
712
- // "form-item-slot" = "form-item-slot",
713
- /**
714
- - @description: 多选框
715
- - @return {_}
716
- _/
717
- "checkbox" = "checkbox",
718
- /\*\*
719
- - @description: 多选框列表,输入输出都是字符串列表 ["value1", "value2", "value3"]
720
- - @return {_}
721
- _/
722
- "checkbox-list" = "checkbox-list",
723
- /\*\*
724
- - @description: FieldDescription 描述
725
- - @return {_}
726
- _/
727
- "description" = "description",
728
- }
729
-
730
- # RBaseTabs
731
-
732
- tab栏,支持parametersType
463
+ /**
464
+
465
+ \* @description: 单选框
466
+
467
+ */
468
+
469
+ 'radio' = 'radio',
470
+
471
+ /**
472
+
473
+ \* @description: 自定义元素,插槽组件
474
+
475
+ */
476
+
477
+ 'form-item-slot'='form-item-slot',
478
+
479
+ /**
480
+
481
+ \* @description: 多选框
482
+
483
+ */
484
+
485
+ 'checkbox'='checkbox',
486
+
487
+
488
+
489
+ # VInfiniteScrollList对虚拟滚动列表+接口的封装
490
+
491
+
492
+
493
+ ![image-20231208165229296](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202312081652392.png)
494
+
495
+ ```
496
+ import { VInfiniteScrollList } from 'general-basic-form'
497
+ import 'general-basic-form/style'
498
+ <VInfiniteScrollList
499
+ :search="search"
500
+ id="user_id"
501
+ name="name"
502
+ ref="InfiniteScrollListRef"
503
+ checkbox
504
+ :extra="extraRender"
505
+ :max="1"
506
+ />
507
+ ```
508
+ ```
509
+ 移动端配合下拉刷新使用
510
+ import { getOrderItem } from "../orderItem/functional"
511
+ // getOrderItem为JSX函数,返回一个VUE组件
512
+
513
+ <t-pull-down-refresh v-model="refreshing" @refresh="onRefresh" class="refresh-content">
514
+ <VInfiniteScrollList :search="loadData" :checkbox="false" id="cancelId" ref="InfiniteScrollListRef" checkbox
515
+ :extra="getOrderItem" height="100%" infinite-scroll-distance="50"/>
516
+ </t-pull-down-refresh>
517
+ ```
518
+ ```
519
+ search:数据接口 (page: Number) => Promise<[]>
520
+ id:数据key值(唯一和选择值)
521
+ name:显示名字
522
+ checkbox:是否有多选功能,不传的话就是单纯的虚拟滚动列表
523
+ extra:同行额外显示的内容,(item: any) => VNode | String;
524
+ //el-checkbox有固定高度,如果需要配置高度比较高,例如有换行的自定义extra,最好处理一下样式,例子:
525
+ //:deep(.el-checkbox) {
526
+ // padding: 6px 16px !important;
527
+ // display: flex;
528
+ // align-items: baseline;
529
+ // height: auto;
530
+ //}
531
+ defaultSelection:包含数据key值的对象数组或者直接传入key值数组
532
+ height:默认272px String
533
+ ```
733
534
 
734
535
  ```
735
- import { RBaseTabs } from 'general-basic-form';
736
- const tabPanes = [
536
+ defineExpose({ reset, loadList, selectInfo, list, ifbottom });
537
+ InfiniteScrollListRef?.value?.reset():重置列表内容
538
+ InfiniteScrollListRef?.value?.lowReset():重置列表内容,但保留已选择的选项
539
+ InfiniteScrollListRef?.value?.loadList():向下滚动列表内容,受到loading和ifbottom的影响
540
+ InfiniteScrollListRef?.value?.refreshList():刷新列表,滚动列表会对整个内容重新请求数据,已选择的内容会自动选择
541
+ InfiniteScrollListRef?.value?.selectInfo:选择的内容
542
+ InfiniteScrollListRef?.value?.list:列表的内容
543
+ InfiniteScrollListRef?.value?.ifbottom:是否到底部
544
+ InfiniteScrollListRef?.value?.loading:加载中
545
+ ```
546
+
547
+ # VDescriptions对展示描述列表的封装
548
+
549
+ ![image-20231208182455415](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202312081824708.png)
550
+
551
+ ```
552
+ import { VDescriptions } from 'general-basic-form'
553
+ <VDescriptions
554
+ :formData="props.formData"
555
+ :formItem="formItem"
556
+ componentType="Ant Design Vue"
557
+ ...其他el-descriptions的配置
558
+ />
559
+ ```
560
+
561
+ ```
562
+ formData:Object
563
+ formItem:[ {
564
+ label: '受访人',
565
+ prop: 'contactors',
566
+ render: (scope: any) => {
567
+ const { $index, row = {} } = scope
568
+ const { contactors = [] } = row
569
+ const ele = (contactors.length > 0 ? <span>{contactors.map((item: any) => item.name).join(",")} </span> : null)
570
+ return ele
571
+ }
572
+ },
737
573
  {
738
- value: 'rewards',
739
- label: '配置1',
740
- render: (tabPane, index) => {
741
- return <Rewards />;
742
- },
743
- }
744
- ]
745
- <RBaseTabs tabPanes={tabPanes} parametersType="indexDB" DBPrimaryKey={auth.get.user().id}></RBaseTabs>;
574
+ label: '拜访详情',
575
+ prop: 'detail',
576
+ descriptionsItemProps:{
577
+ 'label-class-name': 'label-class-name'
578
+ }
579
+ }]
580
+ componentType:"Ant Design Vue"|"Element Plus"(默认)
581
+ strict:Boolean //使用strict参数后,如果formData内的某个字段没有值,对应的描述元素将不会展示(包括标签文字),但有render的字段仍然会展示
582
+ descriptionsItemProps:a-descriptions-item|el-descriptions-item的配置
583
+ ```
584
+
585
+ # VInputMobilecVerification,VInputGraphicVerification表单里的图形验证码、手机验证码组件,可以单独引入
586
+
587
+ ```
588
+ <VInputGraphicVerification :item="{同表单,可忽略label和rules字段}" :loading="loading"></VInputGraphicVerification>
589
+
590
+ <VInputMobilecVerification :item="{同表单,可忽略label和rules字段}" componentType="Ant Design Vue" ref="VInputMobilecVerificationRef"></VInputMobilecVerification>
591
+ ```
592
+
593
+ ```
594
+ componentType:"Ant Design Vue"|"Element Plus"(默认)
595
+ ```
596
+
746
597
  ```
598
+ 此用法下必须提供:
599
+ provide(/* 注入名 */ "queryParams", /* 表单值对象 */ queryParams);
747
600
 
601
+ componentType为Ant Design Vue需要提供:
602
+ import { Form } from 'ant-design-vue';
603
+ provide(/* 注入名 */ "Form", /* Ant Design Vue Form实例,用于表单数据更新等 */ Form);
748
604
 
605
+ 可选:
606
+ provide("size", size); // 同组件size
607
+ provide("getList", getList); // 输入框回车触发
749
608
 
750
- # RBaseCombobox 单独使用
609
+ 调用发送短信验证码和重置的方法
610
+ VInputMobilecVerificationRef.value.VerificationButtonRef.buttonClick()
611
+ VInputMobilecVerificationRef.value.VerificationButtonRef.reset()
612
+ ```
613
+
614
+ # VTreeTransfer 树形数据穿梭框
751
615
 
752
- 多功能组合弹出框
616
+ ![image-20250425183446375](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202504251834575.png)
617
+
618
+ ```
619
+ <VTreeTransfer :dataSource="classmate" :treeAttributes="{
620
+ 'node-key': 'user_id', props: { label: 'user_name' }, 'default-expand-all': false
621
+ }" transferTitleRight="白名单(不会被选中)" transferTitleLeft="普通名单" filterable :checkedKeys="checkedKeys">
622
+ </VTreeTransfer>
623
+
624
+ import { VTreeTransfer } from 'general-basic-form';
625
+ const VTreeTransferRef = ref([])
626
+ ```
753
627
 
754
628
  ```
755
- import { RBaseCombobox } from 'general-basic-form';
756
- <RBaseCombobox
757
- onFormChange={(params) => {
758
- console.log('queryParams', params);
759
- }}
760
- value='resource'
761
- item={{
762
- options: [
629
+ dataSource:[
630
+ {
631
+ label: 'Level one 1',
632
+ id:1,
633
+ children: [
763
634
  {
764
- label: '指南',
765
- value: '指南',
766
- separator: true, //分割线
635
+ label: 'Level two 1-1',
636
+ id:2,
767
637
  children: [
768
638
  {
769
- value: 'shejiyuanze',
770
- label: '设计原则',
771
- shortcut: 'ctrl+z', //选项右侧的内容
639
+ label: 'Level three 1-1-1',
640
+ id:3,
772
641
  },
773
642
  ],
774
643
  },
775
- {
776
- label: '资源',
777
- value: 'resource',
778
- },
779
644
  ],
780
- setting: {
781
- placeholder: '请输入分类',
782
- empty: '搜索内容为空的提示',
783
- },
784
- container: 'Dialog',
785
- }}
786
- />
787
-
645
+ },] 树状结构数据
646
+ treeAttributes:{} 树形控件的属性,见https://element-plus.org/zh-CN/component/tree.html
647
+ transferTitleLeft:"" 左标题
648
+ transferTitleRight:"" 右标题
649
+ filterable:false 是否显示搜索框
650
+ checkedKeys:[1,2] 选中的值
651
+
652
+ 获取选中的数组详情:
653
+ VTreeTransferRef.value["selectedList"].map((item) => {}))
788
654
  ```
789
- # RBaseDatePicker 单独使用
790
655
 
791
- 日期选择器
792
-
793
- ```
794
- import { RBaseDatePicker } from 'general-basic-form';
795
- <RBaseDatePicker
796
- onFormChange={(params) => {
797
- console.log('queryParams', params);
798
- }}
799
- // ref={RBaseComboboxRef}
800
- value={new Date()}
801
- item={{
802
- setting: {
803
- placeholder: '请选择创建时间',
804
- },
805
- dataPickerType: "month",//day|month
806
- }}
807
- />
808
-
809
- ```