general-basic-form 2.4.4 → 3.0.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.
Files changed (2) hide show
  1. package/README.md +691 -535
  2. package/package.json +59 -21
package/README.md CHANGED
@@ -1,27 +1,30 @@
1
+ <!-- @format -->
2
+
1
3
  # GeneralBasicForm
2
4
 
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 | | | | | | √ | √ |
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 | | | | | | √ | √ |
18
21
 
19
22
  安装:npm i general-basic-form<br/>
20
23
  install: npm i general-basic-form
21
24
 
22
- webpack4兼容:
25
+ webpack4 兼容:
23
26
  加入配置:module.exports = {
24
- transpileDependencies: ['general-basic-form'],
27
+ transpileDependencies: ['general-basic-form'],
25
28
  }
26
29
 
27
30
  示例:
@@ -29,63 +32,62 @@ webpack4兼容:
29
32
  因为兼容性问题,目前只能使用完整引入
30
33
 
31
34
  ```
32
- import ElementPlus from 'element-plus'
33
- import 'element-plus/dist/index.css'
34
- app.use(ElementPlus)
35
+ import { RGeneralBasicForm,RBasicForm } from 'general-basic-form';
35
36
  ```
36
37
 
37
38
  ```
38
- import { VGeneralBasicForm } from 'general-basic-form'
39
- import 'general-basic-form/style'
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>
40
68
  ```
41
69
 
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
-
61
70
  ![image-20210903165502942](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202109031655830.png)
62
71
 
63
72
  在单纯作为表单的时候可以这样使用:
64
73
 
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>
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>
87
89
 
88
- getList会传出默认的参数,首次请求时会有页数和分页大小,重置后会传出默认页数1
90
+ getList 会传出默认的参数,首次请求时会有页数和分页大小,重置后会传出默认页数 1
89
91
 
90
92
  async getList(
91
93
  params = {
@@ -94,296 +96,550 @@ getList会传出默认的参数,首次请求时会有页数和分页大小,重
94
96
  }
95
97
  ) {}
96
98
 
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
- })
99
+ 表单数据校验需要拿到内部表单的 ref
137
100
 
101
+ RGeneralBasicFormRef.current.formAction(); // 触发表单校验和getList
138
102
 
139
103
  ![image-20211014191532067](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202110141915657.png)
140
104
 
141
- parametersType类型介绍
105
+ parametersType 类型介绍
142
106
 
143
- | parametersType形式 | 支持页面刷新 | 参数改变引起路由跳转 | 组件间共享数据 | 存储上限 | 浏览器兼容性 |
144
- | ------------------ | ------------ | -------------------- | -------------- | -------- | ------------ |
145
- | url | 是 | 是 | 是 | 中 | 高 |
146
- | data | 否 | 否 | 否 | 高 | 高 |
147
- | indexDB | 是 | 否 | 是 | 高 | 中 |
107
+ | parametersType 形式 | 支持页面刷新 | 参数改变引起路由跳转 | 组件间共享数据 | 存储上限 | 浏览器兼容性 |
108
+ | ------------------- | ------------ | -------------------- | -------------- | -------- | ------------ |
109
+ | url | 是 | 是 | 是 | 中 | 高 |
110
+ | data | 否 | 否 | 否 | 高 | 高 |
111
+ | indexDB | 是 | 否 | 是 | 高 | 中 |
148
112
 
149
113
  数据示例:
150
114
 
151
- showSearch: true, // 显示搜索条件
152
- getList(); // 请求数据的函数
153
- afterReset(); // 在重置按钮点击完后但还没重新请求时触发的的函数
115
+ formOnly:true // 只展示表单不展示按钮
116
+ getList(queryParams); // 请求数据的函数
117
+ afterReset(queryParams); // 在重置按钮点击完后但还没重新请求时触发的的函数
154
118
  formOnly:true // 只展示表单不展示按钮
155
119
  parametersType:"url" // 见parametersType类型介绍
120
+ DBPrimaryKey: user_id // indexDB主键,配合indexDB使用
156
121
  loading:false // 加载动画
157
- formData:{} // 注意,因为可能出现的性能问题在组件watch formData的变化时没有使用deep,所以有时候深度的修改会不生效,导致表单数据不完整
122
+ formData:{} // 表单数据不完整
158
123
  noInputBlank: true //校验input框不能仅输入空格
159
124
  //例子:formData.value.x=y ✘ | formData.value={...formData.value,x:y} ✔
