general-basic-form 2.2.4 → 2.2.6

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 (4) hide show
  1. package/README.md +101 -73
  2. package/dist/index.js +16109 -7149
  3. package/dist/index.umd.cjs +153 -26
  4. package/package.json +20 -18
package/README.md CHANGED
@@ -70,28 +70,21 @@ import { RGeneralBasicForm,RBasicForm } from 'general-basic-form';
70
70
 
71
71
  在单纯作为表单的时候可以这样使用:
72
72
 
73
- <VGeneralBasicForm
74
- formOnly
75
- :formItem="formItem"
76
- size="small"
77
- ref="VGeneralBasicFormRef"
78
- :labelWidth="formLabelWidth"
79
- :formData: {
80
- // 外部传入的表单数据,用于回填
81
- }
82
- noUrlParameters
83
- :afterReset="afterReset"
84
- v-model:loading="loading"
85
- />
86
-
87
- <style lang="scss" scoped>
88
- :deep(.el-form-item) {
89
- margin-bottom: 16px;
90
- }
91
- :deep(.el-divider--horizontal) {
92
- margin: 8px 0px;
93
- }
94
- </style>
73
+ const RGeneralBasicFormRef = useRef(null);
74
+
75
+ <RGeneralBasicForm
76
+ formOnly
77
+ ref={RGeneralBasicFormRef}
78
+ className="py-4"
79
+ formItem={formItem}
80
+ getList={getList}
81
+ parametersType="data"
82
+ noInputBlank
83
+ formData={formData}
84
+ fieldGroupSetting={{ className: 'grid grid-cols-2 gap-4' }}
85
+ >
86
+ //自定义组件
87
+ </RGeneralBasicForm>
95
88
 
96
89
  getList 会传出默认的参数,首次请求时会有页数和分页大小,重置后会传出默认页数 1
97
90
 
@@ -104,44 +97,7 @@ getList 会传出默认的参数,首次请求时会有页数和分页大小,重
104
97
 
105
98
  表单数据校验需要拿到内部表单的 ref
106
99
 
107
- async getSmscode() {
108
- const VGeneralBasicFormRef = this.$refs['VGeneralBasicFormRef'] as any
109
- const state = await new Promise<boolean>((resolve, reject) => {
110
- VGeneralBasicFormRef.$refs['queryFormRef']?.validateField(
111
- 'user_phone',
112
- async (valid: boolean, props?: FormItemProp[] | undefined) => {
113
- if (valid) {
114
- const { user_phone } = VGeneralBasicFormRef['queryParams']
115
- const res: any = await SmscodeList({ user_phone })
116
- if (res) {
117
- console.log(res)
118
- resolve(true)
119
- } else {
120
- resolve(false)
121
- }
122
- } else {
123
- resolve(false)
124
- }
125
- }
126
- )
127
- })
128
- return state
129
- },
130
-
131
- setup写法:
132
- const VGeneralBasicFormRef = ref()
133
- const params = await new Promise<any>((resolve, reject) => {
134
- VGeneralBasicFormRef.value.$refs['queryFormRef']?.validate(
135
- async (valid: boolean, props?: FormItemProp[] | undefined) => {
136
- if (valid) {
137
- const params = VGeneralBasicFormRef.value['queryParams']
138
- resolve(params)
139
- } else {
140
- reject()
141
- }
142
- }
143
- )
144
- })
100
+ RGeneralBasicFormRef.current.formAction(); // 触发表单校验和getList
145
101
 
146
102
  ![image-20211014191532067](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202110141915657.png)
147
103
 
@@ -155,7 +111,7 @@ parametersType 类型介绍
155
111
 
156
112
  数据示例:
157
113
 
158
- showSearch: true, // 显示搜索条件
114
+ formOnly:true // 只展示表单不展示按钮
159
115
  getList(queryParams); // 请求数据的函数
160
116
  afterReset(queryParams); // 在重置按钮点击完后但还没重新请求时触发的的函数
161
117
  formOnly:true // 只展示表单不展示按钮
@@ -185,6 +141,9 @@ parametersType 类型介绍
185
141
  placeholder: '请输入手机验证码',
186
142
  // style: 'width: 100%',
187
143
  required: true,
144
+ // type: 'number',
145
+ // min: 1,
146
+ // max: 100,
188
147
  },
189
148
  fieldSetting: {
190
149
  className: fieldClassName,
@@ -206,6 +165,17 @@ parametersType 类型介绍
206
165
  ],
207
166
  separator: true, //分割线
208
167
  },
168
+ {
169
+ label: "文本区域",
170
+ prop: "Textarea",
171
+ type: "textarea",
172
+ setting: {
173
+ placeholder: '请输入文本区域',
174
+ },
175
+ fieldSetting: {
176
+ className: fieldClassName,
177
+ }
178
+ },
209
179
  {
210
180
  label: "复杂输入框",
211
181
  prop: "input-group",
@@ -264,10 +234,11 @@ parametersType 类型介绍
264
234
  separator: "text", //文字分割线
265
235
  setting: {
266
236
  heading: true, //是否显示标题
267
- dim: 4, // 多维数组,注意要和columns的长度相等,输出为对象数组
237
+ dim: 5, // 多维数组,注意要和columns的长度相等,输出为对象数组
268
238
  itemWidth: 'mean',//itemWidth: 'auto' | 'mean' 自动宽度(满行) | 平均分配宽度
269
239
  onChange: (value) => {
270
240
  console.log(value);
241
+ setDetail({ ...detail, prices: value })
271
242
  },
272
243
  columns: [
273
244
  {
@@ -304,7 +275,38 @@ parametersType 类型介绍
304
275
  className: 'w-full',
305
276
  },
306
277
  },
307
-
278
+ {
279
+ label: '组合分类',
280
+ prop: 'expense_category_id',
281
+ type: 'combobox',
282
+ setting: {
283
+ placeholder: '请输入分类',
284
+ },
285
+ options: [
286
+ {
287
+ label: '指南',
288
+ value: '指南',
289
+ separator: true, //分割线
290
+ children: [
291
+ {
292
+ value: 'shejiyuanze',
293
+ label: '设计原则',
294
+ shortcut: 'ctrl+z', //选项右侧的内容
295
+ },
296
+ ],
297
+ },
298
+ {
299
+ label: '资源',
300
+ value: 'resource',
301
+ children: [
302
+ {
303
+ value: 'axure',
304
+ label: 'Axure Components',
305
+ },
306
+ ],
307
+ },
308
+ ],
309
+ },
308
310
  {
309
311
  label: '组合分类-多选',
310
312
  prop: 'expense_multiple_checkbox_test',
@@ -313,9 +315,6 @@ parametersType 类型介绍
313
315
  placeholder: '请选择等级',
314
316
  type: 'checkbox-list',
315
317
  },
316
- fieldSetting: {
317
- className: fieldClassName,
318
- },
319
318
  option: [
320
319
  { label: 'Yysyayayasuydsaiewqnkerwjrklwjlwerjwlejrlj3', value: 'Y3' },
321
320
  { label: 'Yysyayayasuydsaiewqnkerwjrklwjlwerjwlejrlj4', value: 'Y4' },
@@ -391,6 +390,16 @@ parametersType 类型介绍
391
390
  className: fieldClassName,
392
391
  },
393
392
  },
393
+ {
394
+ label: "开关",
395
+ prop: "switch_test",
396
+ type: "switch",
397
+ setting: {
398
+ },
399
+ fieldSetting: {
400
+ className: 'col-start-2 col-span-2 mb-8',
401
+ },
402
+ },
394
403
  // {
395
404
  // label: "创建时间",
396
405
  // prop: "create_time",
@@ -437,7 +446,7 @@ parametersType 类型介绍
437
446
  { label: 'Y5', value: 'Y5' },
438
447
  ],
439
448
  fieldSetting: {
440
- className: fieldClassName,
449
+ className: 'col-start-2 col-span-2 mb-8',
441
450
  },
442
451
  setting: {
443
452
  placeholder: '请选择等级',
@@ -448,13 +457,18 @@ parametersType 类型介绍
448
457
  label: '选择框',
449
458
  type: 'checkbox',
450
459
  fieldSetting: {
451
- className: fieldClassName,
460
+ className: 'col-start-4 col-span-2 mb-8',
452
461
  },
453
462
  setting: {
454
463
  placeholder: '请选择套餐',
455
464
  },
456
465
  },
457
-
466
+ // enum ComTypes {
467
+ // "command" = "command",
468
+ // "rc-tree" = "rc-tree",
469
+ // "ant-tree" = "ant-tree",
470
+ // "checkbox-list" = "checkbox-list",
471
+ // }
458
472
  {
459
473
  label: "分类",
460
474
  prop: "分类",
@@ -555,7 +569,8 @@ parametersType 类型介绍
555
569
  setting: {
556
570
  placeholder: '请输入分类',
557
571
  empty: '搜索内容为空的提示',
558
- type: 'rc-tree',
572
+ type: 'ant-tree',
573
+ width: `500px`,//控制组件宽度
559
574
  // checkable: true,
560
575
  // selectable: false
561
576
  },
@@ -623,6 +638,11 @@ export enum FormType {
623
638
  * @return {*}
624
639
  */
625
640
  "input" = "input",
641
+ /**
642
+ * @description: 文本区域
643
+ * @return {*}
644
+ */
645
+ "textarea" = "textarea",
626
646
  /**
627
647
  * @description: 复杂输入框,可自定义前后缀和大小
628
648
  * @return {*}
@@ -638,6 +658,11 @@ export enum FormType {
638
658
  * @return {*}
639
659
  */
640
660
  "select" = "select",
661
+ /**
662
+ * @description: 开关
663
+ * @return {*}
664
+ */
665
+ "switch" = "switch",
641
666
  /**
642
667
  * @description: 带搜索的二级菜单
643
668
  * @return {*}
@@ -674,6 +699,9 @@ export enum FormType {
674
699
  * @return {*}
675
700
  */
676
701
  "checkbox-list" = "checkbox-list",
677
- }
678
-
679
-
702
+ /**
703
+ * @description: FieldDescription 描述
704
+ * @return {*}
705
+ */
706
+ "description" = "description",
707
+ }