160
125
  currentPageKey:"page", //当前页数key
161
126
  pageSizeKey:"limit", //每页显示个数key
162
127
  defCurrentPage:1, //默认的页数
163
128
  defPageSize:10, //默认的每页显示个数
164
- queryWhenReady:false,//初始化完成后自动触发查找数据函数,建议用这个this.$refs["VGeneralBasicFormRef"].handleQuery({ defaultPageFirst: false })
129
+ queryWhenReady:false,//初始化完成后自动触发查找数据函数
130
+ footFieldSetting: {} // 表单底部按钮设置
131
+ fieldGroupSetting: {} // 表单分组设置
132
+ fieldLabelSetting: {} // 表单字段label设置
133
+ onFormChange(queryParams):表单数据变化时触发的函数
134
+ <!--formItem的fieldSetting加入gap-0以避免表单内元素间隔 -->
165
135
  formItem: [
166
- {
167
- label: '',
168
- prop: 'bsName35',
169
- type: 'divider',
170
- setting: {
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();
171
165
  },
172
- template: {
173
- default: () => {
174
- return "123123123";
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
+ );
175
198
  },
176
199
  },
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 })
177
244
  },
178
- { label: "款式名称",
179
- prop: "bsName",
180
- type: "input",
181
- setting: {
182
- placeholder: '请输入手机验证码',
183
- style: 'width: 100%'
245
+ columns: [
246
+ {
247
+ prop: 'id',
248
+ label: '套餐ID',
249
+ type: 'input',
250
+ setting: {
251
+ placeholder: '请输入套餐ID',
252
+ disabled: true,
253
+ className: 'hidden',
254
+ },
184
255
  },
185
- rules: [
186
- {
187
- message: "请输入信息"
256
+ {
257
+ prop: 'days',
258
+ label: '套餐名称',
259
+ type: 'input',
260
+ setting: {
261
+ required: true,
262
+ placeholder: '请输入套餐名称',
263
+ type: 'number'
188
264
  },
189
- {
190
- pattern: /^\w+[\,\,\-\w' '#]+$/,
191
- message: "请输入正确的Invoice单号"
192
- }
193
- ],
194
- template: {
195
- suffix: () => {
196
- return <svg-icon icon-class="baifenbi" />;
265
+ },
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: '请输入分类',
197
286
  },
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
+ ],
198
311
  },
199
- },
312
+ {
313
+ label: '组合分类-多选',
314
+ prop: 'expense_multiple_checkbox_test',
315
+ type: 'combobox',
316
+ setting: {
317
+ placeholder: '请选择等级',
318
+ type: 'checkbox-list',
319
+ },
320
+ option: [
321
+ { label: 'Yysyayayasuydsaiewqnkerwjrklwjlwerjwlejrlj3', value: 'Y3' },
322
+ { label: 'Yysyayayasuydsaiewqnkerwjrklwjlwerjwlejrlj4', value: 'Y4' },
323
+
324
+ ],
325
+ },
326
+ ],
327
+ },
328
+ fieldSetting: {
329
+ className: fieldClassName,
330
+ },
331
+ rules: [
200
332
  {
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
- ],
210
- },
211
- {
212
- label: "创建时间",
213
- prop: "create_time",
214
- type: "date-picker",
215
- setting: {
216
- "range-separator": "至",
217
- }
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
+ },
218
348
  },
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: [
219
368
  {
220
- label: "二次工艺成本价格(人民币分)",
221
- prop: "spCost",
222
- type: "input-number",
223
- "controls-position": "right",
224
- min: 0,
225
- rules: [
226
- {
227
- required: true,
228
- message: "请输入二次工艺成本价格",
229
- trigger: "blur",
230
- },
231
- ],
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
+ },
232
383
  },
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
+ // timeZone: "Asia/Shanghai",
420
+ // locale: ,
421
+ },
422
+ dataPickerType: "month",//day|month
423
+ fieldSetting: {
424
+ className: fieldClassName,
425
+ },
426
+ // rules: [
427
+ // {
428
+ // message: "请输入信息",
429
+ // required: true,
430
+ // }
431
+ // ],
432
+ },
433
+
434
+ // {
435
+ // label: '是否必填',
436
+ // prop: 'is_optional',
437
+ // type: 'radio',
438
+ // setting: {
439
+ // disabled: true
440
+ // },
441
+ // option: [
442
+ // { value: '是', label: 'true', border: true },
443
+ // { value: '否', label: 'false' }
444
+ // ],
445
+ // fieldSetting: {
446
+ // className: fieldClassName,
447
+ // },
448
+ // rules: [
449
+ // {
450
+ // required: true,
451
+ // message: '请输入标签项名称',
452
+ // trigger: 'blur'
453
+ // }
454
+ // ]
455
+ // },
456
+ {
457
+ prop: 'level',
458
+ label: '多选列表',
459
+ legend: '标题',
460
+ type: 'checkbox-list',
461
+ gap: 3,
462
+ option: [
463
+ { label: 'Y3', value: 'Y3' },
464
+ { label: 'Y4', value: 'Y4' },
465
+ { label: 'Y5', value: 'Y5' },
466
+ ],
467
+ fieldSetting: {
468
+ className: 'col-start-2 col-span-2 mb-8',
469
+ },
470
+ setting: {
471
+ placeholder: '请选择等级',
472
+ },
473
+ },
474
+ {
475
+ prop: 'test1',
476
+ label: '选择框',
477
+ type: 'checkbox',
478
+ fieldSetting: {
479
+ className: 'col-start-4 col-span-2 mb-8',
480
+ },
481
+ setting: {
482
+ placeholder: '请选择套餐',
483
+ },
484
+ },
485
+ // enum ComTypes {
486
+ // "command" = "command",
487
+ // "rc-tree" = "rc-tree",
488
+ // "ant-tree" = "ant-tree",
489
+ // "checkbox-list" = "checkbox-list",
490
+ // }
491
+
492
+ // enum ContainerTypes {
493
+ // "Popover" = "Popover",
494
+ // "Drawer" = "Drawer",
495
+ // "Dialog" = "Dialog",
496
+ // }
497
+ {
498
+ label: "分类",
499
+ prop: "分类",
500
+ type: "command",
501
+ setting: {
502
+ placeholder: "请输入分类",
503
+ empty: "搜索内容为空的提示",
504
+ },
505
+ fieldSetting: {
506
+ className: fieldClassName,
507
+ },
508
+ options: [
233
509
  {
234
- label: '',
235
- prop: 'bsName2',
236
- type: 'input-graphic-verification',
237
- setting: {
238
- placeholder: '请输入图形验证码',
239
- style: 'width: 100%'
240
- },
241
- rules: [
510
+ label: "指南",
511
+ value: "guide",
512
+ separator: true, //分割线
513
+ children: [
242
514
  {
243
- message: '请输入图形验证码',
244
- trigger: 'blur'
245
- }
515
+ value: 'shejiyuanze',
516
+ label: '设计原则',
517
+ onSelect: (value) => {
518
+ console.log('Selected', value);
519
+ },
520
+ shortcut: 'ctrl+z', //选项右侧的内容
521
+ },
522
+
246
523
  ],
247
- graphicSrc, // 请求图像的URL
248
- getGraphic, // 重新请求图像的函数
249
- key:Math.random(), // 必传,图像更新后必须更新。如果URL会变化也可以用URL代替
250
524
  },
251
525
  {
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: [
526
+ label: "资源",
527
+ value: "resource",
528
+ children: [
264
529
  {
265
- message: '请输入手机验证码',
266
- trigger: 'blur'
530
+ value: "axure",
531
+ label: "Axure Components",
267
532
  }
268
533
  ],
269
- getSmscode,// 获取验证码的回调函数,获取失败必须返回false,否则计时器不会重新计算
270
534
  },
535
+ ],
536
+ },
537
+ {
538
+ label: '组合分类-多选',
539
+ prop: 'expense_multiple_checkbox',
540
+ type: 'combobox',
541
+ setting: {
542
+ placeholder: '请选择等级',
543
+ type: 'checkbox-list',
544
+ },
545
+ fieldSetting: {
546
+ className: fieldClassName,
547
+ },
548
+ option: [
549
+ { label: 'Y3', value: 'Y3' },
550
+ { label: 'Y4', value: 'Y4' },
551
+ { label: 'Y5', value: 'Y5' },
552
+ ],
553
+ },
554
+ {
555
+ label: '组合分类',
556
+ prop: 'expense_category_id',
557
+ type: 'combobox',
558
+ setting: {
559
+ placeholder: '请输入分类',
560
+ empty: '搜索内容为空的提示',
561
+ },
562
+ fieldSetting: {
563
+ className: fieldClassName,
564
+ },
565
+ options: [
271
566
  {
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: [
567
+ label: '指南',
568
+ value: '指南',
569
+ separator: true, //分割线
570
+ children: [
283
571
  {
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' }
572
+ value: 'shejiyuanze',
573
+ label: '设计原则',
574
+ shortcut: 'ctrl+z', //选项右侧的内容
575
+ },
299
576
  ],
300
- rules: []
301
577
  },
302
578
  {
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>
579
+ label: '资源',
580
+ value: 'resource',
581
+
316
582
  },
583
+ ],
584
+ },
585
+ {
586
+ label: '树形选择',
587
+ prop: 'select_tree',
588
+ type: 'combobox',
589
+ setting: {
590
+ placeholder: '请输入分类',
591
+ empty: '搜索内容为空的提示',
592
+ type: 'ant-tree',
593
+ width: `300px`,//控制组件宽度
594
+ // checkable: true,
595
+ // selectable: false
596
+ },
597
+ container: "Dialog",
598
+ fieldSetting: {
599
+ className: fieldClassName,
600
+ },
601
+ options: [
317
602
  {
318
- label: "分类",
319
- prop: "分类",
320
- type: "cascader",
321
- setting:{},
322
- options: [
603
+ label: '指南',
604
+ value: '指南',
605
+ children: [
323
606
  {
324
- value: "zhinan",
325
- label: "指南",
607
+ value: 'shejiyuanze',
608
+ label: '设计原则',
609
+ setting: {
610
+ icon: () => {
611
+ return <div>ID</div>
612
+ }
613
+ },
326
614
  children: [
327
615
  {
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
- ],
616
+ value: 'leaf',
617
+ label: '叶子节点',
618
+ shortcut: 'ctrl+z', //选项右侧的内容
348
619
  },
349
620
  {
350
- value: "daohang",
351
- label: "导航",
352
- children: [
353
- {
354
- value: "cexiangdaohang",
355
- label: "侧向导航",
356
- },
357
- {
358
- value: "dingbudaohang",
359
- label: "顶部导航",
360
- },
361
- ],
621
+ value: 'leaf1',
622
+ label: '叶子节点1',
623
+ shortcut: 'ctrl+z', //选项右侧的内容
362
624
  },
363
625
  ],
364
626
  },
627
+ ],
628
+ },
629
+ {
630
+ label: '资源',
631
+ value: 'resource',
632
+ children: [
365
633
  {
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
+ value: 'axure',
635
+ label: 'Axure Components',
382
636
  },
383
637
  ],
384
638
  },
385
639
  ],
386
-
640
+ },
641
+ ]
642
+
387
643
  //rules为表单校验规则,每个组件都可以传入
388
644
 
389
645
  //input支持template,支持以下几个属性:
@@ -391,265 +647,165 @@ parametersType类型介绍
391
647
  //suffix 输入框尾部内容,只对 type="text" 有效
392
648
  //prepend 输入框前置内容,只对 type="text" 有效
393
649
  //append 输入框后置内容,只对 type="text" 有效
394
-
650
+
395
651
  //divider支持template:
396
652
  //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',
462
653
 
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
- ```
654
+ 支持组件 type:
655
+
656
+ export enum FormType {
657
+ /\*\*
658
+
659
+ - @description: 输入框
660
+ - @return {_}
661
+ _/
662
+ "input" = "input",
663
+ /\*\*
664
+ - @description: 文本区域
665
+ - @return {_}
666
+ _/
667
+ "textarea" = "textarea",
668
+ /\*\*
669
+ - @description: 复杂输入框,可自定义前后缀和大小
670
+ - @return {_}
671
+ _/
672
+ "input-group" = "input-group",
673
+ /\*\*
674
+ - @description: 表单中的多维列表,可增减元素,内部可以使用的数据类型除自身 form-list 外同 FormType
675
+ - @return {_}
676
+ _/
677
+ "form-list" = "form-list",
678
+ /\*\*
679
+ - @description: 选择器
680
+ - @return {_}
681
+ _/
682
+ "select" = "select",
683
+ /\*\*
684
+ - @description: 开关
685
+ - @return {_}
686
+ _/
687
+ "switch" = "switch",
688
+ /\*\*
689
+ - @description: 带搜索的二级菜单
690
+ - @return {_}
691
+ _/
692
+ "command" = "command",
693
+ /\*\*
694
+ - @description: 响应式下拉框+带搜索的二级菜单/多选
695
+ - @return {_}
696
+ _/
697
+ "combobox" = "combobox",
698
+ /\*\*
699
+ - @description: 日期选择器
700
+ - @return {_}
701
+ _/
702
+ "date-picker" = "date-picker",
703
+
704
+ /\*\*
705
+
706
+ - @description: 单选框
707
+ - @return {_}
708
+ _/
709
+ "radio" = "radio",
710
+ // /**
711
+ // _ @description: 自定义元素,插槽组件
712
+ // _ @return {_}
713
+ // _/
714
+ // "form-item-slot" = "form-item-slot",
715
+ /**
716
+ - @description: 多选框
717
+ - @return {_}
718
+ _/
719
+ "checkbox" = "checkbox",
720
+ /\*\*
721
+ - @description: 多选框列表,输入输出都是字符串列表 ["value1", "value2", "value3"]
722
+ - @return {_}
723
+ _/
724
+ "checkbox-list" = "checkbox-list",
725
+ /\*\*
726
+ - @description: FieldDescription 描述
727
+ - @return {_}
728
+ _/
729
+ "description" = "description",
730
+ }
731
+
732
+ # RBaseTabs
733
+
734
+ tab栏,支持parametersType
534
735
 
535
736
  ```
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
+ import { RBaseTabs } from 'general-basic-form';
738
+ const tabPanes = [
573
739
  {
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
-
740
+ value: 'rewards',
741
+ label: '配置1',
742
+ render: (tabPane, index) => {
743
+ return <Rewards />;
744
+ },
745
+ }
746
+ ]
747
+ <RBaseTabs tabPanes={tabPanes} parametersType="indexDB" DBPrimaryKey={auth.get.user().id}></RBaseTabs>;
597
748
  ```
598
- 此用法下必须提供:
599
- provide(/* 注入名 */ "queryParams", /* 表单值对象 */ queryParams);
600
749
 
601
- componentType为Ant Design Vue需要提供:
602
- import { Form } from 'ant-design-vue';
603
- provide(/* 注入名 */ "Form", /* Ant Design Vue Form实例,用于表单数据更新等 */ Form);
604
750
 
605
- 可选:
606
- provide("size", size); // 同组件size
607
- provide("getList", getList); // 输入框回车触发
608
751
 
609
- 调用发送短信验证码和重置的方法
610
- VInputMobilecVerificationRef.value.VerificationButtonRef.buttonClick()
611
- VInputMobilecVerificationRef.value.VerificationButtonRef.reset()
612
- ```
613
-
614
- # VTreeTransfer 树形数据穿梭框
752
+ # RBaseCombobox 单独使用
615
753
 
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
- ```
754
+ 多功能组合弹出框
627
755
 
628
756
  ```
629
- dataSource:[
630
- {
631
- label: 'Level one 1',
632
- id:1,
633
- children: [
757
+ import { RBaseCombobox } from 'general-basic-form';
758
+ <RBaseCombobox
759
+ onFormChange={(params) => {
760
+ console.log('queryParams', params);
761
+ }}
762
+ value='resource'
763
+ item={{
764
+ options: [
634
765
  {
635
- label: 'Level two 1-1',
636
- id:2,
766
+ label: '指南',
767
+ value: '指南',
768
+ separator: true, //分割线
637
769
  children: [
638
770
  {
639
- label: 'Level three 1-1-1',
640
- id:3,
771
+ value: 'shejiyuanze',
772
+ label: '设计原则',
773
+ shortcut: 'ctrl+z', //选项右侧的内容
641
774
  },
642
775
  ],
643
776
  },
777
+ {
778
+ label: '资源',
779
+ value: 'resource',
780
+ },
644
781
  ],
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) => {}))
782
+ setting: {
783
+ placeholder: '请输入分类',
784
+ empty: '搜索内容为空的提示',
785
+ },
786
+ container: 'Dialog',
787
+ }}
788
+ />
789
+
654
790
  ```
791
+ # RBaseDatePicker 单独使用
655
792
 
793
+ 日期选择器
794
+
795
+ ```
796
+ import { RBaseDatePicker } from 'general-basic-form';
797
+ <RBaseDatePicker
798
+ onFormChange={(params) => {
799
+ console.log('queryParams', params);
800
+ }}
801
+ // ref={RBaseComboboxRef}
802
+ value={new Date()}
803
+ item={{
804
+ setting: {
805
+ placeholder: '请选择创建时间',
806
+ },
807
+ dataPickerType: "month",//day|month
808
+ }}
809
+ />
810
+
811
+ ```